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 |
---|---|---|---|---|---|---|
The default url to be used after updating a resource. You need to overwrite this method in your own RegistrationsController. | def after_update_path_for(resource)
signed_in_root_path(resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_after_update\n resources_url {}\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n\t\tedit_user_registration_path\n\tend",
"def after_update_path_for(_)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path(resource)\n end",
"def after_update_path_for(resource)\n edit_user_registration_path(resource)\n end",
"def after_update_path_for(resource)\r\n settings_path(resource)\r\n end",
"def after_update_path_for(resource)\n super\n end",
"def after_update_path_for(resource)\n edit_publisher_registration_path\n end",
"def after_update_path_for(resource)\n puts :protocol\n me_url(:protocol => 'http')\n end",
"def default_url\n end",
"def after_update_path_for(resource)\n \"/#{resource.username}\"\n end",
"def after_update_path_for(resource)\n rent_path\n end",
"def after_sign_up_path_for(_resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_account_path(resource)\n end",
"def after_sign_up_path_for(resource)\n edit_registration_path(resource)\n end",
"def after_sign_up_path_for(resource)\n edit_registration_path(resource)\n end",
"def after_update_path_for(resource)\n \"/profile/personal\"\n end",
"def default_url\n url 'default'\n end",
"def edit_resource_url(object)\n send route_prefix_to_method_name(\"edit_#{class_name.model_name.singular_route_key}_url\"),\n object\n end",
"def after_update_path_for(resource)\n edit_user_settings_account_path\n end",
"def after_update_path_for(resource) \n profile_index_path()\n end",
"def after_update_path_for(resource)\n users_index_path\n end",
"def default_url(context)\n end",
"def new_resource_url\n send route_prefix_to_method_name(\"new_#{class_name.model_name.singular_route_key}_url\")\n end",
"def after_update_path_for(_resource)\n backend_dashboard_path\n end",
"def after_sign_in_path_for(_resource)\n current_user.email? ? root_url : edit_user_registration_url\n end",
"def default_path\n @default_path ||= h.can?(:update, object) ? h.edit_form_path(object) : h.form_path(object)\n end",
"def after_update_path_for(resource)\n if current_user_is_admin?\n users_path\n else\n super(resource)\n end\n end",
"def after_sign_up_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n profile_path(resource)\n end",
"def after_update_path_for(resource)\n group_path resource\n end",
"def after_update_path_for(resource)\n backend_account_path\n end",
"def after_devise_action_for(resource)\n stored_location_for(resource) || root_url\n end",
"def auto_url_for(resource)\n config = active_admin_resource_for(resource.class)\n return unless config\n\n if config.controller.action_methods.include?(\"show\") &&\n authorized?(ActiveAdmin::Auth::READ, resource)\n url_for config.route_instance_path resource, url_options\n elsif config.controller.action_methods.include?(\"edit\") &&\n authorized?(ActiveAdmin::Auth::EDIT, resource)\n url_for config.route_edit_instance_path resource, url_options\n end\n end",
"def after_update_path_for(resource)\n dashboard_path(resource.membername)\n end",
"def after_update_path_for(resource)\n user_path(resource)\n end",
"def after_update_path_for(resource)\n user_path(resource)\n end",
"def auto_url_for(resource)\n\n\n\n config = active_admin_resource_for(resource.class)\n\n\n\n return unless config\n\n\n\n\n\n\n\n if config.controller.action_methods.include?(\"show\") &&\n\n\n\n authorized?(ActiveAdmin::Auth::READ, resource)\n\n\n\n url_for config.route_instance_path resource\n\n\n\n elsif config.controller.action_methods.include?(\"edit\") &&\n\n\n\n authorized?(ActiveAdmin::Auth::UPDATE, resource)\n\n\n\n url_for config.route_edit_instance_path resource\n\n\n\n end\n\n\n\n end",
"def after_update_path_for(resource)\n backend_profile_path\n end",
"def after_update_path_for(resource)\n if resource.is_a?(User)\n return user_dashboard_index_path\n end\n end",
"def after_update_path_for(resource)\n user_path(current_user)\n end",
"def redirect_after_create\n resources_url {}\n end",
"def url(name, *args)\n return base_controller.url(name, *args) if base_controller\n super\n end",
"def default_url\n PLACEHOLDER_URL\n end",
"def after_update_path\n url_for(@topic)\n end",
"def update_url\n answer_meeting_registration_path(meeting_id: meeting.id)\n end",
"def default_url\n nil\n end",
"def after_sign_in_path_for(_resource)\n root_url\n end",
"def casein_config_dashboard_url\n url_for :controller => :casein, :action => :blank\n end",
"def after_sign_up_path_for(resource)\n edit_user_path(resource.id)\n end",
"def after_sign_up_path_for(resource)\n stored_location_for(resource) || edit_user_registration_path\n end",
"def after_confirmation_path_for(resource_name, resource)\r\n users_settings_path\r\n end",
"def after_update_path_for(resource)\n # sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name) )\n yams_core.edit_user_registration_path(resource)\n end",
"def default_url(version_name = \"\")\n end",
"def casein_config_dashboard_url\n\t\turl_for :controller => :casein, :action => :blank\n\tend",
"def default_url(object, view = \"index\")\n #url_for Util.default_url_for_object( object, view )\n url_for object.default_url( view )\n end",
"def url\n @current_controller.url_for :controller => @controller_name, :action => @action_name\n end",
"def the_update_redirect; {:action => 'index'}; end",
"def default_redirect_url_after_sign_in\n admin_dashboard_url \n end",
"def after_sending_reset_password_instructions_path_for(resource_name)\n store_url\n end",
"def after_sign_in_path_for(resource)\n debugger\n s=0\n if resource.is_a?(User)\n new_organisation_url\n else\n super\n end\n end",
"def after_sign_in_path_for(resource)\n urls_path\n end",
"def after_sign_in_path_for(resource)\n if resource.is_a?(Admin::Administrator)\n admin_url\n else\n root_url\n end\n end",
"def after_inactive_sign_up_path_for(resource)\n rent_path\n end",
"def after_sign_up_path_for(resource)\n Rails.logger.debug(\"controller Clients::RegistrationsController.after_sign_up_path_for\")\n patch = workflow_link(@client_wf)\n patch || super(resource)\n end",
"def url(*args)\n super_url = super\n File.exists?(\"#{root}#{super_url}\") ? super_url : default_url\n end",
"def admin_form_url\n ['', controller_path, object_instance.id].join('/')\n end",
"def default_url(*args); end",
"def edit_url(receiver)\n show_url(receiver)\n end",
"def url\n url = \"/sales/\" + self.notifitable_type.downcase + \"s/\" + self.notifitable_id.to_s + \"/edit\"\n end",
"def url_after_create\n # your special path\n end",
"def url\n if self.controller and self.action and self.page_id\n return \"/#{self.controller}/#{self.action}/#{self.page_id}\"\n end\n if self.controller and self.action\n return \"/#{self.controller}/#{self.action}\"\n end\n if self.controller\n return \"/#{self.controller}\"\n end\n return \"/#{self.shortcut}\"\n end",
"def after_update_path_for(resource)\n puts 'resource!!'\n puts resource\n sign_in_after_change_password? ? tutor_path(resource) : new_tutor_session_path(resource)\n end",
"def after_update_path_for(resource)\n flash[:notice] = \"Votre compte a bien été mis à jour.\" if resource.updated_at_changed?\n edit_user_registration_path\n end",
"def default_url_options; end",
"def after_inactive_sign_up_path_for(resource)\n Rails.logger.debug(\"controller Clients::RegistrationsController.after_inactive_sign_up_path_for\")\n patch = workflow_link(@client_wf)\n patch || super(resource)\n end",
"def after_sign_up_path_for(resource)\n \"/\"\n end",
"def after_sign_up_path_for(resource)\r\n root_path\r\n end",
"def success_url\n url_for(:controller => 'repositories', :action => 'edit', :id => @repository.id)\n end",
"def after_sign_up_path_for(resource)\n if resource.is_a?(User) && resource.is_admin?\n dashboard_path\n else\n root_url\n end\n end",
"def after_sign_up_path_for(resource)\n new_location_path\n end",
"def after_sign_in_path_for(resource)\n dashboard_index_url\n end",
"def after_confirmation_path_for(resource_name, resource) \n send(\"edit_#{resource.class.name.underscore}_path\",resource)\n end",
"def default_path; end",
"def resource_url; nil end",
"def after_sign_up_path_for(_resource)\n root_path\n end",
"def after_update_path_for(user)\n user_home_path\n end"
] | [
"0.7351943",
"0.72497755",
"0.72497755",
"0.7221928",
"0.720645",
"0.71875936",
"0.71875936",
"0.71875936",
"0.71875936",
"0.71875936",
"0.71875936",
"0.7058516",
"0.7058516",
"0.69736576",
"0.6891413",
"0.68902767",
"0.6801212",
"0.6726657",
"0.6697962",
"0.6689395",
"0.6677945",
"0.6674866",
"0.6642311",
"0.6642311",
"0.6638506",
"0.66341794",
"0.66058886",
"0.6595299",
"0.6552797",
"0.6547644",
"0.6526866",
"0.6512771",
"0.6463424",
"0.6456389",
"0.6454684",
"0.64489627",
"0.6440184",
"0.6406178",
"0.63996476",
"0.6392806",
"0.6386953",
"0.6382881",
"0.63769233",
"0.63611144",
"0.63611144",
"0.63518906",
"0.63231236",
"0.6204944",
"0.6191936",
"0.618436",
"0.6161692",
"0.615579",
"0.614313",
"0.6136725",
"0.6133534",
"0.61288345",
"0.61201674",
"0.610466",
"0.610451",
"0.60715646",
"0.6070633",
"0.60626984",
"0.6055462",
"0.60539955",
"0.60457337",
"0.60435134",
"0.6036903",
"0.6035269",
"0.601881",
"0.59624004",
"0.5957684",
"0.59549934",
"0.592285",
"0.5909657",
"0.59078884",
"0.59040445",
"0.5900091",
"0.58993965",
"0.5871325",
"0.5868456",
"0.586274",
"0.58465",
"0.58439237",
"0.58420634",
"0.5835978",
"0.5835731",
"0.5830269",
"0.58216685",
"0.58145595",
"0.5808251",
"0.5805685",
"0.5795879",
"0.5793145",
"0.5779801",
"0.577059"
] | 0.0 | -1 |
Authenticates the current scope and gets the current resource from the session. | def authenticate_scope!
send(:"authenticate_#{resource_name}!", force: true)
self.resource = send(:"current_#{resource_name}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def authenticate_scope!\r\n send(:\"authenticate_#{resource_name}!\")\r\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\r\n end",
"def authenticate_scope!\r\n send(:\"authenticate_user!\", :force => true)\r\n self.resource = send(:\"current_user\")\r\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def signed_in_resource\n warden.authenticate(scope: resource_name)\n end",
"def get_user_from_session\n authorize()\n @user = @current_user\n end",
"def current_user\n login_from_session || login_from_basic_auth \n end",
"def current_user\n login_from_session || login_from_basic_auth\n end",
"def current_user\n return @current_resource_owner ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token\n @current_user ||= warden.authenticate(scope: :user)\n end",
"def current_user_auth\n \t@current_user_auth ||= UserAuth.find_by(id: session[:user_auth_id])\n end",
"def login_from_session\n self.current_ma_user = MA[:user].find_with_conditions(:id => session[MA[:single_resource]]) if session[MA[:single_resource]]\n end",
"def current_user\n load_session\n @current_user\n end",
"def current_user\n # authorization initialization if not run yet\n # (in the case of paper_trial it might not have run)\n authorization_init\n @logged_in_user\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def auth_session\n @auth_session ||= Session.get_session(@controller)\n end",
"def current_user\n\t\t@current_user ||= authorize_request\n\tend",
"def current_user\n if @current_user\n return @current_user\n end\n if session[:person_id]\n @current_user ||= Person.find(session[:person_id])\n else\n authenticate_with_http_basic do |email, password|\n @current_user = Person.authenticate(email, password)\n end\n end\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def get_current_user\n #temporaly solution to simulate login on development \n #if env[\"REMOTE_HOST\"] == \"localhost\"\n # session[:user_id] = 1;\n #end\n return @current_reader if defined?(@current_reader)\n #@current_reader = cookies[:token] && Reader.find_by_token(cookies[:token])\n if session[:user_id]\n @current_reader ||= Reader.find_by_id(session[:user_id])\n end\n end",
"def current_user\n @current_user ||= User.find_by(id: doorkeeper_token[:resource_owner_id])\n # @current_user ||= User.find(doorkeeper_token.resource_owner_id)\n end",
"def current_user\n current_user = Account.find_by(id: session[:account_id])\n end",
"def current_user\n return session[:user]\n end",
"def current_user\n return @current_user if @current_user\n @current_user = UserFactory.resource.find(session[Casual.session_key])\n \n # If user is not active, unset session\n if UserFactory.user_not_active(@current_user)\n @current_user = nil \n session[Casual.session_key] = nil\n end\n \n @current_user\n end",
"def current_user\n session[:user]\n end",
"def current_user\n return @current_user if defined?(@current_user) && @current_user\n @current_user = Authentication.find(session[:authentication_id]) if session[:authentication_id]\n end",
"def authenticate_request!\n return render_unauthorized unless request.headers['Authorization'].present?\n\n @token ||= AuthenticateRequest.get(User, request.headers['Authorization'].split(' ').last)\n @current_user = @token[:user]\n end",
"def current_user\n session.user\n end",
"def current_user\n User.find(session[:user])\n end",
"def current_account\n load_session\n @current_account\n end",
"def current_user\n @current_user ||= User.find_by(token: request.headers[:authorization])\n end",
"def current_user\n @current_user ||= User.authenticatable.find_by_id(session[:user_id]) if session[:user_id]\n #unauthenticate unless @current_user\n @current_user\n end",
"def set_current_user\n current_user\n authorize\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n current_login_credential\n end",
"def get_current_user\n return Account.find_by(user_name: session[:current_user].user_name)\n end",
"def current_auth_user\n @current_auth_user ||= auth_key.try :owner\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def current_user\n auth_token = request.headers['HTTP_AUTH_TOKEN']\n puts auth_token\n @current_user ||= User.find_by(auth_token: auth_token)\n #puts @current_user.name + \" is logged in\"\n end",
"def current_user\n @current_user ||= User.find_by_id(session[:uid]) || User.from_auth_header(request.headers['HTTP_AUTHORIZATION'])\n\n @current_user\n end",
"def current_user\n @user = User.find(@session.user_id)\n end",
"def current_user\n User.find session[:id] if session[:id]\n end",
"def current_user\n authentication.account\n end",
"def current_user\n # this should be:\n # BGoodUser.find_by auth0_id: session[:userinfo][:uid]\n @current_user = BGoodUser.find_by auth0_id: current_auth0_user[\"uid\"] if user_signed_in?\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def authorize_request\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def current_user #used in many methods to pull in the current user stored in sessions. \n \tUser.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n authenticate_token\n end",
"def current_user\n\t\tif session[:user_id]\n\t\t\t@current_user = User.find(session[:user_id])\n\t\telse\n\t\t\tapi_key = ApiKey.where(access_token: token_and_options(request)).first\n\t\t\t@current_user = User.find(api_key.user_id) if api_key\n\t\tend\n\tend",
"def authenticate_scope!\n \n \n do_before_request \n\n end",
"def current_user\n\t\tauthenticated(User)\n\tend",
"def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend",
"def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend",
"def show\n authorize Session\n end",
"def current_user\n User.find(session[:user_id])\n end",
"def current_user\n User.find(session[:user_id])\n end",
"def login_from_session\n self.current_<%= singular_name %> = <%= class_name %>.find_authenticated_model_with_id(session[:<%= singular_name %>]) if session[:<%= singular_name %>]\n end",
"def current_user\n if user_signed_in?\n Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).user\n else\n nil\n end\n end",
"def current_user\n if user_signed_in?\n Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).user\n else\n nil\n end\n end",
"def current_user\n User.get_user(session[:user_id]) if session[:user_id]\n end",
"def current_user\n\tUser.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def load_current_resource; end",
"def current_scope\n params[:scope].try(:to_sym) || railgun_resource.default_scope.try(:key)\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end"
] | [
"0.74981654",
"0.74981654",
"0.7410862",
"0.7368122",
"0.7207636",
"0.7207636",
"0.7207636",
"0.7207636",
"0.7145215",
"0.6772719",
"0.6605786",
"0.65873796",
"0.65733624",
"0.65570974",
"0.6519613",
"0.6494513",
"0.64650905",
"0.6407562",
"0.6407562",
"0.6404784",
"0.640067",
"0.6381768",
"0.6367767",
"0.63606614",
"0.63578826",
"0.6348997",
"0.6324679",
"0.6319554",
"0.63161284",
"0.63110304",
"0.63087565",
"0.62860644",
"0.62789005",
"0.62760985",
"0.6272791",
"0.62607",
"0.6259986",
"0.6259172",
"0.6259172",
"0.6259172",
"0.625498",
"0.6252559",
"0.624771",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.62362885",
"0.6224976",
"0.62207",
"0.62178",
"0.62163574",
"0.6215604",
"0.6214878",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.62112314",
"0.6208524",
"0.6208393",
"0.6208272",
"0.62071025",
"0.6206869",
"0.6205198",
"0.62024266",
"0.62024266",
"0.62002933",
"0.61939615",
"0.61939615",
"0.6186345",
"0.6184807",
"0.6184807",
"0.6180036",
"0.6175562",
"0.61729085",
"0.61729085",
"0.6171708",
"0.6169353",
"0.6160703",
"0.6160703"
] | 0.7254568 | 10 |
Show invalid properties with the reasons. Usually used together with valid? | def list_invalid_properties
invalid_properties = Array.new
if @action.nil?
invalid_properties.push('invalid value for "action", action cannot be nil.')
end
if @repeat.nil?
invalid_properties.push('invalid value for "repeat", repeat cannot be nil.')
end
invalid_properties
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n pattern = Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)\n if [email protected]? && @uuid !~ pattern\n invalid_properties.push(\"invalid value for \\\"uuid\\\", must conform to the pattern #{pattern}.\")\n end\n\n pattern = Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)\n if !@vdisk_id.nil? && @vdisk_id !~ pattern\n invalid_properties.push(\"invalid value for \\\"vdisk_id\\\", must conform to the pattern #{pattern}.\")\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @style.nil?\n invalid_properties.push('invalid value for \"style\", style cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n if [email protected]? && @name.to_s.length > 31\n invalid_properties.push('invalid value for \"name\", the character length must be smaller than or equal to 31.')\n end\n\n pattern = Regexp.new(/^[a-zA-Z0-9\\-\\._:]+$/)\n if [email protected]? && @name !~ pattern\n invalid_properties.push(\"invalid value for \\\"name\\\", must conform to the pattern #{pattern}.\")\n end\n\n pattern = Regexp.new(/^$|((^20|5[0-9a-fA-F]{1}):([0-9a-fA-F]{2}:){6}([0-9a-fA-F]{2}))/)\n if !@static_wwpn_address.nil? && @static_wwpn_address !~ pattern\n invalid_properties.push(\"invalid value for \\\"static_wwpn_address\\\", must conform to the pattern #{pattern}.\")\n end\n\n pattern = Regexp.new(/^$|((^20|5[0-9a-fA-F]{1}):([0-9a-fA-F]{2}:){6}([0-9a-fA-F]{2}))/)\n if [email protected]? && @wwpn !~ pattern\n invalid_properties.push(\"invalid value for \\\"wwpn\\\", must conform to the pattern #{pattern}.\")\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @is_object_icon.nil?\n invalid_properties.push('invalid value for \"is_object_icon\", is_object_icon cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @input_currency.nil?\n invalid_properties.push('invalid value for \"input_currency\", input_currency cannot be nil.')\n end\n\n if @sender.nil?\n invalid_properties.push('invalid value for \"sender\", sender cannot be nil.')\n end\n\n if @recipients.nil?\n invalid_properties.push('invalid value for \"recipients\", recipients cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @index.nil?\n invalid_properties.push('invalid value for \"index\", index cannot be nil.')\n end\n\n if @orientation.nil?\n invalid_properties.push('invalid value for \"orientation\", orientation cannot be nil.')\n end\n\n if @size.nil?\n invalid_properties.push('invalid value for \"size\", size cannot be nil.')\n end\n\n if @type.nil?\n invalid_properties.push('invalid value for \"type\", type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @direction.nil?\n invalid_properties.push('invalid value for \"direction\", direction cannot be nil.')\n end\n\n if @shape.nil?\n invalid_properties.push('invalid value for \"shape\", shape cannot be nil.')\n end\n\n if @linear_angle.nil?\n invalid_properties.push('invalid value for \"linear_angle\", linear_angle cannot be nil.')\n end\n\n if @is_scaled.nil?\n invalid_properties.push('invalid value for \"is_scaled\", is_scaled cannot be nil.')\n end\n\n if @tile_flip.nil?\n invalid_properties.push('invalid value for \"tile_flip\", tile_flip cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @format.nil?\n invalid_properties.push('invalid value for \"format\", format cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n invalid_properties\n end"
] | [
"0.765058",
"0.765058",
"0.765058",
"0.765058",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.73569804",
"0.7336038",
"0.72692806",
"0.72394663",
"0.72318745",
"0.7226795",
"0.7209003",
"0.7177062",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715",
"0.7171715"
] | 0.0 | -1 |
Check to see if the all the properties in the model are valid | def valid?
return false if @action.nil?
return false if @repeat.nil?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_properties\n true\n end",
"def validate_properties\n true\n end",
"def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :flush, String\n check_optional_property :prefetch, String\n check_optional_property :request_to_query, String\n check_optional_property :resource_to_request_patch, String\n check_optional_property :return_if_object, String\n check_optional_property :self_link, String\n end",
"def valid_attributes?\n true\n end",
"def valid_attributes?\n attribute_errors.empty?\n end",
"def valid?\n return false if @property_code.nil?\n return false if @property_name.nil?\n return false if @location.nil?\n return false if @total_price.nil?\n return false if @min_daily_rate.nil?\n return true\n end",
"def validate_presence_of(klazz, properties)\r\n instance = klazz.new \r\n instance.should_not be_valid\r\n \r\n properties.each do |property| \r\n instance.errors.should be_invalid(property)\r\n err_properties = instance.errors[property]\r\n if err_properties.is_a? Array\r\n err_properties.include?(ActiveRecord::Errors.default_error_messages[:blank]).should be_true\r\n else\r\n err_properties.should == ActiveRecord::Errors.default_error_messages[:blank] \r\n end\r\n end \r\n end",
"def validate_attributes!(attributes)\n invalid_properties = attributes.keys.map(&:to_s) - self.attributes.keys\n raise UndefinedPropertyError, \"Undefined properties: #{invalid_properties.join(',')}\" if invalid_properties.size > 0\n end",
"def model_valid?\n true\n end",
"def model_valid?\n true\n end",
"def valid?\n self.errors = []\n self.content_type.fields.each do |field|\n if field.required\n if self.dynamic_getter(field.name).blank?\n self.errors << field.name\n end\n end\n end\n self.errors.blank?\n end",
"def valid?\n validate\n @model.errors.on(:preferences).blank?\n end",
"def validate_properties\n if @properties.keys.count > 0\n if @properties.key?(:label)\n unless @properties[:label] =~ /^[a-zA-Z][\\w|\\s]*$/\n raise 'property label validation error'\n end\n end\n\n if @properties.key?(:default_aggregate)\n unless @properties[:default_aggregate] =~ /^max$|^min$|^avg$|^count$/i\n raise 'property default_aggregate validation error'\n end\n end\n end\n end",
"def validate_properties\n @properties.each do |property, values|\n valid_values = validate_values(property, values)\n\n if valid_values.is_a?(Array) && valid_values == [] || valid_values.nil?\n @properties.delete(property)\n else\n @properties[property] = valid_values\n end\n end\n end",
"def validate\n valid?\n end",
"def validate_attributes!(attributes)\n return attributes if attributes.blank?\n invalid_properties = attributes.keys.map(&:to_s) - self.attributes.keys\n invalid_properties.reject! { |name| self.respond_to?(\"#{name}=\") }\n fail UndefinedPropertyError, \"Undefined properties: #{invalid_properties.join(',')}\" if !invalid_properties.empty?\n end",
"def is_valid; end",
"def valid?\n # TODO validate nested objects\n output = super\n errors.empty? && output\n end",
"def property_checks\n errors.add(:base, \"You can't have a Thing without properties\") if property_keys.empty?\n\n self.property_keys.each do |key|\n errors.add(:properties, \"'#{key}' is an invalid property for this List\") unless available_property_keys.include?(key)\n end\n end",
"def valid_for_attributes( model, attributes )\n unless model.valid?\n errors = model.errors\n our_errors = Array.new\n errors.each { |attr,error|\n if attributes.include? attr\n our_errors << [attr,error]\n end\n }\n errors.clear\n our_errors.each { |attr,error| errors.add(attr,error) }\n return false unless errors.empty?\n end\n return true\n end",
"def valid?\n type_validator = EnumAttributeValidator.new('String', [\"person\", \"business\"])\n return false unless type_validator.valid?(@type)\n return false if @country.nil?\n return false if @street.nil?\n return false if @postal_code.nil?\n return false if @city.nil?\n return false if @email.nil?\n return false if @ip.nil?\n identification_type_validator = EnumAttributeValidator.new('String', [\"DL\", \"PP\", \"ID\", \"OT\"])\n return false unless identification_type_validator.valid?(@identification_type)\n legal_entity_type_validator = EnumAttributeValidator.new('String', [\"sole_proprietorship\", \"partnership\", \"privately_owned_company\", \"publicly_owned_company\", \"government_owned_entity\", \"trust\", \"ngo\", \"club_and_society\", \"go\", \"other\", \"financial_institution\", \"mto\"])\n return false unless legal_entity_type_validator.valid?(@legal_entity_type)\n nature_of_business_validator = EnumAttributeValidator.new('String', [\"personal\", \"agriculture_and_hunting\", \"forestry\", \"fishing\", \"agricultural_by_products\", \"coal_mining\", \"oil_mining\", \"iron_ore_mining\", \"other_metal_and_diamond_mining\", \"other_mineral_mining\", \"manufacturing_of_food_drink_tobacco\", \"manufacturing_of_textiles_leather_fur_furniture\", \"manufacture_of_wooden_products_furniture\", \"manufacture_of_paper_pulp_allied_products\", \"manufacture_of_chemicals_medical_petroleum_rubber_plastic_products\", \"manufacture_of_pottery_china_glass_stone\", \"manufacture_of_iron_steel_non_ferrous_metals_basic_industries\", \"manufacture_of_metal_products_electrical_and_scientific_engineering\", \"manufacture_of_jewelry_musical_instruments_toys\", \"electricity_gas_and_water\", \"construction\", \"wholesale_trade\", \"retail_trade\", \"catering_incl_hotels\", \"transport_storage\", \"communications\", \"finance_and_holding_companies\", \"insurance\", \"business_services\", \"real_estate_development_investment\", \"central_state_governments\", \"community_services_defence_police_prisons_etc\", \"social_services_education_health_care\", \"personal_services_leisure_services\", \"personal_services_domestic_laundry_repairs\", \"personal_services_embassies_international_organisations\"])\n return false unless nature_of_business_validator.valid?(@nature_of_business)\n return false if @documents.nil?\n gender_validator = EnumAttributeValidator.new('String', [\"M\", \"F\", \"O\"])\n return false unless gender_validator.valid?(@gender)\n true\n end",
"def valid?\n return false if !super\n return false if @index.nil?\n return false if @orientation.nil?\n orientation_validator = EnumAttributeValidator.new('String', ['Horizontal', 'Vertical'])\n return false unless orientation_validator.valid?(@orientation)\n return false if @size.nil?\n size_validator = EnumAttributeValidator.new('String', ['Full', 'Half', 'Quarter'])\n return false unless size_validator.valid?(@size)\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', ['Title', 'Body', 'CenteredTitle', 'Subtitle', 'DateAndTime', 'SlideNumber', 'Footer', 'Header', 'Object', 'Chart', 'Table', 'ClipArt', 'Diagram', 'Media', 'SlideImage', 'Picture'])\n return false unless type_validator.valid?(@type)\n true\n end",
"def validate\n validate_string_attributes\n @relations.map(&:validate)\n end",
"def is_valid?\n end",
"def run_validations\n true\n end",
"def validate\n validate_params\n validate_colour\n validate_coordinates\n validate_dimension\n end",
"def checkAttributeRequirements\n if @valid_attributes.empty?\n @error_text = \"No valid attributes found\"\n return false\n elsif (@mandatory_attributes_from_db & @valid_attributes) != @mandatory_attributes_from_db\n missing_attr = @mandatory_attributes_from_db - (@mandatory_attributes_from_db & @valid_attributes)\n\n x_attr_txt = \"\"\n missing_attr.each {|x_attr| x_attr_txt += x_attr[:name] + \", \"}\n @error_text = \"Mandatory attributes #{x_attr_txt[0..-3]} is/are missing\"\n return false\n end\n\n return true\n end",
"def validations\n {}\n end",
"def validatable?\n true\n end",
"def validate\n validate_params\n validate_coordinates\n validate_colour\n validate_dimension\n end",
"def validate_required\n [\n :project_name,\n :status,\n :requester_id,\n :subject_expert_id,\n :sponsor_id,\n :vision,\n :goal,\n :description,\n :scope,\n :advice_required,\n :program_id,\n :train_id,\n :funding_method,\n :cost_center,\n :funding_status,\n :budget_allocated,\n :priority,\n :start_date,\n :end_date,\n :risk_rating,\n :risks,\n :projected_revenue,\n ].each do |field|\n if self.attributes[field.to_s].nil? || self.attributes[field.to_s].blank?\n # intentionally vague!\n add_validation 'All fields are required to perform further validations'\n return false\n end\n end\n true\n end",
"def validate\n validate_root\n validate_associated\n valid?\n end",
"def validate\n true\n end",
"def valid?\n return false if @id.nil?\n return false if @created.nil?\n return false if @modified.nil?\n return false if @company_name.nil?\n return false if @company_name.to_s.length < 1\n return false if @domain_name.nil?\n return false if @state.nil?\n state_validator = EnumAttributeValidator.new('String', [\"active\", \"deactivated\"])\n return false unless state_validator.valid?(@state)\n return false if @billing_email.nil?\n return false if @application_count.nil?\n return false if @user_count.nil?\n return false if @campaigns_active_count.nil?\n return false if @campaigns_inactive_count.nil?\n true\n end",
"def valid?\n _errors_before = self.errors.dup\n _s = super\n validate_attributes\n _errors_before.each { |e| append_error(_errors_before,e) }\n self.errors.empty?\n end",
"def valid?\n true\n end",
"def validate!\n expected_props, required_props = @properties.keys, @required\n\n unless is_a?(Dialect) || is_a?(Template)\n expected_props = expected_props + INHERITED_PROPERTIES.keys\n end\n\n # It has only expected properties (exclude metadata)\n keys = self.keys - [:\"@context\"]\n keys = keys.reject {|k| k.to_s.include?(':')} unless is_a?(Dialect)\n raise \"#{type} has unexpected keys: #{keys - expected_props}\" unless keys.all? {|k| expected_props.include?(k)}\n\n # It has required properties\n raise \"#{type} missing required keys: #{required_props & keys}\" unless (required_props & keys) == required_props\n\n # Every property is valid\n keys.each do |key|\n value = self[key]\n is_valid = case key\n when :columns\n column_names = value.map(&:name)\n value.is_a?(Array) &&\n value.all? {|v| v.is_a?(Column) && v.validate!} &&\n begin\n # The name properties of the column descriptions must be unique within a given table description.\n column_names = value.map(&:name)\n raise \"Columns must have unique names\" if column_names.uniq != column_names\n true\n end\n when :commentPrefix then value.is_a?(String) && value.length == 1\n when :datatype then value.is_a?(String) && DATATYPES.keys.map(&:to_s).include?(value)\n when :default then value.is_a?(String)\n when :delimiter then value.is_a?(String) && value.length == 1\n when :dialect then value.is_a?(Dialect) && value.validate!\n when :doubleQuote then %w(true false 1 0).include?(value.to_s.downcase)\n when :encoding then Encoding.find(value)\n when :foreignKeys\n # An array of foreign key definitions that define how the values from specified columns within this table link to rows within this table or other tables. A foreign key definition is a JSON object with the properties:\n value.is_a?(Array) && value.all? do |fk|\n raise \"Foreign key must be an object\" unless fk.is_a?(Hash)\n columns, reference = fk['columns'], fk['reference']\n raise \"Foreign key missing columns and reference\" unless columns && reference\n raise \"Foreign key has extra entries\" unless fk.keys.length == 2\n raise \"Foreign key must reference columns\" unless Array(columns).all? {|k| self.columns.any? {|c| c.name == k}}\n raise \"Foreign key reference must be an Object\" unless reference.is_a?(Hash)\n\n if reference.has_key?('resource')\n raise \"Foreign key having a resource reference, must not have a schema\" if reference.has_key?('schema')\n # FIXME resource is a URL of a specific resource (table) which must exist\n elsif reference.has_key?('schema')\n # FIXME schema is a URL of a specific schema which must exist\n end\n # FIXME: columns\n true\n end\n when :format then value.is_a?(String)\n when :header then %w(true false 1 0).include?(value.to_s.downcase)\n when :headerColumnCount, :headerRowCount\n value.is_a?(Numeric) && value.integer? && value > 0\n when :length\n # Applications must raise an error if length, maxLength or minLength are specified and the cell value is not a list (ie separator is not specified), a string or one of its subtypes, or a binary value.\n raise \"Use if minLength or maxLength with length requires separator\" if self[:minLength] || self[:maxLength] && !self[:separator]\n raise \"Use of both length and minLength requires they be equal\" unless self.fetch(:minLength, value) == value\n raise \"Use of both length and maxLength requires they be equal\" unless self.fetch(:maxLength, value) == value\n value.is_a?(Numeric) && value.integer? && value > 0\n when :language then BCP47::Language.identify(value)\n when :lineTerminator then value.is_a?(String)\n when :minimum, :maximum, :minInclusive, :maxInclusive, :minExclusive, :maxExclusive\n value.is_a?(Numeric) ||\n RDF::Literal::Date.new(value).valid? ||\n RDF::Literal::Time.new(value).valid? ||\n RDF::Literal::DateTime.new(value).valid?\n when :minLength, :maxLength\n value.is_a?(Numeric) && value.integer? && value > 0\n when :name then value.is_a?(String) && !name.start_with?(\"_\")\n when :notes then value.is_a?(Array) && value.all? {|v| v.is_a?(Hash)}\n when :null then value.is_a?(String)\n when :predicateUrl then Array(value).all? {|v| RDF::URI(v).valid?}\n when :primaryKey\n # A column reference property that holds either a single reference to a column description object or an array of references.\n Array(value).all? do |k|\n self.columns.any? {|c| c.name == k}\n end\n when :quoteChar then value.is_a?(String) && value.length == 1\n when :required then %w(true false 1 0).include?(value.to_s.downcase)\n when :resources then value.is_a?(Array) && value.all? {|v| v.is_a?(Table) && v.validate!}\n when :schema then value.is_a?(Schema) && value.validate!\n when :separator then value.nil? || value.is_a?(String) && value.length == 1\n when :skipInitialSpace then %w(true false 1 0).include?(value.to_s.downcase)\n when :skipBlankRows then %w(true false 1 0).include?(value.to_s.downcase)\n when :skipColumns then value.is_a?(Numeric) && value.integer? && value >= 0\n when :skipRows then value.is_a?(Numeric) && value.integer? && value >= 0\n when :source then %w(json rdf).include?(value)\n when :\"table-direction\" then %w(rtl ltr default).include?(value)\n when :targetFormat, :templateFormat then RDF::URI(value).valid?\n when :templates then value.is_a?(Array) && value.all? {|v| v.is_a?(Template) && v.validate!}\n when :\"text-direction\" then %w(rtl ltr).include?(value)\n when :title then valid_natural_language_property?(value)\n when :trim then %w(true false 1 0 start end).include?(value.to_s.downcase)\n when :urlTemplate then value.is_a?(String)\n when :@id then @id.valid?\n when :@type then value.to_sym == type\n else\n raise \"?!?! shouldn't get here for key #{key}\"\n end\n raise \"#{type} has invalid #{key}: #{value.inspect}\" unless is_valid\n end\n\n self\n end",
"def valid?\n return false if @subject_property.nil?\n return false if @proprietorship.nil?\n proprietorship_validator = EnumAttributeValidator.new('String', [\"Unknown\", \"Sole\", \"Joint\"])\n return false unless proprietorship_validator.valid?(@proprietorship)\n return false if @surname.nil?\n return false if @forename.nil?\n return false if @middle_name.nil?\n return true\n end",
"def valid?\n return false if @class_id.nil?\n class_id_validator = EnumAttributeValidator.new('String', [\"cond.HclStatusDetail\"])\n return false unless class_id_validator.valid?(@class_id)\n return false if @object_type.nil?\n object_type_validator = EnumAttributeValidator.new('String', [\"cond.HclStatusDetail\"])\n return false unless object_type_validator.valid?(@object_type)\n hardware_status_validator = EnumAttributeValidator.new('String', [\"Missing-Os-Driver-Info\", \"Incompatible-Server-With-Component\", \"Incompatible-Processor\", \"Incompatible-Os-Info\", \"Incompatible-Component-Model\", \"Incompatible-Firmware\", \"Incompatible-Driver\", \"Incompatible-Firmware-Driver\", \"Service-Unavailable\", \"Service-Error\", \"Unrecognized-Protocol\", \"Not-Evaluated\", \"Compatible\"])\n return false unless hardware_status_validator.valid?(@hardware_status)\n reason_validator = EnumAttributeValidator.new('String', [\"Missing-Os-Driver-Info\", \"Incompatible-Server-With-Component\", \"Incompatible-Processor\", \"Incompatible-Os-Info\", \"Incompatible-Component-Model\", \"Incompatible-Firmware\", \"Incompatible-Driver\", \"Incompatible-Firmware-Driver\", \"Service-Unavailable\", \"Service-Error\", \"Unrecognized-Protocol\", \"Not-Evaluated\", \"Compatible\"])\n return false unless reason_validator.valid?(@reason)\n software_status_validator = EnumAttributeValidator.new('String', [\"Missing-Os-Driver-Info\", \"Incompatible-Server-With-Component\", \"Incompatible-Processor\", \"Incompatible-Os-Info\", \"Incompatible-Component-Model\", \"Incompatible-Firmware\", \"Incompatible-Driver\", \"Incompatible-Firmware-Driver\", \"Service-Unavailable\", \"Service-Error\", \"Unrecognized-Protocol\", \"Not-Evaluated\", \"Compatible\"])\n return false unless software_status_validator.valid?(@software_status)\n status_validator = EnumAttributeValidator.new('String', [\"Incomplete\", \"Not-Found\", \"Not-Listed\", \"Validated\", \"Not-Evaluated\"])\n return false unless status_validator.valid?(@status)\n true && super\n end",
"def core_attributes_valid\n core_attributes = [@rateable, @rater, @ratee, @rating_type]\n return if core_attributes.all? { |atr| atr.present? && atr.valid? }\n errors.add('message', 'Not all core attributes present and valid.')\n end",
"def valid?\n super\n errors.empty?\n end",
"def valid?\n \n if @account_id.nil?\n false\n elsif @campaign_id.nil?\n false\n elsif @csp_id.nil?\n false\n elsif @status.nil?\n false\n elsif @create_date.nil?\n false\n elsif @auto_renewal.nil?\n false\n elsif @brand_id.nil?\n false\n elsif @usecase.nil?\n false\n elsif @sub_usecases.nil?\n false\n elsif @description.nil?\n false\n elsif @embedded_link.nil?\n false\n elsif @embedded_phone.nil?\n false\n elsif @affiliate_marketing.nil?\n false\n elsif @number_pool.nil?\n false\n elsif @age_gated.nil?\n false\n elsif @direct_lending.nil?\n false\n elsif @subscriber_optin.nil?\n false\n elsif @subscriber_optout.nil?\n false\n elsif @subscriber_help.nil?\n false\n elsif @sample1.nil?\n false\n elsif @mock.nil?\n false\n else\n list_invalid_properties.length() == 0\n end\n end",
"def valid?(metadata)\n validate.each do |attr|\n return false if metadata[attr.to_sym].nil? || metadata[attr.to_sym].zero?\n end\n end",
"def is_valid\n return true\n end",
"def validate_attrs\n @target.present? && [email protected]? && @actor.present? && @action_key.present?\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n if [email protected]? && @name.to_s.length > 31\n invalid_properties.push('invalid value for \"name\", the character length must be smaller than or equal to 31.')\n end\n\n pattern = Regexp.new(/^[a-zA-Z0-9\\-\\._:]+$/)\n if [email protected]? && @name !~ pattern\n invalid_properties.push(\"invalid value for \\\"name\\\", must conform to the pattern #{pattern}.\")\n end\n\n pattern = Regexp.new(/^$|((^20|5[0-9a-fA-F]{1}):([0-9a-fA-F]{2}:){6}([0-9a-fA-F]{2}))/)\n if !@static_wwpn_address.nil? && @static_wwpn_address !~ pattern\n invalid_properties.push(\"invalid value for \\\"static_wwpn_address\\\", must conform to the pattern #{pattern}.\")\n end\n\n pattern = Regexp.new(/^$|((^20|5[0-9a-fA-F]{1}):([0-9a-fA-F]{2}:){6}([0-9a-fA-F]{2}))/)\n if [email protected]? && @wwpn !~ pattern\n invalid_properties.push(\"invalid value for \\\"wwpn\\\", must conform to the pattern #{pattern}.\")\n end\n\n invalid_properties\n end",
"def valid_save?\n valid = true\n\n if self.name.nil? || self.name == \"\"\n valid = false\n end\n\n if self.general_info.nil? || self.general_info == \"\"\n valid = false\n end\n\n if self.technical_specs.nil? || self.technical_specs == \"\"\n valid = false\n end\n\n if self.where_to_buy.nil? || self.where_to_buy == \"\"\n valid = false\n end\n\n return valid\n end",
"def valid?\n schema.validate(self)\n end",
"def valid?\n reset_errors\n valid_date?\n valid_user?\n valid_activity_type?\n self.errors.empty?\n end",
"def valid?\n validate\n end",
"def product_attributes_must_not_be_empty\n\n\t\t# Instance\n\t\tproduct = Product.new\n\n\t\tassert product.invalid?\n\t\tassert product.errors[:title].any?\n\t\tassert product.errors[:description].any?\n\t\tassert product.errors[:price].any?\n\t\tassert product.errors[:image_url].any?\n\tend",
"def valid?\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^psc_[a-zA-Z0-9]+$/)\n carrier_validator = EnumAttributeValidator.new('String', [\"USPS\"])\n return false unless carrier_validator.valid?(@carrier)\n return false if !@front_template_id.nil? && @front_template_id !~ Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n return false if !@back_template_id.nil? && @back_template_id !~ Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n return false if !@front_template_version_id.nil? && @front_template_version_id !~ Regexp.new(/^vrsn_[a-zA-Z0-9]+$/)\n return false if !@back_template_version_id.nil? && @back_template_version_id !~ Regexp.new(/^vrsn_[a-zA-Z0-9]+$/)\n object_validator = EnumAttributeValidator.new('String', [\"postcard\"])\n return false unless object_validator.valid?(@object)\n return false if @url.nil?\n return false if @url !~ Regexp.new(/^https:\\/\\/(lob-assets|lob-assets-staging)\\.com\\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\\/[a-z]{3,4}_[a-z0-9]{15,16}(\\.pdf|_thumb_[a-z]+_[0-9]+\\.png)\\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9_-]+$/)\n return false if [email protected]? && @description.to_s.length > 255\n true\n end",
"def valid?\n return false if @class_id.nil?\n class_id_validator = EnumAttributeValidator.new('String', [\"network.ElementSummary\"])\n return false unless class_id_validator.valid?(@class_id)\n return false if @object_type.nil?\n object_type_validator = EnumAttributeValidator.new('String', [\"network.ElementSummary\"])\n return false unless object_type_validator.valid?(@object_type)\n ethernet_switching_mode_validator = EnumAttributeValidator.new('String', [\"end-host\", \"switch\"])\n return false unless ethernet_switching_mode_validator.valid?(@ethernet_switching_mode)\n fc_switching_mode_validator = EnumAttributeValidator.new('String', [\"end-host\", \"switch\"])\n return false unless fc_switching_mode_validator.valid?(@fc_switching_mode)\n management_mode_validator = EnumAttributeValidator.new('String', [\"IntersightStandalone\", \"UCSM\", \"Intersight\"])\n return false unless management_mode_validator.valid?(@management_mode)\n thermal_validator = EnumAttributeValidator.new('String', [\"unknown\", \"ok\", \"upper-non-recoverable\", \"upper-critical\", \"upper-non-critical\", \"lower-non-critical\", \"lower-critical\", \"lower-non-recoverable\"])\n return false unless thermal_validator.valid?(@thermal)\n true && super\n end",
"def valid?\n\t\t\t\ttrue\n\t\t\tend",
"def validate\r\n validate! rescue false\r\n end",
"def validate\n validate_string_attributes\n end",
"def valid?\n self.errors = Mongomatic::Errors.new\n do_callback(:before_validate)\n check_required_fields\n validate\n do_callback(:after_validate)\n self.errors.empty?\n end",
"def valid\n @valid\n end",
"def valid_objects\n all_objects.select { |o| o.valid? }\n end",
"def valid?\n return false if @summary.nil?\n return false if @summary.to_s.length > 100\n record_type_validator = EnumAttributeValidator.new('String', [\"ServiceTicket\", \"ProjectTicket\", \"ProjectIssue\"])\n return false unless record_type_validator.valid?(@record_type)\n return false if !@wbs_code.nil? && @wbs_code.to_s.length > 50\n return false if @company.nil?\n return false if !@site_name.nil? && @site_name.to_s.length > 50\n return false if !@address_line1.nil? && @address_line1.to_s.length > 50\n return false if !@address_line2.nil? && @address_line2.to_s.length > 50\n return false if [email protected]? && @city.to_s.length > 50\n return false if !@state_identifier.nil? && @state_identifier.to_s.length > 50\n return false if [email protected]? && @zip.to_s.length > 12\n return false if !@contact_phone_number.nil? && @contact_phone_number.to_s.length > 20\n return false if !@contact_phone_extension.nil? && @contact_phone_extension.to_s.length > 15\n return false if !@contact_email_address.nil? && @contact_email_address.to_s.length > 250\n severity_validator = EnumAttributeValidator.new('String', [\"Low\", \"Medium\", \"High\"])\n return false unless severity_validator.valid?(@severity)\n impact_validator = EnumAttributeValidator.new('String', [\"Low\", \"Medium\", \"High\"])\n return false unless impact_validator.valid?(@impact)\n return false if !@external_x_ref.nil? && @external_x_ref.to_s.length > 100\n return false if !@po_number.nil? && @po_number.to_s.length > 50\n return false if !@automatic_email_cc.nil? && @automatic_email_cc.to_s.length > 1000\n sub_billing_method_validator = EnumAttributeValidator.new('String', [\"ActualRates\", \"FixedFee\", \"NotToExceed\", \"OverrideRate\"])\n return false unless sub_billing_method_validator.valid?(@sub_billing_method)\n knowledge_base_link_type_validator = EnumAttributeValidator.new('String', [\"ServiceTicket\", \"ProjectTicket\", \"ProjectIssue\", \"KnowledgeBaseArticle\", \"Time\", \"Activity\"])\n return false unless knowledge_base_link_type_validator.valid?(@knowledge_base_link_type)\n bill_time_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_time_validator.valid?(@bill_time)\n bill_expenses_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_expenses_validator.valid?(@bill_expenses)\n bill_products_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_products_validator.valid?(@bill_products)\n predecessor_type_validator = EnumAttributeValidator.new('String', [\"Ticket\", \"Phase\"])\n return false unless predecessor_type_validator.valid?(@predecessor_type)\n return true\n end",
"def validate!\n true\n end",
"def valid?\n return false if @class_id.nil?\n class_id_validator = EnumAttributeValidator.new('String', [\"vnic.FcIf\"])\n return false unless class_id_validator.valid?(@class_id)\n return false if @object_type.nil?\n object_type_validator = EnumAttributeValidator.new('String', [\"vnic.FcIf\"])\n return false unless object_type_validator.valid?(@object_type)\n return false if [email protected]? && @name.to_s.length > 31\n return false if [email protected]? && @name !~ Regexp.new(/^[a-zA-Z0-9\\-\\._:]+$/)\n return false if !@static_wwpn_address.nil? && @static_wwpn_address !~ Regexp.new(/^$|((^20|5[0-9a-fA-F]{1}):([0-9a-fA-F]{2}:){6}([0-9a-fA-F]{2}))/)\n type_validator = EnumAttributeValidator.new('String', [\"fc-initiator\", \"fc-nvme-initiator\", \"fc-nvme-target\", \"fc-target\"])\n return false unless type_validator.valid?(@type)\n return false if [email protected]? && @wwpn !~ Regexp.new(/^$|((^20|5[0-9a-fA-F]{1}):([0-9a-fA-F]{2}:){6}([0-9a-fA-F]{2}))/)\n wwpn_address_type_validator = EnumAttributeValidator.new('String', [\"POOL\", \"STATIC\"])\n return false unless wwpn_address_type_validator.valid?(@wwpn_address_type)\n true && super\n end",
"def valid?\n validate_survivors and validate_items && validate_records\n end",
"def valid?\n return false if @id.nil?\n return false if @next_send.nil?\n return false if @rrule.nil?\n return false if @session.nil?\n return false if @last_sent.nil?\n return false if @contact_name.nil?\n return false if @parameters.nil?\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', ['Once', 'Hourly', 'Daily', 'Weekly', 'Monthly', 'Yearly'])\n return false unless type_validator.valid?(@type)\n return false if @summary.nil?\n return false if @text_parameters.nil?\n return false if @first_occurrence.nil?\n return false if @last_occurrence.nil?\n return false if @recipients_count.nil?\n return false if @timezone.nil?\n return false if @completed.nil?\n return false if @avatar.nil?\n return false if @created_at.nil?\n true\n end",
"def valid?\n return false if [email protected]? && @description.to_s.length > 255\n return false if @routing_number.nil?\n return false if @routing_number.to_s.length > 9\n return false if @routing_number.to_s.length < 9\n return false if @account_number.nil?\n return false if @account_number.to_s.length > 17\n return false if @account_type.nil?\n account_type_validator = EnumAttributeValidator.new('String', [\"company\", \"individual\"])\n return false unless account_type_validator.valid?(@account_type)\n return false if @signatory.nil?\n return false if @signatory.to_s.length > 30\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^bank_[a-zA-Z0-9]+$/)\n return false if !@signature_url.nil? && @signature_url !~ Regexp.new(/^https:\\/\\/lob-assets\\.com\\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\\/[a-z]{3,4}_[a-z0-9]{15,16}(\\.pdf|_thumb_[a-z]+_[0-9]+\\.png)\\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9_-]+$/)\n return false if @date_created.nil?\n return false if @date_modified.nil?\n return false if @object.nil?\n object_validator = EnumAttributeValidator.new('String', [\"bank_account\"])\n return false unless object_validator.valid?(@object)\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n return false if @id.nil?\n return false if @account_id.nil?\n return false if @organization_id.nil?\n return false if @product_id.nil?\n return false if @product_rate_plan_id.nil?\n return false if @name.nil?\n type_validator = EnumAttributeValidator.new('String', [\"Subscription\", \"FixedTerm\", \"Trial\"])\n return false unless type_validator.valid?(@type)\n return false if @state.nil?\n state_validator = EnumAttributeValidator.new('String', [\"Trial\", \"Provisioned\", \"Paid\", \"AwaitingPayment\", \"Cancelled\", \"Failed\", \"Expired\"])\n return false unless state_validator.valid?(@state)\n return false if @initial_period_start.nil?\n return false if @trial_end.nil?\n managed_by_validator = EnumAttributeValidator.new('String', [\"BillForward\", \"Stripe\"])\n return false unless managed_by_validator.valid?(@managed_by)\n return false if @version_start.nil?\n return false if @version_number.nil?\n return false if @current_time.nil?\n failed_payment_behaviour_validator = EnumAttributeValidator.new('String', [\"CancelSubscription\", \"None\"])\n return false unless failed_payment_behaviour_validator.valid?(@failed_payment_behaviour)\n return true\n end",
"def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end",
"def valid?\n return false if @name.nil?\n return false if @name.to_s.length < 1\n return false if @timezone.nil?\n return false if @timezone.to_s.length < 1\n return false if @currency.nil?\n return false if @currency.to_s.length < 1\n case_sensitivity_validator = EnumAttributeValidator.new('String', [\"sensitive\", \"insensitive-uppercase\", \"insensitive-lowercase\"])\n return false unless case_sensitivity_validator.valid?(@case_sensitivity)\n campaign_priority_validator = EnumAttributeValidator.new('String', [\"universal\", \"stackable\", \"exclusive\"])\n return false unless campaign_priority_validator.valid?(@campaign_priority)\n exclusive_campaigns_strategy_validator = EnumAttributeValidator.new('String', [\"listOrder\", \"lowestDiscount\", \"highestDiscount\"])\n return false unless exclusive_campaigns_strategy_validator.valid?(@exclusive_campaigns_strategy)\n default_discount_scope_validator = EnumAttributeValidator.new('String', [\"sessionTotal\", \"cartItems\", \"additionalCosts\"])\n return false unless default_discount_scope_validator.valid?(@default_discount_scope)\n default_discount_additional_cost_per_item_scope_validator = EnumAttributeValidator.new('String', [\"price\", \"itemTotal\", \"additionalCosts\"])\n return false unless default_discount_additional_cost_per_item_scope_validator.valid?(@default_discount_additional_cost_per_item_scope)\n true\n end",
"def valid?\n run_validation\n @errors.empty?\n end",
"def valid?\n MANDATORY_ATTRIBUTES.each{|a| return false unless self[a]}\n true\n end",
"def valid?\n return false if @id.nil?\n return false if @token.nil?\n return false if @tipo.nil?\n tipo_validator = EnumAttributeValidator.new('String', ['fatture', 'proforma', 'ordini', 'preventivi', 'ndc'])\n return false unless tipo_validator.valid?(@tipo)\n return false if @nome.nil?\n return false if @indirizzo_via.nil?\n return false if @indirizzo_cap.nil?\n return false if @indirizzo_citta.nil?\n return false if @indirizzo_provincia.nil?\n return false if @paese.nil?\n lingua_validator = EnumAttributeValidator.new('String', ['it', 'en', 'de'])\n return false unless lingua_validator.valid?(@lingua)\n return false if @piva.nil?\n return false if @cf.nil?\n return false if @numero.nil?\n return false if @valuta.nil?\n return false if @valuta_cambio.nil?\n return false if @prezzi_ivati.nil?\n return false if @importo_netto.nil?\n return false if @importo_iva.nil?\n return false if @importo_totale.nil?\n mostra_totali_validator = EnumAttributeValidator.new('String', ['tutti', 'netto', 'nessuno'])\n return false unless mostra_totali_validator.valid?(@mostra_totali)\n return false if @lista_articoli.nil?\n pa_tipo_cliente_validator = EnumAttributeValidator.new('String', ['PA', 'B2B'])\n return false unless pa_tipo_cliente_validator.valid?(@pa_tipo_cliente)\n pa_tipo_validator = EnumAttributeValidator.new('String', ['ordine', 'convenzione', 'contratto', 'nessuno'])\n return false unless pa_tipo_validator.valid?(@pa_tipo)\n pa_esigibilita_validator = EnumAttributeValidator.new('String', ['I', 'D', 'S', 'N'])\n return false unless pa_esigibilita_validator.valid?(@pa_esigibilita)\n true\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.')\n end\n\n invalid_properties\n end",
"def valid?\n return false if @name.nil?\n return false if @name.to_s.length > 50\n return false if @prefix_suffix_option.nil?\n prefix_suffix_option_validator = EnumAttributeValidator.new('String', [\"Prefix\", \"Suffix\"])\n return false unless prefix_suffix_option_validator.valid?(@prefix_suffix_option)\n return false if !@invoice_pre_suffix.nil? && @invoice_pre_suffix.to_s.length > 5\n application_units_validator = EnumAttributeValidator.new('String', [\"Amount\", \"Hours\", \"Incidents\"])\n return false unless application_units_validator.valid?(@application_units)\n application_cycle_validator = EnumAttributeValidator.new('String', [\"Contract2Weeks\", \"Contract4Weeks\", \"ContractYear\", \"CalendarMonth\", \"CalendarQuarter\", \"CalendarWeek\", \"ContractQuarter\", \"CalendarYear\"])\n return false unless application_cycle_validator.valid?(@application_cycle)\n return false if @employee_comp_rate.nil?\n employee_comp_rate_validator = EnumAttributeValidator.new('String', [\"Actual\", \"Hourly\"])\n return false unless employee_comp_rate_validator.valid?(@employee_comp_rate)\n return false if @employee_comp_not_exceed.nil?\n employee_comp_not_exceed_validator = EnumAttributeValidator.new('String', [\"Billing\", \"Percent\", \"Amount\"])\n return false unless employee_comp_not_exceed_validator.valid?(@employee_comp_not_exceed)\n return false if @invoicing_cycle.nil?\n invoicing_cycle_validator = EnumAttributeValidator.new('String', [\"CalendarYear\", \"ContractYear\"])\n return false unless invoicing_cycle_validator.valid?(@invoicing_cycle)\n return false if !@invoice_description.nil? && @invoice_description.to_s.length > 4000\n return false if @bill_time.nil?\n bill_time_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_time_validator.valid?(@bill_time)\n return false if @bill_expenses.nil?\n bill_expenses_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_expenses_validator.valid?(@bill_expenses)\n return false if @bill_products.nil?\n bill_products_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_products_validator.valid?(@bill_products)\n return true\n end",
"def validate\n end",
"def valid?\n return false if @to.nil?\n return false if @from.nil?\n carrier_validator = EnumAttributeValidator.new('String', [\"USPS\"])\n return false unless carrier_validator.valid?(@carrier)\n return false if @date_created.nil?\n return false if @date_modified.nil?\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^ltr_[a-zA-Z0-9]+$/)\n return false if !@template_id.nil? && @template_id !~ Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n return false if !@template_version_id.nil? && @template_version_id !~ Regexp.new(/^vrsn_[a-zA-Z0-9]+$/)\n return false if [email protected]? && @url !~ Regexp.new(/^https:\\/\\/(lob-assets|lob-assets-staging)\\.com\\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\\/[a-z]{3,4}_[a-z0-9]{15,16}(\\.pdf|_thumb_[a-z]+_[0-9]+\\.png)\\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9_-]+$/)\n return false if @object.nil?\n object_validator = EnumAttributeValidator.new('String', [\"letter\"])\n return false unless object_validator.valid?(@object)\n return false if [email protected]? && @description.to_s.length > 255\n return false if !@tracking_events.nil? && @tracking_events.length > 0\n address_placement_validator = EnumAttributeValidator.new('String', [\"top_first_page\", \"insert_blank_page\", \"bottom_first_page_center\", \"bottom_first_page\"])\n return false unless address_placement_validator.valid?(@address_placement)\n true\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def supports_validations?\n true\n end",
"def valid?\n @errors = self.class.valid_against_schema?(self.class.json_schema, self)\n @errors.empty?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n return false if @first_name.nil?\n return false if @first_name.to_s.length > 30\n return false if !@last_name.nil? && @last_name.to_s.length > 30\n return false if !@address_line1.nil? && @address_line1.to_s.length > 50\n return false if !@address_line2.nil? && @address_line2.to_s.length > 50\n return false if [email protected]? && @city.to_s.length > 50\n return false if [email protected]? && @state.to_s.length > 50\n return false if [email protected]? && @zip.to_s.length > 12\n return false if [email protected]? && @country.to_s.length > 50\n return false if !@security_identifier.nil? && @security_identifier.to_s.length > 184\n return false if [email protected]? && @title.to_s.length > 100\n return false if [email protected]? && @school.to_s.length > 50\n return false if !@nick_name.nil? && @nick_name.to_s.length > 30\n return false if !@significant_other.nil? && @significant_other.to_s.length > 30\n return false if !@portal_password.nil? && @portal_password.to_s.length > 15\n return false if !@portal_security_level.nil? && @portal_security_level > 6.0\n return false if !@portal_security_level.nil? && @portal_security_level < 1.0\n gender_validator = EnumAttributeValidator.new('String', [\"Male\", \"Female\"])\n return false unless gender_validator.valid?(@gender)\n presence_validator = EnumAttributeValidator.new('String', [\"Online\", \"DoNotDisturb\", \"Away\", \"Offline\", \"NoAgent\"])\n return false unless presence_validator.valid?(@presence)\n return true\n end",
"def validated?; end",
"def valid?\n return false if @name.nil?\n return false if @slug.nil?\n return false if @status.nil?\n status_validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])\n return false unless status_validator.valid?(@status)\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', ['digital', 'physical'])\n return false unless type_validator.valid?(@type)\n return false if @sku.nil?\n return false if @price.nil?\n availability_validator = EnumAttributeValidator.new('String', ['available', 'comingSoon', 'retired'])\n return false unless availability_validator.valid?(@availability)\n stock_status_validator = EnumAttributeValidator.new('String', ['available', 'alert', 'unavailable'])\n return false unless stock_status_validator.valid?(@stock_status)\n return false if @categories.nil?\n true\n end",
"def valid?\n self.valid\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end"
] | [
"0.78992486",
"0.78992486",
"0.70971805",
"0.70782334",
"0.7032205",
"0.7031276",
"0.69510347",
"0.6869891",
"0.6858077",
"0.6858077",
"0.68287027",
"0.6823878",
"0.6820306",
"0.68144894",
"0.6794656",
"0.6752167",
"0.66843414",
"0.6676546",
"0.6667755",
"0.66296124",
"0.66184515",
"0.6608204",
"0.6599208",
"0.6594276",
"0.6584302",
"0.6580472",
"0.6578095",
"0.6558585",
"0.6555879",
"0.6542414",
"0.6536983",
"0.6533884",
"0.65315515",
"0.65311855",
"0.65267456",
"0.65258855",
"0.6520786",
"0.65205675",
"0.6511026",
"0.6498394",
"0.64966303",
"0.64935124",
"0.6491113",
"0.64885867",
"0.6479024",
"0.6473706",
"0.64679337",
"0.6467217",
"0.6461245",
"0.64601135",
"0.64553183",
"0.64540446",
"0.6447954",
"0.64393955",
"0.6434162",
"0.64312094",
"0.6428205",
"0.6426148",
"0.6412439",
"0.64070046",
"0.64044213",
"0.6403482",
"0.6399368",
"0.63979715",
"0.63858813",
"0.63855004",
"0.63855004",
"0.63855004",
"0.63855004",
"0.63740236",
"0.6367379",
"0.63645166",
"0.6362151",
"0.63599974",
"0.6357385",
"0.63549066",
"0.63549066",
"0.63549066",
"0.63549066",
"0.6354845",
"0.6354207",
"0.6350302",
"0.6344303",
"0.6344303",
"0.6344303",
"0.6344303",
"0.6344303",
"0.6344303",
"0.6344303",
"0.6344303",
"0.63435715",
"0.63406414",
"0.63344824",
"0.6333158",
"0.63313466",
"0.63294095",
"0.6327076",
"0.63247603",
"0.63247603",
"0.63247603",
"0.63247603"
] | 0.0 | -1 |
Checks equality by comparing each attribute. | def ==(o)
return true if self.equal?(o)
self.class == o.class &&
action == o.action &&
attachments == o.attachments &&
attendees == o.attendees &&
description == o.description &&
duration == o.duration &&
repeat == o.repeat &&
summary == o.summary &&
trigger == o.trigger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def ==(other) # :nodoc:\n @attrs == other.attrs\n end",
"def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n end",
"def assert_equal_attributes(object, expected_attributes)\n expected_attributes.each do |index, value|\n assert_equal value, object[index], \"#{index}\"\n end\n end",
"def attr_equal?(o)\n self == o and\n self.instance_variables_compare(o).empty? and\n self.attributes == o.attributes\n end",
"def same_attributes?(spec)\n @@attributes.all? {|name, default| self.send(name) == spec.send(name) }\n end",
"def ==(other)\n self.class.valid_attrs.each do |attr|\n return false if read(attr) != other.read(attr)\n end\n true\n end",
"def ==(other)\n self.attributes == (other.respond(:attributes) || {} )\n end",
"def ==(other)\n other.present? && self.attributes == other.attributes\n end",
"def ==(other)\n return false if other.nil? || !other.respond_to?(:attributes)\n attributes == other.attributes\n end",
"def match?(attributes)\n attributes.each do |attr, val|\n return false if send(attr).to_s != val.to_s\n end\n true\n end",
"def ==(other)\n self.class == other.class &&\n self.attributes == other.attributes\n end",
"def ==(other)\n self.class == other.class &&\n attributes == other.attributes\n end",
"def ==(other)\n return super unless other.is_a?(self.class)\n\n attributes.all? { |name, value| value == other.send(name) }\n end",
"def changed?(comparison)\n attributes.any? do |attribute, value|\n next unless comparison.key?(attribute)\n comparison[attribute] != value\n end\n end",
"def ==(other)\n return false unless self.class == other.class\n self.attributes == other.attributes\n end",
"def ==(other)\n if other.kind_of? Details::Attribute\n self.name == other.name && self.value == other.value\n else\n self.value == other\n end\n end",
"def ==(other)\n return false unless other.instance_of? self.class\n attributes == other.attributes\n end",
"def ==(other)\n return super unless other.is_a?(self.class)\n\n attributes.all? { |name, value| value == other.attributes[name] }\n end",
"def ==(other)\n return super unless other.is_a?(self.class)\n\n attributes.all? { |name, value| value == other.attributes[name] }\n end",
"def ==(other)\n return super unless other.is_a?(self.class)\n\n attributes.all? { |name, value| value == other.attributes[name] }\n end",
"def ==(other)\n Attribute === other && \n !(Expression === other) &&\n relation == other.relation && \n name == other.name && \n self.alias == other.alias && \n original_relation == other.original_relation\n end",
"def ==(obj)\n if obj.instance_of?(self.class)\n compare_attributes = [\"category_id\", \"combo_item_id\", \"quantity\", \"sequence\"]\n compare_attributes.each do |field|\n if self.send(field) != obj.send(field)\n return false\n end\n end\n return true\n end\n return false\n end",
"def ==(other)\n return false if other.class != self.class\n attr_hash == other.attr_hash\n end",
"def ==(other)\n case other\n when Chair::Row\n @attributes == other.instance_variable_get('@attributes')\n when Array\n @attributes.values == other\n else false\n end\n end",
"def == other\n return false unless other.kind_of? self.class\n attribute_of.all? do |key, val|\n val.get == other.__send__(key)\n end\n end",
"def correct_combination?(attr1, attr2, attr3)\n result = false\n if attr1 == attr2 && attr2 == attr3\n result = true\n elsif attr1 != attr2 && attr2 != attr3 && attr1 != attr3\n result = true\n end\n return result\n end",
"def ==(other)\n return false if self.class != other.class\n return super if @_lazer_model.required_properties.empty?\n @_lazer_model.required_properties.each do |key_name|\n return false if read_attribute(key_name) != other.read_attribute(key_name)\n end\n true\n end",
"def eql?(other)\n other.is_a?(self.class) && !self.class.comparison_attrs.find{|a| send(a) != other.send(a)}\n end",
"def verify_attributes(hash, expected)\n return [] unless expected.attributes\n expected.attributes.map{ |a| verify_attribute_value(hash[a.name.to_s], a) }\n end",
"def assert_attributes obj, attr_hash\n default_attr_hash = {}\n if obj.respond_to? :default_attr_hash\n default_attr_hash = obj.default_attr_hash\n end\n default_attr_hash.merge(attr_hash).each_pair do |key, value|\n assert_equal value, obj.__send__(key), \"Attribute #{key} of #{obj}\"\n end\n end",
"def match_attributes(attrs)\n attrs = Saxxy::Helpers.stringify_keys(attrs)\n attributes.reduce(true) do |b, (k, v)|\n value = attrs[k]\n b && ((!value.nil? && match(v, value)) || (v.nil? && value.nil?))\n end\n end",
"def equal_set(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id).sort\n right = expected.map(&:id).sort\n \n test_case.assert(left != right, message)\n end",
"def ===(other)\n required = self.class.required_attributes\n\n other.respond_to?(:keys) && (common = other.keys & required) &&\n common.size == other.keys.size && common.size == required.size\n end",
"def bt_same_value?(other)\n bt_value_attributes == other.bt_value_attributes\n end",
"def ==(x)\n return true if object_id == x.object_id\n return false unless x.kind_of?(AttrArray)\n each_with_index do |a, n|\n return false unless a == x[n]\n end\n true\n end",
"def equal_set(expected)\n message = \"#{Helpers.inspect_records(@object)} does not have the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id).sort\n right = expected.map(&:id).sort\n \n test_case.assert(left == right, message)\n end",
"def compare_attributes(data_criteria, criteria)\n return false unless data_criteria['dataElementAttributes']&.any?\n\n data_criteria['dataElementAttributes'].map { |dc| dc.except('_id') }.include? criteria['dataElementAttributes'][attribute_index].except('_id')\n end",
"def ==(other)\n @klass == other.class && @attributes == strip_active_record(other)\n end",
"def ==(other)\n other.is_a?(self.class) &&\n other.attribute == attribute &&\n other.validation == validation &&\n other.expected == expected &&\n other.actual == actual\n end",
"def == other\n return false unless self.class == other.class\n [:unit, :frequency, :anchor, :weeks, :monthdays, :weekdays, :times].all? do |attribute|\n self.send(attribute) == other.send(attribute)\n end\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 ==(b) # :nodoc:\n ( b.respond_to?(:result_attributes) &&\n result_attributes == b.result_attributes && \n @result_attributes.all?{ |k| send(k) == b.send(k) } )\n end",
"def validates_different(*attr_names)\n validates_with ValidatesAll::DifferenceValidator, _merge_attributes(attr_names)\n end",
"def identical?\n #Song.first.attributes.each { |v,k| Song.find(:all, :conditions => [\" #{v} like ?\", \"%blah%\"])}\n Song.find(:all, :conditions => [\"name = ? or length = ?\", \"#{self.name}\", self.length]) do |x| \n x.hash == self.hash\n end\n end",
"def diff?(model = self.class.find(id))\n self.class.diffable_attributes.each do |attribute|\n return true if send(attribute) != model.send(attribute)\n end\n return false\n end",
"def filter_attributes_match?(hash_one, hash_two)\n hash_one.all? do |key, value_one|\n value_two = hash_two[key]\n case\n when value_one == value_two\n true\n when value_one.is_a?(Hash) && value_two.is_a?(Hash)\n filter_attributes_match?(value_one, value_two)\n when hash_one[key].to_s == hash_two[key].to_s\n true\n when value_one.is_a?(String) && value_one.start_with?(\"eval:\")\n eval_attribute_value(value_one, value_two)\n else\n false\n end\n end\n end",
"def comparable_attributes\n#\t\tHashWithIndifferentAccess[attributes.select {|k,v| \n#\t\t\t!Abstract.incomparable_attribute_names.include?(k)}]\n\t\tHashWithIndifferentAccess[attributes.select {|k,v| db_fields.include?(k)}]\n\tend",
"def all_equal?\n a = self.first\n all? { |b| a == b }\n end",
"def check_attrs(attr_list)\r\n attrs = []\r\n attr_list.each do |attr_sym|\r\n attr = assigns(attr_sym.to_sym)\r\n assert_not_nil attr, \"Attribute @#{attr_sym} should not be nil\"\r\n assert !attr.new_record?, \"Should have saved the @#{attr_sym} obj\" if attr.class == ActiveRecord\r\n attrs << attr\r\n end\r\n attrs.length > 1 ? attrs : attrs[0]\r\n end",
"def check_attrs(attr_list)\r\n attrs = []\r\n attr_list.each do |attr_sym|\r\n attr = assigns(attr_sym.to_sym)\r\n assert_not_nil attr, \"Attribute @#{attr_sym} should not be nil\"\r\n assert !attr.new_record?, \"Should have saved the @#{attr_sym} obj\" if attr.class == ActiveRecord\r\n attrs << attr\r\n end\r\n attrs.length > 1 ? attrs : attrs[0]\r\n end",
"def attr_set?(cards, attr)\n array = []\n cards.each do |card|\n # evalutes the string 'attr' and returns the value\n array << card.send(attr)\n end\n\n # only return true if it's all the same or totally different\n return true if array.uniq.count == 1\n return true if array.uniq.count == 3\n return false\n end",
"def attribute_changed?(attribute_name)\n (self.diff['attributes']['new']||{})[attribute] != (self.diff['attributes']['old']||{})[attribute]\n end",
"def eql?(other)\n return false if (other.nil? or self.class != other.class)\n return false unless super(other)\n return false unless self.attributes == other.attributes\n return false unless self.nodes == other.nodes\n true\n end",
"def eql?(other)\n return false unless self.class == other.class\n self.key_attributes == other.key_attributes\n end",
"def uniquify_attributes(attributes)\n attributes.each do |ka|\n oldval = send(ka)\n next unless String === oldval\n newval = UniquifierCache.instance.get(self, oldval)\n set_property_value(ka, newval)\n logger.debug { \"Reset #{qp} #{ka} from #{oldval} to unique value #{newval}.\" }\n end\n end",
"def eql?(object)\n self.class.equal?(object.class) && attributes == object.attributes\n end",
"def multi_element_attr_check( elements )\n wanted = Array.new\n found = Array.new\n elements.each do |element|\n print \".\"\n e = $driver.find_element(element[0].to_sym, element[1])\n wanted << [ element[1], element[2], element[3] ]\n found << [ element[1], element[2], e.attribute(element[2]) ]\n end\n\n found.should == wanted\n end",
"def equals(rule)\n element == rule.element && attributes == rule.attributes\n end",
"def attr_reader(*args)\n super\n comparison_attrs.concat(args)\n end",
"def xml_nodes_match_attrs(xml_nodes, attrs, mismatches = [])\n attrs.each_with_index.each { |attr_set, idx|\n xn = xml_nodes[idx]\n attr_set.each { |(attr_key, attr_val)|\n # Either call method, or hash key, or recurse on children\n # p.name vs. p[:name]\n if :children == attr_key\n # recurse over children\n xml_nodes_match_attrs(xn.children, attr_val, mismatches)\n else\n # compare attrs\n xn_val = xn.methods.include?(attr_key) ? xn.send(attr_key) : xn[attr_key]\n if xn_val != attr_val\n mismatches << { node: xn.name_and_class_path, attr: \"#{ attr_key }: expected #{ attr_val.inspect }, got #{ xn_val.inspect }\" }\n end\n end\n }\n }\n mismatches\n end",
"def matches_state_attrs?\n @expected_attrs == state_attrs\n end",
"def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left != right, message)\n end",
"def eql?(other)\n return false unless super(other)\n return false unless attributes == other.attributes\n return false unless content == other.content\n\n true\n end",
"def ==(other)\n return true if other.equal?(self)\n return false unless other.instance_of?(self.class)\n\n self.class.attributes.inject(true) do |memo, attribute|\n attribute_name = attribute.first\n attribute_type = attribute.last[:type]\n\n # Skip associations\n if attribute_type.include?(LazyResource::Resource) || (attribute_type.is_a?(::Array) && attribute_type.first.include?(LazyResource::Resource))\n memo\n else\n memo && self.send(:\"#{attribute_name}\") == other.send(:\"#{attribute_name}\")\n end\n end\n end",
"def matches? item, attributes\n\n attributes.map { |attribute, value|\n\n item.send(attribute) == value\n\n }.flatten == [true]\n\n end",
"def ==( other ) \n\t\t\tcomparison_attributes = lambda{ |area| [ area.area_desc, area.altitude, area.ceiling, area.circles, area.geocodes, area.polygons ]}\n\t\t\tcomparison_attributes.call( self ) == comparison_attributes.call( other )\n\t\tend",
"def all_obs_same_attr?(observations, attr)\n exemplar = observations.first.send(attr)\n observations.all? { |o| o.send(attr) == exemplar }\n end",
"def eql?(*) end",
"def eql?(other)\n return true if equal?(other)\n return false unless self == other\n [:id, :fide_id, :rating, :fide_rating, :title, :gender].each do |m|\n return false if self.send(m) && other.send(m) && self.send(m) != other.send(m)\n end\n true\n end",
"def match\n @matches = attributes_enumerator.map do |(type, value), index|\n attribute_name = self.class.names[index]\n attributes.store(\n attribute_name, type.match(value, context: @context.dup)\n )\n end\n return if (failures = @matches.select(&:invalid?)).empty?\n failures.unshift(failure).reduce(:merge!)\n end",
"def ==(val)\n if val.is_a?(Model)\n # Use normal comparison for a model\n super\n else\n # Compare to attributes otherwise\n attributes == val\n end\n end",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n attribute == o.attribute &&\n statistics == o.statistics &&\n other == o.other &&\n total == o.total &&\n missing == o.missing &&\n term_count == o.term_count &&\n term_type == o.term_type &&\n terms == o.terms\n end",
"def ==(*several_variants)\n #This is a stub, used for indexing\n end",
"def is_equal?(a)\n @amount == a.amount && @code == a.code\n end",
"def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} does not have the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left == right, message)\n end",
"def comparison_attributes\n except_list = ['id', 'updated_at', 'created_at', 'verified_at']\n except_list << 'alternative_phone' unless Spree::Config[:alternative_shipping_phone]\n except_list << 'company' unless Spree::Config[:company]\n\n a = attributes.except(*except_list)\n a.each{|k, v|\n if v.is_a?(String)\n v = v.downcase.strip.gsub(/\\s+/, ' ')\n a[k] = v.present? ? v : nil\n end\n }\n a['state_name'] = nil if a['state_name'].blank?\n a\n end",
"def multi_element_attr_match( elements )\n elements.each do |element|\n print \".\"\n wait_for_element(element[0].to_sym, element[1])\n check_attribute_match(element[0].to_sym, element[1], element[2], element[3])\n end\n end",
"def xml_should_eql(actual, expected)\n same = xml_cmp(actual, expected)\n actual.should.== expected unless same \nend",
"def test_equality_simple\n value1_ = ::Versionomy.create(:major => 2, :minor => 0, :release_type => :alpha, :alpha_version => 5)\n value2_ = ::Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)\n assert_equal(value2_, value1_)\n assert_equal(value2_.hash, value1_.hash)\n end",
"def ==(other)\n other.is_a?(self.class) &&\n name == other.name &&\n attributes == other.attributes\n end",
"def changes(attrs1, attrs2)\n old_attrs = attrs1.slice(*GENERATED_ATTRS)\n new_attrs = attrs2.slice(*GENERATED_ATTRS)\n\n return if old_attrs == new_attrs\n old_attrs.each do |k, v|\n next if new_attrs[k] == v\n @changes << Change.new(nil, k, v, new_attrs[k]) \n end\n end",
"def tdiff_equal(node)\n if (self.class == node.class)\n case node\n when Nokogiri::XML::Attr\n (self.name == node.name && self.value == node.value)\n when Nokogiri::XML::Element, Nokogiri::XML::DTD\n self.name == node.name\n when Nokogiri::XML::Text, Nokogiri::XML::Comment\n self.text == node.text\n when Nokogiri::XML::ProcessingInstruction\n (self.name == node.name && self.content = self.content)\n else\n false\n end\n else\n false\n end\n end",
"def ==(other)\n name == other.name &&\n color == other.color &&\n age == other.age\n end",
"def more_desirable?(attribute_id1, attribute_id2)\n attribute_id1 < attribute_id2\n end",
"def isSame(tab)\n for x in 0..3\n for y in 0..3\n return(false) if (self.val(x,y) != tab.val(x,y)) ;\n end\n end\n return true ;\n end",
"def ==(other)\n # If the classes don't match, they cannot possibly be equal.\n if self.class != other.class\n return false\n end\n\n # If the persisted state doesn't match, they also can never be equal.\n if persisted? != other.persisted?\n return false\n end\n\n # When persisted, check the other's id to see if it's the same,\n # cannot possible be equals if they have different ids.\n if persisted? && id != other.id\n return false\n end\n\n # Finally, compare the attributes hash. If all key/values match,\n # they are considered equal.\n attributes == other.attributes\n end",
"def ==(other)\n self.class == other.class &&\n attributes[\"_id\"] == other.attributes[\"_id\"]\n end",
"def assert_same_values(expected, actual)\n actual.each_pair do |k,v|\n next unless expected[k]\n assert_equal expected[k], v, \"Values for #{k} are not matching\"\n end\n end",
"def assert_equivalent_xml(expected, actual)\n expected_xml = Nokogiri::XML(\"<test-xml>\\n#{expected}\\n</test-xml>\")\n actual_xml = Nokogiri::XML(\"<test-xml>\\n#{actual}\\n</test-xml>\")\n ignored_attributes = %w(style data-disable-with)\n\n equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml, {\n ignore_attr_values: ignored_attributes\n }) do |a, b, result|\n if result === false && b.is_a?(Nokogiri::XML::Element)\n if b.attr('name') == 'utf8'\n # Handle wrapped utf8 hidden field for Rails 4.2+\n result = EquivalentXml.equivalent?(a.child, b)\n end\n if b.delete('data-disable-with')\n # Remove data-disable-with for Rails 5+\n # Workaround because ignoring in EquivalentXml doesn't work\n result = EquivalentXml.equivalent?(a, b)\n end\n if a.attr('type') == 'datetime' && b.attr('type') == 'datetime-local'\n a.delete('type')\n b.delete('type')\n # Handle new datetime type for Rails 5+\n result = EquivalentXml.equivalent?(a, b)\n end\n end\n result\n end\n\n assert equivalent, lambda {\n # using a lambda because diffing is expensive\n Diffy::Diff.new(\n sort_attributes(expected_xml.root),\n sort_attributes(actual_xml.root)\n ).to_s(:color)\n }\n end",
"def sync_duplicate_obj_attributes(obj1, obj2)\n duplicate_keys.each do |key|\n unless obj1[key].blank? && obj2[key].blank?\n if obj1[key].blank?\n obj1.send(\"#{key}=\", obj2[key])\n elsif obj2[key].blank?\n obj2.send(\"#{key}=\", obj1[key])\n else # Each obj has a value\n if obj1[key] != obj2[key]\n raise ArgumentError, \"#{key} attribute values on the two objects don't match: #{obj1[key]} vs #{obj2[key]}\"\n end\n end\n end\n end\n end",
"def eql?(other)\n return true if equal?(other)\n\n # two instances for different models cannot be equivalent\n return false unless other.kind_of?(model)\n\n # two instances with different keys cannot be equivalent\n return false if key != other.key\n\n # neither object has changed since loaded, so they are equivalent\n return true if repository == other.repository && !dirty? && !other.dirty?\n\n # get all the loaded and non-loaded properties that are not keys,\n # since the key comparison was performed earlier\n loaded, not_loaded = properties.select { |p| !p.key? }.partition do |property|\n attribute_loaded?(property.name) && other.attribute_loaded?(property.name)\n end\n\n # check all loaded properties, and then all unloaded properties\n (loaded + not_loaded).all? { |p| p.get(self) == p.get(other) }\n end",
"def assert_event_are_light_equal e1, e2\n return false if e1.class != e2.class\n\n [:subject, :event, :moodid,\n :mood, :music, :location, :taglist, :pickeyword,\n :preformatted, :backdated, :comments, :security, :allowmask,\n :screening,].each do |attr|\n return false if e1.send(attr) != e2.send(attr)\n end\n\n e1.compare_time(e2)\n end",
"def eql(expected)\n set_relativity(:eql, expected)\n end",
"def modified?( original )\n DATA_ATTRIBUTES.any? { |e| send( e ) != original.send( e )}\n end",
"def ==(other)\n @name == other.name && @amount == other.amount\n end",
"def ==(other)\n other.kind_of?(self.class) &&\n @name == other.name && @columns == other.columns && @unique == other.unique?\n end",
"def match_same_name_attributes(*options)\n\n options = options.extract_options!\n same_name_attributes = @from_table.columns.map(&:name) & @to_table.columns.map(&:name)\n\n if same_name_attributes\n same_name_attributes = columns_from_options(same_name_attributes, options)\n same_name_attributes.each do |same_name_attribute|\n from same_name_attribute, :to => same_name_attribute\n end\n end\n end",
"def equal_pair(key, request)\n if @event[\"required\"][key] == request[\"object_attributes\"][key] || event[\"required\"][key] == \"\"\n true\n else\n false\n end\n end",
"def assert_equal(att, value, error = [att, :not_equal])\n assert value === send(att), error\n end",
"def validate\n matched = {}\n duplicated_attributes = []\n attributes.each do |attribute|\n if matched.has_key?(attribute.name) && matched[attribute.name] == attribute.name_format\n duplicated_attributes << attribute.name unless duplicated_attributes.include?(attribute.name)\n else\n matched[attribute.name] = attribute.name_format\n end\n end\n if !duplicated_attributes.empty?\n raise ValidationError, \"An attribute with the same name and name format may only be specified once. The following attributes were specified multiple times: #{duplicated_attributes.join(',')}\"\n end\n end"
] | [
"0.7291717",
"0.7188103",
"0.70395297",
"0.7007927",
"0.68874705",
"0.6861532",
"0.6707156",
"0.6660597",
"0.66147524",
"0.658478",
"0.6584619",
"0.6580019",
"0.65543133",
"0.6543933",
"0.65068495",
"0.6479513",
"0.6456241",
"0.6415999",
"0.6412208",
"0.6412208",
"0.6412208",
"0.6411266",
"0.6380575",
"0.63775986",
"0.6260147",
"0.6246534",
"0.6240681",
"0.62150854",
"0.62014365",
"0.6186426",
"0.61837834",
"0.6164858",
"0.61304426",
"0.61149454",
"0.6097789",
"0.6083095",
"0.6078927",
"0.6067201",
"0.60053444",
"0.59974694",
"0.5994989",
"0.5991373",
"0.59856457",
"0.5985243",
"0.5977118",
"0.59521115",
"0.59428704",
"0.59311265",
"0.59247756",
"0.5921222",
"0.5921222",
"0.59095234",
"0.58795947",
"0.58789194",
"0.5870439",
"0.58598673",
"0.58571184",
"0.5856412",
"0.5855177",
"0.58480394",
"0.5847516",
"0.58370507",
"0.5799985",
"0.5795313",
"0.57880926",
"0.57823527",
"0.57788265",
"0.5776185",
"0.57670164",
"0.5759791",
"0.5758563",
"0.5753949",
"0.57518554",
"0.5750137",
"0.57385117",
"0.57309806",
"0.5729126",
"0.572618",
"0.57250285",
"0.57210624",
"0.5712646",
"0.5710082",
"0.57059866",
"0.57036847",
"0.5702592",
"0.5690256",
"0.5674193",
"0.56433815",
"0.5641553",
"0.56216776",
"0.56148046",
"0.5591313",
"0.5587681",
"0.55836356",
"0.5569298",
"0.5550885",
"0.5546161",
"0.5545665",
"0.55422115",
"0.5539372",
"0.5529004"
] | 0.0 | -1 |
Calculates hash code according to all attributes. | def hash
[action, attachments, attendees, description, duration, repeat, summary, trigger].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n # Add lines like this for each significant instance variable\n code # Return the resulting code\n end",
"def hash(*) end",
"def hash\n code = 17\n code = 37 * code\n self.instance_variables.each do |v|\n code += self.instance_variable_get(v).hash\n end\n code\n end",
"def hash_code; end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end",
"def hash() #:nodoc:\n prime = 31;\n result = 1;\n result = prime * result + @amount.to_i\n result = prime * result + @new_balance.to_i\n result = prime * result + (@date.nil? ? 0 : Bankjob.date_time_to_ofx(@date).hash);\n result = prime * result + (@raw_description.nil? ? 0 : @raw_description.hash);\n result = prime * result + (@type.nil? ? 0 : @type.hash);\n # don't use value date\n return result;\n end",
"def hash\n prime = 31\n result = 1\n result = result * prime + (@decision_target == nil ? 0 : @decision_target.hash)\n result = prime * result + (@string_id == nil ? 0 : @string_id.hash)\n result\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end",
"def hash\r\n a = 0\r\n @id.each_byte {|c| a += c.to_i}\r\n (a + @paired.to_i) * HASH_PRIME\r\n end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def hash\n size.hash ^ rank.hash\n end",
"def hash\n \"#{self.class.name}-#{self.id}-#{@__metadata__.cas}-#{@__attributes__.hash}\".hash\n end",
"def hash\n @hash || calculate_hash!\n end",
"def hash\n return name.hash ^ direction.hash ^ lhs.hash ^ rhs.hash\n end",
"def hash\n value = 0\n my_rows = @rows\n r_size = my_rows.size\n for i in 0..r_size-1 do\n a_row = my_rows[i]\n a_size = a_row.size\n for j in 0..a_size-1 do\n value ^= a_row[j].hash\n end\n end\n return value\n end",
"def hash\n id.hash + 32 * bs_request.hash\n end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def hash\n [self.class, self.val, self.attribute].hash\n end",
"def hash\n 0\n end",
"def hash # :nodoc:\n identifier.hash ^ requirement.hash\n end",
"def hash\n self.class.hash ^ key_attributes.hash\n end",
"def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end",
"def hash\n h = @e.nil? ? 0 : @e\n h = (h << 1) ^ @r.hash\n h = (h << 1) ^ @v.hash\n end",
"def hash() source.hash ^ (target.hash+1); end",
"def hash() source.hash ^ (target.hash+1); end",
"def hash\n\t\t\"#{@x}#{@y}\".hash\n\tend",
"def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end",
"def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end",
"def hash_code\n prime = 31\n result = 1\n result = prime * result + x\n result = prime * result + y\n return result;\n end",
"def hash\n self.class.hash ^ operand.hash\n end",
"def hash!\n\t\t@@email.downcase!\n\t\thash = Digest::MD5.hexdigest(@@email)\n\t\treturn hash\n\tend",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def hash\n ([self.class] + self.class.comparison_attrs.map{|x| send(x)}).hash\n end",
"def hash\n @symbols.hash + 37*positive?.hash\n end",
"def calculate_unique_hash\n unique = ''\n unique += self.content if self.content.present?\n unique += self.summary if self.summary.present?\n unique += self.title if self.title.present?\n self.unique_hash = Digest::MD5.hexdigest unique\n end",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash\n # Memoizing such a simple hash value seems silly, however the\n # profiler showed the Card#hash method as having 22% of the runtime. My\n # memoizing the hash value that was reduced to 12%.\n return @hash unless @hash.nil?\n @hash = @value.hash ^ @suit.hash\n end",
"def hash=(_arg0); end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def hash\n num = 0\n self.each do |k,v|\n if k.is_a?(Integer) && v.is_a?(Integer)\n num += k * 26 + v\n elsif k.is_a?(Integer) && !v.is_a?(Integer)\n num += k * 26 + ALPHA_NUMBERS[v.to_s.downcase]\n elsif v.is_a?(Integer) && !k.is_a?(Integer)\n num += v * 26 + ALPHA_NUMBERS[k.to_s.downcase]\n elsif !k.nil? && !v.nil?\n num += ALPHA_NUMBERS[k.to_s.downcase] * ALPHA_NUMBERS[v.to_s.downcase]\n end\n end\n num\n end",
"def hash\r\n\t\treturn @name.hash() + @type.hash()\r\n\tend",
"def hash\n return @hash_code if defined? @hash_code\n @hash_code = usual_equal_object.hash\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash\n [oct, pc].hash\n end",
"def hash\n excl = @excl ? 1 : 0\n hash = excl\n hash ^= @begin.hash << 1\n hash ^= @end.hash << 9\n hash ^= excl << 24;\n # Are we throwing away too much here for a good hash value distribution?\n return hash & Fixnum::MAX\n end",
"def hash\n code.hash\n end",
"def hash # :nodoc:\n name.hash ^ type.hash ^ requirement.hash\n end",
"def hash\n @vbits.hash\n end",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def hash\n if @sha512hash != nil\n return @sha512hash.to_i(16)\n else\n super\n end\n end",
"def calc_hash(pass)\n salt_cost = SCrypt::Engine.autodetect_cost(self[:salt])\n SCrypt::Engine.scrypt(pass, self[:salt], salt_cost, 32).unpack('H*').first\n end",
"def hash\n [lac, cid, radio, mcc, mnc, signal, psc, asu, ta].hash\n end",
"def calculate_checksum\n last_checksum = previous_event&.checksum\n attrs = attributes.except(\"checksum\", \"id\", \"updated_at\").merge(last_checksum: last_checksum)\n cs = Digest::SHA256.hexdigest(attrs.to_s)\n puts \"#{id} calculate_checksum: #{cs} <- #{attrs} \" if Rails.env.development?\n Rails.logger.info(\"#{id} calculate_checksum: #{cs} <- #{attrs} \")\n return cs\n end",
"def hash\n code.hash\n end",
"def hash\n\t\t[@a, @b, self.class::D].hash\n\tend",
"def consistent_hash\n Zlib.crc32(self.to_yaml, 0)\n end",
"def hash\n @hash[:perm_type].hash ^\n @hash[:perms].hash ^\n @hash[:inheritance].hash ^\n @hash[:target].hash\n end",
"def hash( *strs )\n return Digest::MD5.hexdigest( strs.join )\n end",
"def hash\n @rank.hash ^ @suit.hash\n end",
"def hash\n return Digest::MD5.hexdigest(self.describe(' '))\n end",
"def hash\n @real.hash ^ @image.hash\n end",
"def to_hash() end",
"def hash_length\n super\n end",
"def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end",
"def hash() source.hash ^ target.hash; end",
"def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end",
"def calculate_hash(input, prep_hashes)\n result = 0\n input.unpack('U*').each do |x|\n result += prep_hashes.hash(x)\n end\n (result % MOD_VALUE).to_s(HEX)\nend",
"def c_hash\n sha256 = Digest::SHA256.new\n token = @code.token.token\n hashed_token = sha256.digest(token)\n first_half = hashed_token[0...hashed_token.length / 2]\n Base64.urlsafe_encode64(first_half).tr('=', '')\n end",
"def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end",
"def calculate_hash\n\t\toptions = {:firstname => firstname, :email => email, :phone => phone, :txnid => txnid, :surl => surl, :furl => furl, :productinfo => productinfo, :amount => amount}\n\t\tservice = PayuIndia::Helper.new(payment_gateway_key, payment_gateway_salt, options)\n\t\tself.hast = service.generate_checksum\n\tend",
"def hash\n [rank, suit].hash\n end",
"def hash\n self.class.hash ^ left.hash ^ right.hash\n end",
"def generate_hash(*args)\n Digest::SHA3.hexdigest(args.join(''))\n end",
"def hash_code\n hash_code = {}\n self.seq.each do |letter|\n hash_code.keys.include?(letter) ? hash_code[letter] += 1 : hash_code[letter] = 1\n end\n hash_code\n end",
"def hashify_attributes(attrs)\n Hash.new.tap{ |h| attrs.each{|a| h[a] = self.send(a)} }\n end",
"def hash\n\n self.h.fei.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end"
] | [
"0.7118691",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.68960655",
"0.67847186",
"0.6707762",
"0.670052",
"0.6688737",
"0.66705376",
"0.6489735",
"0.6462376",
"0.6462376",
"0.64444333",
"0.6413127",
"0.6395483",
"0.63898623",
"0.6372129",
"0.635671",
"0.63370055",
"0.62682766",
"0.62533766",
"0.6246914",
"0.6230963",
"0.62173444",
"0.6214272",
"0.6214131",
"0.61962456",
"0.619165",
"0.61866295",
"0.6185355",
"0.6185355",
"0.6153702",
"0.6145376",
"0.6144877",
"0.6139152",
"0.6128312",
"0.61224943",
"0.61217207",
"0.61205214",
"0.61041045",
"0.61000645",
"0.60937095",
"0.60931146",
"0.60818595",
"0.60811466",
"0.60500103",
"0.60322344",
"0.6022704",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.6020012",
"0.60178953",
"0.6014942",
"0.5997442",
"0.59880185",
"0.598736",
"0.59799886",
"0.5972682",
"0.5969595",
"0.5969411",
"0.59594935",
"0.5957466",
"0.59423596",
"0.5942144",
"0.59245354",
"0.5924357",
"0.5904946",
"0.59025365",
"0.58536685",
"0.5847055",
"0.58454466",
"0.5845053",
"0.58447546",
"0.5844059",
"0.5842638",
"0.5840575",
"0.58391696",
"0.5825819",
"0.5824118",
"0.5823615",
"0.58184344",
"0.5815284",
"0.58124787",
"0.5810309",
"0.5808056",
"0.5808056",
"0.5808056",
"0.5806852",
"0.5806852"
] | 0.0 | -1 |
Builds the object from hash | def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
attribute_key = self.class.attribute_map[key]
attribute_key = (attribute_key[0, 1].downcase + attribute_key[1..-1]).to_sym
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
if attributes[attribute_key].is_a?(Array)
self.send("#{key}=", attributes[attribute_key].map { |v| _deserialize($1, v) })
end
elsif !attributes[attribute_key].nil?
self.send("#{key}=", _deserialize(type, attributes[attribute_key]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end",
"def build_from_hash(attributes)\n\n end",
"def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically from the hash. If the attribute\n # does not already exist, then don't re-add the attribute class and\n # variable, just set it with the value from the hash\n hash.keys.each do |key|\n class_eval { attr_accessor key } unless instance.methods.include?(key.to_sym)\n instance.instance_variable_set \"@#{key}\", hash[key]\n end\n\n instance\n end",
"def build(hash, track_changes = true)\n resource = fields.each_with_object(new) do |field, r|\n value = hash.fetch(field.to_s, hash[field.to_sym])\n r.send(\"#{field}=\", value)\n end\n resource.clear_changes! unless track_changes\n resource\n end",
"def initialize hash\n @hash = hash\n end",
"def build(params)\n return new(params) if params.is_a?(Hash)\n raise(\"unexpected parameter, expected Hash, received #{params.class}\")\n end",
"def initialize( hash )\n\t\t\t@hash = hash.dup\n\t\t\t@dirty = false\n\t\tend",
"def initialize(a_hash)\n from_h(a_hash)\n end",
"def initialize\n\t\t\t@hash = {}\n\t\tend",
"def initialize(hash)\n @hash = hash\n @converted = {}\n end",
"def initialize(hash)\n @short_code = hash[\"short_code\"]\n @name = hash[\"name\"]\n @id = hash[\"id\"]\n end",
"def initialize(hash)\n super(hash)\n end",
"def initialize\n @h = new_hash\n end",
"def new_from_hash(hash)\n if hash == nil\n self.class.new.assign(self)\n else\n hash_obj = hash\n if hash.instance_of?(Hash)\n hash_obj = self.class.new\n merge_hash_into_object(hash, hash_obj)\n end\n instance = self.class.new\n object_assign(instance, hash_obj)\n end\n end",
"def initialize(hash={})\n @hash = hash\n end",
"def initialize\n @hash = {}\n end",
"def initialize\n @hash = {}\n end",
"def initialize(hash)\r\n hash.each { |k, v|\r\n # Create getters and setters\r\n self.class.attr_accessor(k)\r\n # Set value for created variable\r\n self.send(\"#{k}=\", v)\r\n }\r\n self.class.all.push(self)\r\n end",
"def build!(hash)\n hash.must(::Hash) { raise ArgumentError, \"#{self} expects Hash, but got #{hash.class}\" }\n\n if hash.size != variables.size\n keys1 = variables.keys\n keys2 = hash.keys.map(&:to_s)\n minus = (keys1 - keys2).map{|i| \"-#{i}\"}\n plus = (keys2 - keys1).map{|i| \"+#{i}\"}\n \n msg = \"#{self} expects #{variables.size}, but got #{hash.size} (%s)\" % (minus + plus).join(\",\")\n raise Typed::SizeMismatch, msg\n end\n\n # 'build' just ignore unknown fields, but 'build!' raise errors\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v\n end\n return obj\n end",
"def initialize(hash)\n @cw_id = hash[\"cw_id\"]\n @cik = hash[\"cik\"]\n @name = hash[\"company_name\"]\n @irs_number = hash[\"irs_number\"]\n @sic_code = hash[\"sic_code\"]\n @industry = hash[\"industry_name\"]\n @sic_sector = hash[\"sic_sector\"]\n @sector_name = hash[\"sector_name\"]\n @source_type = hash[\"source_type\"]\n @address = hash[\"raw_address\"]\n @country = hash[\"country_code\"]\n @state = hash[\"subdiv_code\"]\n @top_parent_id = hash[\"top_parent_id\"]\n @num_parents = hash[\"num_parents\"]\n @num_children = hash[\"num_children\"]\n @max_year = hash[\"max_year\"]\n @min_year = hash[\"min_year\"]\n end",
"def from_hash(hash)\n instance = allocate\n instance.instance_variable_set :@attributes, hash.freeze\n instance\n end",
"def from_hash(hash)\n hash = DEFAULTS.merge(hash)\n hash['spdx_id'] = hash.delete('spdx-id')\n ordered_array = hash.values_at(*members.map(&:to_s))\n new(*ordered_array)\n end",
"def from_hash(hash)\n hash.each_pair do |key, value|\n\n # We need to catch hashes representing child objects\n # If the hash key:value is a of a Hash/BSON:Ordered hash\n if hash[key].class == Hash || hash[key].class == BSON::OrderedHash\n # If we have a classname we know we need to return to an object\n if hash[key][\"@classname\"]\n self.instance_variable_set(key, ::Object::full_const_get(hash[key][\"@classname\"]).new(hash[key])) unless key.to_s.start_with?(\"_\")\n else\n self.instance_variable_set(key, value) unless key.to_s.start_with?(\"_\")\n end\n else\n self.instance_variable_set(key, value) unless key.to_s.start_with?(\"_\")\n end\n end\n end",
"def from_hash(hash)\n hash.each_pair do |key, value|\n\n # We need to catch hashes representing child objects\n # If the hash key:value is a of a Hash/BSON:Ordered hash\n if hash[key].class == Hash || hash[key].class == BSON::OrderedHash\n # If we have a classname we know we need to return to an object\n if hash[key][\"@classname\"]\n self.instance_variable_set(key, ::Object::full_const_get(hash[key][\"@classname\"]).new(hash[key])) unless key.to_s.start_with?(\"_\")\n else\n self.instance_variable_set(key, value) unless key.to_s.start_with?(\"_\")\n end\n else\n self.instance_variable_set(key, value) unless key.to_s.start_with?(\"_\")\n end\n end\n end",
"def initialize(hash=nil)\n @table = HashWithIndifferentAccess.new\n\n for k,v in hash\n @table[k] = v\n new_ostruct_member(k)\n end if hash\n end",
"def initialize(hash)\n @hash = hash\n @data = resourcify_data\n end",
"def from_hash hash\n @id= hash['id']\n\n @admin= hash['admin']\n @username= hash['username']\n @timezone= hash['timezone']\n @email_address= hash['email_address']\n\n @password = nil\n\n @created_at= DateTime.parse(hash['created_at'])\n @updated_at= DateTime.parse(hash['updated_at'])\n end",
"def hash_to_obj hash\n OpenStruct.new(hash) rescue raise ConfigError, \"Can't convert setup to object\"\n end",
"def from_hash( h)\n\t\th.each { |name,attributes|\n\t\t\tklass = Klass.new\n\t\t\tklass.from_hash( { name => attributes } )\n\t\t\tself.add_class( klass)\n\t\t}\n\n\t\t# this is an experiment in handling \"through\" attributes\n\t\t# i.e. enriching the model with the join classes\n\tend",
"def initialize(hash)\n load_hash(hash)\n end",
"def initialize(*args)\n super\n # hash = {}\n end",
"def build_object(resp)\n return resp unless resp.respond_to?(:merge)\n @build_object ||= final_object_class.new(resp.merge(additional_hash_to_serialize_after_response))\n end",
"def from_hash(hash)\n ordered_array = hash.values_at(*members.map(&:to_s))\n new(*ordered_array)\n end",
"def __convert hash #:nodoc:\n instance = self.class.new\n hash.each do |k, v|\n k = k.to_s if !k.respond_to?(:to_sym) && k.respond_to?(:to_s)\n instance.new_ostruct_member k\n if v.is_a?(Hash)\n v = v[\"type\"] == \"hash\" ? v[\"contents\"] : __convert(v)\n elsif v.is_a?(Array)\n v = v.map{|e| e.instance_of?(Hash) ? __convert(e) : e}\n end\n instance.send \"#{k}=\".to_sym, v\n end\n instance\n end",
"def initialize(hash)\n\t\t@id = hash['id']\n\t\t@first_name = hash['first_name']\n\t\t@last_name = hash['last_name']\n\t\t@mentor = hash['mentor']\n\tend",
"def initialize(hash={})\n @name = validate_name(hash[:name])\n @description = hash[:description]\n @snmp_opts = hash[:snmp_opts]\n\n save # Save a copy of self to Redis on creation\n end",
"def initialize\n @hash_dict = {}\n end",
"def initialize(hash=nil)\n @attributes = hash\n @attributes ||= {}\n end",
"def initialize(hash={})\n self.init_attrs_from_hash(hash)\n end",
"def from_hash(hash)\n apply_nested_hash(hash)\n end",
"def initialize(hash)\n # @id = hash[\"id\"]\n # @street_address = hash[\"street_address\"]\n # @city = hash[\"city\"]\n # @state = hash[\"state\"]\n # @zipcode = hash[\"zipcode\"]\n # @country = hash[\"country\"]\n\n #add in correct details\n end",
"def from_hash(hash)\n @data_object.user_acc_name = hash['user_acc_name']\n @data_object.user_affiliate = hash['user_affiliate']\n @user_over_13 = hash['user_over_13']\n\n contact.from_hash(hash)\n end",
"def initialize(hash)\n @name = hash[\"campaign\"] #decided to change it to \"name\" since this is the campaign class\n date_elements = hash[\"date\"].split(\"/\") #date is being passed in as a string, need this array to create the Date object in the next line\n @date = Date.new(date_elements[2].to_i + 2000, date_elements[0].to_i, date_elements[1].to_i) #added 2000 to year since the program was considering it as the year 15; this creates the date object\n @spend = hash[\"spend\"].to_f #use .to_f to make sure spend comes in as a float instead of a string\n @impressions = hash[\"impressions\"].to_i #need it as an integer for counting purposes later\n @actions = JSON.parse(hash[\"actions\"])#ensures that each action comes in as an array instead of a string\n @@all << self #shovels it into the all array\n end",
"def initialize(hash)\n hash.each do |k, v|\n self.send(\"#{k}=\", v) if self.respond_to?(\"#{k}=\")\n end\n @id = hash[\"id\"]\n end",
"def initialize (hash)\n hash.each {|key, value|\n self.class.attr_accessor(key)\n self.send((\"#{key}=\"), value)\n }\n @@all << self\n end",
"def initialize(hash={})\n @data = Hash.new\n hash.each do |key, value|\n self[key] = value\n end\n end",
"def create_from_hash(hash, opts={})\n create_opts = update_or_create_options(hash, opts)\n create { |instance| instance.set(create_opts) }\n end",
"def initialize(hash={})\n # assign the attributes here (???)\n hash.each do |k, v| # name = id, name, etc.\n self.send(\"#{k}=\", v)\n # self.k = v # there's no '.k' method\n #binding.pry\n end\n end",
"def initialize(hash) #.new\n @name = hash[:name][0]\n @region = hash[:region]\n @population = hash[:population]\n @capital = hash[:capital]\n @flag_link = hash[:flag_link]\n @@all << self\n #binding.pry\n end",
"def initialize( hash )\n\t\t@object_classes = self.parse_objectclasses( hash['objectClasses'] || [] )\n\t\t@attribute_types = self.parse_attribute_types( hash['attributeTypes'] || [] )\n\t\t@ldap_syntaxes = self.parse_ldap_syntaxes( hash['ldapSyntaxes'] || [] )\n\t\t@matching_rules = self.parse_matching_rules( hash['matchingRules'] || [] )\n\t\t@matching_rule_uses = self.parse_matching_rule_uses( hash['matchingRuleUse'] || [] )\n\tend",
"def initialize(hash = {})\n super(hash)\n\n @action = extract_value(hash, :action)\n @clientId = extract_value(hash, :clientId)\n @clientIdAlias = extract_value(hash, :clientIdAlias)\n @clientIdAliasUsed = extract_boolean_value(hash, :clientIdAliasUsed)\n @expiresAt = extract_integer_value(hash, :expiresAt)\n @subject = extract_value(hash, :subject)\n @scopes = extract_value(hash, :scopes)\n @existent = extract_boolean_value(hash, :existent)\n @usable = extract_boolean_value(hash, :usable)\n @sufficient = extract_boolean_value(hash, :sufficient)\n @refreshable = extract_boolean_value(hash, :refreshable)\n @responseContent = extract_value(hash, :responseContent)\n @properties = extract_array_value(hash, :scopes) do |element|\n Authlete::Model::Property.parse(element)\n end\n end",
"def objects_from_serialized_hash(hash) # :nodoc:\n klass, attributes = Helpers.to_class_and_attributes(hash)\n klass.from_seedable_attributes(attributes)\n end",
"def from_hash(hash)\n super(hash)\n verify\n end",
"def initialize (hash)\n @name = hash [:name]\n @color = hash [:color]\n @robots = hash [:robots]\n @moon_count = hash [:moon_count]\n @cats = hash [:cats]\n #@solar_rotation = solar_rotation .....I dont really understand what a solar rotation is.... it's confusing.....\n @distance_from_the_sun = hash [:distance_from_the_sun]\n end",
"def initialize(hash = nil)\n @arguments = 0\n return if hash.nil?\n @name = hash['name']\n @arguments = hash['arguments']\n end",
"def _from_hash(hsh)\n hsh.each do |k, v|\n v = restore_hash(v)\n v = v.map { |iv| restore_hash(iv) } if v.is_a?(Array)\n send(:\"#{k}=\", v)\n end\n self\n end",
"def from_hash(hash)\n struct = SparkleStruct.new\n struct._camel_keys_set(:auto_discovery)\n struct._load(hash)\n struct._camel_keys_set(nil)\n struct\n end",
"def from_hash(hash)\n struct = SparkleStruct.new\n struct._camel_keys_set(:auto_discovery)\n struct._load(hash)\n struct._camel_keys_set(nil)\n struct\n end",
"def initialize(hash={})\n self.attributes = hash\n end",
"def initialize(raw_hash)\n if valid_hash?(raw_hash)\n self.replace(raw_hash)\n @version, @cost, @salt, @checksum = split_hash(self)\n else\n raise Errors::InvalidHash.new(\"invalid hash\")\n end\n end",
"def initialize(raw_hash)\n if valid_hash?(raw_hash)\n self.replace(raw_hash)\n @version, @cost, @salt, @checksum = split_hash(self)\n else\n raise Errors::InvalidHash.new(\"invalid hash\")\n end\n end",
"def build(base, object, type = nil, selected_fields = nil)\n return object unless object.is_a?(Hash)\n if _loading?\n Factory.from_db(klass, object, nil, selected_fields)\n else\n Factory.build(klass, object)\n end\n end",
"def initialize(raw_hash)\n if valid_hash?(raw_hash)\n self.replace(raw_hash)\n @cost, @salt, @digest = split_hash(self.to_s)\n else\n raise Errors::InvalidHash.new(\"invalid hash\")\n end\n end",
"def initialize(hash)\n super(hash)\n @size = hash[\"size\"]\n end",
"def instantiate hash, extra_attributes={}\n return hash unless hash.kind_of? Hash\n# init = hash.values_at(*@singulars).compact.first\n init = hash[@singular]\n inits = hash[@plural]\n if init\n new init.merge extra_attributes\n elsif inits\n inits.map {|each| new each.merge extra_attributes}\n else\n hash\n end\n end",
"def from_hash(values)\n @data_object.team_challenge = values['team_challenge']\n @data_object.team_level = values['team_level']\n @data_object.team_name = values['team_name']\n\n# @mgr_email = values['mgr_email']\n\n names = values['tm_name']\n\n TeamMember::MEMBERS_PER_TEAM.times do |i|\n if names[i].empty?\n @members[i].clear\n else\n @members[i].tm_name = names[i]\n @members[i].tm_grade = values['tm_grade'][i].to_i\n @members[i].tm_dob_mon = values['tm_dob_mon'][i]\n @members[i].tm_dob_day = values['tm_dob_day'][i]\n @members[i].tm_dob_year = values['tm_dob_year'][i]\n @members[i].tm_sex = values['tm_sex'][i]\n end\n end\n end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def initialize(raw_hash)\n raise Errors::InvalidHash, 'invalid hash' unless valid_hash?(raw_hash)\n\n replace(raw_hash)\n\n @cost, @salt, @digest = split_hash(to_s)\n end",
"def initialize( confighash={} )\n\t\tihash = internify_keys( untaint_values(confighash) )\n\t\tmergedhash = DEFAULTS.merge( ihash, &HashMergeFunction )\n\n\t\t@struct = ConfigStruct.new( mergedhash )\n\t\t@create_time = Time.now\n\t\t@name = nil\n\t\t@loader = nil\n\n\t\tsuper()\n\tend",
"def initialize(*args)\n @hash = HashWithIndifferentAccess.new(*args)\n end",
"def create(hash={})\n model = self.new(hash)\n model.save\n model\n end",
"def from_hash(hash:, klass:)\n validate_class_kit(klass)\n\n @hash_helper.indifferent!(hash)\n entity = klass.new\n attributes = @attribute_helper.get_attributes(klass)\n attributes.each do |attribute|\n key = attribute[:name]\n type = attribute[:type]\n\n #if the hash value is nil skip it\n next if hash[key].nil?\n\n value = if is_class_kit?(type)\n from_hash(hash: hash[key], klass: type)\n elsif type == Array\n hash[key].map do |array_element|\n if attribute[:collection_type].nil?\n array_element\n else\n if is_class_kit?(attribute[:collection_type])\n from_hash(hash: array_element, klass: attribute[:collection_type])\n else\n @value_helper.parse(type: attribute[:collection_type], value: array_element)\n end\n end\n end\n else\n hash[key]\n end\n\n entity.public_send(:\"#{key}=\", value)\n end\n\n entity\n end",
"def from_h(hash, converter = nil)\n instance = new\n\n hash.each do |k, v|\n v = convert(v, k, converter) if converter\n instance.instance_variable_set(:\"@#{k}\", v)\n end\n\n instance\n end",
"def initialize(hash_that_represents_json)\n\t\t@data = hash_that_represents_json\n\tend",
"def hash_for_merging(hash)\n new_hash = { id: hash['message_id'].to_i,\n date: Time.at(hash['date'].to_i),\n from: User.new(hash['from'], @bot),\n chat: Chat.new(hash['chat'], @bot) }\n\n type = TYPES.find { |t| hash[t.to_s] }\n new_hash[type] = hash[type.to_s] # TODO: fail if type not found\n\n new_hash\n end",
"def initialize(hash)\n @header = Msg::Header.new(hash)\n @body = Msg::Body.new(content_is_json?, hash)\n end",
"def build_resource(hash = {})\n self.resource = resource_class.new(hash)\n end",
"def initialize()\n @hash = {}\n @values = []\n end",
"def build\n fail \"Please provide a value for key, currently: #{key}\" if key.nil?\n\n if in_key\n { in_key.to_sym => { key => data } }\n else\n process_data\n transform_to_hash\n end\n end",
"def initialize(build)\n @build = build\n @hash = {}\n @already_run = []\n end",
"def new_from_hash_marketplace(h)\n self.url = h\n h=h.split('/')\n h=h[h.size-2]\n self.original_id = h\n return self\n end",
"def initialize(hash, type, dump)\n self.hash = hash\n self.type = type.to_sym\n self.dump = dump\n end",
"def initialize(hash_data, opts: {})\n @hsh = hash_data\n @opts = opts\n\n @title = @hsh[:title]\n @body = @hsh[:body_hash]\n end",
"def initialize(hash)\n @color = hash[:color]\n @scent = hash[:scent]\n end",
"def initialize(hash = nil)\n hash.each { |key, value| self[key] = value } if !hash.nil? && hash.is_a?(Hash)\n end",
"def create(hash)\n NotImplementedError\n end",
"def from_h(hash, converter = nil)\n instance = new\n\n hash.each do |k, v|\n v = instance.convert(v, k, converter) if converter\n instance.send(:\"#{k}=\", v)\n end\n\n instance\n end",
"def init_jaxb_json_hash(_o)\n super _o\n @id = String.from_json(_o['id']) unless _o['id'].nil?\n @version = String.from_json(_o['version']) unless _o['version'].nil?\n @description = String.from_json(_o['description']) unless _o['description'].nil?\n @url = String.from_json(_o['url']) unless _o['url'].nil?\n @name = String.from_json(_o['name']) unless _o['name'].nil?\n @organization = Org::Apache::Archiva::Metadata::Model::Organization.from_json(_o['organization']) unless _o['organization'].nil?\n @issueManagement = Org::Apache::Archiva::Metadata::Model::IssueManagement.from_json(_o['issueManagement']) unless _o['issueManagement'].nil?\n @scm = Org::Apache::Archiva::Metadata::Model::Scm.from_json(_o['scm']) unless _o['scm'].nil?\n @ciManagement = Org::Apache::Archiva::Metadata::Model::CiManagement.from_json(_o['ciManagement']) unless _o['ciManagement'].nil?\n if !_o['licenses'].nil?\n @licenses = Array.new\n _oa = _o['licenses']\n _oa.each { | _item | @licenses.push Org::Apache::Archiva::Metadata::Model::License.from_json(_item) }\n end\n if !_o['mailingLists'].nil?\n @mailingLists = Array.new\n _oa = _o['mailingLists']\n _oa.each { | _item | @mailingLists.push Org::Apache::Archiva::Metadata::Model::MailingList.from_json(_item) }\n end\n if !_o['dependencies'].nil?\n @dependencies = Array.new\n _oa = _o['dependencies']\n _oa.each { | _item | @dependencies.push Org::Apache::Archiva::Metadata::Model::Dependency.from_json(_item) }\n end\n @incomplete = Boolean.from_json(_o['incomplete']) unless _o['incomplete'].nil?\n end",
"def create_version_hash\n new_version = {}\n new_version['created'] = ''\n new_version['message'] = ''\n new_version['user'] = {}\n # user is #name, # address.\n new_version['user']['name'] = ''\n new_version['user']['address'] = ''\n new_version['state'] = {}\n new_version\n end",
"def create_from_hash hash\n values = values_from_hash hash\n unless obj = find(:first, :conditions => values)\n return nil if values[:id]\n obj = create!(values)\n raise ArgumentError, \"#{obj.errors.to_s}\" unless obj.errors.empty?\n end\n obj\n end",
"def initialize result_hash={}\n @result_hash = result_hash\n end",
"def create_hash(&block); end",
"def create_hash(&block); end",
"def initialize(attrs={})\n from_hash(attrs)\n end",
"def init_jaxb_json_hash(_o)\n @groupId = String.from_json(_o['groupId']) unless _o['groupId'].nil?\n @artifactId = String.from_json(_o['artifactId']) unless _o['artifactId'].nil?\n @version = String.from_json(_o['version']) unless _o['version'].nil?\n @packaging = String.from_json(_o['packaging']) unless _o['packaging'].nil?\n @className = String.from_json(_o['className']) unless _o['className'].nil?\n if !_o['repositories'].nil?\n @repositories = Array.new\n _oa = _o['repositories']\n _oa.each { | _item | @repositories.push String.from_json(_item) }\n end\n @bundleVersion = String.from_json(_o['bundleVersion']) unless _o['bundleVersion'].nil?\n @bundleSymbolicName = String.from_json(_o['bundleSymbolicName']) unless _o['bundleSymbolicName'].nil?\n @bundleExportPackage = String.from_json(_o['bundleExportPackage']) unless _o['bundleExportPackage'].nil?\n @bundleExportService = String.from_json(_o['bundleExportService']) unless _o['bundleExportService'].nil?\n @classifier = String.from_json(_o['classifier']) unless _o['classifier'].nil?\n @includePomArtifacts = Boolean.from_json(_o['includePomArtifacts']) unless _o['includePomArtifacts'].nil?\n @queryTerms = String.from_json(_o['queryTerms']) unless _o['queryTerms'].nil?\n @bundleImportPackage = String.from_json(_o['bundleImportPackage']) unless _o['bundleImportPackage'].nil?\n @bundleRequireBundle = String.from_json(_o['bundleRequireBundle']) unless _o['bundleRequireBundle'].nil?\n @pageSize = Fixnum.from_json(_o['pageSize']) unless _o['pageSize'].nil?\n @selectedPage = Fixnum.from_json(_o['selectedPage']) unless _o['selectedPage'].nil?\n end",
"def build_request_data(hash)\n {\n :attributes! => {\n addressinfo: { \"xsi:type\" => \"ns2:Map\" },\n },\n username: @username,\n password: @password,\n addressinfo: {\n item: [\n { key: 'name', value: hash[:name] },\n { key: 'address1', value: hash[:address1] },\n { key: 'address2', value: hash[:address2] },\n { key: 'city', value: hash[:city] },\n { key: 'state', value: hash[:state] },\n { key: 'zip', value: hash[:zip] },\n { key: 'fflno', value: hash[:fflno] },\n { key: 'fflexp', value: hash[:fflexp] }\n ]\n },\n testing: @testing\n }\n end",
"def initialize(order_hash)\n @id = order_hash['id']\n @number = order_hash['number']\n @special_instructions = order_hash['special_instructions']\n @total = order_hash['total']\n @total_quantity = order_hash['total_quantity']\n @created_at = order_hash['created_at']\n @updated_at = order_hash['updated_at']\n end",
"def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /^Array<(.*)>/i\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n else\n #TODO show warning in debug mode\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n else\n # data not found in attributes(hash), not an issue as the data can be optional\n end\n end\n\n self\n end",
"def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /^Array<(.*)>/i\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n else\n #TODO show warning in debug mode\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n else\n # data not found in attributes(hash), not an issue as the data can be optional\n end\n end\n\n self\n end",
"def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /^Array<(.*)>/i\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n else\n #TODO show warning in debug mode\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n else\n # data not found in attributes(hash), not an issue as the data can be optional\n end\n end\n\n self\n end",
"def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /^Array<(.*)>/i\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n else\n #TODO show warning in debug mode\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n else\n # data not found in attributes(hash), not an issue as the data can be optional\n end\n end\n\n self\n end"
] | [
"0.8011192",
"0.74710494",
"0.745837",
"0.72571075",
"0.7244619",
"0.70055205",
"0.6972621",
"0.6954448",
"0.69452715",
"0.693933",
"0.6935897",
"0.6916681",
"0.6870851",
"0.67959535",
"0.6782485",
"0.6756477",
"0.6756477",
"0.67557365",
"0.6751677",
"0.67142427",
"0.6667296",
"0.6624043",
"0.66109264",
"0.66109264",
"0.66109204",
"0.65917873",
"0.657155",
"0.65477604",
"0.65245456",
"0.6524222",
"0.6512398",
"0.65028286",
"0.6497868",
"0.6485378",
"0.6483645",
"0.64758426",
"0.6458484",
"0.6454313",
"0.64405316",
"0.6434813",
"0.6401297",
"0.639885",
"0.6398073",
"0.6390987",
"0.6371735",
"0.6362554",
"0.6359208",
"0.6313545",
"0.629578",
"0.6293235",
"0.6292609",
"0.62710285",
"0.62705576",
"0.62629515",
"0.6250652",
"0.62494105",
"0.624316",
"0.624316",
"0.6242846",
"0.62404954",
"0.6240382",
"0.62316483",
"0.62283677",
"0.62282956",
"0.62277997",
"0.622547",
"0.62200636",
"0.6217926",
"0.6209963",
"0.62076384",
"0.62036294",
"0.62019116",
"0.61783326",
"0.616619",
"0.6160374",
"0.614005",
"0.6127229",
"0.6114322",
"0.6104685",
"0.60977",
"0.6096617",
"0.60896283",
"0.6063162",
"0.6061086",
"0.60587287",
"0.6058327",
"0.60416806",
"0.60403866",
"0.6036085",
"0.60344076",
"0.6030274",
"0.6021386",
"0.6021386",
"0.6016532",
"0.60153276",
"0.60144913",
"0.6009261",
"0.6002817",
"0.6002817",
"0.6002817",
"0.6002817"
] | 0.0 | -1 |
Deserializes the data based on type | def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
sub_type = value[:type] || value[:discriminator] || type
if AsposeEmailCloud.const_defined?(sub_type)
type = sub_type
end
temp_model = AsposeEmailCloud.const_get(type).new
temp_model.build_from_hash(value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Telstra_Messaging.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = FattureInCloud.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = IFClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = WineShipping.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = UltracartClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n DearInventoryRuby.const_get(type).build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Mooncard.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Aimastering.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Harbor1Client.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Intrinio.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /^(true|t|yes|y|1)$/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Pier.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = CrelateClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = CrelateClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = CrelateClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = CrelateClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = CrelateClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = WellsFargoAchClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ArtikCloud.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Dkron.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n MailSlurpClient.const_get(type).build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n MailSlurpClient.const_get(type).build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Esi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Esi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Esi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :Time\n Time.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n # models (e.g. Pet) or oneOf\n klass = Fastly.const_get(type)\n klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :Time\n Time.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n # models (e.g. Pet) or oneOf\n klass = Fastly.const_get(type)\n klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :Time\n Time.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n # models (e.g. Pet) or oneOf\n klass = Fastly.const_get(type)\n klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :Time\n Time.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n # models (e.g. Pet) or oneOf\n klass = Fastly.const_get(type)\n klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n ::DateTime.parse(value)\n when :Date\n ::Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Models.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n ::DateTime.parse(value)\n when :Date\n ::Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Models.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :Time\n Time.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n # models (e.g. Pet) or oneOf\n klass = Hubspot::Cms::Performance.const_get(type)\n klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = SmoochApi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Tradenity.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Tradenity.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = SamplifyAPIClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = OpsgenieClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = LemonWayClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = BudgeaClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = BudgeaClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :Boolean\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n Nodeum.const_get(type).build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TextMagic.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TextMagic.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TextMagic.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n Date.parse value\n when :Date\n Date.parse value\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else\n # model\n temp_model = GroupDocsViewerCloud.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n Date.parse value\n when :Date\n Date.parse value\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else\n # model\n temp_model = GroupDocsViewerCloud.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n Date.parse value\n when :Date\n Date.parse value\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else\n # model\n temp_model = GroupDocsViewerCloud.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = ConnectWise.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = NSXT.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = NSXT.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = NSXT.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TreezorClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TreezorClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TreezorClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = SwiftApi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = SwiftApi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = TripletexApi.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = unwiredClient.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end",
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s =~ /\\A(true|t|yes|y|1)\\z/i\n true\n else\n false\n end\n when :Object\n # generic object (usually a Hash), return directly\n value\n when /\\AArray<(?<inner_type>.+)>\\z/\n inner_type = Regexp.last_match[:inner_type]\n value.map { |v| _deserialize(inner_type, v) }\n when /\\AHash<(?<k_type>.+?), (?<v_type>.+)>\\z/\n k_type = Regexp.last_match[:k_type]\n v_type = Regexp.last_match[:v_type]\n {}.tap do |hash|\n value.each do |k, v|\n hash[_deserialize(k_type, k)] = _deserialize(v_type, v)\n end\n end\n else # model\n temp_model = Quandoo.const_get(type).new\n temp_model.build_from_hash(value)\n end\n end"
] | [
"0.7330926",
"0.7274019",
"0.72504056",
"0.7245751",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.7218884",
"0.7213926",
"0.71909",
"0.7183136",
"0.71796805",
"0.71796805",
"0.71796805",
"0.71796805",
"0.71796805",
"0.71796805",
"0.71796805",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71791923",
"0.71712995",
"0.71712995",
"0.71712995",
"0.71712995",
"0.71712995",
"0.71632504",
"0.71549904",
"0.71473306",
"0.71413666",
"0.71413666",
"0.7141116",
"0.7141116",
"0.7141116",
"0.7133874",
"0.7133874",
"0.7133874",
"0.7133874",
"0.71333444",
"0.71333444",
"0.7127688",
"0.7125744",
"0.71210617",
"0.71210617",
"0.71190786",
"0.71184087",
"0.711393",
"0.7113519",
"0.7113519",
"0.7113516",
"0.71119875",
"0.71119875",
"0.71119875",
"0.7105169",
"0.7105169",
"0.7105169",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7104928",
"0.7102596",
"0.7102596",
"0.7102596",
"0.7101596",
"0.7101596",
"0.7101596",
"0.70996517",
"0.70996517",
"0.7097952",
"0.7097185",
"0.70965225"
] | 0.0 | -1 |
Returns the string representation of the object | def to_s
to_hash.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @object.to_s\n end",
"def to_s\n object.to_s\n end",
"def serialize(object)\n object.to_s\n end",
"def to_s\n self.inspect\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id} #{info}>\"\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id}> @names=#{names}>\"\n end",
"def to_s\n self.inspect\n end",
"def to_s\n toString()\n end",
"def to_s\r\n dump\r\n end",
"def to_s\n inspect\n end",
"def to_s\n toString\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n\t\t\t@string\n\t\tend",
"def to_s\n stringify\n end",
"def to_s\n to_h.to_s\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def inspect\n serialize.to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n @string ||= Builder::ToString.new(self).string\n end",
"def to_s\n self\n end",
"def to_s()\n serialize.to_s()\n end",
"def to_s()\n serialize.to_s()\n end",
"def to_s\n string\n end",
"def to_s\n inspect\n end",
"def to_s\n inspect\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n self.to_s\n end",
"def inspect\n self.to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def inspect\n to_s.inspect\n end",
"def inspect()\n serialize.to_s()\n end",
"def inspect()\n serialize.to_s()\n end",
"def inspect\n return self.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",
"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",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end"
] | [
"0.901024",
"0.89506465",
"0.84703195",
"0.83409667",
"0.8337169",
"0.8337169",
"0.8332247",
"0.82546586",
"0.8145818",
"0.8144667",
"0.81357557",
"0.812714",
"0.8093436",
"0.8086725",
"0.8073356",
"0.8039774",
"0.80308646",
"0.80064154",
"0.80064154",
"0.80064154",
"0.80064154",
"0.7962831",
"0.7962831",
"0.7962831",
"0.7962831",
"0.7954296",
"0.79446983",
"0.7919419",
"0.7909274",
"0.78848016",
"0.78848016",
"0.78841925",
"0.788328",
"0.788328",
"0.78758216",
"0.78758216",
"0.78758216",
"0.78758216",
"0.78758216",
"0.78758216",
"0.78758216",
"0.7866813",
"0.7866813",
"0.7865939",
"0.7865939",
"0.7850519",
"0.7850519",
"0.7850519",
"0.7850519",
"0.7808076",
"0.7784745",
"0.7784745",
"0.7767656",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824",
"0.77608824"
] | 0.0 | -1 |
to_body is an alias to to_hash (backward compatibility) | def to_body
to_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_body\r\n to_hash\r\n end",
"def to_body\n to_hash\nend",
"def to_body\n to_hash\nend"
] | [
"0.84283537",
"0.8347048",
"0.8347048"
] | 0.0 | -1 |
Returns the object in the form of hash | def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n object\n end",
"def hash\r\n return to_s.hash\r\n end",
"def hash\n to_a.hash\n end",
"def hash\n [_hash, name, owner].hash\n end",
"def hash\n return to_s.hash\n end",
"def hash\n @hash\n end",
"def hash\n @hash.hash\n end",
"def hash\n @hash ||= self.to_a.hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def hash\n to_s.hash\n end",
"def to_hash\n @hash\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @object\n end",
"def to_h\n @hash\n end",
"def to_h\n @hash\n end",
"def hash\n to_h.hash ^ self.class.hash\n end",
"def as_hash\n @hash\n end",
"def __getobj__\n @hashobj\n end",
"def to_hash() end",
"def hash\n to_s.hash\n end",
"def hash\n to_s.hash\n end",
"def hash\n object_id\n end",
"def to_hash\n @_hash_\n end",
"def hash\n\t\treturn self.name.to_s.hash\n\tend",
"def to_hash\n to_a.hash\n end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def hash\n data.hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\r\n id.hash\r\n end",
"def hash\n \"#{self.class.name}-#{self.id}-#{@__metadata__.cas}-#{@__attributes__.hash}\".hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end",
"def hash\n self.to_f.hash\n end",
"def hash\n end",
"def hash\n end",
"def hash\n end",
"def to_hash\n return self\n end",
"def hash\n return @id.hash\n end",
"def to_hash(object)\n validate_class_kit(object.class)\n\n @hash_helper.to_hash(object)\n end",
"def to_h\n Hash[ self ]\n end",
"def to_hash\n Hash[self]\n end",
"def to_h\n @hash.dup\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def to_h\n @hash.dup\n end",
"def hash\n model.hash + key.hash\n end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def hash\n [self.class, to_s].hash\n end",
"def hash\n id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n self.atoms.hash\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def to_h\n Hash[self]\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def hash\n [description, routing_number, account_number, account_type, signatory, metadata, id, signature_url, bank_name, verified, date_created, date_modified, deleted, object].hash\n end",
"def hash\n @id.hash\n end",
"def hash\n id.hash\n end",
"def hash\n self.class.name.hash\n end",
"def to_h\n @_hash.dup\n end",
"def hash\n\t\t[@id].hash\n\tend",
"def hash\n [self.class, to_s].hash\n end",
"def __hash\n @hash\n end"
] | [
"0.8269158",
"0.7879479",
"0.78746766",
"0.7803831",
"0.7791617",
"0.77827746",
"0.7777764",
"0.7770165",
"0.7762157",
"0.7762157",
"0.77586275",
"0.77329206",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.7649045",
"0.7649045",
"0.76284003",
"0.76047856",
"0.7594347",
"0.7585171",
"0.7582596",
"0.7582596",
"0.7536447",
"0.7496933",
"0.74357307",
"0.74127036",
"0.73856944",
"0.7368907",
"0.7367698",
"0.7367698",
"0.7367698",
"0.7362576",
"0.73620075",
"0.7361348",
"0.7361348",
"0.7361348",
"0.7341068",
"0.73382866",
"0.733239",
"0.733239",
"0.733239",
"0.73185706",
"0.7305189",
"0.7304782",
"0.72966003",
"0.72875834",
"0.7266684",
"0.726607",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264358",
"0.7264034",
"0.7255076",
"0.72531855",
"0.72531855",
"0.72531855",
"0.72531855",
"0.72531855",
"0.72531855",
"0.7250168",
"0.72496414",
"0.72496414",
"0.724369",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.72316253",
"0.7231487",
"0.7225899",
"0.72200346",
"0.72153366",
"0.72139865",
"0.71958643",
"0.7185333",
"0.7184086",
"0.7173835",
"0.7168306"
] | 0.0 | -1 |
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value | def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [value].hash\n end",
"def hash\n [value].hash\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def hash\n value.hash\n end",
"def hash\n @value.hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash\n @value\n end",
"def to_hash\n @value\n end",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def output_hash; end",
"def to_hash() end",
"def hash\n return to_s.hash\n end",
"def hash\n value_id.hash\n end",
"def to_hash\n call\n @hash = @value\n @hash\n end",
"def hash\n to_s.hash\n end",
"def hash\n to_s.hash\n end",
"def hash\n self.to_f.hash\n end",
"def hash\n to_s.hash\n end",
"def to_hash(obj = T.unsafe(nil)); end",
"def to_h\n @value\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map { |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map { |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map { |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map { |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def value_to_hash(value, options = T.unsafe(nil)); end",
"def to_s\r\n to_hash.to_s\r\n end",
"def _to_hash(value)\r\n if value.is_a?(Array)\r\n value.compact.map{ |v| _to_hash(v) }\r\n elsif value.is_a?(Hash)\r\n {}.tap do |hash|\r\n value.each { |k, v| hash[k] = _to_hash(v) }\r\n end\r\n elsif value.respond_to? :to_hash\r\n value.to_hash\r\n else\r\n value\r\n end\r\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def to_s\n to_hash.to_s\nend",
"def to_s\n to_hash.to_s\nend",
"def to_h(value)\n return value unless @to_h\n @to_h.call value\n end",
"def to_hash\n Hash[to_a]\n end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def read\n value = super\n value = value.to_hash if value.respond_to?(:to_hash)\n value\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_hash\n value.to_hash\n else\n value\n end\n end"
] | [
"0.67208356",
"0.67208356",
"0.6670458",
"0.6658251",
"0.65890694",
"0.64540917",
"0.64168423",
"0.64168423",
"0.63834745",
"0.6347218",
"0.6303483",
"0.6224962",
"0.6153922",
"0.61043525",
"0.6080379",
"0.6080379",
"0.607271",
"0.603735",
"0.6020807",
"0.59384143",
"0.59025747",
"0.59025747",
"0.59025747",
"0.59025747",
"0.59025747",
"0.58894324",
"0.58894324",
"0.58835113",
"0.58835113",
"0.5867303",
"0.58561647",
"0.58344513",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5821252",
"0.5804465",
"0.5804465",
"0.5799168",
"0.5780086",
"0.57732856",
"0.57732856",
"0.57732856",
"0.57732856",
"0.57732856",
"0.57732856",
"0.5771402",
"0.5771402",
"0.5769127",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806",
"0.57686806"
] | 0.0 | -1 |
GET /heartbeats GET /heartbeats.json | def index
@heartbeats = Heartbeat.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @heartbeats }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @heart_beats = HeartBeat.all\n end",
"def show\n render json: @heartbeat\n end",
"def show\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def get_heartbeats\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.by(proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id })\n end\n end",
"def index\n @beats = Beat.all\n end",
"def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end",
"def show\n @beat = Beat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beat }\n end\n end",
"def index\n @hearts = Heart.all\n end",
"def index\n @hearteds = Hearted.all\n end",
"def heartbeat\n request(Resources::RESOURCE_HEARTBEAT, HTTP_METHOD_POST)\n end",
"def index\n @heart_rate_types = HeartRateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heart_rate_types }\n end\n end",
"def index\n @hearts = Heart.all \n\n end",
"def key_worker_heartbeats\n key(\"worker_heartbeats\")\n end",
"def beat\n Logger.trace \"beat heart #{Zensu.node.id} #{Time.now.to_i}\"\n remote_publish(\"zensu.heartbeat\", Zensu.node.id, Zensu.config.router_endpoint, Time.now.to_i.to_s)\n end",
"def set_heart_beat\n @heart_beat = HeartBeat[Person.first.id.to_s].find(params[:id])\n end",
"def new\n @heartbeat = Heartbeat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def destroy\n @heart_beat.destroy\n respond_to do |format|\n format.html { redirect_to heart_beats_url }\n format.json { head :no_content }\n end\n end",
"def hearings(options = {})\n get('/hearings', options)\n end",
"def find_heartbeats(params, options)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.by({ proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id } }.merge(params), options)\n end\n end",
"def heart_params\n params.require(:heart).permit(:beat)\n end",
"def beacons\n response = request(:get, \"/beacon\")\n response_to_array(response, \"beacons\", KontaktIo::Resource::Beacon)\n end",
"def show\n @heart_rate_type = HeartRateType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heart_rate_type }\n end\n end",
"def show\n @beattape = Beattape.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beattape }\n end\n end",
"def show\n @song_id = get_song_id(@heart.beats)\n end",
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def index\n # only list current user's hangouts\n @hangouts = current_user.hangouts.order(\"start_date_time DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hangouts }\n end\n end",
"def show\n @hangout = Hangout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hangout }\n end\n end",
"def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end",
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def new\n @beat = Beat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beat }\n end\n end",
"def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end",
"def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end",
"def index\n @time_frames = TimeFrame.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @time_frames }\n end\n end",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@teaches) }\n\t\tend\n\n end",
"def index\n @tacks = Tack.all\n\n render json: @tacks\n end",
"def heartbeat\n end",
"def index\n @sayings = Saying.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sayings }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def index\n @brochures = Brochure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brochures }\n end\n end",
"def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_success: true,\n data: { chats: @chats }\n }\n end",
"def index\n @talks = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talks }\n end\n end",
"def show\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def create\n @heart = Heart.new(heart_params)\n\n respond_to do |format|\n if @heart.save\n format.html { redirect_to @heart, notice: 'Heart was successfully created.' }\n format.json { render :show, status: :created, location: @heart }\n else\n format.html { render :new }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @honey_badgers = HoneyBadger.all\n respond_to do |format|\n format.html\n format.json { render json: @honey_badgers }\n end\n end",
"def beat\n Logger.trace \"beat heart #{Node.id} #{Time.now.to_i}\"\n notifier.async.publish(config.topic, Node.id, Router.endpoint, Time.now.to_i.to_s)\n end",
"def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def show\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beacon }\n end\n end",
"def index\n @economy_hands = EconomyHand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @economy_hands }\n end\n end",
"def create\n @heartbeat = Heartbeat.new(params[:heartbeat])\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }\n format.json { render json: @heartbeat, status: :created, location: @heartbeat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n respond_to do |format|\n format.html { render text: \"\", layout: \"application\" }\n format.json { render json: Bacon.all }\n end\n end",
"def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @talk = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk }\n end\n end",
"def index\n @high_scores = HighScore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @high_scores }\n end\n end",
"def get_heroes\n heroes = []\n Hero.all.each do |hero|\n heroes << hero.to_json\n end\n heroes << Hero.first.to_json\n send_message({:action => \"get heroes list\", :status => game.status, :heroes => heroes})\n end",
"def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end",
"def heartbeat_command\n logger.debug(\"heartbeat_command: enter \")\n logger.debug(client.observers_overview.join(\", \"))\n begin\n client.refresh_observers_if_needed\n client.update_cluster if client.status == :down\n client.get(\"foo\")\n rescue Exception => e\n client.status = :down\n logger.debug \"heartbeat - #{e.message} #{e.backtrace}\"\n end\n sleep freq\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def show\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blocking_client }\n end\n end",
"def show\n render json: @dice\n end",
"def index\n @lesson = Lesson.find(params[:lesson_id])\n @beats = @lesson.beats\n end",
"def show\n @beat = Beat.find(params[:id])\n end",
"def index\n @recent = Highfive.recent.approved\n @leaders = User.leaders\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @highfives }\n end\n end",
"def index\n @health_levels = HealthLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @health_levels }\n end\n end",
"def index\n @events = Event.all\n\n render json: @events, include: :talks\n end",
"def index\n @topics = Topic.where('timeint >= :timeint', :timeint => Topic.current_timeint(Time.now))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def ping\n render json: {\n message: \"OK\",\n time: DateTime.current.strftime(\"%Q\")\n }\n end",
"def index\n @you_owe_mes = YouOweMe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @you_owe_mes }\n end\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n if @heartbeat.update(heartbeat_params)\n head :no_content\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def handle_get(event)\n make_response(200, get_scores)\nend",
"def index\n @quacks = Quack.all\n # SSE expects the `text/event-stream` content type\n response.headers['Content-Type'] = 'text/event-stream'\n\n sse = Reloader::SSE.new(response.stream)\n begin\n loop do\n sse.write({ :time => Time.now })\n sleep 1\n end\n rescue IOError\n # When the client disconnects, we'll get an IOError on write\n ensure\n sse.close\n end\n end",
"def index\n @fundamental_guilds = Fundamental::Guild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_guilds }\n end\n end",
"def index\n\n # use a shooting collection cache\n\n respond_to do |format|\n format.html # index.html.erb\n format.json do\n @shootings = Shooting.get_shootings_from_yammer(Yammer::TokenClient.new(token: current_user.access_token))\n render json: { shootings: @shootings }\n end\n end\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n @push_day = session[:push_day] \n end",
"def index\n respond_to do |format|\n format.json {\n user_leaderboard = []\n userid = params[:user_id]\n if userid\n # First, get the list of leaderboard values for current user\n current_user = User.find(userid)\n user_leaderboard << get_leaderboard_values_for_user(userid, current_user.fbid, current_user.fb_name, current_user.membertime)\n\n # Then, get leaderboard values for user's friends\n fbid_array = current_user.fb_friends\n if fbid_array.length > 0\n fbid_array = fbid_array.split(\"|\")\n friends_list = User.where(\"fbid in (?)\", fbid_array)\n\n friends_list.each do |friend|\n user_leaderboard << get_leaderboard_values_for_user(friend.id, friend.fbid, friend.fb_name, friend.membertime)\n end\n end\n\n log_event(:user_leaderboard, :get, user_leaderboard)\n render json: user_leaderboard.as_json\n else\n create_error(:unprocessable_entity, :get, \"\", \"Missing user\")\n end\n }\n end\n end",
"def index\n @beehives = Beehive.where(user_id: current_user.id)\n end",
"def index\n @beverages = Beverage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @beverages }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @event, methods: [:talks] }\n end\n end",
"def index\n render json: { message: \"you're on the welcome page!\" }\n end",
"def index\n @likes = Like.all\n render json: @likes, status: 200\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n end",
"def index\n @tracks = Track.all\n render json: {tracks: @tracks}\n end",
"def index\n @bowlers = Bowler.all\n respond_with(@bowlers)\n end",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def beat\n if params[:key]\n @server = Server.find_by_key params[:key]\n @server.beat_counter += 1\n else\n @server = Server.new\n @server.key ||= Digest::MD5.hexdigest(rand.to_s)\n @server.beat_counter = 1\n end\n \n @server.hostname = params[:hostname] || request.remote_ip\n @server.port = (params[:port] || 28997).to_i\n @server.title = params[:title] || \"New Server\"\n @server.game_mode = nil\n \n if @server.save\n render :text => @server.key\n else\n render :text => 'Error saving record', :status => 500\n end\n end",
"def index\n @tracks = Track.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tracks }\n end\n end",
"def process_heartbeats(data, reply, subject)\n # No payload assumed, just reply to the heartbeat.\n nats.publish(reply, '')\n end",
"def destroy\n @hearted.destroy\n respond_to do |format|\n format.html { redirect_to hearteds_url }\n format.json { head :no_content }\n end\n end",
"def index\n @decks = Deck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @decks }\n end\n end",
"def index\n @decks = Deck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @decks }\n end\n end",
"def healthcheck\n url = \"#{self.url}/heartbeat\"\n status, _ = rest_get( url )\n return( status )\n end",
"def healthcheck\n url = \"#{self.url}/heartbeat\"\n status, _ = rest_get( url )\n return( status )\n end",
"def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend",
"def index #TODO redundant with home\n add_breadcrumb 'Your hubs', :hubs_path\n append_title 'Hubs'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @hubs }\n end\n end",
"def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end",
"def index\n @favorite_routes = FavoriteRoute.all\n render json: @favorite_routes\n end",
"def heart_beat_params\n params.require(:heart_beat).permit(:heart_beat, :intensity)\n end"
] | [
"0.7511931",
"0.6779174",
"0.6749216",
"0.6321797",
"0.6292863",
"0.6237424",
"0.6233557",
"0.61642194",
"0.6153539",
"0.6063671",
"0.60364866",
"0.59836525",
"0.594041",
"0.5924661",
"0.59223926",
"0.5862464",
"0.5850641",
"0.5742875",
"0.57217294",
"0.5690941",
"0.56587386",
"0.56380826",
"0.5580851",
"0.55784273",
"0.55580914",
"0.5542748",
"0.552801",
"0.5520638",
"0.5500144",
"0.5491134",
"0.5482979",
"0.54716575",
"0.54666543",
"0.54655993",
"0.54640096",
"0.5458233",
"0.5458168",
"0.5447945",
"0.54243696",
"0.54213893",
"0.5405444",
"0.54052746",
"0.53910375",
"0.5383188",
"0.5378743",
"0.5375674",
"0.5374013",
"0.5366023",
"0.5350924",
"0.5342252",
"0.5334095",
"0.533363",
"0.53295314",
"0.5328927",
"0.53230023",
"0.53180456",
"0.5305261",
"0.52937734",
"0.5293227",
"0.52905047",
"0.52885807",
"0.5287563",
"0.5283509",
"0.52828187",
"0.52752924",
"0.52686155",
"0.5266837",
"0.5262337",
"0.52610976",
"0.52606887",
"0.5258383",
"0.52537847",
"0.5245918",
"0.523296",
"0.5232565",
"0.5216645",
"0.52161443",
"0.5205268",
"0.52044064",
"0.5202519",
"0.5199889",
"0.51979125",
"0.5191536",
"0.5191536",
"0.5191333",
"0.5191263",
"0.51872975",
"0.51842624",
"0.518004",
"0.51781607",
"0.51754415",
"0.51717883",
"0.51717883",
"0.51710176",
"0.51710176",
"0.5170808",
"0.5169546",
"0.51627123",
"0.51525813",
"0.51512104"
] | 0.79452735 | 0 |
GET /heartbeats/1 GET /heartbeats/1.json | def show
@heartbeat = Heartbeat.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @heartbeat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @heartbeats = Heartbeat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heartbeats }\n end\n end",
"def index\n @heart_beats = HeartBeat.all\n end",
"def show\n render json: @heartbeat\n end",
"def get_heartbeats\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.by(proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id })\n end\n end",
"def show\n @beat = Beat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beat }\n end\n end",
"def set_heart_beat\n @heart_beat = HeartBeat[Person.first.id.to_s].find(params[:id])\n end",
"def new\n @heartbeat = Heartbeat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end",
"def heartbeat\n request(Resources::RESOURCE_HEARTBEAT, HTTP_METHOD_POST)\n end",
"def index\n @beats = Beat.all\n end",
"def beat\n Logger.trace \"beat heart #{Zensu.node.id} #{Time.now.to_i}\"\n remote_publish(\"zensu.heartbeat\", Zensu.node.id, Zensu.config.router_endpoint, Time.now.to_i.to_s)\n end",
"def key_worker_heartbeats\n key(\"worker_heartbeats\")\n end",
"def find_heartbeats(params, options)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.by({ proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id } }.merge(params), options)\n end\n end",
"def show\n @song_id = get_song_id(@heart.beats)\n end",
"def destroy\n @heart_beat.destroy\n respond_to do |format|\n format.html { redirect_to heart_beats_url }\n format.json { head :no_content }\n end\n end",
"def show\n @beattape = Beattape.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beattape }\n end\n end",
"def index\n @hearts = Heart.all\n end",
"def index\n @hearteds = Hearted.all\n end",
"def show\n @heart_rate_type = HeartRateType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heart_rate_type }\n end\n end",
"def index\n @heart_rate_types = HeartRateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heart_rate_types }\n end\n end",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def heartbeat\n end",
"def beat\n if params[:key]\n @server = Server.find_by_key params[:key]\n @server.beat_counter += 1\n else\n @server = Server.new\n @server.key ||= Digest::MD5.hexdigest(rand.to_s)\n @server.beat_counter = 1\n end\n \n @server.hostname = params[:hostname] || request.remote_ip\n @server.port = (params[:port] || 28997).to_i\n @server.title = params[:title] || \"New Server\"\n @server.game_mode = nil\n \n if @server.save\n render :text => @server.key\n else\n render :text => 'Error saving record', :status => 500\n end\n end",
"def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end",
"def index\n @hearts = Heart.all \n\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n if @heartbeat.update(heartbeat_params)\n head :no_content\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def new\n @beat = Beat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beat }\n end\n end",
"def show\n @beat = Beat.find(params[:id])\n end",
"def heartbeat_command\n logger.debug(\"heartbeat_command: enter \")\n logger.debug(client.observers_overview.join(\", \"))\n begin\n client.refresh_observers_if_needed\n client.update_cluster if client.status == :down\n client.get(\"foo\")\n rescue Exception => e\n client.status = :down\n logger.debug \"heartbeat - #{e.message} #{e.backtrace}\"\n end\n sleep freq\n end",
"def ping\n render json: {\n message: \"OK\",\n time: DateTime.current.strftime(\"%Q\")\n }\n end",
"def show\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beacon }\n end\n end",
"def create\n @heartbeat = Heartbeat.new(params[:heartbeat])\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }\n format.json { render json: @heartbeat, status: :created, location: @heartbeat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def show\n @hangout = Hangout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hangout }\n end\n end",
"def beat\n Logger.trace \"beat heart #{Node.id} #{Time.now.to_i}\"\n notifier.async.publish(config.topic, Node.id, Router.endpoint, Time.now.to_i.to_s)\n end",
"def show\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blocking_client }\n end\n end",
"def show\n @heat_log = HeatLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heat_log }\n end\n end",
"def get_heartbeat(id)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.find(id)\n end\n end",
"def index\n @time_frames = TimeFrame.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @time_frames }\n end\n end",
"def heart_params\n params.require(:heart).permit(:beat)\n end",
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def ping\n get('')\n end",
"def index\n # TODO pull out api key before pushing to github & pull out binding prys\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 subId = message[:data][0][:id]\n else\n # Port is open in our router\n params = { url: SUBSCRIPTION_URL, events: ['invitee.created', 'invitee.canceled'] }\n newRes = HTTParty.post URL, body: params, headers: HEADERS\n message = JSON.parse newRes.body, symbolize_names: true\n # TODO need error handling\n subId = message[:id]\n end\n end\n end",
"def show\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gauge }\n end\n end",
"def heartbeat\n me = WORKER_TEMPLATE.dup\n me['name'] = id\n @heartbeat_entry ||= write(me, @heartbeat_refresh + 10)\n @heartbeat_entry.renew(@heartbeat_refresh) unless @heartbeat_entry.canceled?\n end",
"def index\n @topics = Topic.where('timeint >= :timeint', :timeint => Topic.current_timeint(Time.now))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def show\n @logstash = Logstash.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @logstash }\n end\n end",
"def show\n begin\n @fucker = Fucker.find(params[:id])\n respond_to do |format|\n format.json { render json: @fucker }\n end\n rescue => err\n $log.warn(err)\n respond_to do |format|\n format.json { render json: err, status: :internal_server_error }\n end\n end\n end",
"def index\n @quacks = Quack.all\n # SSE expects the `text/event-stream` content type\n response.headers['Content-Type'] = 'text/event-stream'\n\n sse = Reloader::SSE.new(response.stream)\n begin\n loop do\n sse.write({ :time => Time.now })\n sleep 1\n end\n rescue IOError\n # When the client disconnects, we'll get an IOError on write\n ensure\n sse.close\n end\n end",
"def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end",
"def show\n @tick_track = TickTrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tick_track }\n end\n end",
"def healthcheck\n url = \"#{self.url}/heartbeat\"\n status, _ = rest_get( url )\n return( status )\n end",
"def healthcheck\n url = \"#{self.url}/heartbeat\"\n status, _ = rest_get( url )\n return( status )\n end",
"def show\n @health_record = HealthRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @health_record }\n end\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def get(path)\n with_monitoring do\n connection.get(path)\n end\n end",
"def show\n @sleep = Sleep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sleep }\n end\n end",
"def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @event, methods: [:talks] }\n end\n end",
"def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end",
"def show\n @healthrecord = Healthrecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @healthrecord }\n end\n end",
"def show\n @heat_type = HeatType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heat_type }\n end\n end",
"def show\n @metric = Metric.find(params[:id])\n\n render json: @metric\n end",
"def show\n @grumble = Grumble.find(params[:id])\n render status: 200, json: @grumble.to_json\n end",
"def show\n @consensu = Consensu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consensu }\n end\n end",
"def beacons\n response = request(:get, \"/beacon\")\n response_to_array(response, \"beacons\", KontaktIo::Resource::Beacon)\n end",
"def index\n render json: {time: Time.now}\n end",
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def show\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @scribble }\n end\n end",
"def ping\n return true unless active && heartbeat_path.present?\n\n resp = http_get(uri: \"#{api_base_url}#{heartbeat_path}\")\n resp.present? && resp.code == 200\n end",
"def ping\n return true unless active? && heartbeat_path.present?\n\n resp = http_get(uri: \"#{api_base_url}#{heartbeat_path}\")\n resp.present? && resp.code == 200\n end",
"def health\n render json: { status: 'OK' }\n end",
"def show\n refresh_date = Time.at(params[:id].to_i/1000)\n player_updates = Player.where(\"updated_at > ?\", refresh_date)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => {:server_time => Time.now.to_i, :players => player_updates}}\n end\n end",
"def index\n @tacks = Tack.all\n\n render json: @tacks\n end",
"def index\n respond_to do |format|\n format.html { render text: \"\", layout: \"application\" }\n format.json { render json: Bacon.all }\n end\n end",
"def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end",
"def index\n @talks = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talks }\n end\n end",
"def ping\n begin \n @connection = $redis.ping\n rescue => e\n @connection = {status: 500, message: e.message }\n end\n\n respond_to do |format|\n format.json { render json: @connection }\n end\n end",
"def index\n @lesson = Lesson.find(params[:lesson_id])\n @beats = @lesson.beats\n end",
"def create\n @heart = Heart.new(heart_params)\n\n respond_to do |format|\n if @heart.save\n format.html { redirect_to @heart, notice: 'Heart was successfully created.' }\n format.json { render :show, status: :created, location: @heart }\n else\n format.html { render :new }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n end",
"def index\n status = get_health_status( )\n response = make_response( status )\n #render json: response, :status => response.is_healthy? ? 200 : 500\n render json: response, :status => 200 # dont want to continuously restart the container\n end",
"def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end",
"def index\n status = get_health_status( )\n response = make_response( status )\n render json: response, :status => response.is_healthy? ? 200 : 500\n end",
"def index\n status = get_health_status( )\n response = make_response( status )\n render json: response, :status => response.is_healthy? ? 200 : 500\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n @push_day = session[:push_day] \n end",
"def index\n @talk = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk }\n end\n end",
"def show\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monkey }\n end\n end",
"def mget\n begin \n params.reject! {|key, value| ['controller', 'action', 'format'].include?(key)}\n @connections = []\n params.each do |key, value|\n @connections << {key: value, value: to_obj($redis.get(value)), ttl: $redis.ttl(value)}\n end \n rescue => e\n @connections = {status: 500, message: e.message }\n end \n\n respond_to do |format|\n format.json { render json: @connections }\n end\n end",
"def show\n @chatline = Chatline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chatline }\n end\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def index\n @shorteners = Shortener.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shorteners }\n end\n end",
"def update\n respond_to do |format|\n if @heart_beat.update(heart_beat_params)\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n # only list current user's hangouts\n @hangouts = current_user.hangouts.order(\"start_date_time DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hangouts }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def index\n @sayings = Saying.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sayings }\n end\n end",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@teaches) }\n\t\tend\n\n end",
"def create\n heart_beat= DateTime.new(params[\"heart_beat\"][\"heart_beat(1i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(2i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(3i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(4i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(5i)\"].to_i)\n @heart_beat = HeartBeat.new({heart_beat: heart_beat, intensity: params[\"heart_beat\"][\"intensity\"].to_i})\n @heart_beat.person = Person.first\n\n respond_to do |format|\n if @heart_beat.save\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @heart_beat }\n else\n format.html { render action: 'new' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @cocktail_history = CocktailHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cocktail_history }\n end\n end",
"def index\n @health_levels = HealthLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @health_levels }\n end\n end"
] | [
"0.7678846",
"0.72466946",
"0.68842596",
"0.65022284",
"0.63617367",
"0.6158657",
"0.61320883",
"0.6118239",
"0.6009443",
"0.59720826",
"0.59686863",
"0.59295446",
"0.5848068",
"0.57926166",
"0.5792602",
"0.578136",
"0.5769746",
"0.57173455",
"0.57107013",
"0.5699612",
"0.5665607",
"0.5658927",
"0.5632661",
"0.5625428",
"0.5615181",
"0.56044036",
"0.5600802",
"0.55694115",
"0.55668217",
"0.55558616",
"0.5539014",
"0.553719",
"0.5512643",
"0.5498462",
"0.54822767",
"0.5456002",
"0.54369944",
"0.54309964",
"0.5414241",
"0.54104304",
"0.5396221",
"0.5373911",
"0.53433865",
"0.53385067",
"0.5335599",
"0.53264374",
"0.53053695",
"0.5296906",
"0.5293934",
"0.5291038",
"0.5289967",
"0.5286499",
"0.5286499",
"0.5279818",
"0.5256638",
"0.5253231",
"0.52501595",
"0.52463686",
"0.5245107",
"0.524257",
"0.52354765",
"0.52296454",
"0.5228205",
"0.52277756",
"0.5227004",
"0.52268225",
"0.52237284",
"0.5221848",
"0.52192485",
"0.5217901",
"0.5212929",
"0.5211202",
"0.5195769",
"0.51894337",
"0.51880753",
"0.51870304",
"0.51751816",
"0.51684743",
"0.516304",
"0.5162678",
"0.5162678",
"0.51625323",
"0.5158238",
"0.51570773",
"0.51570773",
"0.51569223",
"0.5152662",
"0.51329356",
"0.51247036",
"0.5123726",
"0.51129216",
"0.5112557",
"0.51101947",
"0.5106464",
"0.51009834",
"0.5099778",
"0.50979745",
"0.5094387",
"0.50936437",
"0.50885504"
] | 0.70229924 | 2 |
GET /heartbeats/new GET /heartbeats/new.json | def new
@heartbeat = Heartbeat.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @heartbeat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @beat = Beat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beat }\n end\n end",
"def create\n @heartbeat = Heartbeat.new(params[:heartbeat])\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }\n format.json { render json: @heartbeat, status: :created, location: @heartbeat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end",
"def new\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end",
"def new\n @beattape = Beattape.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beattape }\n end\n end",
"def index\n @heartbeats = Heartbeat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heartbeats }\n end\n end",
"def create\n @heart = Heart.new(heart_params)\n\n respond_to do |format|\n if @heart.save\n format.html { redirect_to @heart, notice: 'Heart was successfully created.' }\n format.json { render :show, status: :created, location: @heart }\n else\n format.html { render :new }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @have = Have.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @have }\n end\n end",
"def new\n @hangout = Hangout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hangout }\n end\n end",
"def create\n @hearted = Hearted.new(hearted_params)\n\n respond_to do |format|\n if @hearted.save\n format.html { redirect_to @hearted, notice: 'Hearted was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hearted }\n else\n format.html { render action: 'new' }\n format.json { render json: @hearted.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @heat_log = HeatLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heat_log }\n end\n end",
"def new\n @beacon = Beacon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beacon }\n end\n end",
"def new\n @heat_type = HeatType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heat_type }\n end\n end",
"def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end",
"def new\n @sleep = Sleep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sleep }\n end\n end",
"def new\n @rainbow = Rainbow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def new\n @heart_rate_type = HeartRateType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heart_rate_type }\n end\n end",
"def new\n @believer = Believer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @believer }\n end\n end",
"def create\n @beat = Beat.new(params[:beat])\n\n respond_to do |format|\n if @beat.save\n format.html { redirect_to @beat, notice: 'Beat was successfully created.' }\n format.json { render json: @beat, status: :created, location: @beat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tick_track = TickTrack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tick_track }\n end\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @badge }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announce }\n end\n end",
"def new\n @logstash = Logstash.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logstash }\n end\n end",
"def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end",
"def show\n render json: @heartbeat\n end",
"def new\n @health_record = HealthRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @health_record }\n end\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @kickoff = Kickoff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kickoff }\n end\n end",
"def new\n @blocking_client = BlockingClient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @blocking_client }\n end\n end",
"def new\n @stalking = Stalking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stalking }\n end\n end",
"def new\n @replay = Replay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @replay }\n end\n end",
"def new\n @healthrecord = Healthrecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @healthrecord }\n end\n end",
"def new\n @cocktail_history = CocktailHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cocktail_history }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk }\n end\n end",
"def show\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def new\n @bounty = Bounty.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bounty }\n end\n end",
"def index\n @heart_beats = HeartBeat.all\n end",
"def new\n @beer = Beer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer }\n end\n end",
"def new\n @beer = Beer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @talk }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @talk }\n end\n end",
"def new\n @wish = Wish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wish }\n end\n end",
"def new\n @playing = Playing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @playing }\n end\n end",
"def new\n @beasts = Beast.all\n @noise = Noise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @noise }\n end\n end",
"def new\n @fire = Fire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fire }\n end\n end",
"def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end",
"def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end",
"def new\n @hour = Hour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hour }\n end\n end",
"def new\n @hour = Hour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hour }\n end\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @track }\n end\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @track }\n end\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @track }\n end\n end",
"def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end",
"def new\n @historical = Historical.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historical }\n end\n end",
"def new\n @saying = Saying.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @saying }\n end\n end",
"def new\n @habit = Habit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @habit }\n end\n end",
"def new\n @habit = Habit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @habit }\n end\n end",
"def new\n @livestock = Livestock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @livestock }\n end\n end",
"def create\n heart_beat= DateTime.new(params[\"heart_beat\"][\"heart_beat(1i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(2i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(3i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(4i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(5i)\"].to_i)\n @heart_beat = HeartBeat.new({heart_beat: heart_beat, intensity: params[\"heart_beat\"][\"intensity\"].to_i})\n @heart_beat.person = Person.first\n\n respond_to do |format|\n if @heart_beat.save\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @heart_beat }\n else\n format.html { render action: 'new' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n add_breadcrumb 'Your hubs', :hubs_path\n add_breadcrumb 'New hub', new_hub_path\n append_title 'New hub'\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @hub }\n end\n end",
"def new\n @chatline = Chatline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chatline }\n end\n end",
"def new\n @sticky = Sticky.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sticky }\n end\n end",
"def new\n @heat_source = HeatSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heat_source }\n end\n end",
"def new\n @belief = Belief.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @belief }\n end\n end",
"def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end",
"def new\n @time_track = TimeTrack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_track }\n end\n end",
"def new\n @pocket = Pocket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pocket }\n end\n end",
"def new\n @cocktail = Cocktail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cocktail }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_frame }\n end\n end",
"def new\n @hive = Hive.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hive }\n end\n end",
"def new\n @eatvent = Eatvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @eatvent }\n end\n end",
"def new\n @hive_event = HiveEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hive_event }\n end\n end",
"def new\n @gauge = Gauge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gauge }\n end\n end",
"def new\n @ptrack = Ptrack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ptrack }\n end\n end",
"def new\n @notice = Notice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @notice }\n end\n end",
"def new\n @gossip = Gossip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gossip }\n end\n end",
"def new\n @back_pocket = Back_pocket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @back_pocket }\n end\n end",
"def new\n @witch = Witch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @witch }\n end\n end",
"def new\n @like = Like.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @like }\n end\n end",
"def new\n @threshold = Threshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @threshold }\n end\n end",
"def new\n @cocktail = Cocktail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cocktail }\n end\n end",
"def new\n @highfive = Highfive.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @highfive }\n end\n end",
"def new\n @jetty = Jetty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jetty }\n end\n end",
"def new\n @wait_time = WaitTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wait_time }\n end\n end",
"def new\n @pushup = Pushup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pushup }\n end\n end",
"def new\n @waiter = Waiter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @waiter }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @secret_record }\n end\n end",
"def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end",
"def new\n @climb = Climb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @climb }\n end\n end",
"def new\n @essay = Essay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @essay }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @chat = Chat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chat }\n end\n end",
"def new\n @baton = Baton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @baton }\n end\n end",
"def new\n @thing = Thing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end",
"def new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @favorite }\n end\n end"
] | [
"0.7272637",
"0.6936148",
"0.68952334",
"0.66982365",
"0.66821927",
"0.6655151",
"0.66112405",
"0.6546821",
"0.6492818",
"0.64558715",
"0.6447968",
"0.64155996",
"0.64078236",
"0.6396624",
"0.6394969",
"0.6393895",
"0.6384182",
"0.6314045",
"0.63070434",
"0.62736917",
"0.62665826",
"0.62551725",
"0.6238506",
"0.6227333",
"0.62240005",
"0.6218572",
"0.6208497",
"0.6208065",
"0.61993456",
"0.61961913",
"0.6194426",
"0.6192778",
"0.6191714",
"0.6187386",
"0.61779857",
"0.6167637",
"0.6167637",
"0.6139207",
"0.61296064",
"0.6128306",
"0.61275333",
"0.61275333",
"0.6123237",
"0.61218",
"0.61184424",
"0.611616",
"0.61158967",
"0.6114301",
"0.6109639",
"0.6109639",
"0.6107777",
"0.6107777",
"0.6107676",
"0.6107676",
"0.6107676",
"0.6103424",
"0.60978967",
"0.6089659",
"0.60893583",
"0.60893583",
"0.6082426",
"0.60810953",
"0.6079186",
"0.60737324",
"0.60656846",
"0.6060557",
"0.6058488",
"0.6056551",
"0.60486275",
"0.6048082",
"0.6047628",
"0.6040953",
"0.604048",
"0.6039759",
"0.6036655",
"0.60351807",
"0.6034153",
"0.603269",
"0.6032244",
"0.6024603",
"0.6017501",
"0.6012727",
"0.60090655",
"0.60087615",
"0.6004902",
"0.60040754",
"0.60000557",
"0.59938234",
"0.5992007",
"0.5983353",
"0.59828895",
"0.5982503",
"0.5977046",
"0.5974201",
"0.5974201",
"0.5971413",
"0.59606993",
"0.59606713",
"0.5959299",
"0.59584945"
] | 0.77907175 | 0 |
POST /heartbeats POST /heartbeats.json | def create
@heartbeat = Heartbeat.new(params[:heartbeat])
respond_to do |format|
if @heartbeat.save
format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }
format.json { render json: @heartbeat, status: :created, location: @heartbeat }
else
format.html { render action: "new" }
format.json { render json: @heartbeat.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def index\n @heartbeats = Heartbeat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heartbeats }\n end\n end",
"def heartbeat\n request(Resources::RESOURCE_HEARTBEAT, HTTP_METHOD_POST)\n end",
"def heart_params\n params.require(:heart).permit(:beat)\n end",
"def create\n @heart = Heart.new(heart_params)\n\n respond_to do |format|\n if @heart.save\n format.html { redirect_to @heart, notice: 'Heart was successfully created.' }\n format.json { render :show, status: :created, location: @heart }\n else\n format.html { render :new }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n heart_beat= DateTime.new(params[\"heart_beat\"][\"heart_beat(1i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(2i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(3i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(4i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(5i)\"].to_i)\n @heart_beat = HeartBeat.new({heart_beat: heart_beat, intensity: params[\"heart_beat\"][\"intensity\"].to_i})\n @heart_beat.person = Person.first\n\n respond_to do |format|\n if @heart_beat.save\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @heart_beat }\n else\n format.html { render action: 'new' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hearted = Hearted.new(hearted_params)\n\n respond_to do |format|\n if @hearted.save\n format.html { redirect_to @hearted, notice: 'Hearted was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hearted }\n else\n format.html { render action: 'new' }\n format.json { render json: @hearted.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @heart_beats = HeartBeat.all\n end",
"def create\n @beat = Beat.new(params[:beat])\n\n respond_to do |format|\n if @beat.save\n format.html { redirect_to @beat, notice: 'Beat was successfully created.' }\n format.json { render json: @beat, status: :created, location: @beat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_heartbeat\n timestamp = Time.now.to_i\n store.zadd(\"hb:#{@client.uid}\", timestamp, [Time.now.to_s(:db), @payload].to_json)\n end",
"def heart_beat_params\n params.require(:heart_beat).permit(:heart_beat, :intensity)\n end",
"def beat\n if params[:key]\n @server = Server.find_by_key params[:key]\n @server.beat_counter += 1\n else\n @server = Server.new\n @server.key ||= Digest::MD5.hexdigest(rand.to_s)\n @server.beat_counter = 1\n end\n \n @server.hostname = params[:hostname] || request.remote_ip\n @server.port = (params[:port] || 28997).to_i\n @server.title = params[:title] || \"New Server\"\n @server.game_mode = nil\n \n if @server.save\n render :text => @server.key\n else\n render :text => 'Error saving record', :status => 500\n end\n end",
"def process_heartbeats(data, reply, subject)\n # No payload assumed, just reply to the heartbeat.\n nats.publish(reply, '')\n end",
"def heart!(post)\n self.hearts.create!(post_id: post.id)\n end",
"def new\n @heartbeat = Heartbeat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def destroy\n @heart_beat.destroy\n respond_to do |format|\n format.html { redirect_to heart_beats_url }\n format.json { head :no_content }\n end\n end",
"def beat\n Logger.trace \"beat heart #{Zensu.node.id} #{Time.now.to_i}\"\n remote_publish(\"zensu.heartbeat\", Zensu.node.id, Zensu.config.router_endpoint, Time.now.to_i.to_s)\n end",
"def heart_params\n params.require(:heart).permit(:heart_count, :image_id)\n end",
"def key_worker_heartbeats\n key(\"worker_heartbeats\")\n end",
"def heart_params\n params.require(:heart).permit(:feeling, :date, :mind_id)\n end",
"def heartbeats_params\n params.permit(:device_id)\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def show\n render json: @heartbeat\n end",
"def set_heart_beat\n @heart_beat = HeartBeat[Person.first.id.to_s].find(params[:id])\n end",
"def create\n @beattape = Beattape.new(params[:beattape])\n\n respond_to do |format|\n if @beattape.save\n format.html { redirect_to @beattape, notice: 'Beattape was successfully created.' }\n format.json { render json: @beattape, status: :created, location: @beattape }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beattape.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n if @heartbeat.update(heartbeat_params)\n head :no_content\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def hearted_params\n params.require(:hearted).permit(:userx_id, :usery_id, :matched, :userx_heart_time, :usery_heart_time, :match_time, :notification_time)\n end",
"def heartbeat\n end",
"def beat\n Logger.trace \"beat heart #{Node.id} #{Time.now.to_i}\"\n notifier.async.publish(config.topic, Node.id, Router.endpoint, Time.now.to_i.to_s)\n end",
"def create\n @heart_rate_type = HeartRateType.new(params[:heart_rate_type])\n\n respond_to do |format|\n if @heart_rate_type.save\n format.html { redirect_to @heart_rate_type, notice: 'Heart rate type was successfully created.' }\n format.json { render json: @heart_rate_type, status: :created, location: @heart_rate_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heart_rate_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @beat = Beat.new(params[:beat])\n respond_to do |format| \n if @beat.save\n flash[:notice] = 'Beat was successfully created.'\n format.html { redirect_to (@beat) }\n else\n format.html { render :action => \"new\" }\n end\r\n end \n end",
"def create\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n description = params[:description]\n \n timestamp = params[:timestamp]\n total_sleep_seconds = params[:total_sleep]\n deep_sleep_seconds = params[:deep]\n light_sleep_seconds = params[:light]\n awake_seconds = params[:awake]\n \n if timestamp.nil? || total_sleep_seconds.nil?\n \n puts 'timestamp is nil or total_sleep_seconds is nil :('\n \n else\n \n total_sleep = total_sleep_seconds / 60.0\n deep = deep_sleep_seconds / 60.0\n light = light_sleep_seconds / 60.0\n awake = awake_seconds / 60.0\n \n post_to_twitter = false\n post_to_facebook = false\n \n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\n timestamp_datetime = DateTime.parse(timestamp)\n formatted_timestamp = timestamp_datetime.strftime(\"%a, %d %b %Y %H:%M:%S\")\n \n json_hash['timestamp'] = formatted_timestamp\n json_hash['total_sleep'] = deep\n json_hash['deep'] = deep\n json_hash['light'] = light\n json_hash['awake'] = awake\n json_hash['post_to_twitter'] = post_to_twitter\n json_hash['post_to_facebook'] = post_to_facebook\n \n url = 'https://api.runkeeper.com/sleep'\n \n uri = URI.parse(url)\n \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[\"Authorization\"] = \"Bearer \" + RUNKEEPER_ACCESS_TOKEN\n request[\"Content-Type\"] = \"application/vnd.com.runkeeper.NewSleep+json\"\n request.body = json_hash.to_json\n \n response = http.request(request)\n \n puts response.body\n \n end\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n \n end",
"def post_haiku(line_1,line_2,line_3)\n url = ENV[\"SLACK_URL\"]\n payload = {username: \"haiku-bot\", icon_url: \"christmas-haiku.jpg\", text: line_1+\"\\n\"+line_2+\"\\n\"+line_3, channel: \"#random\"}\n RestClient.post(url, payload.to_json, accept: :json)\n end",
"def create\n @highfive = Highfive.new(params[:highfive])\n @highfive.user1 = current_user\n\n respond_to do |format|\n if @highfive.save\n # Send push notification to highfive recipient\n message = @highfive.id\n broadcast(\"/messages/#{@highfive.user2.id}\", message)\n format.html { redirect_to highfives_path, :notice => \"Highfive was successfully submitted. Awaiting confirmation from #{@highfive.user2.username}.\" }\n format.json { render :json => @highfive, :status => :created, :location => @highfive }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @highfive.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def heart! \n self.increment!(:hearts_count)\n end",
"def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end",
"def create\n @beacon = Beacon.new(params[:beacon])\n\n respond_to do |format|\n if @beacon.save\n format.html { redirect_to @beacon, notice: 'Beacon was successfully created.' }\n format.json { render json: @beacon, status: :created, location: @beacon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beacon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def heartbeat\n me = WORKER_TEMPLATE.dup\n me['name'] = id\n @heartbeat_entry ||= write(me, @heartbeat_refresh + 10)\n @heartbeat_entry.renew(@heartbeat_refresh) unless @heartbeat_entry.canceled?\n end",
"def new\n @beat = Beat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beat }\n end\n end",
"def index\n @quacks = Quack.all\n # SSE expects the `text/event-stream` content type\n response.headers['Content-Type'] = 'text/event-stream'\n\n sse = Reloader::SSE.new(response.stream)\n begin\n loop do\n sse.write({ :time => Time.now })\n sleep 1\n end\n rescue IOError\n # When the client disconnects, we'll get an IOError on write\n ensure\n sse.close\n end\n end",
"def emit_flood(event, time, sink)\n data = {\n \"time\": time.to_s,\n \"id\": event[\"site_no\"] + time.to_s.gsub(\" \", \"\"),\n \"type\": \"flood\",\n \"lat\": event[\"dec_lat_va\"],\n \"long\": event[\"dec_long_va\"],\n # \"measure\": (event[\"stage\"] - event[\"floodstage\"].to_f).round(2), # Something's wrong with the API, changing for now until fixed\n \"measure\": event[\"flow\"],\n \"metadata\": event.to_json\n }\n\n puts \"data: #{data}\"\n\n @logger.info(\"Sending message to #{sink}\")\n r = HTTParty.post(sink, \n :headers => {\n 'Content-Type' => 'text/plain',\n 'ce-specversion' => '0.2',\n 'ce-type' => 'dev.knative.naturalevent.flood',\n 'ce-source' => 'dev.knative.flood'\n },\n :body => data.to_json\n )\n\n if r.code != 200 or r.code != 202\n @logger.error(\"Error! #{r.code} - #{r}\")\n @logger.error(\"Body: #{r.body}\")\n end\nend",
"def snooze!\n log \"Sending #{@method} to Snooze.io\"\n handle_post_response { Snooze::Post.send(@method, @clock_id) }\n end",
"def create\n @scribble = Scribble.new(params[:scribble])\n @scribble.posted_by_uid=current_user.beamer_id\n @scribble.posted_by=current_user.first_name+\" \"+current_user.last_name\n @scribble.ups=0\n @scribble.downs=0\n respond_to do |format|\n if @scribble.save!\n format.html { redirect_to root_path }\n format.json { render :json => @scribble, :status => :created, :location => @scribble }\n else\n format.html { redirect_to root_path }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def scrobble( params )\n LastFM.requires_authentication\n # Tracks are passed to the service using array notation for each of the above params\n array_params = {}\n params.each do |hkey, hval|\n hval = hval.to_i if hval.is_a?(Time)\n Array(hval).each_with_index do |aval, index|\n array_params[\"#{hkey}[#{index}]\"] = aval\n end\n end\n LastFM.post( \"track.scrobble\", array_params )\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n @push_day = session[:push_day] \n end",
"def create\n puts \"==========================\"\n puts \"CREATE\"\n JSON[params[\"updates\"].read].each do |notification|\n user = User.find(notification[\"subscriptionId\"])\n if user\n case notification[\"collectionType\"]\n when \"sleep\"\n user.fitbit.client.sleep_on_date(notification[\"date\"])[\"sleep\"].each do |data|\n sleep_event = { user_id: notification[\"subscriptionId\"], provider: params[:app_id], body: data }\n sleep_logger.info sleep_event\n end\n end\n end\n end\n render text: \"\", status: 204\n end",
"def test_json_success\n c = Example::HaberdasherClient.new(conn_stub(\"/example.Haberdasher/MakeHat\") {|req|\n [200, jsonheader, '{\"inches\": 99, \"color\": \"red\"}']\n }, content_type: \"application/json\")\n\n resp = c.make_hat({})\n assert_nil resp.error\n assert_equal 99, resp.data.inches\n assert_equal \"red\", resp.data.color\n end",
"def create\n megam_rest.post_event(to_hash)\n end",
"def update\n respond_to do |format|\n if @heart_beat.update(heart_beat_params)\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_heartbeats\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.by(proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id })\n end\n end",
"def beat_params\n params.require(:beat).permit(:title, :position, :board_id)\n end",
"def send(key)\n HTTParty.post(@add_url, {\n :headers => {\n \"Content-Type\" => \"application/json; charset=UTF8\",\n \"X-Accept\" => \"application/json\"\n },\n :body => {\n #:url => formatted[:url],\n :url => \"https://www.engadget.com/2016/10/09/more-galaxy-note-7-replacement-fires/\",\n #:tags => formatted[:tags],\n :consumer_key => ENV['POCKET_CONSUMER_KEY'],\n :access_token => key\n }.to_json\n })\n end",
"def create\n @bee = Bee.new(bee_params)\n\n respond_to do |format|\n if @bee.save\n format.html { redirect_to @bee, notice: 'Bee was successfully created.' }\n format.json { render :show, status: :created, location: @bee }\n else\n format.html { render :new }\n format.json { render json: @bee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def alert_birthday(message, chann, user)\n HTTParty.post(@url, body: {channel: chann, username: user, text: message, icon_emoji: \":david:\"}.to_json)\n end",
"def create\n @twizzle = Twizzle.new(twizzle_params)\n\n respond_to do |format|\n if @twizzle.save\n format.html { redirect_to @twizzle, notice: 'Twizzle was successfully created.' }\n format.json { render :show, status: :created, location: @twizzle }\n else\n format.html { render :new }\n format.json { render json: @twizzle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tack = Tack.new(tack_params)\n\n if @tack.save\n render json: @tack, status: :created, location: @tack\n else\n render json: @tack.errors, status: :unprocessable_entity\n end\n end",
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def create\n @beehive = Beehive.new(beehive_params)\n @beehive.user_id = current_user.id\n respond_to do |format|\n if @beehive.save\n format.html { redirect_to @beehive, notice: 'Beehive was successfully created.' }\n format.json { render :show, status: :created, location: @beehive }\n else\n format.html { render :new }\n format.json { render json: @beehive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bike_rack = BikeRack.new(bike_rack_params)\n\n respond_to do |format|\n if @bike_rack.save\n flash[:success] = 'Bike rack was successfully created.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :created, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem with creating Bike rack.'\n format.html { render :new }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n params[\"_json\"].each do |params_hash|\n puts params_hash.inspect\n @ticker_activity = TickerActivity.new(params_hash)\n @ticker_activity.save\n end\n\n #@ticker_activity = TickerActivity.new(params[:ticker_activity])\n\n respond_to do |format|\n if @ticker_activity.save\n format.html { redirect_to @ticker_activity, notice: 'Ticker was successfully created.' }\n format.json { render json: @ticker_activity, status: :created, location: @ticker_activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticker_activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def schedule_hangup(params)\n path = @version + '/Call/Hangup/Schedule/'\n method = 'POST'\n return request(path, method, params)\n end",
"def create\n @monkey = Monkey.new(params[:monkey])\n\n respond_to do |format|\n if @monkey.save\n format.html { redirect_to @monkey, notice: 'Monkey was successfully created.' }\n format.json { render json: @monkey, status: :created, location: @monkey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monkey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rainbow = Rainbow.new(params[:rainbow])\n\n respond_to do |format|\n if @rainbow.save\n format.html { redirect_to @rainbow, notice: 'Rainbow was successfully created.' }\n format.json { render json: @rainbow, status: :created, location: @rainbow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rainbow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @beacon = Beacon.new(beacon_params)\n\n if @beacon.save\n render :show, status: :created, location: @beacon\n else\n render json: @beacon.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @heart.update(heart_params)\n format.html { redirect_to @heart, notice: 'Heart was successfully updated.' }\n format.json { render :show, status: :ok, location: @heart }\n else\n format.html { render :edit }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @heart.update(heart_params)\n format.html { redirect_to @heart, notice: 'Heart was successfully updated.' }\n format.json { render :show, status: :ok, location: @heart }\n else\n format.html { render :edit }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @chat = Hangout.new(chat_params)\r\n @chat.save\r\n\r\n respond_to do |format|\r\n if @chat.save\r\n format.html { redirect_to chat_path(@chat), notice: 'Chat was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @chat }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @chat.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @beef = Beef.new(beef_params)\n\n respond_to do |format|\n if @beef.save\n format.html { redirect_to @beef, notice: 'Beef was successfully created.' }\n format.json { render :show, status: :created, location: @beef }\n else\n format.html { render :new }\n format.json { render json: @beef.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tick = Tick.new(tick_params)\n\n respond_to do |format|\n if @tick.save\n format.html { redirect_to @tick, notice: 'Tick was successfully created.' }\n format.json { render :show, status: :created, location: @tick }\n else\n format.html { render :new }\n format.json { render json: @tick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n r = Redis.new\n r.publish(params[:key], \"event: alert\\ndata: #{params[:msg]}\\n\\n\")\n r.quit\n render json: {ok: 1}\n end",
"def create\n request.format = :json\n event = params[:event]\n ActiveSupport::Notifications.instrument(\"closeio.#{event[:action]}\", event)\n\n #must return an ok - check Rails version to determine whether to return nothing or head response.\n if ::Rails.version =~ /^4/\n render nothing: true\n else\n head :ok\n end\n end",
"def destroy\n @hearted.destroy\n respond_to do |format|\n format.html { redirect_to hearteds_url }\n format.json { head :no_content }\n end\n end",
"def beat_params\n params.require(:beat).permit(:title, :preview, :mp3, :wav, :free, :cover, :tempo, :scale)\n end",
"def send(message)\n headers = { 'Content-Type' => 'application/json' }\n payload = { text: message }.to_json\n HTTParty.post(@webhook_url, body: payload, headers: headers)\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n if @heartbeat.update_attributes(params[:heartbeat])\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hangout = Hangout.new(params[:hangout])\n @hangout.user = current_user\n\n # save hangout\n respond_to do |format|\n if @hangout.save\n format.html { redirect_to @hangout, notice: 'Hangout was successfully created.' }\n format.json { render json: @hangout, status: :created, location: @hangout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hangout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_to_fancyhands\n post_to_fancyhands_now\n end",
"def create\n #Convert comma seprated value into an array\n hashtags = battle_params[:hashtags].split(',')\n @battle = Battle.new(name: battle_params[:name])\n if @battle.save\n\n #Insert hashtags into the battle\n @battle.add_hashtags(hashtags)\n\n $redis = Redis.new(:host => Rails.application.config.redis_host, :port => Rails.application.config.redis_port, :password => Rails.application.config.redis_password, :thread_safe => true)\n\n #Pull data from twitter streaming api\n begin\n end_time = (Time.now + 5.minutes)\n\n @battle.hashtags.each do |battle_ht|\n data = {:keyword => \"#{battle_ht.title.downcase}\", :end_time => end_time }\n $redis.publish(\"battle:hashtag:#{@battle.id}\", data.to_json )\n sleep 1\n end\n\n TweetStream::Client.new.track(@battle.hashtags_csv) do |object, client|\n\n if object.hashtags?\n object.hashtags.each do |ht|\n @battle.hashtags.each do |battle_hashtag|\n if battle_hashtag.title.downcase == ht.text.downcase\n\n data = {:keyword => ht.text.downcase, :end_time => end_time }\n\n #Check time left\n if Time.now > end_time\n logger.info \"Time's up\"\n client.stop\n $redis.quit\n break\n else\n $redis.publish(\"battle:hashtag:#{@battle.id}\", data.to_json )\n sleep 1\n end\n\n end\n end\n end\n end\n end\n\n\n rescue => error\n logger.info \"#{error}\"\n #render :json => {:status=> \"error\", :message => \"#{error}\" }, :status=>500\n #return\n ensure\n #logger.info \"Stopping twitter stream\"\n #$redis.quit\n end\n render :json => {:status=>\"success\", :message => \"done\"}, :status=>200\n else\n render :json => {:status=> :unprocessable_entity, :error => @battle.errors }, :status=>422\n end\n\n end",
"def create\n @shout = Shout.new(params[:shout])\n\n sendPush (@shout.name + ' just shouted ' + @shout.shout_message)\n \n respond_to do |format|\n if @shout.save\n format.html { redirect_to(@shout, :notice => 'Shout was successfully created.') }\n format.xml { render :xml => @shout, :status => :created, :location => @shout }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n if @user.hearts >= @reward.cost\n @redemption = Redemption.new()\n @redemption.user = @user\n @redemption.cost = @reward.cost\n @redemption.reward = @reward\n\n if @reward.ifttt?\n key = ENV[\"IFTTT_KEY\"]\n\turl = \"https://maker.ifttt.com/trigger/#{@user.account}#{@reward.event}/with/key/#{key}\"\n\tresponse = RestClient.get url\n\n\trespond_to do |format|\n\t if response.code == 200 && @redemption.save\n @user.hearts = @user.hearts - @reward.cost\n @user.save!\n\n format.json { render json: @redemption.as_json(include: {reward: {only: :name}}).merge({hearts: @user.hearts}), status: :created }\n else\n format.json { render json: nil, status: :not_acceptable }\n end\n end\n elsif @reward.cash?\n \trespond_to do |format|\n if @redemption.save\n @user.hearts = @user.hearts - @reward.cost\n\t @user.save!\n\t SmsMailer.sms_email(Admin.all.first).deliver\n\n\t format.json { render json: @redemption.as_json(include: {reward: {only: :name}}).merge({hearts: @user.hearts}), status: :created }\n\t else\n\t format.json { render json: nil, status: :not_acceptable }\n\t end\n\tend\n end\n else\n respond_to do |format|\n format.json { render json: {message: \"Not enough hearts!\"}, status: :not_acceptable }\n end\n end\n end",
"def find_heartbeats(params, options)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.by({ proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id } }.merge(params), options)\n end\n end",
"def create\n @musictrack = Musictrack.new(musictrack_params)\n\n respond_to do |format|\n if @musictrack.save\n format.html { redirect_to @musictrack, notice: 'Musictrack was successfully created.' }\n format.json { render :show, status: :created, location: @musictrack }\n else\n format.html { render :new }\n format.json { render json: @musictrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def conference_hangup(params)\n path = @version + '/Conference/Member/Hangup/'\n method = 'POST'\n return request(path, method, params)\n end",
"def new\n @beattape = Beattape.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beattape }\n end\n end",
"def create\n @anime = Pusher.create_anime(params[:anime])\n\n if @anime.valid?\n render json: @anime, status: :created, location: @anime\n else\n render json: @anime.errors, status: :unprocessable_entity\n end\n end",
"def index\n @beats = Beat.all\n end",
"def create\n @eat = Eat.new(eat_params)\n\n respond_to do |format|\n if @eat.save\n format.html { redirect_to @eat, notice: 'Eat was successfully created.' }\n format.json { render :show, status: :created, location: @eat }\n else\n format.html { render :new }\n format.json { render json: @eat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_hearted\n @hearted = Hearted.find(params[:id])\n end",
"def panic_tapped\n\n data = {answer: 1, email: App::Persistence['email'], cohort: App::Persistence['cohort']}\n\n BubbleWrap::HTTP.post(\"http://equanimity.herokuapp.com/users/m/:id/responses\", {payload: data}) do |response|\n\n puts data\n # puts \"response = #{response}\"\n # puts \"response.body = #{response.body.to_str rescue ''}\"\n # puts \"response.error_message = #{response.error_message}\"\n # puts \"response.status_code = #{response.status_code.to_s rescue ''}\"\n # puts \"response ok = #{response.ok?}\"\n\n if response.ok?\n\n App.alert(\"Thanks!\")\n else\n App.alert(\"Something went wrong...\")\n end\n end\n end",
"def create\n data = reload(get_series('sleep'), str(Date.strptime(params[:sleep].values.join(\"-\"))))\n saved = false\n get_series('sleep').each do |s|\n data[s].each do |day|\n logger.debug \"data=#{day} date=#{day['dateTime']} value=#{day['value']}\"\n @sleep = for_date(day['dateTime'])\n\t# get variable name from last part of series\n @sleep.send(s.rpartition('/')[2] + '=', day['value'])\n saved = @sleep.save\n if not saved\n flash[:error] = @sleep.errors\n end\n end\n end\n \n respond_to do |format|\n flash[:success] = 'Sleep was successfully created.'\n format.html { redirect_to sleeps_path }\n format.json { render :json => sleeps_path, :status => :created, :location => sleeps_path }\n end\n end",
"def start_heartbeat\n @hb_received_at = Time.now\n send_heartbeat\n @heartbeat_timer = @reactor.periodical_timer(@heartbeat_interval) { send_heartbeat }\n end",
"def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT], @session.seq)\n end",
"def call method, args = {}\n unless args.is_a? Hash\n raise ArgumentError.new \"argument must be a Hash\"\n end\n\n args.each_key do |key|\n if args[key].is_a?(Array) || args[key].is_a?(Hash)\n args[key] = JSON.dump(args[key])\n end\n end\n\n @faraday.post method, args\n end",
"def create\n @bow = Bow.new(bow_params)\n\n respond_to do |format|\n if @bow.save\n format.html { redirect_to @bow, notice: 'Bow was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bow }\n else\n format.html { render action: 'new' }\n format.json { render json: @bow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @health_record = HealthRecord.new(health_record_params)\n\n respond_to do |format|\n if @health_record.save\n format.html { redirect_to @health_record, notice: 'Health record was successfully created.' }\n format.json { render action: 'show', status: :created, location: @health_record }\n else\n eatings_invalid\n format.html { render action: 'new' }\n format.json { render json: @health_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def heart!(comment)\n self.hearts.create!(comment_id: comment.id)\n end",
"def new\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n end"
] | [
"0.6958232",
"0.6912646",
"0.65134186",
"0.64758384",
"0.64440364",
"0.6372636",
"0.6287073",
"0.6213387",
"0.6197699",
"0.6187945",
"0.61289394",
"0.60297734",
"0.59501183",
"0.59390837",
"0.59079117",
"0.58413213",
"0.579141",
"0.57741016",
"0.5758004",
"0.56950766",
"0.56927055",
"0.5648858",
"0.56375027",
"0.5598501",
"0.5596048",
"0.55819005",
"0.55397147",
"0.5519119",
"0.5496478",
"0.54828876",
"0.543276",
"0.53718764",
"0.53265166",
"0.5313127",
"0.5302998",
"0.5291691",
"0.5291364",
"0.52763563",
"0.5272531",
"0.5260971",
"0.5254072",
"0.524212",
"0.52301073",
"0.5222768",
"0.5207196",
"0.5179723",
"0.5171525",
"0.5168816",
"0.51618123",
"0.5155084",
"0.5135876",
"0.5119884",
"0.5117475",
"0.51095074",
"0.5103406",
"0.5095222",
"0.5087701",
"0.50835735",
"0.5078696",
"0.5068691",
"0.50675774",
"0.5048651",
"0.5043863",
"0.5022687",
"0.5019123",
"0.50151724",
"0.50120467",
"0.50120467",
"0.49994358",
"0.4994645",
"0.49929798",
"0.49899772",
"0.4989958",
"0.4982916",
"0.4982896",
"0.4981856",
"0.49556243",
"0.4948584",
"0.49460083",
"0.49365664",
"0.49300277",
"0.492982",
"0.4926667",
"0.4922939",
"0.49162737",
"0.4908956",
"0.48991734",
"0.48916557",
"0.4887389",
"0.48763546",
"0.4869214",
"0.4865788",
"0.4854124",
"0.48425767",
"0.4839156",
"0.4838465",
"0.4838102",
"0.483771",
"0.48314506",
"0.48226294"
] | 0.6765585 | 2 |
PUT /heartbeats/1 PUT /heartbeats/1.json | def update
@heartbeat = Heartbeat.find(params[:id])
respond_to do |format|
if @heartbeat.update_attributes(params[:heartbeat])
format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @heartbeat.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n if @heartbeat.update(heartbeat_params)\n head :no_content\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @heart_beat.update(heart_beat_params)\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @heart.update(heart_params)\n format.html { redirect_to @heart, notice: 'Heart was successfully updated.' }\n format.json { render :show, status: :ok, location: @heart }\n else\n format.html { render :edit }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @heart.update(heart_params)\n format.html { redirect_to @heart, notice: 'Heart was successfully updated.' }\n format.json { render :show, status: :ok, location: @heart }\n else\n format.html { render :edit }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_heart_beat\n @heart_beat = HeartBeat[Person.first.id.to_s].find(params[:id])\n end",
"def update\n respond_to do |format|\n if @beat.update(beat_params)\n format.html { redirect_to @beat, notice: \"Beat was successfully updated.\" }\n format.json { render :show, status: :ok, location: @beat }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @beat = Beat.find(params[:id])\n\n respond_to do |format|\n if @beat.update_attributes(params[:beat])\n format.html { redirect_to @beat, notice: 'Beat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hearted.update(hearted_params)\n format.html { redirect_to @hearted, notice: 'Hearted was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hearted.errors, status: :unprocessable_entity }\n end\n end\n end",
"def beat\n if params[:key]\n @server = Server.find_by_key params[:key]\n @server.beat_counter += 1\n else\n @server = Server.new\n @server.key ||= Digest::MD5.hexdigest(rand.to_s)\n @server.beat_counter = 1\n end\n \n @server.hostname = params[:hostname] || request.remote_ip\n @server.port = (params[:port] || 28997).to_i\n @server.title = params[:title] || \"New Server\"\n @server.game_mode = nil\n \n if @server.save\n render :text => @server.key\n else\n render :text => 'Error saving record', :status => 500\n end\n end",
"def heart_params\n params.require(:heart).permit(:beat)\n end",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def save_heartbeat\n timestamp = Time.now.to_i\n store.zadd(\"hb:#{@client.uid}\", timestamp, [Time.now.to_s(:db), @payload].to_json)\n end",
"def update\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\n\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\n format.json { render :show, status: :ok, location: @thing }\n\n # Realtime push\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\n uri = URI.parse(\"http://localhost:9292/faye\")\n Net::HTTP.post_form(uri, :message => message.to_json)\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def index\n @heartbeats = Heartbeat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heartbeats }\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def create\n @heartbeat = Heartbeat.new(params[:heartbeat])\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }\n format.json { render json: @heartbeat, status: :created, location: @heartbeat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @heart_beat.destroy\n respond_to do |format|\n format.html { redirect_to heart_beats_url }\n format.json { head :no_content }\n end\n end",
"def heartbeat\n request(Resources::RESOURCE_HEARTBEAT, HTTP_METHOD_POST)\n end",
"def index\n @heart_beats = HeartBeat.all\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end",
"def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end",
"def update\n @fight = Fight.find(params[:id])\n \n secret = '9f8urg90$u3#92u8rh_gu(rfhi8rj*fih'\n\tbegin\n\t\tclient = SocketIO.connect(\"http://localhost:8190\") do\n\t\t after_start do\n\t\t\tobj = { :secret => secret, :action => 'fight', :info => { :status => 'changed' } }\n\t\t\temit(\"tournament-ruby\", obj)\n\t\t\tdisconnect \n\t\t end\n\t\tend\n\trescue\n\tend\n\n respond_to do |format|\n if @fight.update_attributes(params[:fight])\n format.html { redirect_to @fight, notice: 'Fight was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fight.errors, status: :unprocessable_entity }\n end\n end\n end",
"def heart! \n self.increment!(:hearts_count)\n end",
"def update\n status_key = STATUS[rand(STATUS.length)]\n\n n = Spooge.update_all_on_redis(:touch_date, DateTime.now)\n n = Spooge.update_all_on_redis(:status, status_key)\n resp = {:updated => n, :status_key => status_key}\n render :json => resp\n end",
"def heart_beat_params\n params.require(:heart_beat).permit(:heart_beat, :intensity)\n end",
"def edit_heartbeat(id, params = {})\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n hb = m.where(id: id).first\n hb.hostname = params[:hostname] if params[:hostname]\n hb.save\n hb\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def set_heart\n @heart = Heart.find(params[:id])\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n end",
"def update\n @heart_rate_type = HeartRateType.find(params[:id])\n\n respond_to do |format|\n if @heart_rate_type.update_attributes(params[:heart_rate_type])\n format.html { redirect_to @heart_rate_type, notice: 'Heart rate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heart_rate_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def heartbeats_params\n params.permit(:device_id)\n end",
"def set_hearted\n @hearted = Hearted.find(params[:id])\n end",
"def create\n heart_beat= DateTime.new(params[\"heart_beat\"][\"heart_beat(1i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(2i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(3i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(4i)\"].to_i,\n params[\"heart_beat\"][\"heart_beat(5i)\"].to_i)\n @heart_beat = HeartBeat.new({heart_beat: heart_beat, intensity: params[\"heart_beat\"][\"intensity\"].to_i})\n @heart_beat.person = Person.first\n\n respond_to do |format|\n if @heart_beat.save\n format.html { redirect_to @heart_beat, notice: 'Heart beat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @heart_beat }\n else\n format.html { render action: 'new' }\n format.json { render json: @heart_beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @beat = Beat.find(params[:id])\n\n if @beat.update_attributes(params[:beat])\r\n flash[:notice] = 'Beat was successfully created.'\r\n redirect_to(@beat) \r\n else\r\n render :action => \"edit\" \r\n end\r\n \n end",
"def heartbeat\n end",
"def set_beat\n @beat = Beat.find(params[:id])\n end",
"def show\n render json: @heartbeat\n end",
"def beat\n Logger.trace \"beat heart #{Zensu.node.id} #{Time.now.to_i}\"\n remote_publish(\"zensu.heartbeat\", Zensu.node.id, Zensu.config.router_endpoint, Time.now.to_i.to_s)\n end",
"def create\n @heart = Heart.new(heart_params)\n\n respond_to do |format|\n if @heart.save\n format.html { redirect_to @heart, notice: 'Heart was successfully created.' }\n format.json { render :show, status: :created, location: @heart }\n else\n format.html { render :new }\n format.json { render json: @heart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @beattape = Beattape.find(params[:id])\n\n respond_to do |format|\n if @beattape.update_attributes(params[:beattape])\n format.html { redirect_to @beattape, notice: 'Beattape was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beattape.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update update\n case update.type.to_sym\n when :update_snakes\n snakes = update.msg \n if @client\n begin\n stonedSnakes = snakes.map { |s| {\"name\" => s.get_name, \"tail\" => s.get_tail.to_json} }\n stoneColdKilledSnakes = JSON.dump(stonedSnakes)\n msg = Message.new(\"update_snakes\", stoneColdKilledSnakes)\n @client.puts(JSON.dump(msg))\n rescue Exception => myException\n @log.info \"Exception rescued: #{myException}\"\n @client = nil\n @isBot = true\n end \n end\n when :update_colors\n if @client\n @client.puts(JSON.dump(update))\n end\n when :identity\n if @client\n# @client.puts(JSON.dump(update));\n end\n end\n end",
"def heartbeat\n me = WORKER_TEMPLATE.dup\n me['name'] = id\n @heartbeat_entry ||= write(me, @heartbeat_refresh + 10)\n @heartbeat_entry.renew(@heartbeat_refresh) unless @heartbeat_entry.canceled?\n end",
"def set_heart\n @heart = Heart.find(params[:id])\n @push_day = session[:push_day] \n end",
"def update(tweet)\n client.update tweet\n end",
"def show\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def put(*args, &block)\n self.client.put *args\n end",
"def heart_params\n params.require(:heart).permit(:heart_count, :image_id)\n end",
"def put!\n request! :put\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def create\n @beat = Beat.new(params[:beat])\n\n respond_to do |format|\n if @beat.save\n format.html { redirect_to @beat, notice: 'Beat was successfully created.' }\n format.json { render json: @beat, status: :created, location: @beat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tick.update(tick_params)\n format.html { redirect_to @tick, notice: 'Tick was successfully updated.' }\n format.json { render :show, status: :ok, location: @tick }\n else\n format.html { render :edit }\n format.json { render json: @tick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def key_worker_heartbeats\n key(\"worker_heartbeats\")\n end",
"def message(twitt)\n @client.update(twitt)\n end",
"def put_update\n response = self.class.put(\"/service/#{$service_id}/version/#{$service_version}/logging/sftp/#{$name}\", \n headers: { \"Fastly-Key\" => $key }, \n body: $put_form_data )\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 get_credentials\n begin\n response = resource[\"/update/#{app}\"].post(:apikey => @credentials[1], :frequency => options[:frequency])\n rescue RestClient::InternalServerError\n display \"An error has occurred.\"\n end\n display response.to_s\n end",
"def put(*args)\n request :put, *args\n end",
"def modify_server(server_uuid, params)\n data = { \"server\" => params }\n json = JSON.generate data\n response = put \"server/#{server_uuid}\", json\n\n response\n end",
"def update\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n if @beacon.update_attributes(params[:beacon])\n format.html { redirect_to @beacon, notice: 'Beacon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beacon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @task = Task.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { head :no_content }\n $redis.publish('tasks.update', TaskSerializer.new(Task.last).to_json)\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(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_put(@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 beat\n Logger.trace \"beat heart #{Node.id} #{Time.now.to_i}\"\n notifier.async.publish(config.topic, Node.id, Router.endpoint, Time.now.to_i.to_s)\n end",
"def heartbeat_command\n logger.debug(\"heartbeat_command: enter \")\n logger.debug(client.observers_overview.join(\", \"))\n begin\n client.refresh_observers_if_needed\n client.update_cluster if client.status == :down\n client.get(\"foo\")\n rescue Exception => e\n client.status = :down\n logger.debug \"heartbeat - #{e.message} #{e.backtrace}\"\n end\n sleep freq\n end",
"def update\n @bowler.update(bowler_params)\n respond_with(@bowler)\n end",
"def update\n @shot = Shot.find(params[:id])\n\n if @shot.update(shot_params)\n head :no_content\n else\n render json: @shot.errors, status: :unprocessable_entity\n end\n end",
"def update\n @metric = Metric.find(params[:id])\n\n if @metric.update(params[:metric])\n head :no_content\n else\n render json: @metric.errors, status: :unprocessable_entity\n end\n end",
"def update\n @anime = Pusher.update_anime(params)\n\n if @anime.valid?\n head :no_content\n else\n render json: @anime.errors, status: :unprocessable_entity\n end\n end",
"def update\n put :update\n end",
"def update\n @animal.update(animal_params)\n respond_with(@shelter)\n end",
"def update\n @tack = Tack.find(params[:id])\n\n if @tack.update(tack_params)\n head :no_content\n else\n render json: @tack.errors, status: :unprocessable_entity\n end\n end",
"def update_ping\n put 'ping'\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def heart_params\n params.require(:heart).permit(:feeling, :date, :mind_id)\n end",
"def update\n \n respond_to do |format|\n if @hub.update(params[:hub])\n format.html { redirect_to @hub, :notice => 'Hub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hub.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @hearted = Hearted.new(hearted_params)\n\n respond_to do |format|\n if @hearted.save\n format.html { redirect_to @hearted, notice: 'Hearted was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hearted }\n else\n format.html { render action: 'new' }\n format.json { render json: @hearted.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @spice.update(spice_params)\n head :no_content\n else\n render json: @spice.errors, status: :unprocessable_entity\n end\n end",
"def update\n head :ok\n end",
"def update\n thing_name = params[:id]\n is_on = params[:on].to_i\n client = Broker::Wrapper.new(current_user, thing_name)\n result = client.set_state(is_on)\n\n result_hash = result.as_json\n render json: result_hash, status: 200\n end",
"def update\n @bubble_tea = BubbleTea.find(params[:id])\n\n if @bubble_tea.update(bubble_tea_params)\n render json: @bubble_tea\n else\n render plain: \"Failed to update drink information\"\n end\n end",
"def update\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n if @rainbow.update_attributes(params[:rainbow])\n format.html { redirect_to @rainbow, notice: 'Rainbow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rainbow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end",
"def new\n @heartbeat = Heartbeat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def update\n respond_to do |format|\n if @musictrack.update(musictrack_params)\n format.html { redirect_to @musictrack, notice: 'Musictrack was successfully updated.' }\n format.json { render :show, status: :ok, location: @musictrack }\n else\n format.html { render :edit }\n format.json { render json: @musictrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @habbit.update(habbit_params)\n format.html { redirect_to @habbit, notice: 'Habbit was successfully updated.' }\n format.json { render :show, status: :ok, location: @habbit }\n else\n format.html { render :edit }\n format.json { render json: @habbit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shot = Shot.find(params[:id])\n @shot.update_attributes(shot_params)\n respond_with @shot\n end",
"def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end",
"def update\n if @beacon.update(beacon_params)\n render :show, status: :ok, location: @beacon\n else\n render json: @beacon.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @beef.update(beef_params)\n format.html { redirect_to @beef, notice: 'Beef was successfully updated.' }\n format.json { render :show, status: :ok, location: @beef }\n else\n format.html { render :edit }\n format.json { render json: @beef.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bolt.update(bolt_params)\n format.html { redirect_to @bolt, notice: 'Bolt was successfully updated.' }\n format.json { render :show, status: :ok, location: @bolt }\n else\n format.html { render :edit }\n format.json { render json: @bolt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update(index_name, payload)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = \"application/json\"\n req.body = payload.to_json\n @client.send_http(req, true, ['200'])\n end",
"def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id}.to_json)\n else\n render json: @sensor.errors, status: :unprocessable_entity\n end\n end",
"def update\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n if @blocking_client.update_attributes(params[:blocking_client])\n format.html { redirect_to @blocking_client, notice: 'Blocking client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @blocking_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def update\n @topic.update_attributes!(topic_params)\n json_response(@topic)\n end"
] | [
"0.67865086",
"0.6541957",
"0.6242728",
"0.6242728",
"0.6181133",
"0.60072243",
"0.5899777",
"0.5897234",
"0.5780656",
"0.57372075",
"0.5713923",
"0.5704083",
"0.56895727",
"0.5688631",
"0.56798774",
"0.5676323",
"0.5652997",
"0.5638146",
"0.55519944",
"0.5484099",
"0.54692894",
"0.5451457",
"0.5441965",
"0.54388756",
"0.53969496",
"0.53856945",
"0.53819513",
"0.53640187",
"0.535822",
"0.5355783",
"0.5355783",
"0.5354114",
"0.53296363",
"0.53148925",
"0.5314221",
"0.529664",
"0.5290885",
"0.5287587",
"0.5283283",
"0.5281555",
"0.52692485",
"0.52664137",
"0.52595425",
"0.52566946",
"0.5243258",
"0.5240742",
"0.520575",
"0.51999426",
"0.51962626",
"0.51945317",
"0.5189027",
"0.5151544",
"0.51449347",
"0.5137246",
"0.5135231",
"0.5131891",
"0.51234883",
"0.5111819",
"0.5109094",
"0.51042104",
"0.5083435",
"0.5080364",
"0.5071299",
"0.50694174",
"0.5069193",
"0.5061355",
"0.50541747",
"0.50539285",
"0.5041608",
"0.50283355",
"0.5028289",
"0.5021562",
"0.5015285",
"0.5013612",
"0.5013612",
"0.49982005",
"0.4996363",
"0.49941438",
"0.4992198",
"0.49912706",
"0.4987673",
"0.4986372",
"0.49856058",
"0.49779662",
"0.49777567",
"0.49750972",
"0.49710298",
"0.4967902",
"0.49667206",
"0.49583492",
"0.49547952",
"0.495216",
"0.4945551",
"0.49423698",
"0.49389556",
"0.49346238",
"0.49304852",
"0.4927648",
"0.4921346",
"0.49161908"
] | 0.64544845 | 2 |
DELETE /heartbeats/1 DELETE /heartbeats/1.json | def destroy
@heartbeat = Heartbeat.find(params[:id])
@heartbeat.destroy
respond_to do |format|
format.html { redirect_to heartbeats_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @heart_beat.destroy\n respond_to do |format|\n format.html { redirect_to heart_beats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heartbeat.destroy\n\n head :no_content\n end",
"def destroy\n @hearted.destroy\n respond_to do |format|\n format.html { redirect_to hearteds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beat = Beat.find(params[:id])\n @beat.destroy\n\n respond_to do |format|\n format.html { redirect_to beats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beat.destroy\n respond_to do |format|\n format.html { redirect_to beats_url, notice: \"Beat was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\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 clear_heartbeats\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.where(proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id }).delete\n end\n end",
"def destroy\n @heart.destroy\n respond_to do |format|\n format.html { redirect_to hearts_url, notice: 'Heart was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heart.destroy\n respond_to do |format|\n format.html { redirect_to hearts_url, notice: 'Heart was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @beattape = Beattape.find(params[:id])\n @beattape.destroy\n\n respond_to do |format|\n format.html { redirect_to beattapes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beacon = Beacon.find(params[:id])\n @beacon.destroy\n\n respond_to do |format|\n format.html { redirect_to beacons_url }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def delete_heartbeat(id)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.where(id: id).delete\n end\n end",
"def destroy\n @logstash = Logstash.find(params[:id])\n @logstash.destroy\n\n respond_to do |format|\n format.html { redirect_to logstashes_url }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @heart_rate_type = HeartRateType.find(params[:id])\n @heart_rate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heart_rate_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @client.delete( name )\n end",
"def destroy\n @heat_log = HeatLog.find(params[:id])\n @heat_log.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_logs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def host_delete(host)\n curl = setup_curl(\"#{@foreman_url}/api/hosts/#{host}\", true)\n curl.http_delete\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @blocking_client = BlockingClient.find(params[:id])\n @blocking_client.destroy\n\n respond_to do |format|\n format.html { redirect_to blocking_clients_url }\n format.json { head :no_content }\n end\n end",
"def delete\n api_client.delete(url)\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @tick.destroy\n respond_to do |format|\n format.html { redirect_to ticks_url, notice: 'Tick was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server_rack = ServerRack.find(params[:id])\n @server_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(server_racks_url) }\n format.xml { head :ok }\n end\n end",
"def delete!\n server.delete(name)\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to monkeys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stash = Stash.find(params[:id])\n @stash.destroy\n\n respond_to do |format|\n format.html { redirect_to stashes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health_record.destroy\n respond_to do |format|\n format.html { redirect_to health_records_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health_record = HealthRecord.find(params[:id])\n @health_record.destroy\n\n respond_to do |format|\n format.html { redirect_to health_records_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @beacon_transmitter.destroy\n respond_to do |format|\n format.html { redirect_to beacon_transmitters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hub.destroy\n\n respond_to do |format|\n format.html { redirect_to hubs_url }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @musictrack.destroy\n respond_to do |format|\n format.html { redirect_to musictracks_url, notice: 'Musictrack was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to healths_url, notice: 'Health was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beacon.destroy\n DateUpdate.new().save\n respond_to do |format|\n format.html { redirect_to local_beacons_path, notice: 'Beacon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.delete(@name)\n end",
"def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end",
"def destroy\n @bird.destroy\n \n begin\n respond_to do |format|\n format.json { render json:({:status => NO_CONTENT}) }\n end\n else\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end",
"def destroy\n @rainbow = Rainbow.find(params[:id])\n @rainbow.destroy\n\n respond_to do |format|\n format.html { redirect_to rainbows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beacon.destroy\n respond_to do |format|\n Beacon.gimbal_delete_beacon(@beacon)\n format.html { redirect_to owner_path(@beacon.owner), notice: 'Beacon was successfully deactivated.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @barrack = Barrack.find(params[:id])\n @barrack.destroy\n\n respond_to do |format|\n format.html { redirect_to barracks_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @beef.destroy\n respond_to do |format|\n format.html { redirect_to beefs_url, notice: 'Beef was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to \"/dashboard\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def delete\n api(\"Delete\")\n end",
"def destroy\n @beat = Beat.find(params [:id])\n @beat.destroy\n\n respond_to do |format|\n format.html { redirect_to post_comment_url(@lesson) }\n format.xml { head :ok }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hangout = Hangout.find(params[:id])\n @hangout.destroy\n\n respond_to do |format|\n format.html { redirect_to hangouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sound_bite.destroy\n respond_to do |format|\n format.html { redirect_to sound_bites_url, notice: 'Sound bite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to bounties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hit = Hit.find(params[:id])\n @hit.reactions.destroy_all\n @hit.destroy\n\n respond_to do |format|\n format.html { redirect_to hits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hive = Hive.find(params[:id])\n @hive.destroy\n\n respond_to do |format|\n format.html { redirect_to hives_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @uptime.destroy\n respond_to do |format|\n format.html { redirect_to uptimes_url, notice: 'Uptime was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @probe.destroy\n respond_to do |format|\n format.html { redirect_to probes_url, notice: 'Probe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @have = Have.find(params[:id])\n @have.destroy\n\n respond_to do |format|\n format.html { redirect_to haves_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @daily_happiness.destroy\n respond_to do |format|\n format.html { redirect_to daily_happinesses_url, notice: 'Daily happiness was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beast.destroy\n respond_to do |format|\n format.html { redirect_to beasts_url, notice: 'Bestia została usunięta' }\n format.json { head :no_content }\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def destroy\n @sticky = Sticky.find(params[:id])\n @sticky.destroy\n\n respond_to do |format|\n format.html { redirect_to stickies_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @hangout.destroy\n respond_to do |format|\n format.html { redirect_to hangouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @throughput_metric.destroy\n respond_to do |format|\n format.html { redirect_to throughput_metrics_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @kickoff = Kickoff.find(params[:id])\n @kickoff.destroy\n\n respond_to do |format|\n format.html { redirect_to kickoffs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bike_rack.destroy\n respond_to do |format|\n flash[:success] = 'Bike rack was successfully destroyed.'\n format.html { redirect_to bike_racks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gauge = Gauge.find(params[:id])\n @gauge.destroy\n\n respond_to do |format|\n format.html { redirect_to gauges_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end"
] | [
"0.7675414",
"0.7251349",
"0.6893917",
"0.68327665",
"0.6829877",
"0.6743467",
"0.6726435",
"0.6646477",
"0.66232115",
"0.66232115",
"0.6596064",
"0.6574833",
"0.6530344",
"0.6443542",
"0.64309454",
"0.62750304",
"0.62739617",
"0.62703896",
"0.62701684",
"0.6240999",
"0.6239933",
"0.6239933",
"0.62329066",
"0.6220733",
"0.61912656",
"0.6178775",
"0.61672354",
"0.6156784",
"0.6151558",
"0.6133253",
"0.61207366",
"0.61158735",
"0.61104804",
"0.6108594",
"0.6101994",
"0.60742146",
"0.60535944",
"0.60516787",
"0.60471475",
"0.60461974",
"0.6044297",
"0.6038372",
"0.60370815",
"0.60350174",
"0.6031891",
"0.6031891",
"0.6031891",
"0.6031891",
"0.60276765",
"0.6023314",
"0.6020745",
"0.6014349",
"0.60106975",
"0.60058117",
"0.6003309",
"0.6003309",
"0.5999146",
"0.5990483",
"0.59878874",
"0.59859407",
"0.59858745",
"0.598044",
"0.5979559",
"0.59758043",
"0.5973193",
"0.59662336",
"0.5962221",
"0.59605163",
"0.59584785",
"0.594349",
"0.5942712",
"0.5942412",
"0.5941795",
"0.5941143",
"0.59396666",
"0.59387743",
"0.5938323",
"0.5938271",
"0.5933287",
"0.5932568",
"0.5931654",
"0.5928824",
"0.59243625",
"0.5924278",
"0.59241956",
"0.59240234",
"0.5923656",
"0.59218985",
"0.5921159",
"0.59188133",
"0.59178627",
"0.5916385",
"0.59152627",
"0.59106976",
"0.59067136",
"0.5899814",
"0.5898131",
"0.5892539",
"0.5890363",
"0.5888498"
] | 0.7842111 | 0 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notifier.order_received.subject | def order_received(order)
@order = order
mail :to => "[email protected]", :subject => 'Pragmatic Store Order Confirmation'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_subject=(value)\n @message_subject = value\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def message_subject\n return @message_subject\n end",
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def subject=(subject); @message_impl.setSubject subject; end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject\n message.subject\n end",
"def subject; @message_impl.getSubject; end",
"def subject\n @mail.subject\n end",
"def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def received(order)\n @order = order\n\n mail to: order.email, subject: '7 facts you will never believe! 3 will shock you'\n end",
"def translation_scope\n \"order_details.notices\"\n end",
"def course_notification_item_details(course)\n t('notifications.subscribe_course')\n end",
"def subject\n self['subject']\n end",
"def title_for_received_review\n I18n.t(\"notification.user_received_review.title\")\n end",
"def order_received(order)\n @order = order\n\n mail :subject => \"order received!\"\n end",
"def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end",
"def received(order)\n # Also :cc, :from, :subject]\n @order = order\n mail to: order.email, subject: 'Pragmatic Store Order Confirmation'\n puts order.to_yaml\n puts \"Mail to: #{mail.to}\"\n puts \"Mail from: #{mail.from}\"\n puts \"Mail subject: #{mail.subject}\"\n puts \"Mail Body:\"\n puts mail.body.encoded\n end",
"def notify_order(order)\n @order = order\n to = ADMIN_EMAIL\n\n mail :to => email_to(to), :subject => \"Pocket Prints Order ##{order.order_code}\"\n end",
"def received(order)\n @order = order\n mail to: order.e_mail, subject: 'Eloctronic Shop Store Order Confirmation'\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def order_notification(order, recipient)\n @order = order\n attach_all_icals_from_order(@order)\n send_nucore_mail recipient, text(\"views.purchase_notifier.order_notification.subject\"), \"order_receipt\"\n end",
"def subject=(string)\n set('Subject', string)\n end",
"def order_received(order)\r\n @order = order\r\n\r\n mail :to => order.email, \r\n :subject => 'Potvrzení objednávky z Pragmatické knihovny'\r\n end",
"def notify(msg, subject)\n end",
"def subject\n return self.order(self.order_id).order_goods[0].order_item_info_str\n end",
"def notify(type,subject,target=nil)\n self.notices.create :type => type, :subject => subject, :target => target\n end",
"def notification_msg\n author_name = author.firstname\n \"An issue has been reported by #{author_name}\"\n end",
"def received(order)\n @order = order\n\n mail to: order.email, subject: 'Fast Find Auto Parts Order Confirmation'\n end",
"def set_subject(subject)\n\t\tend",
"def received(order)\n @order = order\n\n mail to: order.email, subject: 'Pragmatic Store Order Confirmation'\n end",
"def order_received(order)\n@order = order\nmail :to => order.email, :subject => 'Sedin Online Store Order Confirmation'\nend",
"def received(order)\n @order = order\n mail to: order.email, subject: 'Pragmatic Store Order Confirmation'\n end",
"def send_receive_sample order_mail\n @order = order_mail.order\n client = @order.client\n subject = \"#{t('order_mails.type.receive_sample')} #{t('activerecord.attributes.order.sn')}: #{@order.sn}\"\n mail to: to, subject: subject\n end",
"def commerce_order_send_mail(order, event = 'email_order_received')\n bk_l = I18n.locale\n I18n.locale = order.get_meta('locale', 'en').to_s\n subject, content_key = case event\n when 'email_order_received'\n [I18n.t('plugins.ecommerce.email.order_received_label', default: 'Order Received'), 'email_order_received']\n when 'email_order_confirmed'\n [I18n.t('plugins.ecommerce.email.order_confirmed_label', default: 'Order Confirmed'), 'email_order_confirmed']\n when 'email_order_confirmed_bank'\n [I18n.t('plugins.ecommerce.email.order_bank_confirmed_label', default: 'Order Bank Confirmed'), 'email_order_confirmed']\n when 'email_order_confirmed_on_delivery'\n [I18n.t('plugins.ecommerce.email.order_on_delivery_confirmed_label', default: 'Order on Delivery Confirmed'), 'email_order_confirmed']\n when 'email_order_shipped'\n [I18n.t('plugins.ecommerce.email.order_shipped_label', default: 'Order Shipped'), 'email_order_shipped']\n when 'email_order_cancelled'\n [I18n.t('plugins.ecommerce.email.order_cancelled_label', default: 'Order Cancelled'), 'email_order_cancelled']\n end\n data = {template_name: nil, content: current_site.e_email_for(content_key).to_s.translate, files: []}\n replaces = {\n order_table: render_to_string(partial: 'plugins/ecommerce/partials/email/product_table', locals: {order: order}),\n shipping_info: render_to_string(partial: 'plugins/ecommerce/partials/email/shipping_address', locals: {order: order}),\n billing_info: render_to_string(partial: 'plugins/ecommerce/partials/email/billing_address', locals: {order: order}),\n cancelled_description: order.get_meta('description').to_s,\n root_url: current_site.the_url,\n date: order.the_created_at,\n current_date: l(Date.today, format: :long),\n number: order.slug,\n name: order.user.first_name,\n full_name: order.user.fullname,\n tracking_url: order.the_url_tracking.to_s,\n shipping_name: order.the_shipping_method.to_s,\n invoice_number: order.invoice_number.to_s,\n status: order.the_status,\n url: order.the_url\n }\n args={order: order, replaces: replaces}; hooks_run('commerce_custom_email_replacements', args) # permit to add custom replacements\n\n if order.status == 'paid'\n order.products.each do |product|\n data[:files] += product.get_fields('ecommerce_files').map{|f| CamaleonCmsLocalUploader::private_file_path(f, current_site) }\n end\n data[:files] = data[:files].uniq\n pdf_path = order.the_invoice_path\n data[:ecommerce_invoice] = {pdf_path: pdf_path, html: current_site.e_email_for('email_order_invoice').to_s.translate.to_s.cama_replace_codes(replaces, format_code = '{')}\n data[:files] << pdf_path\n order.update_column(:invoice_path, pdf_path.split('/').last)\n end\n data[:content] = data[:content].to_s.cama_replace_codes(replaces, format_code = '{')\n cama_send_email(order.user.email, subject, data)\n I18n.locale = bk_l\n end",
"def received(morder)\n @morder = morder\n mail to: morder.email, subject: \"Pragmatic Store Order Confirmation\"\n end",
"def order_received(order)\n @order = order\n\n mail to: order.email, subject: 'Potvrzení objednávky z obchodu Pragmatická Ivona'\n end",
"def get_subject\n\t\tend",
"def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end",
"def i18n_scope\n \"exhibits.notifications.order.delivery_confirmation_period_elapsed.#{role}\"\n end",
"def received(order)\n @order = order\n\n mail to: order.email, subject: 'PMAC Store Order Confirmation'\n end",
"def received(order)\n @greeting = \"Hi\"\n @order = order\n\n mail to: \"[email protected]\", subject: \"Success! Pragmatic Store Order Confirmation.\"\n # mail to: \"[email protected]\", subject: \"Success! Pragmatic Store Order Confirmation.\"\n # mail to: \"[email protected]\", subject: \"Success! Pragmatic Store Order Confirmation.\"\n end",
"def received(order)\r\n @order = order\r\n mail to: order.email, subject: 'Подтверждение заказа в Pragmatic Store'\r\n end",
"def recevied(order)\n @order = order\n\n mail to: \"[email protected]\", subject: \"Rails Store Order Conformation..\"\n end",
"def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end",
"def received(order)\n @order = order\n\n mail to: order.email, subject: \"Canteen App Order Confirmation\"\n end",
"def received(order)\n @order = order\n mail to: order.email, subject: 'Подтверждение заказа в GlebKs stall'\n end",
"def rezm_subject_and_status(message)\n if message.receiver_deleted?\n message.subject + \" (Deleted)\" \n elsif message.read_at.nil?\n message.subject + \" (Unread)\" \n else \n message.subject\n end\n end",
"def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <[email protected]>\",\n from: \"BaseRails <[email protected]>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end",
"def received(order)\n @order = order\n mail to: order.email, subject: 'Подтверждение заказа в Card Shop'\nend",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def new_notification_email(notification,receiver)\n @notification = notification\n @receiver = receiver\n #DIFFERENT FROM ORIGINAL----------------------\n subject = notification.subject.to_s\n subject = decode_basic_notification(subject,notification.notified_object)\n subject = subject.gsub(/\\n/,'')\n #END OF DIFFERENCE----------------------------\n subject = strip_tags(subject) unless subject.html_safe?\n mail(:to => receiver.send(Mailboxer.email_method,notification), :subject => t('mailboxer.notification_mailer.subject', :subject => subject)) do |format|\n format.text {render __method__}\n format.html {render __method__}\n end\n end",
"def received(order)\n @order = order\n \n mail :to => order.email, :subject => 'Montagna Verde Order Confirmation'\n end",
"def received(order)\n @order = order\n\n mail to: order.email, subject: \"My Favorite Store Order Confirmation\"\n end",
"def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def received(order)\n @order = order \n\n mail to: order.email, subject: 'justEat Order Confirmation'\n end",
"def subject\n @subject\n end",
"def subject\n @options.fetch(:subject) { \"Invitation\" }\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def subject\n @subject\n end",
"def subject\n @subject\n end",
"def subject\n raise \"Override #subject in the service class\"\n end",
"def order_received(order)\n@order=order\nmail(:to => order.email, :subject => 'Pragmatic Toy Shop Order Confirmation')\nend",
"def title_for_request_message_for_requester\n I18n.t(\"notification.received_a_travel_request_message_is_owner.title\")\n end",
"def notify_english(dest)\n mail(dest, ENGLISH_SUBJECT, mail_content(english_model_file))\n end",
"def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end",
"def order_received(order)\n @order = order\n mail:to => order.email, :subject => 'pragmetic store order confirmation'\n end",
"def received(order)\n \t@order = order\n\n @greeting = \"Привет, #{@order.profile.first_name}!\"\n\n emails = [@order.profile.email, '[email protected]']\n # emails = [@order.profile.email]\n mail to: emails, subject: \"Ginius: заявка №#{@order.id} принята!\"\n end",
"def new_quote_notice(quote)\n @quote = quote\n mail(subject: \"[team] New Enquiry Received\")\n end",
"def order_notification(ship)\n @ship = ship\n mail :subject => t('mytranslations.order_notification.subject'),\n :to => Refinery::Inquiries::Setting.notification_recipients,\n :reply_to => ship.client.email\n end",
"def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end",
"def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end",
"def subject_name\n return @subject_name\n end",
"def received(order)\n @order = order\n\n mail to: order.email, subject: 'Confirmación de compra Farmacia Zi'\n end",
"def notify_french(dest)\n mail(dest, FRENCH_SUBJECT, mail_content(french_model_file))\n end",
"def product_order_notification(order_detail, recipient)\n @order = order_detail.order\n @order_detail = OrderDetailPresenter.new(order_detail)\n attach_reservation_ical(order_detail.reservation) if order_detail.reservation.present?\n send_nucore_mail recipient, text(\"views.purchase_notifier.product_order_notification.subject\", product: order_detail.product)\n end",
"def received(order)\n @order=order\n mail(to: order.email, subject: 'BookShelf Order Confirmation') do |format|\n format.html\n end\n end",
"def new_message_email(message,receiver)\n @message = message\n @receiver = receiver\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :from => \"Panel KW Kraków <reply+#{message.conversation.code}@panel.kw.krakow.pl>\",\n :subject => @subject,\n :template_name => 'new_message_email'\n end",
"def parent_reserved_notification(order)\n\n @order = order\n @student = order.student\n @parent = @student.parent\n @admin = order.admin_user\n @greeting = \" #{@parent.name} y #{@student.name}\"\n\n mail(to: @parent.email, subject: \"Orden de Tutorias Reservada\", \n cc: [@admin.email,\"[email protected]\", \"[email protected]\"])\n end",
"def recieved (order)\n @order=order\n\n mail to: order.email, subject: \"You are receiveing the first Mail from Depot App\"\n end",
"def translation_scope\n \"mailers.#{mailer_name.tr(\"/\", \".\").sub(\"_mailer\", \"\")}.#{action_name}\"\n end",
"def subject\n title \n end",
"def new_message_email(message,receiver)\n @message = message\n @receiver = receiver\n @conversation = @message.conversation\n\n if @conversation.reservation.present?\n @reservation = @conversation.reservation\n end\n\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :subject => t('mailboxer.message_mailer.subject_new', :subject => @subject),\n :template_name => 'new_message_email'\n end",
"def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end",
"def subject_name\n subject_full_name\n end",
"def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end",
"def message\n if subject && !subject.empty?\n subject + \"\\n\" + body\n else\n body\n end\n end",
"def order_receipt(args)\n @user = args[:user]\n @order = args[:order]\n @greeting = text(\"views.purchase_notifier.order_receipt.intro\")\n attach_all_icals_from_order(@order)\n send_nucore_mail args[:user].email, text(\"views.purchase_notifier.order_receipt.subject\")\n end",
"def order_received\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end"
] | [
"0.6800689",
"0.67945725",
"0.66193247",
"0.6467936",
"0.64646465",
"0.6463497",
"0.6422386",
"0.63573945",
"0.63530016",
"0.61479187",
"0.6111878",
"0.6008901",
"0.595026",
"0.5921207",
"0.59105027",
"0.5879055",
"0.5839955",
"0.58369374",
"0.5816302",
"0.5795407",
"0.5755452",
"0.5754782",
"0.5750644",
"0.5750644",
"0.5750644",
"0.5750644",
"0.5750644",
"0.5750644",
"0.5747959",
"0.5740466",
"0.5738311",
"0.57368094",
"0.5734449",
"0.57176036",
"0.5715093",
"0.57061833",
"0.56936795",
"0.56930876",
"0.56909394",
"0.56903595",
"0.56850123",
"0.56837445",
"0.56824666",
"0.5679109",
"0.56763315",
"0.5668702",
"0.56517917",
"0.56448704",
"0.5636823",
"0.5626724",
"0.5617354",
"0.56104463",
"0.5608181",
"0.5600717",
"0.5598562",
"0.5595776",
"0.55812263",
"0.55642825",
"0.55635643",
"0.5553817",
"0.5548584",
"0.5548165",
"0.55398315",
"0.5525264",
"0.5521913",
"0.55209935",
"0.55141497",
"0.55141497",
"0.55141497",
"0.55141497",
"0.55045515",
"0.55045515",
"0.54885286",
"0.54871166",
"0.54850614",
"0.54738355",
"0.5473789",
"0.5471906",
"0.54642475",
"0.54627043",
"0.54576576",
"0.54558724",
"0.54428893",
"0.5441544",
"0.5432487",
"0.542374",
"0.54227656",
"0.5418719",
"0.54178834",
"0.5413665",
"0.54058063",
"0.539015",
"0.53896976",
"0.53745466",
"0.53679717",
"0.5356788",
"0.5356081",
"0.5343031",
"0.5330691",
"0.53221923"
] | 0.5743169 | 29 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notifier.order_shipped.subject | def order_shipped
@order = order
mail :to => "[email protected]", :subject => 'Pragmatic Store Order Shipped'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_notification(ship)\n @ship = ship\n mail :subject => t('mytranslations.order_notification.subject'),\n :to => Refinery::Inquiries::Setting.notification_recipients,\n :reply_to => ship.client.email\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def order_shipped(order)\n @order = order\n mail :to => User.find_by_id(@order.user_id).email, :subject => \"来自Time international GmbH的包裹发送信息\"\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def notify_shipped(order)\n @order = order\n @info = @order.info\n email = @order.user.email\n subject = \"特快車出貨通知! (訂單編號:#{@order.token})\"\n\n mail(to: email, subject: subject) do |format|\n format.text\n format.html\n end\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def translation_scope\n \"order_details.notices\"\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def order_shipped(order)\n \t@order = order\n mail to: order.email, subject: 'Pragmatic Store Order Shipped'\n end",
"def course_notification_item_details(course)\n t('notifications.subscribe_course')\n end",
"def order_shipped(order)\r\n @order = order\r\n\r\n mail :to => order.email, \r\n :subject => 'Objednávka z Pragmatické knihovny byla odeslána'\r\n end",
"def shipped(order)\n @order=order\n mail(\n to: order.email,\n subject: 'BookShelf Order Shipped',\n from: \"BookShelf\",\n return_path: \"[email protected]\",\n date: Time.now,\n template_path: 'order_notifier',\n template_name: 'shipped'\n )\n end",
"def shipped(order)\n @order = order\n\n # defaults to using html template\n mail to: order.email, subject: \"O'Trendy Store Order Shipped\"\n end",
"def message_subject=(value)\n @message_subject = value\n end",
"def shipped(config, order)\n\t\t@subject = \"#{config[:application][:name][:value]} Shipping Notification: Order \\##{order.id}\"\n\t\t@recipients = \"#{order.user} <#{order.user.email}>\"\n\t\t@from = \"#{config[:application][:name][:value]} <#{config[:emails][:shipping][:value]}>\"\r\n\t\t@sent_on = Time.now\n\t\t@body['order'] = order\n\t\t@body['items'] = order.items\n\t\t@body['team_name'] = config[:application][:team_name][:value]\r\n\tend",
"def shipped(order)\r\n @order = order\r\n mail to: order.email, subject: 'Заказ из Pragmatic Store отправлен'\r\n end",
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def subject; @message_impl.getSubject; end",
"def order_shipped(order)\n @order = order\n\n mail :subject => \"order shipped!\"\n end",
"def subject\n @mail.subject\n end",
"def subject=(subject); @message_impl.setSubject subject; end",
"def notify_order(order)\n @order = order\n to = ADMIN_EMAIL\n\n mail :to => email_to(to), :subject => \"Pocket Prints Order ##{order.order_code}\"\n end",
"def order_shipped\n @order = order\n\n mail to: order.email, subject: 'Objednávka z obchodu Pragmatická Ivona byla odeslána'\n end",
"def shipped(order)\n @order = order\n\n mail to: order.email, subject: '8 facts you will never believe! Doctors hate it!'\n end",
"def title_for_request_message_for_requester\n I18n.t(\"notification.received_a_travel_request_message_is_owner.title\")\n end",
"def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end",
"def shipped(order)\n @order = order\n mail to: order.mail, subject: 'Заказ из GlebKs stall отправлен'\n end",
"def i18n_scope\n \"exhibits.notifications.order.delivery_confirmation_period_elapsed.#{role}\"\n end",
"def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end",
"def title_for_received_review\n I18n.t(\"notification.user_received_review.title\")\n end",
"def subject\n message.subject\n end",
"def subject\n return self.order(self.order_id).order_goods[0].order_item_info_str\n end",
"def parent_reserved_notification(order)\n\n @order = order\n @student = order.student\n @parent = @student.parent\n @admin = order.admin_user\n @greeting = \" #{@parent.name} y #{@student.name}\"\n\n mail(to: @parent.email, subject: \"Orden de Tutorias Reservada\", \n cc: [@admin.email,\"[email protected]\", \"[email protected]\"])\n end",
"def translation_scope\n \"mailers.#{mailer_name.tr(\"/\", \".\").sub(\"_mailer\", \"\")}.#{action_name}\"\n end",
"def shipped(order)\n @order = order\n mail to: order.email, subject: 'Pragmatic Store Order shipped'\n end",
"def shipped(order)\n @order = order\n\n mail to: order.email,subject: \"Pragmatic Store Order Shipped\"\n end",
"def shipped(order)\n @order = order\n mail to: \"[email protected]\"\n end",
"def title_for_user_applied_to_travel\n I18n.t(\"notification.user_applied_to_travel.title\")\n end",
"def order_notification(order, recipient)\n @order = order\n attach_all_icals_from_order(@order)\n send_nucore_mail recipient, text(\"views.purchase_notifier.order_notification.subject\"), \"order_receipt\"\n end",
"def notification_msg\n author_name = author.firstname\n \"An issue has been reported by #{author_name}\"\n end",
"def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end",
"def shipped(order)\n @order = order\n\n mail to: order.email, subject: 'Pragmatic Store Order Shipped'\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def shipped(order)\n @order = order\n\n mail to: order.e_mail, subject: 'Eloctronic Shop Order Shipped'\n end",
"def shipped(order)\n @order = order\n\n mail to: order.email, subject: 'Fast Find Auto Parts Order Shipped'\n end",
"def shipped(order)\n @order = order\n mail to: order.email, subject: 'Заказ из Card Shop отправлен'\nend",
"def order_received(order)\n@order = order\nmail :to => order.email, :subject => 'Sedin Online Store Order Confirmation'\nend",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def message_subject\n return @message_subject\n end",
"def shipped\n OrderNotifierMailer.shipped\n end",
"def subject_name\n subject_full_name\n end",
"def shipped(order)\n @order = order\n mail to: order.email, subject: 'Pragmatic Store Order Shipped'\n puts order.to_yaml\n puts \"Mail to: #{mail.to}\"\n puts \"Mail from: #{mail.from}\"\n puts \"Mail subject: #{mail.subject}\"\n puts \"Mail Body:\"\n puts mail.body.encoded\n end",
"def label\n @order = params[:order]\n @shipping = params[:shipping]\n mail(to: @order.email, subject: \"🛠Thank you for the order \" + @order.order_no.to_s + \" \"+ @order.product.model_no + \" this is your shipping label\").attachments[@shipping + \".pdf\"] = File.read('public/uploads/labels/'+ @shipping +'.pdf')\n end",
"def shipped (order)\n @order=order\n\n mail to: order.email, subject: \"You are receiveing the first Mail from Depot App\"\n end",
"def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end",
"def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end",
"def order_shipped(order)\n @order = order\n\n mail(to: @order.user.email , subject: 'Order Confirmation')\n end",
"def shipped(order)\n @order = order\n @greeting = \"Hello from rails4book\"\n\n mail to: order.email, subject: 'rails4book order shipped'\n end",
"def notification_subject_publish(brother)\n if (brother == self.brother)\n return \"[Voucher] You Just Created a Voucher\"\n else\n return \"[Voucher] Voucher request from: \" + self.brother.display_name\n end\n end",
"def shipped(order)\n @order = order\n\n puts \">> shipped order email sent\"\n\n mail to: @admin_email, subject: 'Pragmatic Store Order Shipped'\n end",
"def shipped(order)\n @order = order\n mail to: order.email, subject: 'PMAC Store Order Shipped'\n end",
"def notify(type,subject,target=nil)\n self.notices.create :type => type, :subject => subject, :target => target\n end",
"def recevied(order)\n @order = order\n\n mail to: \"[email protected]\", subject: \"Rails Store Order Conformation..\"\n end",
"def shipped(order)\n @greeting = \"Hi\"\n @order = order\n\n mail to: \"[email protected]\", subject: \"Success! You shipped it.\"\n end",
"def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <[email protected]>\",\n from: \"BaseRails <[email protected]>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end",
"def notify_company_admin(admin, task_submission)\n @submitter = task_submission.submitter\n\n I18n.with_locale(admin.locale) do\n mail(to: admin.email, subject: I18n.t(\"tskz.notifier.requesting_approval_of_tasks\", name: @submitter.full_name), track_opens: true)\n end\n end",
"def set_title\n @title = t(:message_0, :scope => [:controller, :scholarships])\n end",
"def shipped\n OrderNitifierMailer.shipped\n end",
"def shipped(order)\n @order = order\n \n mail :to => order.email, :subject => 'Montagna Verde Order Shipped'\n end",
"def subject\n @options.fetch(:subject) { \"Invitation\" }\n end",
"def send_notice(type:,adjustment:,previous_data: nil, subject:,title:,email: '[email protected]')\n @type = type\n @adjustment = adjustment\n @previous_data = previous_data\n @title = title\n @link = inventory_adjustments_url\n mail :to => email, :subject => subject\n end",
"def subscriber_notice_subscription_paid\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'subscription_paid'\n )\n end",
"def order_shipped\n@greeting = \"Hi\"\nmail :to => \"[email protected]\"\nend",
"def shipped(order)\n @order = order\n\n mail to: order.email, subject: 'Envío de compra Farmacia Zi'\n end",
"def shipped(order)\n @order = order\n\n mail to: order.email, subject: \"Your Favorite Store Order Shipped\"\n end",
"def send_when_ordered(order)\n @order = order\n mail to: \t order.email,\n \t subject: '注文を承りました'\n end",
"def deliver\n I18n.switch_locale self.language || Utility.language_code do \n EmailMailer.deliver_share_kase(self, self.kase) if self.valid?\n end\n end",
"def invite_subject\n \"Your invitation to #{org_name.possessive} Creative Difference Dashboard\"\n end",
"def append_delivery_notes\n self.message += \"\\n----\\nFrom: #{self.user.email} #{Time.now}\\n\" + I18n.translate(:delivered_to)+\" \"\n if( all_users = (@recipients.count == User.count))\n self.message += I18n.translate(:all_users, count: @recipients.count)\n else\n self.message += @recipients.all.map { |recipient|\n recipient.name + \" (#{recipient.email})\"\n }.join(\", \")\n end\n end",
"def order_received(order)\n@order=order\nmail(:to => order.email, :subject => 'Pragmatic Toy Shop Order Confirmation')\nend",
"def shipped(morder)\n @morder = morder\n\n mail to: morder.email, subject: \"Pragmatic Store Order Shipped\"\n end",
"def product_order_notification(order_detail, recipient)\n @order = order_detail.order\n @order_detail = OrderDetailPresenter.new(order_detail)\n attach_reservation_ical(order_detail.reservation) if order_detail.reservation.present?\n send_nucore_mail recipient, text(\"views.purchase_notifier.product_order_notification.subject\", product: order_detail.product)\n end",
"def notify_french(dest)\n mail(dest, FRENCH_SUBJECT, mail_content(french_model_file))\n end",
"def subject\n self['subject']\n end",
"def shipped(order)\n @order = order \n\n mail to: order.email, subject: 'justEat Order Shipped'\n end",
"def notify_order_state(order, current_user)\n @order = order\n receiver = current_user.is_user? ? order.designer : order.user\n subject = \"\"\n case order.aasm_state\n when \"picked\"\n subject = \"[DesignDeck] 您好,您的订单:#{order.title},设计师已接单 \"\n when \"drafts_submitted\"\n subject = \"[DesignDeck] 您好,您的订单:#{order.title},设计师已提交初稿 #{order.title}\"\n when \"versions_submitted\"\n subject = \"[DesignDeck] 您好,您的订单:#{order.title},设计师已提交新稿件 #{order.title}\"\n when \"completed\"\n if current_user.is_user?\n subject = \"[DesignDeck] 您好,您的订单:#{order.title},最终版本文件打包已上传 #{order.title}\"\n else\n subject = \"[DesignDeck] 您好,您接的订单:#{order.title},用户已确认最终版,请上传打包文件 #{order.title}\"\n end\n when \"draft_selected\"\n subject = \"[DesignDeck] 您好,您接的订单:#{order.title},用户已选择初稿 #{order.title}\"\n when \"version_selected\"\n subject = \"[DesignDeck] 您好,您接的订单:#{order.title},用户已对稿件提出修改意见 #{order.title}\"\n end\n mail(to: receiver.email, subject: subject)\n end",
"def shipped\n OrderMailer.shipped\n end",
"def shipped\n OrderMailer.shipped\n end",
"def send_submitted_order(order)\n @order = order\n mail :to => '[email protected]', :subject => \"Landing International: Order Submitted\"\n end",
"def shipped\n @greeting = \"Hi\"\n @order = order\n mail(to: order.email, subject: 'Your Chocolate Bar order was received')\n end",
"def set_subject(subject)\n\t\tend",
"def received(order)\r\n @order = order\r\n mail to: order.email, subject: 'Подтверждение заказа в Pragmatic Store'\r\n end",
"def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end",
"def order_shipped\n\t\torder = Order.first\n\t\tOrderMailer.order_shipped(order)\n end",
"def received(order)\n @greeting = \"Hi\"\n @order = order\n\n mail to: \"[email protected]\", subject: \"Success! Pragmatic Store Order Confirmation.\"\n # mail to: \"[email protected]\", subject: \"Success! Pragmatic Store Order Confirmation.\"\n # mail to: \"[email protected]\", subject: \"Success! Pragmatic Store Order Confirmation.\"\n end"
] | [
"0.6710821",
"0.6340845",
"0.6214348",
"0.61685276",
"0.610235",
"0.6096921",
"0.6091533",
"0.60842127",
"0.60469395",
"0.60194784",
"0.59917605",
"0.59889793",
"0.59597987",
"0.595626",
"0.59555376",
"0.5940288",
"0.59357095",
"0.593068",
"0.59248656",
"0.5906353",
"0.5904925",
"0.5901258",
"0.59000003",
"0.58974797",
"0.58632404",
"0.586187",
"0.58597493",
"0.5845682",
"0.5834669",
"0.58318883",
"0.58231217",
"0.5809715",
"0.5803136",
"0.5788029",
"0.5783609",
"0.5777381",
"0.57604474",
"0.57579875",
"0.57548857",
"0.5743212",
"0.5728443",
"0.5719352",
"0.5707613",
"0.5705739",
"0.5703391",
"0.56945133",
"0.568992",
"0.5680663",
"0.56757927",
"0.56749094",
"0.56749094",
"0.56749094",
"0.56749094",
"0.5666872",
"0.56640244",
"0.56593245",
"0.5658847",
"0.5655",
"0.5652707",
"0.5650949",
"0.564118",
"0.56394136",
"0.5633363",
"0.5633012",
"0.56318414",
"0.5628817",
"0.5627895",
"0.5617969",
"0.5616455",
"0.56121814",
"0.5599718",
"0.5596708",
"0.5593538",
"0.5581813",
"0.558153",
"0.5567387",
"0.55668724",
"0.55655164",
"0.55607593",
"0.5560159",
"0.55578",
"0.55572057",
"0.55558693",
"0.5545493",
"0.55310196",
"0.5529362",
"0.5529021",
"0.55243415",
"0.552318",
"0.5517089",
"0.5505671",
"0.5505545",
"0.5505545",
"0.5498295",
"0.54905504",
"0.54905486",
"0.5484172",
"0.54722404",
"0.54717326",
"0.5469686"
] | 0.59147054 | 19 |
method for converting input into an index | def input_to_index(input_text)
user_input = input_text.to_i
user_input -= 1
return user_input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(user_input)\n index=(user_input .to_i) -1\nend",
"def input_to_index(user_input) \n #converts the user's input (a string) into an integer / would use .to_i\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0) \n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input = user_input.to_i # converts string into integer\n index = user_input - 1 # Change user input to array index.\nend",
"def input_to_index(user_input) #this method takes one argument (the users input)\n new_user_input = user_input.to_i #this specific .to converts the string into an intergeer\n new_user_input -= 1 #this subtracts it by 1 since arrays start with 0\nend",
"def input_to_index(input)\n #converts the user's input (a string) into an integer\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0)\n input.to_i - 1\n end",
"def input_to_index(input)\n input_int = input.to_i\n index = input_int - 1\nend",
"def input_to_index(input)\r\n index = input.to_i - 1\r\nend",
"def input_to_index(input)\n index = input.to_i-1\nend",
"def input_to_index(input)\n return input.to_i - 1\n #idx = [inpu - 1]\n # return idx\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n end",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\nend",
"def input_to_index(input)\n index = input.to_i - 1\nend",
"def input_to_index (input)\n index = input.to_i\n index - 1\n end",
"def input_to_index(input)\n self.convert_to_i(input) - 1\n end",
"def input_to_index(index)\n index.to_i - 1 \nend",
"def to_index(input)\n input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i\n index -= 1\nend",
"def input_to_index(user_input)\n index = (user_input.to_i - 1)\n end",
"def input_to_index(input)\n @input = input.to_i - 1\n end",
"def input_to_index(input)\n index = (input.to_i) - 1\nend",
"def input_to_index(user_input)\nindex = user_input.to_i - 1 #convert to integer and covert to index\nreturn index #return index for use in other methods\nend",
"def input_to_index(index)\n index = (index.to_i) - 1\nend",
"def input_to_index(index)\n return index.to_i - 1\nend",
"def input_to_index(index)\n return index.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(input)\n input = input.to_i - 1\n end",
"def input_to_index(input)\n\t\tinput.to_i - 1\n\tend",
"def construct_index\n end",
"def input_to_index(input)\n input = input.to_i\n input = input - 1\nend",
"def input_to_index(user_input)\nconverted_input = user_input.to_i - 1\nend",
"def input_to_index(input)\n newInput = input.to_i\n return newInput - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\nend",
"def input_to_index(user_input)\n index = (user_input.to_i - 1)\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\n return index\nend",
"def input_to_index(input)\n return index = input.to_i - 1\nend",
"def input_to_index( position )\n position = position.to_i\n position = position - 1\nend",
"def input_to_index(input)\r\n input.to_i - 1 \r\nend",
"def input_to_index(input)\n input.to_i - 1\n end",
"def input_to_index(user_input) #this method converts the user_input into the 0-8 index, AKA the position on the board\n user_input = user_input.to_i # assign user_input to (user_input.to_i), which converts the user_input to an integer\n user_input = user_input-1 # assign user_input to (user_input-1), which substracts 1 from the user_input\n #the above line with the (user_input-1) also returns -1 for strings without integers\n end",
"def input_to_index tato\n tato.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1 # user_input converted to an integer\nend",
"def input_to_index(input)\n user_input=input.to_i\n user_input - 1\nend",
"def index_to_input(index)\n (index + 1).to_s\n end",
"def to_searchable index\n _getarray[index].to_s\n end",
"def index(p0) end",
"def index(p0) end",
"def input_to_index(position)\n index = position.to_i - 1\n end",
"def idx(input)\n @idx = input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input = user_input.to_i\n user_input = user_input - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1 # user_input converted to an integer\n end",
"def input_to_index(user_input)\nuser_input = user_input.to_i\nuser_input = user_input - 1\n\n\nend",
"def input_to_index(input)\n index = input.to_i\n index -= 1\n return index\nend",
"def input_to_index(input)\n input=(input.to_i) - 1;\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(input)\n input.to_i - 1\nend",
"def input_to_index(user_input = 0)\n index = (user_input.to_i - 1)\nend",
"def input_to_index(position)\n index = position.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(input)\r\n return input.to_i - 1\r\n end",
"def input_to_index(user_input)\n user_input = user_input.to_i\n index = user_input - 1\n return index\nend",
"def input_to_index( user_input )\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(input)\n offset = input.to_i - 1\n return offset\nend",
"def input_to_index(user_input)\n\n user_input.to_i - 1\n\n\nend",
"def input_to_index(position)\n position = position .to_i\n index = position-1\nend",
"def input_to_index(user_input)\n (user_input).to_i - 1 \nend",
"def input_to_index (input)\n return input.to_i - 1\n\nend",
"def input_to_index(string_input)\n\n #coverting string input to an integer and subtracting it by 1\n (string_input.to_i) - 1\n\nend",
"def input_to_index(input)\n (input.to_i) - 1\nend",
"def input_to_index(user_input)\n\tactual_input = user_input.to_i - 1\n\nend",
"def input_to_index(input)\n return input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input = user_input.to_i\n user_input = user_input-1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n return index\n end",
"def input_to_index(input)\n index = input.to_i\n index = index-1\n return index\nend"
] | [
"0.7487145",
"0.7487145",
"0.7487145",
"0.7451344",
"0.74293756",
"0.74141085",
"0.74085337",
"0.73864603",
"0.7358067",
"0.73324275",
"0.730765",
"0.72817945",
"0.7238189",
"0.7238189",
"0.7225225",
"0.7225225",
"0.7202509",
"0.7179698",
"0.71718866",
"0.7157185",
"0.7153394",
"0.7122868",
"0.7116412",
"0.7111002",
"0.7104384",
"0.70995414",
"0.706726",
"0.706726",
"0.705709",
"0.705709",
"0.705709",
"0.705709",
"0.7032052",
"0.7029982",
"0.70218676",
"0.70171106",
"0.6983516",
"0.69833326",
"0.6982084",
"0.69819814",
"0.69513965",
"0.69508713",
"0.69432855",
"0.69431806",
"0.6915973",
"0.69110936",
"0.6894763",
"0.68922955",
"0.68919176",
"0.6884573",
"0.6884449",
"0.6882274",
"0.6860233",
"0.6860233",
"0.68554723",
"0.68413556",
"0.6840293",
"0.68391544",
"0.68371725",
"0.6835725",
"0.68339866",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68163127",
"0.68142545",
"0.6811965",
"0.6797049",
"0.6797049",
"0.6797049",
"0.6782625",
"0.6782324",
"0.6781827",
"0.6778271",
"0.6778271",
"0.6778271",
"0.6778271",
"0.6778271",
"0.677005",
"0.67659223",
"0.6763515",
"0.67627746",
"0.675404",
"0.67479223",
"0.6745454",
"0.67421305",
"0.6736335",
"0.673427",
"0.6731234",
"0.67291564"
] | 0.0 | -1 |
method returns true/false based on index | def valid_move?(board_arr, index)
if index.between?(0, 8)
if board_arr[index] == "" or board_arr[index] == " " or board_arr[index] == NIL
return true
end
end
puts "invalid"
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable?(index); self.index == index; end",
"def has_index? index\n @index.include? index\n end",
"def has_index? index\n @index.include? index\n end",
"def index?\n true\n end",
"def index_valid?(index)\n index > -1 && index != length ? true : false\n end",
"def includes_index?(index)\n (-self.length...self.length).cover?(index)\n end",
"def check?\n index?\n end",
"def index?\n true\n end",
"def index?\n false\n end",
"def index?\n false\n end",
"def index_exists? index, list\n return index < list.length # Return true if the index is less than the length\n end",
"def single?(index)\n number_of_targets(index) == 1\n end",
"def is_decision\n return (@index == 89)\n end",
"def [](index)\n set?(index)\n end",
"def valid_index?(index)\n index >= 0 && index < self.length\n end",
"def first?\n index == 0\n end",
"def index?\n return true\n end",
"def include?(index)\n true\n end",
"def validate_index(index)\n if @board[index] == X_TOKEN || @board[index] == O_TOKEN\n false\n else\n true\n end\n end",
"def contain?(position); end",
"def has_index_helper(index_map, index)\n return index_map[\"key\"].has_key?(index)\nend",
"def include?(x)\n @indices[x] # huh\n end",
"def index?\n true\n end",
"def index?\n true\n end",
"def index?\n true\n end",
"def index?\n true\n end",
"def first?\n index == 0\n end",
"def first?\n index == 0\n end",
"def index?\n false\n end",
"def indexed?(table, column); end",
"def indexed?(obj, index)\n indexes_for(index).map { |i| i[:_id] }.include? obj.id\n end",
"def has_index?( *indexes )\n \n has_index = false\n \n indexes.each do |this_index|\n break unless has_index = @indexes.has_key?( index_name )\n end\n \n return has_index\n \n end",
"def odd?\n @index.odd?\n end",
"def include?(indexes)\n indexes.all? { |index| self[index] == 1 }\n end",
"def being_indexed?(item)\n state_group(item) == :finalization\n end",
"def equals_index?(arr)\n for i in 0...arr.length do\n if arr[i] == i\n return true\n end\n end \n return false\nend",
"def can_win?(array, index)\n\nend",
"def can_win?(array, index)\nend",
"def is_visible? index\n j = index - @prow #@toprow\n j >= 0 && j <= scrollatrows()\n end",
"def first?\n self.index == 0\n end",
"def genesis?\n\t\treturn self.index.zero?\n\tend",
"def in_index?\n [email protected](/[ MARC]/)\n end",
"def satisfied?(index)\n @array_rep[index] >= left_child_key(index) and\n @array_rep[index] >= right_child_key(index)\n end",
"def has_index(index_lists, index)\n contains = false\n index_lists.each do |key, value|\n if has_index_helper(value, index)\n contains = true\n return key, value, contains\n end\n end\n return nil, nil, contains\nend",
"def unique?\n indexes.any?{|i| i.unique}\n end",
"def valid_index?(array, index_number)\n if index_number >= 0 && index_number < array.length\n return true\n end\nend",
"def invalid_position(index)\n nums = [1,2,3,4,5,6,7,8,9]\n unless nums.include?(index)\n TRUE\n end\n end",
"def should_index?\n\t\t!deleted?\n \tend",
"def all?(indexes = (0...@size).to_a)\n Array(indexes).all? do |index| \n validate_index(index)\n bit_on?(index)\n end\n end",
"def has_index?( *index_names )\n \n has_index = false\n \n index_names.each do |this_index_name|\n break unless has_index = indexes.has_key?( this_index_name )\n end\n \n return has_index\n\n end",
"def valid_row?(index)\n row_values = row(index).compact\n row_values == row_values.uniq\n end",
"def command_enabled?(index)\n @list[index] == @list[@index]\n end",
"def even?\n @index.even?\n end",
"def index_assignment?\n arguments.length.equal?(2) && index_assignment_selector?\n end",
"def exhasusted?\n @index >= @lines.count\n end",
"def in_index?(item = nil)\n item ||= default_to_self\n last_saved = item[:last_saved]\n last_indexed = item[:last_indexed]\n last_indexed.present? && last_saved.present? && (last_indexed > last_saved)\n end",
"def any?(indexes = (0...@size).to_a)\n indexes.any? do |index| \n validate_index(index)\n bit_on?(index)\n end\n end",
"def index?\n INDEXES.include? self.name\n end",
"def current_item_enabled?\r\n enable?(index)\r\n end",
"def current_item_enabled?\n enable?(@index)\n end",
"def got_three?(a) #no idea why thisis not working #wasn't calling the method got_three?\n #iterating over each index and using the .any? method (which returns true as long as the block is not false or nil)\n #so when a[index 1] is the same as index 2 AND index 3, the block is true and the any? method returns true.\n #if not it will return false.\n a.each_index.any? {|i| a[i] == a[i+1] && a[i+1] == a[i+2]}\nend",
"def index_field?(name)\n index_fields.key?(name)\n end",
"def in_range?(index)\n index >= 0 and index < size\n end",
"def bad_index?\n if self.account_number == nil || self.account_bank_number == nil ||\n self.student.uic == nil || self.sident == -666 || self.sident == nil\n if self.has_any_scholarship?\n return true\n end\n end\n return false\n end",
"def unique?\n if @data.fetch(:Index_type) == \"UNIQUE\" || @data.fetch(:Non_unique).to_i == 0\n return true\n else\n return false\n end\n end",
"def position_taken?(index)\n if @board[index] == \"X\"\n true\n elsif @board[index] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, index)\n index = index.to_i\n position = board[index]\n a = position == \"X\"\n b = position == \"O\"\n \n if a||b\n return true\n else\n return false\n end\nend",
"def unique?\n if @args[:data][:Index_type] == \"UNIQUE\"\n return true\n else\n return false\n end\n end",
"def current_item_enabled?\n enabled?(index)\n end",
"def is_matched(ind)\n\t\treturn @tile_Array[ind].return_match\n\tend",
"def position_taken?(arr, ind)\n\n if(arr[ind]==\"X\"||arr[ind]==\"O\")\n true\n else\n false\n end\nend",
"def index_valid?\n false\n end",
"def is_valid_index?(row, column)\r\n # Check if the specified row is out of bounds\r\n if ( row < 0 ) || ( row >= @image_array.length )\r\n return false\r\n end\r\n\r\n # Check if the specified column is out of bounds\r\n if ( column < 0 ) || ( column >= @image_array[row].length )\r\n return false\r\n end\r\n\r\n return true\r\n end",
"def indexing?\n File.exist?(@indexing)\n end",
"def has_block_index?( *index_names )\n \n has_index = false\n \n index_names.each do |this_index_name|\n break unless has_index = block_indexes.has_key?( this_index_name )\n end\n \n return has_index\n\n end",
"def index?\n File.basename(path, '.*') == 'index'\n end",
"def []( index )\n feedme while !@done and index >= @truth.size\n return @truth[index]\n end",
"def valid_index_in?(array, index)\n index <= (array.length - 1) && index >= (0 - array.length)\n end",
"def valid_indexes?(file_index, rank_index)\n validate_class file_index, Integer\n validate_class rank_index, Integer\n (file_index > -1 && file_index < files.size) &&\n (rank_index > -1 && rank_index < ranks.size)\n end",
"def index_exists?(index)\n indexes([index[:table]]).find {|i| i[\"columns\"] == index[:columns]}\n end",
"def current_item_enabled?\n return !@data[index].nil?\n end",
"def command_enabled?(index)\r\n @list[index][:enabled]\r\n end",
"def has_explicit_index?( *index_names )\n \n has_index = false\n \n index_names.each do |index_name|\n break unless has_index = explicit_indexes.has_key?( index_name )\n end\n \n return has_index\n \n end",
"def indexes_exist?(vegie_arr, choice_arr)\n vegie_index = []\n vegie_arr.each_index {|index| vegie_index << index}\n if choice_arr.length > vegie_arr.length\n return false\n else\n choice_arr.each do |value|\n return false if !vegie_index.include?(value - 1)\n end\n end\n true\n end",
"def enable?(index)\r\n @actor ? @actor.equip_change_ok?(index) : false\r\n end",
"def indexed?\n @index_file and File.exist?(@index_file)\n end",
"def index?\n basename == \"index\"\n end",
"def index?\n basename == \"index\"\n end",
"def degenerate?\n @indexes.size == 0\n end",
"def has_index?\n INDEX_REGEXP =~ rootname_minus_role\n end",
"def indexTest(data,i)\n if data.is_a?(Array) and i<data.length and i>=-1*data.length\n return data[i]\n elsif data.is_a?(Hash) and data.keys.include? i\n return data[i]\n else\n return 0\n end\nend",
"def valid_move?(index)\n if (index.between?(0,8) == true) && (position_taken?(index) == false)\n return true \n else\n return false\n end\nend",
"def index?\n !running_from_rake?\n end",
"def current_item_enabled?\n enable?(@data[index])\n end",
"def current_item_enabled?\n enable?(@data[index])\n end",
"def current_item_enabled?\n enable?(@data[index])\n end",
"def current_item_enabled?\n enable?(@data[index])\n end",
"def current_item_enabled?\n enable?(@data[index])\n end",
"def current_item_enabled?\n enable?(@data[index])\n end",
"def is_index_form_column(record,input_name)\n\t\tcheck_box :record, :is_index, :name => input_name, \n\t\t\t\t\t\t\t:onclick => \"javascript:alert('Checking this check box means this page will become index page and the previous one will not remains as index page');\"\n\tend",
"def index_valid?\n timestamp = File.open(@index_path, 'rb') { |f| read_int(0, f) }\n timestamp == @data_timestamp\n rescue\n false\n end"
] | [
"0.7796415",
"0.7555843",
"0.7555843",
"0.7471939",
"0.7447597",
"0.74435395",
"0.73727673",
"0.7296839",
"0.72059846",
"0.72059846",
"0.7088272",
"0.7082087",
"0.7064204",
"0.70628333",
"0.7046051",
"0.6956422",
"0.6955822",
"0.6926004",
"0.68981075",
"0.68938947",
"0.68593967",
"0.6833267",
"0.68202376",
"0.68202376",
"0.68202376",
"0.68202376",
"0.6796734",
"0.6796734",
"0.6736612",
"0.6733887",
"0.67325795",
"0.67237014",
"0.66957736",
"0.6672497",
"0.6671264",
"0.6657473",
"0.6657409",
"0.6643828",
"0.6631719",
"0.66249186",
"0.6611423",
"0.66058385",
"0.66000444",
"0.65948",
"0.6578081",
"0.6569275",
"0.6568527",
"0.65306234",
"0.65288824",
"0.6514348",
"0.64985573",
"0.6482602",
"0.6476123",
"0.6471668",
"0.64713657",
"0.64613837",
"0.64497834",
"0.64481556",
"0.6444808",
"0.6442813",
"0.6434729",
"0.642562",
"0.641188",
"0.640484",
"0.64003414",
"0.63870674",
"0.6355611",
"0.6346876",
"0.63364834",
"0.6335851",
"0.6331203",
"0.63173985",
"0.63145113",
"0.63033164",
"0.6295515",
"0.6294795",
"0.6289609",
"0.6287922",
"0.6284355",
"0.62802154",
"0.62741977",
"0.6272795",
"0.62706906",
"0.6269382",
"0.6262983",
"0.62583816",
"0.6247707",
"0.6247707",
"0.6243245",
"0.62395954",
"0.6239201",
"0.62358165",
"0.62093705",
"0.6200665",
"0.6200665",
"0.6200665",
"0.6200665",
"0.6200665",
"0.6200665",
"0.61964023",
"0.6195547"
] | 0.0 | -1 |
Returns the HTML for a sublist of the sitemap (an unsorted list with clickable node titles) up to a specified number of submenu levels. arguments +item+ The content node to create an unsorted list for. +levels+ The maximum of sublists. | def create_subitem(item, levels)
@current_level ||= 0
subitems = item.node.children.accessible.public.shown_in_menu.include_content.order(:position).all.map { |n| n.content }
if item.node.leaf? || subitems.empty? || @current_level == levels
@current_level = 0 if @current_level == levels
content = link_to(h(item.content_title), content_node_path(item.node), :title => h(item.content_title))
content_tag(:li, content, :class => 'link')
else
@current_level += 1
ul = content_tag(:ul, subitems.map { |subitem| create_subitem(subitem, levels) }.join("\n").html_safe)
content = link_to(h(item.content_title), content_node_path(item.node), :title => h(item.content_title))
content_tag(:li, content + ul, :class => 'subitem')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_items(item, limit, index, hierarchical = false, root_path = \"\")\n return \"\" if index > limit || !item.children.present?\n\n html = \"<ul class='#{index == 1 ? \"menu\" : \"sub-menu\"}'>\"\n item.children.order_default.each do |i|\n if i.visible && i.active\n html << \"<li class='#{\"menu-item-has-children\" if i.children.present?} #{\"active\" if i.slug == params[:menu_id] || i.slug == request.original_fullpath.match(/(\\D+\\/{1}|\\D+)/)[0].gsub('/', '')}'>\"\n\n if i.external_link.blank?\n if hierarchical\n html << \"<a href='#{root_path}/#{i.slug}'>#{i.name}</a>\"\n else\n html << \"<a href='/#{i.slug}'>#{i.name}</a>\"\n end\n else\n html << \"<a href='#{i.external_link}' rel='#{(i.follow || i.follow.nil?) ? \"follow\" : \"nofollow\"}' target='#{i.target.blank? ? '_self' : i.target}'>#{i.name}</a>\"\n end\n\n html << build_items(i, limit, index + 1, hierarchical, root_path + \"/#{i.slug}\")\n html << \"</li>\"\n end\n end\n html << \"</ul>\"\n html.html_safe\n end",
"def menu(items, path, level = 0, maxlevel = 1000)\n return '' unless items # No items, nothing to display\n return '' if level >= maxlevel + 1 || level >= items.size # We've gone too deep or there aren't this many levels\n \n val = \"<ul>\";\n # Go through each item on this level and render them as list items\n items[level].each {|item|\n # We're viewing a nav item in the active path, mark it active and show it's children recursively\n if(path && path[level] && item.id == path[level].id)\n val = val + '<li class=\"active\">' + link_to(item.title, item.realpath) + menu(items, path, level+1, maxlevel)\n else\n val = val + '<li>' + link_to(item.title, item.realpath)\n end\n val = val + '</li>'\n }\n return val + \"</ul>\"\n end",
"def sitemap\n\tpages = []\n\tPage.each_with_level(Page.find(:all, :order => 'lft ASC')) do |page,level|\n\t pages << {\n\t :page => page,\n\t :level => level\n\t }\n\tend\n\tpages[0..-2].map! do |p|\n\t p.update(:have_children => p[:level] < pages[pages.index(p)+1][:level])\n\tend\n\tpages.last.update(:have_children => false) unless pages.empty?\n\n\tul_li_for pages do |page|\n %[<a href=\"#{root_url+page[:page].url}\">#{page[:page].menu}</a>]\n\tend\n end",
"def render_submenu(menu_items = roots)\n if menu_items.present?\n menu_items.each_with_index.inject(ActiveSupport::SafeBuffer.new) do |buffer, (item, index)|\n buffer << render_submenu_items(menu_item_children(item)) if selected_item_or_descendant_item_selected?(item)\n buffer\n end\n end\n end",
"def createNextItemSublist\n\t\titemPouch = @hero.itemPouch\n\t\t#Checks for appropriate index.\n\t\tif @subMenuIndex * 9 >= itemPouch.length\n\t\t\t@subMenuIndex = 0\n\t\telsif @subMenuIndex < 0\n\t\t\t@subMenuIndex = (itemPouch.length - 1) / 9\n\t\tend\n\n\t\ttotalList = []\n\t\tlist = []\n\t\t(@subMenuIndex * 9...(@subMenuIndex + 1) * 9).each { |index|\n\t\t\tif (itemPouch[index] == nil)\n\t\t\t\tlist.push(\"\")\n\t\t\telse\n\t\t\t\tlist.push(itemPouch[index])\n\t\t\tend\n\t\t\tif (list.length == 3)\n\t\t\t\ttotalList.push(list)\n\t\t\t\tlist = []\n\t\t\tend\n\t\t}\n\t\treturn totalList\n\tend",
"def sub_items\n [\n [:subnav1, 'subnav1', 'subnav1_url', {}],\n [:subnav2, 'subnav2', 'subnav2_url', {}]\n ]\nend",
"def construct_html(menu, nested = false)\n return if menu.blank?\n \n links = menu.inject([]) do |items, (item, opts)|\n next(items) unless execute_proc(opts[:if])\n \n text, path, attrs = self.disect(item, opts)\n subnav = construct_html(menu[item][SUBMENU], true).to_s\n attrs.merge!(:class => [attrs[:class], self.current_css(item, nested)].compact.join(' '))\n items << self.view.content_tag(:li, self.view.link_to(text, path) + subnav, attrs)\n end\n \n nested ? self.view.content_tag(:ul, links, :class => 'sub-navigation') : links\n end",
"def from_list_to_html(list, depth_to_traverse=1000, start_depth=0)\n depth = start_depth\n if list.is_a?(Array) && !list.empty?\n str =''\n str << '<ul>'\n depth += 1\n list.each do |value|\n unless depth > depth_to_traverse\n str << \"<li> #{value} </li> \"\n if value.is_a?(Array) \n str << from_hash_to_html(value, depth_to_traverse, depth)\n end\n end\n end\n str << '</ul> '\n return str\n end\n return ''\n end",
"def menu_item_atom( current_piece, page, page_index = 0)\n return '' if current_piece.enabled_depth < page.depth\n\n leaves_content = ''\n unless page.leaf?\n child_index = page_index # consider all descendants as one list for even/odd\n leaves_content = content_tag(:ul, raw( page.children.map{|child| child_index+=1 ;menu_item_atom( current_piece, child, child_index )}.join ), class: \"depth#{page.depth+1}\" )\n end\n cycle_css_class = (page_index%2 == 0 ? 'even' : 'odd')\n item_content = content_tag(:span, page.name, class: 'name' )\n\n item_content= if page.clickable?\n if page.current?\n link_to item_content, page.path, page.extra_html_attributes.merge( { :class=>\"selected depth#{page.depth} #{cycle_css_class}\" } )\n else\n link_to item_content, page.path, page.extra_html_attributes.merge( { :class=>\"depth#{page.depth} #{cycle_css_class}\" } )\n end\n else\n link_to item_content, page.path, page.extra_html_attributes.merge( { :class=>\"noclick depth#{page.depth} #{cycle_css_class}\", :href=>'javascript:void(0)' } )\n end\n\n content_tag(:li, raw( item_content+ leaves_content ) )\n end",
"def render_menu ( menu , options={}, style=:tabs , level=1 )\n links = []\n case style\n when :tabs\n Atlantis::MenuManager.items_at_level(menu, level).each do |node|\n links << render_menu_node(node, style, options)\n end\n links.empty? ? '' : content_tag('ul', links.join(\"\\n\").html_safe , :class=>options[:ul_class] ).html_safe\n when :divs\n Atlantis::MenuManager.items_at_level(menu, level-1).each do |node|\n links2 = Array.new\n node.children.each do |n|\n links2 << render_menu_node(n, style, options)\n end\n links << content_tag('div', links2.join(\"\\n\").html_safe).html_safe\n end\n links.empty? ? '' : links.join(\"\\n\").html_safe\n end\n end",
"def nestable_list_recursive(items, block)\n content_tag(:ol, class: 'dd-list') do\n tags = items.map do |item|\n content_tag(:li, class: 'dd-item', data: { id: item.to_param }) do\n content = capture_with_haml { block.call(item) }\n recurse = if item.children.empty?\n ''.html_safe\n else\n nestable_list_recursive(item.children, block)\n end\n\n content.html_safe + recurse\n end\n end\n\n tags.join.html_safe\n end\n end",
"def print_menu_entry(sons, entry, view_ctrl)\n has_submenu = sons[entry.id].present?\n is_current_page = (@page && @page == entry.target) || request.path == entry.url\n item_class = entry.html_class.present? ? [entry.html_class] : []\n item_class << 'sub' if has_submenu\n item_class << 'current_page' if is_current_page\n\n content_tag :li, id: \"menu_item_#{entry.id}\", class: item_class.join(' ') do\n title_link = link_to(entry.title,\n entry.target_id.to_i > 0 ? main_app.site_page_path(entry.target_id) : entry.url,\n alt: entry.title, title: entry.description, target: entry.new_tab ? '_blank' : '')\n\n li_content = []\n li_content << content_tag(:div, '', class: 'hierarchy') if view_ctrl\n li_content << if view_ctrl\n content_tag(:div, style: 'min-height: 25px', class: \"menuitem-ctrl#{' deactivated' unless entry.publish}\") do\n div_content = []\n div_content << content_tag(:span) do\n [\n toggle_field(entry, 'publish', 'toggle', controller: 'sites/admin/menus/menu_items', menu_id: entry.menu_id),\n \" #{title_link}\",\n ( (entry and entry.target) ? \" [ #{entry.target.try(:title)} ] \" : \" [ #{entry.url unless entry.url.blank?} ] \")\n ].join.html_safe\n end\n div_content << content_tag(:div, class: 'pull-right') do\n menu_content = []\n menu_content << link_to(icon('edit', text: ''), edit_site_admin_menu_menu_item_path(entry.menu_id, entry.id), title: t('edit')) if test_permission(:menu_items, :edit)\n menu_content << link_to(icon('trash', text: ''), site_admin_menu_menu_item_path(entry.menu_id, entry.id), method: :delete, data: { confirm: t('are_you_sure') }, title: t('destroy')) if test_permission(:menu_items, :destroy)\n menu_content << link_to(icon('move', text: ''), '#', class: 'handle', title: t('move')) if test_permission(:menu_items, :change_position)\n menu_content << link_to('+', new_site_admin_menu_menu_item_path(entry.menu_id, parent_id: entry.id), class: 'btn btn-success btn-xs', title: t('add_sub_menu')) if test_permission(:menu_items, :new)\n menu_content.join.html_safe\n end\n div_content.join.html_safe\n end\n else\n title_link\n end\n li_content << content_tag(:menu, class: 'submenu') do\n sons[entry.id].map do |child|\n print_menu_entry(sons, child, view_ctrl)\n end.join.html_safe\n end if has_submenu\n li_content.join.html_safe\n end\n end",
"def list_children(parent_url)\n depth = path_depth(parent_url)\n children = sitemap.resources.select do |r|\n r.url.include?(parent_url) && path_depth(r.url) == depth + 1\n end.sort_by { |r| r.path }\n return \"\" if children.size == 0\n list = children.reduce(\"\") do |a, e|\n a << \"<li>#{link_to_resource(e)}</li>\\n\"\n end\n \"<ul class='list-unstyled'>#{list}</ul>\"\n end",
"def print_item(level:, current_item:)\n # Print the current item\n tabs = \"\\t\" * level\n puts tabs + '+ ' + current_item[:name]\n\n # Print the current item's children\n children = $children_of[current_item[:id]]\n if children && children.length > 0\n children.each do |child|\n print_item(\n level: level + 1, \n current_item: child\n )\n end\n end\nend",
"def render_entry_children(context, page, depth)\n output = %{}\n\n children = page.children_with_minimal_attributes(@options[:add_attributes]).reject { |c| !include_page?(c) }\n if children.present?\n output = %{<ul id=\"#{@options[:id]}-#{page.slug.to_s.dasherize}\" class=\"#{bootstrap? ? 'dropdown-menu' : ''}\">}\n children.each do |c, page|\n css = []\n css << 'first' if children.first == c\n css << 'last' if children.last == c\n\n output << render_entry_link(context, c, css.join(' '), depth)\n end\n output << %{</ul>}\n end\n\n output\n end",
"def tag_for(item, level)\n level = level || false\n\n # Get simple-navigation options\n link_options = options_for(item)\n link_options[:data] ||= {}\n\n # Store toggle options\n toggle_options = {}\n toggle_options[:data] ||= {}\n toggle_options[:class] ||= \"\"\n toggle_options[:title] = \"Open menu\"\n\n if accessible\n toggle_options[:data][:navigation_level] = level\n link_options[:data][:navigation_level] = level\n end\n\n if level && level > 1 && accessible\n link_options[:data][:navigation_item] = \"\"\n toggle_options[:data][:navigation_item] = \"\"\n end\n\n # Add navigation data attributes for navigation.js \n # accessibility\n if include_sub_navigation?(item) && accessible\n link_options[:data][:navigation_parent] = \"\"\n toggle_options[:data][:navigation_parent] = \"\"\n end\n\n item_content = item.name\n\n # Add description to link item\n if has_descriptions\n description = item.html_options[:description]\n show_description = has_descriptions.eql?(true) || has_descriptions.include?(level)\n if has_toggles && show_description && description.present?\n item_content = \"<span>#{item_content}<span class='#{get_class(\"--item-description\")}'>#{description}</span></span>\"\n else\n link_options[\"data-description\"] = description\n end\n end\n\n # Parent links\n if include_sub_navigation?(item)\n \n # Add data-toggle attributes\n if has_toggles\n toggle_options[:data][:toggle_anchor] = build_item_key(item)\n toggle_options[:data][:toggle_timing] = \"100\"\n toggle_options[:data][:toggle_temporary_anchor] = \"\" if has_temporary_toggles\n toggle_options[:class] += \"active\" if has_toggle_default_open(item)\n end\n\n if has_icons && !has_split_toggles\n item_content = \"#{item_content} #{get_icons()}\"\n end\n\n # Split parents have a link + button\n if has_split_toggles\n content_tag(:div, (\n link_to(content_tag(:span, item_content), item.url, link_options) +\n content_tag('button', get_icons(), toggle_options)\n ), class: get_class(\"--split-parent\"))\n\n # Non-split parents have just a button\n elsif has_toggles\n content_tag('button', content_tag(:span, item_content), link_options.merge(toggle_options))\n else\n link_to(content_tag(:span, item_content), item.url, link_options)\n end\n\n # Non-parents get either just a span (for no link) or a link\n else\n if suppress_link?(item)\n content_tag('span', item_content, link_options)\n else\n link_to(content_tag(:span, item_content), item.url, link_options)\n end\n end\n end",
"def create_submenu(item)\n submenu = CP::MENU_COMMANDS.COMMANDS[item][1]\n c_list = []\n @sw_list = []\n CP::MENU_COMMANDS.COMMANDS.each_with_index do |comm, index|\n next unless comm.include?(submenu)\n next if index == item\n c_list.push(comm[0])\n @sw_list.push(index)\n end\n @submenu_window = Window_Command.new(120, c_list)\n save_op = !$game_system.save_disabled\n char_op = $game_party.members.size != 0\n CP::MENU_COMMANDS.COMMANDS.each_with_index do |comm, index|\n i = @cm_list.index(index)\n next unless i\n if comm.include?(:save)\n @submenu_window.draw_item(i, save_op)\n end\n if comm.include?(:no1)\n @submenu_window.draw_item(i, char_op)\n end\n end\n @submenu_window.x = @command_window.x + 32\n @submenu_window.y = @command_window.y + 26 + @command_window.index * 24\n @submenu_window.y -= @command_window.oy\n @submenu_window.active = true\n @command_window.active = false\n end",
"def custom_hook_all(items)\n grouped_by_page = items.group_by do |i|\n \"#{i[:category]}-#{i[:subcategory]}\"\n end\n grouped_by_page.each do |_, pages|\n page_record = {\n category: pages[0][:category],\n hierarchy: pages[0][:hierarchy],\n subcategory: pages[0][:subcategory],\n tagname: 'h1',\n text: nil,\n display_title: \"Go to #{pages[0][:subcategory]}\",\n title: pages[0][:category],\n url: pages[0][:url],\n weight_tag_name: 90,\n weight_order: -1\n }\n items << page_record\n end\n items\n end",
"def main_menu_accord(items_hash, show_properties=false, depth=0)\n if(depth == 0 && items_hash.keys.empty?)\n return \"No Items Available\"\n end\n if(@items_to_select.nil?)\n @items_to_select = []\n end\n if(items_hash.keys.empty?)\n return \"\"\n end\n pt = \"<ul \"\n if(depth == 0)\n pt += \"id=\\\"id#{Time.now.usec}\\\" class=\\\"accordion\\\"\"\n end\n pt+=\">\"\n expand = true\n for item in items_hash.keys\n pt += \"<li\"\n if(depth == 0 && expand && (!item.is_a?(Property) || !item.valuefields.empty?))\n pt += \" class=\\\"expand\\\"\"\n expand = false\n end\n pt +=\">\"\n if(item.is_a?(Category))\n pt += \"<div class=\\\"inline\\\">   </div><label class=\\\"label_main_menu\\\">#{link_to(item.name, item)}</label>\"\n elsif(item.is_a?(Component))\n pt += \"<div class=\\\"inline\\\">   </div><label class=\\\"label_main_menu\\\">#{link_to(item.name, 'tabs/component/' + item.id.to_s)}</label>\"\n end\n pt += main_menu_accord(items_hash[item], show_properties, depth+1)\n pt += \"</li>\"\n end\n pt += \"</ul>\"\n return pt\n end",
"def render_entry_children(context, page, depth)\n output = %{}\n\n children = children(page).reject { |c| !include_page?(c) }\n if children.present?\n dropdown_class = @source == 'site' && page.depth == 1 ? @options[:dropdown_class] : ''\n output = %{<ul id=\"#{@options[:id]}-#{page.slug.to_s.dasherize}\" class=\"#{bootstrap? ? 'dropdown-menu' : dropdown_class}\">}\n children.each do |c, page|\n css = []\n css << 'first' if children.first == c\n css << 'last' if children.last == c\n\n output << render_entry_link(context, c, css.join(' '), depth)\n end\n output << %{</ul>}\n end\n\n output\n end",
"def subpage_navigation(page)\n l = \"<ul>\\n\"\n page.pages.each do |page|\n l << page_navigation_helper(page)\n end\n l << \"</ul>\"\n end",
"def create_level_linked_list (root, lists, level)\n return if root == nil\n\n list = nil\n if lists.length == level\n list = LinkedList.new\n lists.add(list)\n else\n list = lists[level]\n end\n list.append(root)\n create_level_linked_list(root.left, lists, level + 1)\n create_level_linked_list(root.righ, lists, level + 1)\nend",
"def render_children\n children = ''\n\n list_item.children.each do |child|\n children += self.class.render(child, opts)\n end\n\n children\n end",
"def build_menu_items_extended (i, index, active_ids = [], options)\n\n return \"\" if index > options[:limit]\n html = \"\"\n if i.visible && i.active\n item_class = build_item_class(i, options, active_ids)\n html << \"<li #{\"class='#{item_class}'\" unless item_class.blank?} >\"\n\n locale_prefix = \"/#{I18n.locale.to_s}\" if options[:with_locale]\n locale_prefix ||= ''\n if i.external_link.blank?\n html << \"<a #{\"class='#{options[:a_class]}'\" if options[:a_class]} href='#{locale_prefix}#{i.real_slug(options[:hierarchical])}'>#{i.name}</a>\"\n else\n html << \"<a #{\"class='#{options[:a_class]}'\" if options[:a_class]} href='#{i.external_link}' #{\"rel='nofollow'\" unless i.follow || i.follow.nil?} #{\"target='#{i.target}'\" unless (i.target.blank? || i.target == '_self') }>#{i.name}</a>\"\n end\n\n items_html = \"\"\n\n i.children.order_default.each do |item_child|\n items_html << build_menu_items_extended(item_child, index + 1, active_ids, options)\n end\n\n content_item_class = [item_class, options[:content_item_class]].compact.join(\" \")\n i.contents.displayed.order_default.each do |content|\n next if ((options[:content_type].blank? || (options[:content_type].exclude?(content.type.to_s))) && (!options[:all_content_types]))\n items_html << \"<li #{\"class='#{content_item_class}'\" unless content_item_class.blank?}>\"\n items_html << \"<a #{\"class='#{options[:a_class]}'\" if options[:a_class]} href='#{locale_prefix}#{content.slug}'>#{content.title}</a>\" if content.respond_to?(\"slug\")\n items_html << \"</li>\"\n end\n\n unless items_html.empty?\n html << \"<div class='#{options[:ul_nested_wrapper_class]}'>\" unless options[:ul_nested_wrapper_class].nil?\n html << \"<ul #{\"class='#{options[:ul_nested_class]}'\" if options[:ul_nested_class]}>\"\n html << items_html\n html << \"</ul>\"\n html << \"</div>\" unless options[:ul_nested_wrapper_class].nil?\n end\n html << \"</li>\"\n end\n html.html_safe\n end",
"def create_tree(items, rootpage)\n _, tree = visit_nodes(items, rootpage.lft + 1, rootpage.id, rootpage.depth + 1, {}, \"\", rootpage.restricted)\n tree\n end",
"def menu_list(*link_hashes)\n content_tag :ul do \n links = link_hashes.collect do |lh| \n menu_item_if_permitted(lh[:name], lh[:path], *lh[:sublist])\n end\n raw links.join\n end\n end",
"def level_items_list(type, levels)\n levels = levels.join(',') if levels.is_a?(Array)\n response = api_response(type, levels)\n\n # The vocabulary API call without specifying levels returns a Hash instead\n # of an Array, so this is a hacky way of dealing with it.\n if response[\"requested_information\"].is_a?(Hash)\n return response[\"requested_information\"][\"general\"]\n else\n return response[\"requested_information\"]\n end\n end",
"def child_index(path)\n resource = sitemap.find_resource_by_path(\"#{path}/index.html\")\n return \"\" if resource.children.size == 0\n resource.children.each { |e| \"<li>#{link_to e.data.id, e.url}</li>\" }\n index = resource.children.reduce(\"\") { |a, e| a + \"<li>#{link_to e.data.title, e.url}</li>\" }\n \"<ul>#{index}</ul>\"\n end",
"def menu_items_html\n @menu_items = MenuItem.where(show: true, type_item: \"Головне меню\").order(order_item: :asc)\n\n @menu = '<ul class=\"nav navbar-nav\">'\n\n @menu_items.each do |m_a|\n if m_a.parent_id == 0\n @menu << \"<li class='dropdown'><a class='dropdown-toggle' aria-expanded='false' aria-haspopup = 'true' data-toggle = 'dropdown' href = '#{m_a.link}' role = 'button' target= 'blank'> #{m_a.title} <span class='caret'></span></a>\" if m_a.type_level == 'Заголовок меню'\n @menu << \"<li > <a href = '#{m_a.link}'> #{m_a.title} </span></a>\" if m_a.type_level == 'Пункт меню'\n\n get_children m_a.id, m_a.type_level\n\n @menu << '</li>'\n end\n end\n @menu << '</ul>'\n # $menu << @menu\n end",
"def build_menus(menu, items)\n\t\titems.each { |id, item|\n\t\t\t# For each JSON, add the item and then run build_menus in that item\n\t\t\t# in case it has sub menus. Hopefully such a recursive method won't\n\t\t\t# cause any problems.\n\t\t\tif item.is_a?(JSON)\n\t\t\t\tsub_menu = add_item(menu, id)\n\t\t\t\tbuild_menus(sub_menu, item)\n\t\t\tend\n\t\t}\n\tend",
"def get_sub_tree items, elem, *args\n # Can't use debug logging here, as it maybe isn't turned on yet\n # puts \"In Gless::EnvConfig, get_sub_tree: items: #{items}, elem: #{elem}, args: #{args}\"\n\n return nil if items.nil?\n\n new_items = items[elem.to_sym]\n return nil if new_items.nil?\n\n if args.empty?\n return new_items\n else\n return get_sub_tree( new_items, *args )\n end\n end",
"def render_entry_children(page, depth, context)\n entries = children_of(page)\n css = self.bootstrap? ? 'dropdown-menu' : ''\n\n unless entries.empty?\n self.render_tag(:ul, id: \"#{@_options[:id]}-#{page.slug.to_s.dasherize}\", css: css) do\n self.build_entries_output(entries, depth, context)\n end\n else\n ''\n end\n end",
"def get_nested_pages(title)\n sitemap.resources.select { |resource| resource.data.type == 'page' and resource.data.nested == true and resource.data.parent == title }\n .sort_by { |r| get_page_priority(r.data) }\n end",
"def item(*args)\n @__submenu_generation__.item(*args)\n end",
"def sitemap(tree)\n list_children(tree, nil, 'sitemap')\n end",
"def generate_sitemap\n menu, current_context = parse_and_create_menu_data_structure\n return '<ul class=\"site_map\">' + sitemap_output( menu ) + '</ul>'.html_safe\n end",
"def create_subitems\n if parsed_xml && parsed_xml.respond_to?(:sections)\n parsed_xml.sections.collect do |section_xml|\n Section.from_xml(section_xml, self)\n end\n end\n end",
"def create_subitems\n if parsed_xml && parsed_xml.respond_to?(:sections)\n parsed_xml.sections.collect do |section_xml|\n Section.from_xml(section_xml, self)\n end\n end\n end",
"def sitemap pages = nil, indent = 0\n pages ||= self.subpages\n dated, regular = pages.partition(&:dated?)\n\n bonus = 0\n prev = nil\n regular = regular\n subpages =\n regular.sort_by { |p| p.url } +\n dated.sort_by { |p| [-p.date.to_i, p.url] }\n\n subpages.map { |page|\n x = []\n\n if page.dated? then\n bonus = 1\n fmt ||= page.config[\"date_fmt\"] || \"%Y-%m\" # REFACTOR: yuck\n curr = page.date.strftime fmt\n if prev != curr then\n x << \"#{\" \" * (indent)}* #{curr}:\"\n prev = curr\n end\n end\n\n x << \"#{\" \" * (indent+bonus)}* [#{page.title}](#{page.clean_url})\"\n x += [page.sitemap(nil, indent+bonus+1)] unless page.subpages.empty?\n x\n }.flatten.join \"\\n\"\n end",
"def print_tree(array , item, level)\n items = array[item]\n unless items == nil\n indent = level > 0 ? sprintf(\"%#{level * 2}s\", \" \") : \"\"\n items.each do |e|\n puts \"#{indent}-#{e[:title]}\"\n print_tree(e, level + 1)\n end\n end\nend",
"def print_recursive_menu(menu_entry)\n menu_children = MenuEntry.find_all_by_parent_id(menu_entry.id)\n current_entry = \"<li>\" + menu_link(menu_entry) + \"</li>\"\n return current_entry if menu_children.size == 0\n current_entry = \"<li>\" + menu_link(menu_entry) + \"<ul>\"\n for menu_child in menu_children do\n current_entry += print_recursive_menu(menu_child)\n end\n current_entry += \"</ul></li>\"\n return current_entry\n end",
"def render_list( items, type: :ul, *args )\n non_empty_content_tag( type, *args ) { render_items( items }\n end",
"def levels\n level_names = []\n properties[\"pages\"].each do |page|\n page[\"levels\"].each do |page_level_name|\n level_names << page_level_name\n end\n end\n\n Level.where(name: level_names)\n end",
"def get_item_hierarchy(course_id, expand_items=nil)\r\n\t if expand_items.nil?\r\n relative_url = PATH_COURSES_ITEMHIERARCHY % [course_id]\r\n\t else\r\n\t relative_url = PATH_COURSES_ITEMHIERARCHY_EXPANDITEMS % [course_id, expand_items]\r\n\t end\r\n get(relative_url)\r\n end",
"def sitemap_children_for(page)\n sitemap_pages.fetch(page.id, []).sort_by(&:position)\n end",
"def list_children(taxons_collection)\n taxons_collection.sort_by {|p| p.hierarchy}\n html_var = \"\"\n taxons_collection.each do |t|\n if not t.children.empty?\n html_var << \"<li><i class='icon-plus'> </i>\" << link_to(t.name, t) << \"<ul>\" << list_children(t.children) << \"</ul>\"\n else\n html_var << \"<li><i class='icon-white' style='visibility: hidden;'> </i>\" << link_to(t.name, t)\n end\n html_var << \"</li>\\n\"\n end\n return html_var.html_safe\nend",
"def get_children(children, level, array)\n return if children.nil?\n\n children.each do |child|\n \n blocked = (child.blocked == \"true\") ? \"BLOCKED\" : \"\" # syntax highlighting matches 'BLOCKED' word\n display_str = \" \" * (level*2) + \"#{child.formatted_i_d}: #{StringUtils.html2text(child.name)}\"\n array << \"#{display_str.rjust(display_str.length, ' ').ljust(65, ' ')} #{formatted_story_state(child.schedule_state).ljust(15, ' ')} #{blocked}\\n\"\n get_children(child.children, level+1, array)\n end\n end",
"def render_items items, *args\n items.map do |item|\n non_empty_content_tag( :li, *args ) { render( item, *args ) }\n end\n items.join.html_safe\n end",
"def navigation nodes_stack, nodes, level=0\n nodes.map do |node|\n model_param = node.abstract_model.to_param\n url = locale_url_for(:action => :index, :controller => 'rails_admin/main', :model_name => model_param)\n level_class = \" nav-level-#{level}\" if level > 0\n\n li = content_tag :li, \"data-model\"=>model_param do\n #content_tag(:i, '', class: \"icon icon-#{model_param}\")\n #link_to(node.label_plural, url, :class => \"pjax#{level_class}\")\n adata = t('admin.menu.tip.'\"#{model_param}\")\n link_to url, class: \"tip-right pjax#{level_class}\", 'data-original-title' => adata do\n content_tag(:i, '', class: \"icon icon-#{model_param}\") + content_tag(:span, node.label_plural )\n end\n end\n li + navigation(nodes_stack, nodes_stack.select{ |n| n.parent.to_s == node.abstract_model.model_name}, level+1)\n end.join.html_safe\n end",
"def print_depth(item)\n return if item.hidden?\n print_item item, 0\n list_recur_print item, 2\n end",
"def category_menu_items(aRootCategory, aOptions={})\n\t\t\taBaseUrl = (aOptions[:base_url] || '')\n\t\t\taIdPrefix = (aOptions[:id_prefix] || '')\n\t\t\tcategory = aOptions[:category]\n\t\t\tcategory = category.name.urlize('+') if category.is_a?(Category)\n\t\t\ttree_nodes = construct_category_tree(aRootCategory)\n\t\n\t\t\t# now turn tree_nodes into menu items, still as array of levels\n\t\t\ttree_items = []\n\t\t\tlast_lvl = nil\n\t\t\ttree_nodes.each do |lvl|\n\t\t\t\titem_level = []\n\t\t\t\tlvl.each do |node|\n\t\t\t\t\tname = (node.name.index('/') ? File.basename(node.name) : node.name)\n\t\t\t\t\titem = {:id => aIdPrefix+node.id.to_s, :name => name }\t\n\t\t\t\t\titem[:node] = node\n\t\t\t\t\tif last_lvl && parent_item = last_lvl.find {|i| i[:node].id == node.parent_id}\n\t\t\t\t\t\tparent_item[:children] ||= []\n\t\t\t\t\t\tparent_item[:children] << item\n\t\t\t\t\t\titem[:url] = parent_item[:url]\n\t\t\t\t\t\titem[:url] += '+' unless item[:url]=='' || item[:url].ends_with?('/') || item[:url].ends_with?('+')\n\t\t\t\t\t\titem[:url] += name.urlize('-')\n\t\t\t\t\telse\n\t\t\t\t\t\titem[:url] = File.join(aBaseUrl,name.urlize('-'))\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\titem[:selected] = true if category && (category==node.name.urlize('+'))\n\t\t\t\t\titem[:order] = aOptions[:order_proc].call(item) if aOptions.has_key?(:order_proc)\n\t\t\t\t\titem_level << item\n\t\t\t\tend\n\t\t\t\ttree_items << item_level\n\t\t\t\tlast_lvl = item_level\n\t\t\tend\n\t\t\t# clean\n\t\t\ttree_items.each do |lvl|\n\t\t\t\tlvl.each do |i| \n\t\t\t\t\ti.filter_include!([:url,:selected,:id,:name,:children,:order])\n\t\t\t\t\ti[:children].sort! {|a,b| a[:order].to_i <=> b[:order].to_i} if i[:children].is_a?(Array)\n\t\t\t\tend\n\t\t\tend\n\t\t\ttree_items.first.sort! {|a,b| a[:order].to_i <=> b[:order].to_i}\n\t\t\ttree_items.first\n\t\tend",
"def item(title, url = '#', options = {})\n raise 'item third parameter expects a Hash' unless options.kind_of?(Hash)\n\n prev_item = menu_items.last\n\n if prev_item.parent == true # This came from root or dropdown\n lft = prev_item.lft + 1 # Go down. from lft\n rgt = prev_item.rgt + 1\n else\n lft = prev_item.rgt + 1 # Go accross, from rgt\n rgt = prev_item.rgt + 2\n end\n\n menu_items.each do |item|\n item.rgt = (item.rgt + 2) if item.rgt > (lft - 1)\n item.lft = (item.lft + 2) if item.lft > (lft - 1)\n end\n\n atts = build_menu_item_attributes(title, url, options).merge({:lft => lft, :rgt => rgt})\n\n menu_items.build(atts)\n end",
"def submenu\n children.select { |item| item.shown_in_menu? }.sort\n end",
"def render_child_forums(forum, html = \"\")\n forum.each do |key, val|\n break if key.depth >= 2 # break iteration after max_depth is reach\n html << render(:partial => \"level#{key.depth}_post\", :locals => {:child => key})\n unless val.empty?\n render_child_forums(val, html)\n end\n end\n\n raw html\n end",
"def navtree_build(ret, item, el, el_type = \"\")\n module_name = item[:classnames][2] ? item[:classnames][2] : item[:classnames][1];\n page_name = item[:crumb]\n\n if !ret[module_name]\n ret[module_name] = {:id => module_name, :children => Hash.new}\n #if item[:deprecated] ret[module_name][:deprecated] = true\n end\n\n if !ret[module_name][:children][page_name]\n ret[module_name][:children][page_name] = {\n :id => page_name,\n :path => item.identifier,\n :children => Hash.new\n }\n #if item[:deprecated] ret[module_name][:deprecated] = true\n end\n\n el_name = el.respond_to?(:name) ? el.name : el\n ret[module_name][:children][page_name][:children][el_name] = {\n :signature => el.respond_to?(:sass_signature) ? el.sass_signature(:none) : el,\n :el_type => el_type\n }\n\n ret\nend",
"def side_menu\n items = @menu_setup[:main_menu].nil? ? [] : MENU_DATA['menu'][@menu_setup[:main_menu].to_s]['submenus']\n html = \"\"\n\n items.each do |item, opciones|\n active = is_active_side_menu?(opciones['active_submenu'])\n html << content_tag(:li, link_to((opciones['text'] + (active ? ' <i class=\"fa fa-angle-right pull-right\"></i>' : '')).html_safe, opciones['url']), class: active ? 'active' : '')\n end\n\n html.html_safe\n end",
"def render_admin_subnavigation(entries)\n render \"alchemy/admin/partials/sub_navigation_tab\", :entries => entries\n end",
"def get_levels(page)\n levels = Array.new\n class_id = 0\n line_no = 1\n page.each do |line|\n if line.include? \"ic_class_wh24_box\"\n levels[class_id] = page[line_no] # This line contains a class level\n class_id += 1\n end\n line_no += 1\n end\n\n # Get rid of junk items\n levels.delete_at(0)\n levels.delete_at(0)\n levels.delete_at(9)\n levels.delete_at(12)\n\n # Get just the numbers\n levels.each_with_index { |val, index| levels[index] = val[5..6] }\n\n # If the number is a single digit, or non-existant, strip the extra character(s)\n levels.each_with_index do |val,index|\n levels[index] = val.gsub(/\\D/, \"\")\n end\n\n levels\n end",
"def get_levels(page)\n levels = Array.new\n class_id = 0\n line_no = 1\n page.each do |line|\n if line.include? \"ic_class_wh24_box\"\n levels[class_id] = page[line_no] # This line contains a class level\n class_id += 1\n end\n line_no += 1\n end\n\n # Get rid of junk items\n levels.delete_at(0)\n levels.delete_at(0)\n levels.delete_at(9)\n levels.delete_at(12)\n\n # Get just the numbers\n levels.each_with_index { |val, index| levels[index] = val[5..6] }\n\n # If the number is a single digit, or non-existant, strip the extra character(s)\n levels.each_with_index do |val,index|\n levels[index] = val.gsub(/\\D/, \"\")\n end\n\n levels\n end",
"def subnav title = nil, &block\n concat content_tag(:li) {\n output = String.new()\n output << content_tag( :span, title ) unless title.nil?\n output << navigation(&block)\n }\n end",
"def get_level_children(dirname,level) #:nodoc:\n dir_children = full_entries(dirname)\n @level_children += dir_children\n if level < @max_level\n dir_children.each {|e|\n if File.directory?(e)\n get_level_children(e,level + 1)\n end\n }\n end\n end",
"def get_submenu_items(submenu_data, location_name, meal_name)\n items = []\n \n submenu_data.css(\"a\").each do |item|\n item_url = @base_url + item.attributes[\"href\"].value\n item_doc = Nokogiri::HTML(open(item_url))\n \n # NOTE: currently, we always update existing item records; maybe allow skipping in future?\n curr_item = Item.find_or_create_by(name: item.text, location: location_name, date: Time.now.utc.in_time_zone(\"Pacific Time (US & Canada)\").to_date, mealtime: meal_name)\n \n # Check nutrition availability. If unavailable, add to items and skip to next iter.\n if item_doc.css(\"font\").select{|candidate| candidate.css(\"i\").text =~ /^Nutritional Information is not available/}.empty?\n curr_item.nutrition_available = true\n else\n #curr_item.nutrition_available = false\n curr_item.save\n curr_item.touch\n next\n end\n \n c_match = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^Calories/}.text.match(/^Calories.(\\d*)/)\n curr_item.calories = c_match[1] if c_match\n \n cff_match = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Calories from/}.text.match(/Calories from Fat.(\\d*)/)\n curr_item.calories_from_fat = cff_match[1] if cff_match\n \n tf_text = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^Total/}.next.text\n curr_item.fat = tf_text if tf_text\n #curr_item.total_fat_percent = (curr_item.total_fat[0..-2].to_f / 65 * 100).round.to_s if tf_text\n \n tc_text = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^Tot\\./}.next.text\n curr_item.carb = tc_text if tc_text\n #curr_item.total_carbohydrates_percent = (curr_item.total_carbohydrates[0..-2].to_f / 300 * 100).round.to_s if tc_text\n \n #sf_text = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Sat\\./}.next.text\n #curr_item.saturated_fat = sf_text if sf_text\n #curr_item.saturated_fat_percent = (curr_item.saturated_fat[0..-2].to_f / 20 * 100).round.to_s if sf_text\n \n #df_text = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Dietary/}.next.text\n #curr_item.dietary_fiber = df_text if df_text\n #curr_item.dietary_fiber_percent = (curr_item.dietary_fiber[0..-2].to_f / 25 * 100).round.to_s if df_text\n \n #trf_text = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Trans/}.next.text\n #curr_item.trans_fat = trf_text if trf_text\n \n #su_text = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Sugars/}.next.text\n #curr_item.sugars = su_text if su_text\n \n ch_text = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^Cholesterol/}.next.text\n curr_item.cholesterol = ch_text if ch_text\n #curr_item.cholesterol_percent = (curr_item.cholesterol[0..-3].to_f / 300 * 100).round.to_s if ch_text\n \n p_text = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^Protein/}.next.text\n curr_item.protein = p_text if p_text\n \n sd_text = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^Sodium/}.next.text\n curr_item.sodium = sd_text if sd_text\n #curr_item.sodium_percent = (curr_item.sodium[0..-3].to_f / 2400 * 100).round.to_s if sd_text\n \n # Percentage\n #vc_match = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Vitamin C/}.next.next.text.match(/(\\d*)%\\z/)\n #curr_item.vitamin_c_percent = vc_match[1] if vc_match\n \n # Percentage\n #ca_match = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Calcium/}.next.next.text.match(/(\\d*)%\\z/)\n #curr_item.calcium_percent = ca_match[1] if ca_match\n \n # Percentage\n #fe_match = item_doc.css(\"font\").find{|candidate| candidate.text =~ /Iron/}.next.next.text.match(/(\\d*)%\\z/)\n #curr_item.iron_percent = fe_match[1] if fe_match\n \n # Form: single string (looks like list)\n #al_match = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^ALLERGENS/}.text.tr(\"\\u00A0\", \" \").match(/ALLERGENS:\\s+(.*)/)\n #curr_item.allergens = al_match[1] if al_match\n \n # Form: single string (looks like list)\n #ing_match = item_doc.css(\"font\").find{|candidate| candidate.css(\"b\").text =~ /^INGREDIENTS/}.text.tr(\"\\u00A0\", \" \").match(/INGREDIENTS:\\s+(.*)/)\n #curr_item.ingredients = ing_match[1] if ing_match\n \n curr_item.save\n curr_item.touch\n items << curr_item\n end\n \n return items\n end",
"def kanji_list(levels = nil)\n return level_items_list(\"kanji\", levels)\n end",
"def print_link_list(items)\n\n linkString = \"\"\n if(!items.empty? && items[0].is_a?(Category))\n linkString += \"<tr><td>#{link_to \"New Category\", new_category_url, {:style=>'color:#FF8000'}}</td></tr>\"\n linkString += \"<tr><td>#{main_menu_accord(all_category_hash)}</td></tr>\"\n elsif(!items.empty? && items[0].is_a?(Component))\n linkString += \"<tr><td>#{link_to \"New Component\", new_component_url, {:style=>'color:#FF8000'}}</td></tr>\"\n linkString += \"<tr><td>#{main_menu_accord(all_component_hash)}</td></tr>\"\n elsif(!items.empty?)\n for item in items\n if(item.is_a?(Product))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Product\", new_product_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.name, 'tabs/product/' + item.id.to_s)}</td></tr>\"\n elsif(item.is_a?(Group))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Group\", new_group_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.name, item)}</td></tr>\"\n elsif(item.is_a?(Property))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Property\", new_property_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.name, item)}</td></tr>\"\n elsif(item.is_a?(DataFile))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Data File\", new_data_file_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.filedata_file_name, item)}</td></tr>\"\n elsif(item.is_a?(Image))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Image\", new_image_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.picture_file_name, item)}</td></tr>\"\n elsif(item.is_a?(Validation))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Validation\", new_validation_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.extension, item)}</td></tr>\"\n elsif(item.is_a?(Valuefield))\n if(item == items[0])\n linkString += \"<tr><td>#{link_to \"New Value Field\", new_valuefield_url, {:style=>'color:#FF8000'}}</td></tr>\"\n end\n linkString += \"<tr><td>#{link_to(item.name, item)}</td></tr>\"\n elsif(item.is_a?(TableAlias))\n if(item == items[0])\n linkString += \"<tr><th>Original Name</th>\"\n linkString += \"<th>Current Name</th></tr>\"\n end\n linkString += \"<tr><td>#{item.tableName}</td>\"\n linkString += \"<td>#{link_to(item.aliasName, item)}</td></tr>\"\n end\n end\n else\n linkString += \"None Available.\"\n end\n\n return linkString\n end",
"def index\n @homepage_submenus = HomepageSubmenu.all\n end",
"def ancestry_options(items, &block)\n return ancestry_options(items){ |i| \"#{'-' * i.depth} #{i.name}\" } unless block_given?\n\n result = []\n items.map do |item|\n result << {\"name\" => yield(item), \"id\" => item.id}\n end\n result\n end",
"def build_levels(build)\n\t\tlevels = \"#{build.name}\\n\" + build.lvls.reduce(\"\") {|str,(k,v)| str + \"#{k.to_s}: #{v}\\n\"} \n\tend",
"def TreeView_SortChildren(hwnd, hitem, recurse)\r\n send_treeview_message(hwnd, :SORTCHILDREN, wparam: recurse, lparam: hitem)\r\n end",
"def draw_tree(item, selector, tab=nil, is_last=true, items_index=0)\n space = ' '\n if items_index < 10\n print ' '\n elsif items_index < 100\n print ' '\n elsif items_index > 999 # good god, man!\n space = ''\n end\n print items_index.to_s + \":\" + space\n\n if tab\n print tab\n if is_last\n print '`-- '\n tab += ' '\n else\n print '+-- '\n tab += '| '\n end\n else\n print '. '\n tab = ''\n end\n\n if self == item || $sugarcube_view == item\n print \"\\033[1m\"\n end\n if item.is_a?(UIView) && item.method(:to_s).arity == -1\n puts item.to_s superview: false\n else\n puts item.to_s\n end\n if self == item || $sugarcube_view == item\n print \"\\033[0m\"\n end\n\n if selector.is_a? Proc\n items = selector.call(item)\n else\n items = item.send(selector)\n end\n items ||= []\n\n items.each_with_index { |subview, index|\n items_index += 1\n if self.respond_to? :draw_tree\n items_index = draw_tree(subview, selector, tab, index == items.length - 1, items_index)\n else\n items_index = SugarCube::Adjust::draw_tree(subview, selector, tab, index == items.length - 1, items_index)\n end\n }\n\n return items_index\n end",
"def to_html_ul(&block)\n ctag = 'div' # HTML tag for content\n btag = 'div' # HTML tag for bullets\n\n o = content ? content.clone : nil\n if block.respond_to? :call\n block.call(self, o)\n end\n\n s = \"\"\n\n hmenu_content_class = \"hmenu-content\"\n\n hmenu_content_class << \" hmenu-root\" if is_root?\n\n # TODO: use displayed_name\n if o\n hmenu_content_class << ' ' << o[:extra_class] if o[:extra_class]\n s << \"<#{ctag} class=\\\"#{hmenu_content_class}\\\" title=\\\"#{(o[:desc] || '')}\\\">\"\n if o[:href]\n s <<\n \"<a href=\\\"#{o[:href]}\\\">#{o[:name]}</a>\" \n elsif o[:name]\n s << (o[:name] || '') \n end\n s << \"</#{ctag}>\"\n else\n s << \"<#{ctag} class=\\\"#{hmenu_content_class}\\\">\" << name.capitalize << \"</#{ctag}>\"\n end\n\n if has_children?\n\n if is_root? \n s += '<ul class=\"hmenu\">'\n else\n s += \"<ul>\"\n end\n\n children.sort.each do |child|\n\n o = child.content ? child.content.clone : nil\n if block.respond_to? :call\n block.call(child, o)\n end\n\n css_li_class = \n child.has_children? ? \n 'hmenu-submenu' : \n 'hmenu-item'\n css_li_class << ' ' << o[:extra_class] if o and o[:extra_class]\n css_bullet_class = \n child.has_children? ? \n 'hmenu-bullet' : \n 'hmenu-bullet-nochildren'\n\n s += \"<li class=\\\"#{css_li_class}\\\">\" << \"<#{btag} class=\\\"#{css_bullet_class}\\\" onclick=\\\"toggle_submenu(this);\\\"></#{btag}>\" << child.to_html_ul(&block) << \"</li>\"\n\n end\n\n s += \"</ul>\"\n\n end\n\n return s\n end",
"def tag_for(item, level)\n level = level || false\n\n # Get simple-navigation options\n item_options = options_for(item)\n item_options[:data] = item_options[:data] || {}\n\n if level && level > 1\n item_options[:data][:navigation_item] = \"\"\n end\n\n # Add navigation data attributes for navigation.js \n # accessibility\n if include_sub_navigation?(item)\n item_options[:data][:navigation_parent] = \"\"\n end\n\n if accessible && include_sub_navigation?(item)\n # Add data-toggle attributes\n if has_toggles\n item_options[:data][:toggle_anchor] = build_item_key(item)\n item_options[:data][:toggle_timing] = \"100\"\n item_options[:data][:toggle_temporary_anchor] = \"\"\n end\n\n # Render the button with all the options\n if has_icons\n item_content = \"#{item.name} #{icon('chevron_right')}\"\n else\n item_content = item.name\n end\n content_tag('button', item_content, item_options)\n else\n if suppress_link?(item)\n content_tag('span', item.name, item_options)\n else\n link_to(item.name, item.url, item_options)\n end\n end\n end",
"def process_toc(post, items, toc_title)\n begin\n toc = \"<div class=\\\"toc\\\">\\n\"\n toc += \"p(#toc_title). #{toc_title}\\n\"\n base_level = items.first[:level] - 1\n items.each do |item|\n depth = item[:level] - base_level\n toc += \"#{\"*\"*depth}(depth_#{depth}) \\\"(toc_link)#{item[:link_text]}\\\":##{item[:id]}\\n\"\n end\n\n toc += \"\\n</div>\"\n post.content.gsub!(/<!-- TOC -->/, toc)\n rescue\n puts \"Depth error in #{post.title}\"\n items.each do |item|\n base_level = items.first[:level] - 1\n puts \"Level: #{item[:level]} Depth: #{item[:level] - base_level} Title: #{item[:link_text]}\"\n end\n end\n end",
"def recurse(item_index, items, bins)\n if item_index > items.last\n pp bins\n return\n end\n\n bins.each do |bin|\n bin.push(item_index)\n recurse(item_index+1, items, bins)\n bin.delete(item_index)\n end\nend",
"def draw_tree(item, selector, tab=nil, is_last=true, items_index=0)\n space = ' '\n if items_index < 10\n print ' '\n elsif items_index < 100\n print ' '\n elsif items_index > 999 # good god, man!\n space = ''\n end\n print items_index.to_s + \":\" + space\n\n if tab\n print tab\n if is_last\n print '`-- '\n tab += ' '\n else\n print '+-- '\n tab += '| '\n end\n else\n print '. '\n tab = ''\n end\n\n if self == item || $sugarcube_view == item\n print \"\\033[1m\"\n end\n if item.is_a? NSView\n puts \"#{item} frame: [[#{item.frame.origin.x}, #{item.frame.origin.y}], [#{item.frame.size.width}, #{item.frame.size.height}]]\"\n else\n puts item.to_s\n end\n if self == item || $sugarcube_view == item\n print \"\\033[0m\"\n end\n\n if selector.is_a? Proc\n items = selector.call(item)\n else\n items = item.send(selector)\n end\n items ||= []\n\n items.each_with_index { |subview, index|\n items_index += 1\n if self.respond_to? :draw_tree\n items_index = draw_tree(subview, selector, tab, index == items.length - 1, items_index)\n else\n items_index = SugarCube::Adjust::draw_tree(subview, selector, tab, index == items.length - 1, items_index)\n end\n }\n\n return items_index\n end",
"def path\n html = ''\n a = []\n m = DcBigMenu.find( @parent.page.menu_id )\n a << m\n while m.parent \n m = DcBigMenu.find( m.parent )\n a << m\n end\n# \n (a.size - 1).downto(0) do |i| \n html << \"<span id=menu-path-#{a.size - 1 - i}>\"\n html << link_4menu(a[i]) \n html << (i > 0 ? ' » ' : '') #›➔\n html << '</span>'\n end\n# Save level to parents params object\n @parent.params[:menu_level] = a.size\n html\nend",
"def list_recur_print(item, desc = 0)\n item.children.each do |child|\n next if child.hidden?\n print_item child, desc\n list_recur_print(child, desc + 2)\n end\n end",
"def ul_li_menu menu_name, options = {}, &block\n\traise 'no block given' unless block_given?\n\n\t# collection\n\tif options[:root]\n\t begin\n\t collection = Page.find_by_name(options[:root]).self_and_descendants\n\t rescue\n\t collection = []\n\t end\n\telse\n\t collection = Page.find(:all, :order => 'lft ASC')\n\tend\n\n\t# one SQL!\n\tpages = []\n\tPage.each_with_level(collection) do |page,level|\n\t pages << {\n\t :page => page,\n\t :level => level,\n\t :visible => page.visible_in_menu?(menu_name)\n\t }\n\tend\n\n\t# deleting invisible pages\n\tthis_level = 0\n\tdestroy_this_level = false\n\tpages.each_index do |i|\n\t if destroy_this_level and (pages[i][:level] > this_level)\n\t pages[i] = nil\n\t else\n\t this_level = pages[i][:level]\n\t if pages[i][:visible]\n\t destroy_this_level = false\n\t else\n\t destroy_this_level = true\n\t pages[i] = nil\n\t end\n\t end\n\tend\n\tpages.compact!\n\n\t# detecting children(ето делается для избежания дополнительного SQL-запроса)\n\tpages[0..-2].map! do |p|\n\t p.update(:have_children => p[:level] < pages[pages.index(p)+1][:level])\n\tend\n\tpages.last.update(:have_children => false) unless pages.empty?\n\n\t# draw menu\n\tunless pages.empty?\n\t ul_li_for(pages,options,&block)\n\telse\n\t warning('pages array empty')\n\tend\n end",
"def open_node_hierarchy(tree, items)\n return if items.blank?\n\n items.each { |node| tree.open_node(TreeNode.new(node).key) }\n end",
"def site_page_navigation_menu(pages, menu_html={}, item_html={})\n content_tag :ul, menu_html do\n pages.each do |page|\n site_page_navigation_item(page.name, page_path(page), item_html)\n end\n end\n end",
"def default\n html = '<div class=\"menu0-div\"><ul>'\n @selected = find_selected\n level_0 = DcBigMenu.where(dc_site_id: @site._id, parent: nil, active: true).sort(order: 1).to_a\n level_0.each do |item|\n# menu can be hidden from user \n can_view, msg = dc_user_can_view(@parent, item)\n next unless can_view\n klas = item.id == @selected.id ? \"menu0-selected\" : \"menu0-item\"\n html << \"<li class='#{klas}'>#{ link_4menu(item) }</li>\\n\"\n end\n html << \"</ul></div>\"\n# submenu\n level_1 = DcBigMenu.where(dc_site_id: @site._id, parent: @selected.id, active: true).sort(order: 1).to_a\n html << \"<div class='menu1-div'><ul>\\n\"\n level_1.each do |item1|\n# menu can be hidden from user \n can_view, msg = dc_user_can_view(@parent, item1)\n next unless can_view\n html << \" <li class='menu1-item'>#{link_4menu(item1)}</li>\\n\"\n end\n html << '</ul></div>'\nend",
"def index\n @guide_subitems = Guide::Subitem.order(:ordinal)\n end",
"def visit_nodes(nodes, my_left, parent, depth, tree, url, restricted)\n nodes.each do |item|\n my_right = my_left + 1\n my_restricted = item['restricted'] || restricted\n urls = process_url(url, item)\n\n if item['children']\n my_right, tree = visit_nodes(item['children'], my_left + 1, item['id'], depth + 1, tree, urls[:children_path], my_restricted)\n end\n\n tree[item['id']] = TreeNode.new(my_left, my_right, parent, depth, urls[:my_urlname], my_restricted)\n my_left = my_right + 1\n end\n\n [my_left, tree]\n end",
"def allnewsub\n levels = [1, 2, 3, 4, 5]\n if (params.has_key?:levels)\n levels = []\n levels_int = params[:levels].to_i\n for l in [1, 2, 3, 4, 5]\n if (levels_int & (1 << (l-1)) != 0)\n levels.push(l)\n end\n end\n end\n section_condition = ((params.has_key?:section) and params[:section].to_i > 0) ? \"problems.section_id = #{params[:section].to_i}\" : \"\"\n @submissions = Submission.joins(:problem).joins(problem: :section).select(needed_columns_for_submissions(true)).includes(:user, followings: :user).where(:status => :waiting, :visible => true).where(section_condition).where(\"problems.level in (?)\", levels).order(\"submissions.created_at\").to_a\n end",
"def nodeAsHTML(node, level)\n output = \"\"\n indent = \"\\t\" * level.size\n max = level.size\n \n special = false\n\n if node.title\n output += indent + '<dt>'\n \n prefix = \"\"\n index = 0\n maxIndex = level.size - 1\n level.each do |sect|\n prefix += sect.to_s\n if index < maxIndex\n prefix += \".\"\n end\n index = index + 1\n end\n node.levelPrefix = prefix\n \n output += \"#{prefix}</dt>\\n\"\n\n output += indent + '<dd>'\n if node.pageID\n output += '<a href=\"' + linkToPageIDFrom(node.pageID, \"toc\") + '\" target =\"main\">' + CGI::escapeHTML(node.title) + '</a>'\n else\n output += CGI::escapeHTML(node.title)\n end\n output += \"</dd>\\n\"\n\n output += indent + '<dd class=\"special\">' + \"\\n\"\n special = true\n end\n \n if node.childNodes.size > 0\n level.push(1)\n output += indent + '<dl>' + \"\\n\"\n node.childNodes.each do |childNode|\n output += nodeAsHTML(childNode, level)\n end\n output += indent + \"</dl>\\n\"\n level.pop\n end\n \n if special\n output += indent + \"</dd>\\n\"\n end\n \n if level.size > 0\n level[-1] = level[-1] + 1\n end\n return output\nend",
"def decreaseLevels(levels)\n @level = @level - levels >= 1? @level-levels : 1 \n end",
"def find_all_sidebar_submenu_category(category)\n if !category.children.empty?\n html_code = ''\n category.children.each do |sub_category|\n html_code += '<div class=\"col-sm-12 col-md-3\">\n <ul class=\"links list-unstyled\">'\n html_code += print_sidebar_submenu_category(sub_category)\n html_code += '</ul></div>'\n end\n end\n html_code += ''\n end",
"def displayed_main_menus\n $displayed_main_menus = @session.all(:xpath,MAIN_MENUS_XPATH).size\n k = 0\n $menu_list = Array.new\n for i in 1..$displayed_main_menus do\n menu_xpath =\"//*[@id='menu']/div/div/div/ul/li[\"+i.to_s+\"]/a\"\n menu_name = @session.find(:xpath,menu_xpath).text\n $menu_list.insert(k,menu_name)\n k=k + 1\n end\nend",
"def displayed_main_menus\n $displayed_main_menus = @session.all(:xpath,MAIN_MENUS_XPATH).size\n k = 0\n $menu_list = Array.new\n for i in 1..$displayed_main_menus do\n menu_xpath =\"//*[@id='menu']/div/div/div/ul/li[\"+i.to_s+\"]/a\"\n menu_name = @session.find(:xpath,menu_xpath).text\n $menu_list.insert(k,menu_name)\n k=k + 1\n end\nend",
"def index\n @nodes = Node.find(:all,:order => :lft)\n \n @node_list = []\n 0.upto(@nodes.size-1) do |i|\n node = @nodes[i]\n links = []\n if i > 0\n \tprev_node = @nodes[i-1]\n \tif prev_node.level == node.level\n links << {:link_type=> :arrow_right, :to => 'child_of', :dest_id => prev_node}\n \tend\n \tif prev_node.level < node.level\n links << {:link_type=> :arrow_left, :to => 'right_of', :dest_id => prev_node}\n \tend\n links << {:link_type=> :arrow_up, :to => 'left_of', :dest_id => prev_node}\n end\n if i < @nodes.size-1\n (i+1).upto(@nodes.size-1) do |n|\n if @nodes[n].level <= node.level\n links << {:link_type=> :arrow_down, :to => 'right_of', :dest_id => @nodes[n]}\n break\n end\n end\n end\n @node_list << [node,links]\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def create_child_items\n category.path.each do |category|\n create_child_item_for_category category\n end\n end",
"def make_tree(in_list, pid = self.pid)\n [].tap do |top_level|\n left_over = []\n # Categorize into top level, or not top level\n in_list.each do |node|\n if node['parent_page_id'].blank? || node['parent_page_id'] == pid\n top_level.unshift node\n else\n left_over.unshift node\n end\n end\n\n # For each of the top_level nodes make a subtree with the leftovers.\n top_level.each do |node|\n node['children'] = make_tree(left_over, node['id'])\n end\n end\n end",
"def cut_by_level(desired)\n if desired > level\n [all_members]\n else\n members.map { |m| [m] } + @children.flat_map { |c| c.cut_by_level(desired) }\n end\n end",
"def link_tree\n ''.html_safe.tap do |content|\n content << toggle_link\n\n unless leaf?\n content << h.content_tag(:ul) do\n h.content_tag_for(:li, children) do |c|\n c.decorate.link_tree\n end\n end\n end\n end\n end",
"def nav_sub_menu_item(sub_menu_label, permission, route = '#', title = '', options = {})\n model_name = route.gsub( /(new|path|admin|_|\\/)/, '').strip.capitalize.singularize.constantize\n controller = route.gsub(/(new|path|admin|_|\\/)/, '').strip.downcase.underscore.pluralize\n sub_menu_label = t(\"activerecord.models.#{sub_menu_label}\")\n action, sub_menu_label = permission.eql?(:create) ? [:new, \"Cadastrar #{sub_menu_label}\"] : [:index, \"Listar #{sub_menu_label}\"]\n new_route = { :controller => \"admin/#{controller}\", :action => action }\n content_tag(:li, link_to(sub_menu_label, new_route, :title => title)) if can? permission, model_name\n end",
"def menu_html\n menu = wiki.settings.menu\n if !menu.nil?\n html = \"<ul>\\n\"\n menu.each do |item|\n title, href = item['title'], item['href']\n if version != 'master' && item['href'].index('/') == 0\n prefix = version.start_with?('v') ? \"/#{version}\" : \"/v#{version}\"\n else\n prefix = \"\"\n end\n html << \"<li class=\\\"minibutton\\\"><a href=\\\"#{prefix}#{href}\\\">#{title}</a></li>\\n\"\n end\n html << \"</ul>\\n\"\n end\n end",
"def render_facet_hierarchy_item(field_name, data, key)\n item = data[:_]\n subset = data.reject { |k,v| ! k.is_a?(String) }\n \n li_class = subset.empty? ? 'h-leaf' : 'h-node'\n li = ul = ''\n \n if item.nil?\n li = key\n elsif facet_in_params?(field_name, item.qvalue)\n li = render_selected_qfacet_value(field_name, item)\n else\n li = render_qfacet_value(field_name, item)\n end\n \n unless subset.empty?\n subul = subset.keys.sort.collect do |subkey| \n render_facet_hierarchy_item(field_name, subset[subkey], subkey) \n end.join('')\n ul = \"<ul>#{subul}</ul>\".html_safe\n end\n \n %{<li class=\"#{li_class}\">#{li.html_safe}#{ul.html_safe}</li>}.html_safe\nend",
"def list\n #\n @menu_items = []\n # Loop through\n MenuItem.where('nested_under_id is NULL').order('ordinal').each do |item|\n if item.roles.count > 0\n item.roles.each do |role|\n @menu_items << item if current_user.isinrole(role.id)\n end\n else\n @menu_items << item\n end\n end\n # Hand out the member items\n render status: 200, json: @menu_items.as_json(include: { nested_items: { } })\n end",
"def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end",
"def navigation(options = {})\n options.reverse_merge!( page: @page, depth: 1 )\n page = options[:page]\n children = page.home? ? page.navigable_children : page.parent.navigable_children\n html = (is_home_and_shown_in_nav?(page) ? nav_link(Page.home) : '').html_safe\n html << list_items(children, options[:depth])\n content_tag(:ul, html, options.slice(:id, :class))\n end",
"def dropdown_menu(name, path, menu_sub_items)\n caret = content_tag(:b, '', class: 'caret')\n content_tag(:li, '', class: 'dropdown') do\n link_to(raw(name + caret), path, {'data-toggle' => 'dropdown', class: 'dropdown-toggle'}) +\n content_tag(:ul, raw(menu_sub_items.join(\" \")), class: 'dropdown-menu')\n end\n end"
] | [
"0.6414822",
"0.59429574",
"0.5788237",
"0.55942804",
"0.55320394",
"0.5193488",
"0.51562625",
"0.513643",
"0.5130661",
"0.510976",
"0.49862352",
"0.4950537",
"0.4905398",
"0.48753336",
"0.4870776",
"0.4865183",
"0.48480874",
"0.48325905",
"0.48297837",
"0.48096552",
"0.47922045",
"0.4711342",
"0.46998155",
"0.46824798",
"0.46819407",
"0.4670542",
"0.46436217",
"0.4628467",
"0.46226975",
"0.46199134",
"0.461175",
"0.46026275",
"0.45994303",
"0.4568186",
"0.45596802",
"0.4543613",
"0.4519718",
"0.4519718",
"0.44822046",
"0.44817612",
"0.4477757",
"0.44733205",
"0.44690302",
"0.44685838",
"0.44658837",
"0.44639596",
"0.44520453",
"0.4444575",
"0.4438352",
"0.4436643",
"0.44264647",
"0.441442",
"0.44101268",
"0.4402939",
"0.43999064",
"0.43938285",
"0.43865806",
"0.43767115",
"0.43767115",
"0.43714118",
"0.43619466",
"0.43601316",
"0.43469083",
"0.43378612",
"0.43355817",
"0.43323177",
"0.43113947",
"0.43055692",
"0.43039483",
"0.430062",
"0.4299401",
"0.42912272",
"0.42884612",
"0.4253256",
"0.42498422",
"0.42484227",
"0.4240053",
"0.42310405",
"0.42269328",
"0.42223603",
"0.4221372",
"0.421523",
"0.42128742",
"0.42118436",
"0.42062438",
"0.4205083",
"0.41807023",
"0.41807023",
"0.4179628",
"0.41713858",
"0.41706976",
"0.41690424",
"0.41687694",
"0.41616037",
"0.4156116",
"0.41456664",
"0.41397324",
"0.4139606",
"0.4134475",
"0.4132413"
] | 0.77893 | 0 |
Get the input from user input | def start
puts 'Enter size of matrix'
grid_size = gets.to_i
fail 'Grid size should be < 100 ' if grid_size > 100
# position of bot
puts 'Enter the position of bot(m) separated by space Ex: 0 2'
bot_pos_x, bot_pos_y = gets.strip.split.map(&:to_i)
# Get matrix rows from user input
puts 'Specify matrix rows: Values must be separated by space'
princess_position = get_princess_position(grid_size)
# Find the next move
puts next_move(bot_pos_x, bot_pos_y, princess_position)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_input\n\tgets\nend",
"def get_input\n @input = gets.strip\n end",
"def get_input\n input = gets\n return input\nend",
"def get_input\n gets.chomp\n end",
"def get_input(*msg)\n print *msg\n return gets.strip\n end",
"def get_input\n @input = gets.chomp\n end",
"def get_input\n #Get input from the user\nend",
"def get_user_input\n input = gets.chomp\n #input\nend",
"def get_input(question)\n\t\tputs \"What's your #{question}?\"\n\t\tgets.chomp\nend",
"def get_input\n\t#Get input from the user.\n return gets.chomp\nend",
"def get_input\n gets.chomp \nend",
"def get_user_input\n gets.chomp\nend",
"def get_user_input\n gets.chomp\nend",
"def fetch_input(question_to_user)\n print question_to_user\n gets.chomp # return not needed\nend",
"def get_input\n begin\n inp = gets.chomp\n raise Error unless %w{s h d}.include?(inp)\n rescue\n retry\n end\n inp\n end",
"def get_user_input\n user_input_valid gets.chomp\n end",
"def get_user_input\n gets.strip\nend",
"def get_user_input\n print \">> \"\n input = gets.chomp\n begin\n parse_user_input(input)\n rescue StandardError\n invalid_command\n end\n end",
"def get_user_input(message)\n puts message\n gets.chomp\n end",
"def user_input\n input = gets.chomp\n end",
"def gets\n @input.gets\n end",
"def get_input\n story = gets.chomp\nend",
"def ask\n gets.strip\n end",
"def get_input;\t@input \t\tend",
"def get_input\n gets.strip #chomp was also used..\nend",
"def input\n @input ||= args.dig(:input)\n end",
"def user_input\n\tuser_selection = gets.strip.to_i\n\tinput_logic(user_selection)\nend",
"def ask_for(detail)\n puts \"Enter #{detail}\"\n STDIN.gets.chomp \nend",
"def captureInput\n return gets.chomp\n end",
"def get_input \n puts \"to save this game, input 's,filename'\"\n puts \"to load a game, input 'l,filename'\"\n puts \"input a coordinate to access. prefix with r for reveal or f for flag\"\n puts \"example 'f,1,2' places a flag at 1,2\"\n input = gets.chomp\n \n args = input.split(',')\n end",
"def get_input\n puts \"Please enter a search term(s)\"\n input = gets.chomp\n puts \"You've entered #{input}\"\n input\nend",
"def input_name\n\tname = gets.chomp\nend",
"def gets_input\n\tgets.strip\nend",
"def user_input\n gets.chomp\nend",
"def user_input\n gets.chomp\nend",
"def user_input\n user_input = gets.chomp\nend",
"def read_input\n end",
"def ask_input\n\t\tputs \"where do you want to go ? N, S, W, E\"\n\t\tuser_input = gets.chomp\n\tend",
"def get_input message\n\n puts message\n input = gets.chomp.downcase\n\nend",
"def input(thing)\n print \"Enter #{thing}: \"\n gets.chomp\nend",
"def get_user_input(prompt)\n print \"#{prompt}: \"\n gets.chomp\nend",
"def get_input(prompt)\n #get a message to display to the user and return the entered value\n print prompt\n gets.chomp\nend",
"def prompt_and_get_input_from_user\n prompt_user\n input = $stdin.readline.strip\nend",
"def user_input_capture\n print \">>: \"\n response = gets.chomp\n response\n end",
"def get_user_input\n input = @prompt.ask(\"Enter a series_name:\".red)\n end",
"def getInput ( question )\n puts question\n response = STDIN.gets.strip\n puts\n response\nend",
"def stdinput\n @input\n end",
"def user_input\n Rushmate::UserInput\n end",
"def get_answer_to(question)\n puts question\n answer = gets.chomp\n return answer\nend",
"def ask_user_for(something)\n puts \"What is the recipe #{something} ?\"\n return gets.chomp\n end",
"def get_user_input(input) \n # case statement\n # puts Contact.all\n choice = input[0]\n case choice\n when 'new'\n puts \"you choose new\"\n puts Contact.create(input[1], input[2])\n when 'list'\n puts \"you choose list\"\n puts contact_array = Contact.all\n puts \"Total contacts: #{contact_array.length}\"\n when 'show'\n puts \"you choose show by ID\"\n # Contact.all\n puts Contact.find(input[1].to_i)\n when 'search'\n puts \"you choose search\"\n # Contact.all\n p Contact.search(input[1].downcase)\n else \n display_menu\n # choice = gets.chomp\n # get_user_input(choice)\n end\n end",
"def input msg\n puts msg\n print \" \"\n return STDIN.gets.chomp\nend",
"def input; @input; end",
"def input; @input; end",
"def get_input(question)\n\t# ask question \n \t# check to make sure something has been entered:\n \tanswer = \"\"\n\twhile answer.empty?\n\t\tputs question\n\t\t#get input and remove NewLine character\n\t\tanswer = gets.delete(\"\\n\")\n\tend\n\tanswer\nend",
"def get_input_main\n input = gets.chomp.downcase\n case input\n when 'all'\n flight_list \n when 'year'\n year\n when 'rocket'\n rocket\n when 'success'\n success_failure\n when 'number'\n flight_number\n when 'mission'\n mission_name\n when 'random'\n random\n when 'exit'\n exit\n else \n begin\n raise Error\n rescue Error => error\n Error.invalid_input\n get_input_main\n end\n end\n end",
"def get_answer_to(question)\n puts question\n answer = gets.chomp\nend",
"def input; end",
"def input; end",
"def input; end",
"def get_input(question)\n\t# ask question \n \t# check to make sure something has been entered:\n\n \tanswer = \"\"\n \tputs answer.empty?\n\twhile answer.empty?\n\t\tputs question\n\t\t#get input and remove NewLien character\n\t\tanswer = gets.delete(\"\\n\")\n\tend\n\treturn answer\nend",
"def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend",
"def fetch_input(prompt)\n\tprint prompt\n\tgets.chomp #implicit return again\nend",
"def get_user_input\n puts 'Welcome to Google Books Searcher'\n puts 'Enter a search term:'\n gets.chomp\nend",
"def input\n @options[:input]\n end",
"def read_from_console\n puts 'Enter URL, please:'\n @url = STDIN.gets.chomp\n\n puts 'Enter the name to this link, please:'\n @text = STDIN.gets.chomp\n end",
"def get_user_input\n puts \"Please enter a search term\"\n gets.chomp\nend",
"def get_user_choice\n @user_choice = gets.chomp\n end",
"def read_input; end",
"def user_input_value()\n puts \"Enter a value: \"\n value = gets.chomp.to_s\n return value\nend",
"def input(type)\r\n print \"#{type}>\"\r\n gets.chomp\r\nend",
"def prompt_input\n class_invariant\n print ps1\n command = gets.chomp\n class_invariant\n return command\n end",
"def user_imput\n gets.chomp\n end",
"def get_input(variable_symbol, question=nil)\n present(question, newline: false) if question\n\n # creating this method allows us to test it easily\n # without requiring terminal input\n set_input_variable(variable_symbol, gets.chomp)\n\n end",
"def get_user_input\n print \"username: \"\n username = STDIN.gets.chomp\n\n print \"password: \"\n password = STDIN.noecho(&:gets).chomp\n end",
"def get_name\n\tputs \"Name:\"\n\tname = gets.chomp\nend",
"def get_input\n\t\tputs \"Press 1 to raise by 100\"\n\t\tputs \"Press 2 to call\"\n\t\tputs \"Press 3 to fold\"\n\t\tinput = gets().chomp().to_i\n\t\treturn input\n\n\tend",
"def get_input\n user = Input.new\n loop do\n input = user.get_input\n return loss(input) if self[input].value == \"O\"\n return reveal_adjacent_cells(input) if !self[input].show\n puts \"Invalid input\"\n end\n end",
"def get_user_input\n puts\n puts \"Type your question below or select from the following:\"\n puts\n puts \"1) Type Q to exit program\"\n puts\n puts \"2) Type P to print all answers\"\n puts\n puts \"3) Type R to reset answers to originals\"\n puts\n puts \"4) Type A to add your own answers to the originals\"\n puts\n question = gets.strip.to_s.downcase\n puts\n handle_user_input(question)\n end",
"def begin_input\n\t\tinput = nil\n\t\tuntil input != nil\n\t\t\tinput = case gets.chomp.downcase\n\t\t\twhen \"hard\", \"h\" then :hard\n\t\t\twhen \"medium\", \"m\" then :medium\n\t\t\twhen \"mom\" then :mom\n\t\t\telse nil\n\t\t\tend\n\t\t\tputs \"That is not a valid input!\" if not input\n\t\tend\n\t\tinput\n\tend",
"def text_input; end",
"def gets_user_input\n input = gets.chomp\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # binding.pry\n\n if input == \"exit\"\n exit\n end\n\n return input\n end",
"def input(applied_action_as_symbol_or_string = :inspect)\r\n gets.send(applied_action_as_symbol_or_string)\r\nend",
"def player_input\n print \"> \"\n input = gets.chomp\n puts \"\\n\"\n return input\nend",
"def player_input\n print \"> \"\n input = gets.chomp\n puts \"\\n\"\n return input\nend",
"def name_of_person\n\tputs 'What is you name?'\n\ttheir_name = gets\nend",
"def ask_user_for(something)\n # Print question asking for the name, price, or something else\n puts \"What is the #{something.capitalize}?\"\n print \"> \"\n # return the user´s input\n return gets.chomp\n end",
"def get_input input\n\n case input\n\n # avancar\n when 'a'\n case menu\n when 'do_inicio',\n 'continuar' then line_forth\n when 'escrevendo' then next_char\n when 'ler' then @filelist.rotate!\n else next_option\n end\n\n # voltar\n when 'v'\n case menu\n when 'do_inicio',\n 'continuar' then line_back\n when 'escrevendo' then last_char\n when 'ler' then @filelist.rotate! -1\n else last_option\n end\n\n # fim\n when 'f'\n case menu\n when 'escrevendo' then end_of_text\n end\n\n # enter\n when 'e'\n case menu\n\n when 'ler'\n @filename = @filelist.first[:file]\n seleciona_ler_modo\n\n when 'principal',\n 'ler_modo'\n self.send \"seleciona_#{@options.first.gsub(\" \",\"_\")}\"\n\n when 'escrever'\n @writer = Writer.new('nota')\n @options = ['nota']\n seleciona_escrevendo\n\n when 'escrevendo' then end_of_line\n\n when 'salvar' then save_action\n\n end\n\n # backspace\n when 'b'\n case menu\n when 'escrevendo' then delete_char\n end\n\n # esc\n when 's'\n case menu\n when 'ler','escrever' then seleciona_principal\n when 'ler_modo',\n 'do_inicio',\n 'continuar' then seleciona_ler\n when 'escrevendo'\n save_options\n seleciona_salvar\n end\n\n # inputs de dados\n else\n case menu\n when 'escrevendo' then insert_char(input)\n end\n end\n\n end",
"def get_name()\n puts \"Please enter your name\"\n name = gets.chomp\n return(name)\nend",
"def pt;z.gets 'Your choice:'; end",
"def input\n @all[:input]\n end",
"def read_user_input(message, default = \"\", show_input = true)\n print interpolate_message(message, default)\n show_input ? gets : silent_command { gets }\n ($_.chomp.empty?) ? default.chomp : $_.chomp\n end",
"def get_input\n puts \"Input [L] to turn Left, [R] to turn right and [M] to move your Mars rover forward. Type [Q] to leave. See you, Space Cowboy\"\n @input = gets.chomp.downcase\n # Loops through the array of inputs to specify commands for each specific instruction with a case statement\n @input.each_char do |i|\n case i\n # If l is inputted, make the Rover face left\n when \"l\"\n turn_left\n # If r is inputted, make the Rover face right\n when \"r\"\n turn_right\n # Get the rover to move forward in the direction it's facing.\n when \"m\"\n move\n # Exit the game when q is typed\n when \"q\"\n exit\n end\n # Convert the results to a string\n to_s\n end\n end",
"def get_input\n puts \"Please enter the 10 digit number :\"\n form_words gets.chomp\n end",
"def input\n puts \"It's #{@player_turn.capitalize}'s turn. Please enter your move/ command.\"\n @input = gets.chomp.upcase\n end",
"def user_input\n print \"Say your thang\"\n user_comment = get.chomp.downcase\nend",
"def do_input\n prompted, item = input_prompt\n print '? ' unless prompted\n val = $stdin.gets.chomp\n\n # All digits (and decimal point)\n val = (val.include?('.') ? val.to_f : val.to_i) if val =~ NUMBER_REGEX\n\n @variables[item.value] = val\n end",
"def get_input(original_input, msg)\n if original_input.nil?\n puts \"#{msg}: \\n\"\n new_input = STDIN.gets.chomp\n if !new_input.nil? && new_input.length > 0\n return new_input\n else\n # keep bugging the user until they answer or despair\n puts \"Please enter a valid response\"\n get_input(nil, msg)\n end\n else\n return original_input\n end\nend",
"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 input\n print '>> '\n $input = gets.chomp.downcase\n end",
"def user_input()\n return gets.chomp.to_i\n end"
] | [
"0.83598006",
"0.82188255",
"0.8194689",
"0.8076257",
"0.8055432",
"0.8031101",
"0.80216414",
"0.79102564",
"0.78491485",
"0.78305614",
"0.78255945",
"0.7813109",
"0.7813109",
"0.7812008",
"0.77891475",
"0.7775199",
"0.7749966",
"0.77125245",
"0.7711839",
"0.7694568",
"0.7663573",
"0.7608137",
"0.7577603",
"0.75735354",
"0.7566096",
"0.75441104",
"0.75275254",
"0.7513037",
"0.750829",
"0.7505633",
"0.74868196",
"0.74686563",
"0.7465245",
"0.7463025",
"0.7463025",
"0.7432596",
"0.7428865",
"0.7425553",
"0.7405452",
"0.73821795",
"0.7377031",
"0.7355765",
"0.73392844",
"0.7261173",
"0.7236921",
"0.7215488",
"0.71964425",
"0.71742153",
"0.7172773",
"0.71664625",
"0.71663624",
"0.7158787",
"0.7151697",
"0.7151697",
"0.71455973",
"0.71323955",
"0.7126349",
"0.7115014",
"0.7115014",
"0.7115014",
"0.7112775",
"0.7112699",
"0.71087784",
"0.70988625",
"0.70957774",
"0.70895636",
"0.70851755",
"0.70842636",
"0.7075251",
"0.70426226",
"0.70305765",
"0.7030547",
"0.702767",
"0.70137924",
"0.70127857",
"0.7010759",
"0.70092165",
"0.6998659",
"0.69931054",
"0.6991551",
"0.6989563",
"0.6989007",
"0.69829684",
"0.6972",
"0.6972",
"0.6966177",
"0.69564104",
"0.69479215",
"0.69446653",
"0.6940451",
"0.6939665",
"0.6920743",
"0.6912389",
"0.6910564",
"0.69100726",
"0.6904098",
"0.6896007",
"0.688984",
"0.6885277",
"0.6883701",
"0.6883669"
] | 0.0 | -1 |
Find princess position from user input matrix rows | def get_princess_position(grid_size)
princess_position = nil
grid = Array.new(grid_size)
(0...grid_size).each do |i|
grid_row = gets.split
princess_position = [i, grid_row.index('p')] if grid_row.include? 'p'
grid[i] = grid_row
end
princess_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coord_to_pos(row,col)\n return nil if row.even? && col.even? || row.odd? && col.odd? #these are always empty squares in checkers!\n return row*4+(col/2).floor+1\n end",
"def index_of_position(row, col = 0)\n\t\tline_index(row) + col + 1\n\tend",
"def find_position(grid, p_m)\n grid.each_with_index do |row, index|\n @position_x = index\n @position_y = row.index(p_m)\n break if @position_y\n end\n fail \"#{p_m == 'p' ? 'Princess' : 'Bot'} not found\" unless @position_y\n [@position_x, @position_y]\n end",
"def get_index_for_pos(prow, pcol)\r\n idx = 0\r\n ct = 0\r\n maxidx = 1e10.to_i\r\n #deblog(\"idx4pos(row:#{prow}, col:#{pcol}) starts; maxidx=#{maxidx}\")\r\n while idx < maxidx\r\n ct += 1\r\n idx += 1\r\n STDERR.print '.' if ct % 1000 == 0\r\n STDERR.puts \">#{idx}: #{get_pos_for_idx(idx)}\" if ct % (1000*100) == 0\r\n aa = get_pos_for_idx(idx)\r\n #deblog(\"aa=#{aa} pos4idx tst #{idx}\")\r\n if aa[0]==prow and aa[1]==pcol\r\n tracelog(\"idx4pos=#{idx} @ [#{prow}, #{pcol}]\")\r\n return idx\r\n end\r\n end\r\n #deblog(\"idx4pos fail=#{idx} @ [#{prow}, #{pcol}]\")\r\n raise \"no pos4idx found\"\r\nend",
"def determine_center_position(rows, columns)\n values = Hash.new \n rows.each do |row| \n columns.each do |column| \n values[@matrix[row][column]] = [row, column]\n end \n end \n highest_value_square(values)\nend",
"def get_vacant_pos col\n vacant_position = nil\n\n @row.times do |idx|\n if @grid[idx][col-1] == \"O\"\n vacant_position = idx + 1\n else\n break\n end\n end\n\n vacant_position\n end",
"def findPrincessPosition(n, grid)\n return calculate_position_coordinates(n, grid, 'p')\nend",
"def position(user_input)\n cells[user_input.to_i - 1]\n end",
"def position(input)\n cell_index_taken = input.to_i-1\n cells[cell_index_taken]\n end",
"def position(user_input)\n return self.cells[user_input.to_i - 1]\n end",
"def position_value(row, col)\n x, y = coordinate = coordinate_for(row, col)\n level = [x.abs, y.abs].max\n if x < level && y > -level\n # return number for top left portion of ring\n first_number(level) +\n steps_between(first_coordinate(level), coordinate)\n else\n last_number(level) -\n steps_between(last_coordinate(level), coordinate)\n end\n end",
"def matrix_find(row, column)\n self[row*9 + column]\n end",
"def mineLocation(field)\n row = 0\n column = 0\n field.each_with_index do |array, index|\n row = index if array.include?(1)\n end\n\n field[row].each_with_index do |num, index|\n column = index if num.eql?(1)\n end\n [row, column]\nend",
"def find_pivot(col, m)\n aux = 999999\n row = 0\n num_cols = m[0].size\n init = m[0][0] == 'z' ? 1:2\n for i in init..m.size-1\n div = (m[i][col] != 0) ? (m[i][num_cols-1] / m[i][col]) : -1\n if div < aux && div >= 0\n aux = div\n row = i \n end\n end\n m[row][0] = 'X' + (col).to_s\n print \"Encontrar o pívot => m[#{row}][#{col}] = #{m[row][col]}\".italic.blue\n row\nend",
"def find(num)\n $pre_grid.each_with_index do |row,row_i|\n row.each_with_index do |e,e_i|\n i = [ row_i, e_i ]\n # special case for finding second 1\n if e.to_i == num && i != $first1\n return i\n end\n end\n end\nend",
"def position(input)\n cells[input.to_i-1]\n end",
"def position(input)\n cells[input.to_i-1]\n end",
"def position(row, column)\n\t\tcolmn = get_column(column)\n\t\treturn colmn[row] unless colmn.nil?\n\tend",
"def position(input)\n\t\tcells[input.to_i - 1]\n\tend",
"def position(input)\n cells[self.idx(input)]\n end",
"def find_princess_position\n position_coordinates('p')\n end",
"def get_destination\n dest_pos = nil\n (0..(@matrix.length - 1)).each { |x| (0..(@m - 1)).each { |y| dest_pos = Point.new(x, y) if @matrix[x][y] == '*' } }\n dest_pos\n end",
"def peek(row, col, direction)\n x, y = [row, col]\n x, y = peek_apply(x, y, direction)\n return 0 unless valid_boundary?(x, y)\n\n begin\n cell = matrix[x][y]\n return 1 if cell == '#'\n return 0 if cell == 'L'\n x, y = peek_apply(x, y, direction)\n end while valid_boundary?(x, y)\n\n 0\n end",
"def position(input)\n cells[input.to_i - 1]\n end",
"def position_coordinates(character)\n which_row = []\n which_cell = []\n (0...@n).each { |i| prepare_set(i, character, which_row, which_cell) }\n [which_row, which_cell]\n end",
"def position (r,c)\n if (0...ROWS).member? r\n if (0...COLS).member? c\n {row: r, col: c, pos: COLS*r + c}\n end\n end\nend",
"def calculate_position_coordinates(n, grid, character)\n which_row = []\n which_cell = []\n (0...n).each do |i|\n grid[i].split('').each_with_index do |k ,index|\n if k == character\n which_row << i\n which_cell << index\n end \n end\n end\n return which_row, which_cell\nend",
"def position(input)\n self.cells[input.to_i - 1]\n end",
"def position(input)\n @cells[input.to_i - 1]\n end",
"def check_prow\n @prow = 0 if @prow < 0\n if @prow > @maxrow-1\n @prow = @maxrow-1\n end\n if @pcol > @maxcol-1\n @pcol = @maxcol-1\n end\n @pcol = 0 if @pcol < 0\n end",
"def position(input)\n @cells[input.to_i-1]\n end",
"def find_index(column, row)\n\n # Column 0 is for shelf numbers, so no index.\n return nil if column == 0\n\n # Find shelf number.\n shelf = ((row + 1) / 2.0).ceil\n\n # Return index number.\n if (row % 2 != 0)\n return 3 * (shelf - 1) + 2\n else\n return 3 * (shelf - 1) + (column - 1)\n end\n\n end",
"def search_matrix(matrix, target)\n (0..matrix[0].length).each do |num|\n p num\n end\nend",
"def row(p)\n x = p * (p - 1)\n y = x + p - 1\n x.upto(y) {|i| cell(p.odd? ? x - i + y : i) }\n end",
"def position(user_input)\n\t\tindex = (user_input.to_i-1)\n\t\tself.cells[index]\n\tend",
"def locate_coordinate(position)\n x = -1\n y = -1\n \n @position_matrix.each_with_index do |array, index| \n if array.include?(position)\n y = index \n x = array.index(position)\n end\n end\n return x, y\n end",
"def find_position(type, color)\n @grid.each_with_index do |row, ridx|\n row.each_with_index do |square, cidx|\n if square != nil && square.type == type && square.color == color\n return [ridx, cidx]\n end\n end\n end\n nil\n end",
"def position(input)\n self.cells[self.input_to_index(input)]\n end",
"def row(position)\n position[0]\n end",
"def get_position(legal_positions)\n pos = nil\n\n until legal_positions.include?(pos)\n puts \"Player #{mark.to_s}, enter two numbers representing a position in the format `row col`\"\n pos = gets.chomp.split(' ').map(&:to_i)\n puts \"#{pos} is not a legal position\" if !legal_positions.include?(pos)\n raise 'sorry, that was invalid :(' if pos.length != 2\n end\n\n pos\n end",
"def valid_locations(r, c)\n positions = []\n #top row\n positions << [r - 1, c - 1]\n positions << [r - 1, c]\n positions << [r - 1, c + 1]\n\n #center row\n positions << [r, c-1]\n positions << [r, c + 1]\n\n #bottom row\n positions << [r + 1, c - 1]\n positions << [r + 1, c]\n positions << [r + 1, c + 1]\n \n #array boundry Check on the list of positions to find those that are on the board\n positions.delete_if {|v| v[0] < 0 || v[0] >= row}.delete_if{|v| v[1] < 0 || v[1] >= column}\n return positions\n end",
"def set_starting_position\n start_rows = find_possible_centers(@matrix.length)\n start_columns = find_possible_centers(@matrix[0].length)\n determine_center_position(start_rows, start_columns)\nend",
"def position(player_input)\n cells[move_to_index(player_input)]\n end",
"def find_next_coords(row_coord, column_coord)\n if column_coord + 1 < canvas.size && !canvas[row_coord][column_coord + 1] && !missing_up?(row_coord, column_coord)\n [row_coord, column_coord + 1]\n elsif row_coord + 1 < canvas.size && !canvas[row_coord + 1][column_coord]\n [row_coord + 1, column_coord]\n elsif column_coord - 1 >= 0 && !canvas[row_coord][column_coord - 1]\n [row_coord, column_coord - 1]\n elsif row_coord - 1 >= 0 && !canvas[row_coord - 1][column_coord]\n [row_coord - 1, column_coord]\n end\n end",
"def getCurrentPosInCsvRow(row)\n x = row[@index_current_position_in_model_x].to_f ;\n y = row[@index_current_position_in_model_y].to_f ;\n z = row[@index_current_position_in_model_z].to_f ;\n return [x,y,z] ;\n end",
"def position\n [ChessBoard.col_index(pos[0]), pos[1].to_i]\n end",
"def start\n puts 'Enter size of matrix'\n grid_size = gets.to_i\n fail 'Grid size should be < 100 ' if grid_size > 100\n\n # position of bot\n puts 'Enter the position of bot(m) separated by space Ex: 0 2'\n bot_pos_x, bot_pos_y = gets.strip.split.map(&:to_i)\n\n # Get matrix rows from user input\n puts 'Specify matrix rows: Values must be separated by space'\n princess_position = get_princess_position(grid_size)\n\n # Find the next move\n puts next_move(bot_pos_x, bot_pos_y, princess_position)\nend",
"def evaluate_position_as player, row, col, win_condition, score\n\n result = 0\n\n # score of 0, we cant place it there\n if row >= @row\n return result\n end\n\n @board.data[row][col] = player.generate_token\n\n @board.get_neighbours(row, col, win_condition.length).each do |neighbours|\n\n if check_if_neighbour_win neighbours, win_condition\n result = score\n break\n end\n end\n\n # function does not reset the board\n return result\n\n end",
"def pos(a,b)\n\t\t@mat[a][b]\n\tend",
"def position\n [row.position, column.position]\n end",
"def position(input)\n if input.to_i.between?(1,9)\n @cells[input.to_i - 1]\n end\n end",
"def search_in_sorted_matrix(matrix, target)\n row = 0\n col = matrix[0].length - 1\n while row < matrix.length && col >= 0\n if matrix[row][col] > target\n col -= 1\n elsif matrix[row][col] < target\n row += 1\n else\n return [row, col]\n end\n end\n return [-1, -1]\nend",
"def find_row(temp)\n array_row = 0\n rows = [1, 3, 5, 7, 9, 11]\n rows.each do |row|\n unless @display[row][temp..(temp + 4)] != '37;49'\n array_row = row\n end\n end\n array_row\n end",
"def get_start(processed_maze)\n # start_horizontal; start_vertical = nil\n processed_maze.each_with_index do |row, vertical_index|\n row.each_with_index do |item, horizontal_index|\n if item == 'o'\n @start_vertical = vertical_index\n @start_horizontal = horizontal_index\n end\n end\n end\n end",
"def row_winning_move\n\t\[email protected]_with_index do |row, r|\n\t\t\tother_nil_index = contains_two_marks(row)\n\t\t\tif(other_nil_index)\n\t\t\t\treturn [r, other_nil_index]\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def positions(passes) = passes.map { find_position(_1) }",
"def search_sorted_matrix(array, target)\n row = 0\n col = matrix[0].length - 1\n\n while row < array.length && col >= 0\n if matrix[row][col] > target\n col -= 1\n elsif matrix[row][col] < target\n row += 1\n else\n return [row, col]\n end\n end\n\n return [-1, -1]\nend",
"def find_min_elem(matrix)\n min = matrix[1][2]\n indices = [1, 2] \n for i in 1...matrix.length\n for j in i+1...matrix.length\n if ( matrix[i][j] < min )\n min = matrix[i][j]\n indices = [i, j]\n end\n end\n end\n indices\nend",
"def position(input)\n player_position = input.to_i - 1\n @cells[player_position]\n end",
"def get_position(full_move)\n full_move[0..1].map { | num | num.to_i - 1 }\n end",
"def next_row\n observation_matrix.observation_matrix_rows.where('position > ?', position).order(:position).first\n end",
"def getCurrentPosIndexInCsvRow(row)\n pos = getCurrentPosInCsvRow(row) ;\n index = getPosIndex(pos) ;\n if(@posIndexTable[index].nil?) then\n @posIndexTable[index] = index ;\n end\n return @posIndexTable[index] ;\n end",
"def get_row(matrix, row)\n matrix[row].select { |n| !n.nil? }\nend",
"def next_column\n observation_matrix.observation_matrix_columns.where(\"position > ?\", position).order(:position).first\n end",
"def get_index(row, col)\n index, row_end = @row_vector[row], @row_vector[row + 1]\n\n while (index < row_end) and (index < nnz) and (col >= @col_vector[index])\n return [index, @data[index]] if @col_vector[index] == col\n index += 1\n end\n [index, nil]\n end",
"def search_matrix(matrix, target)\n row = matrix.length - 1\n col = 0\n\n until row >= matrix.length || col >= matrix[0].length || row < 0 || col < 0\n p num = matrix[row][col]\n\n return true if num == target\n col += 1 if num < target\n row -= 1 if num > target\n end\n\n false\nend",
"def find_left_entry\n maze[0].each_with_index do |value, index|\n return index if value == open_value\n end\n end",
"def row_col(pos)\n _pos = 0\n row = 0\n col = 1\n @codes.each do |code|\n break if _pos >= pos\n if line_terminator?(code)\n row += 1\n col = 0\n else\n col += 1\n end\n _pos += 1\n end\n return [row+1, col+1]\n end",
"def solution \n row_search \n columns_search \n diagonal_search\n end",
"def adjacent_mines(row, col)\n 0\n end",
"def adjacent_mines(row, col)\n 0\n end",
"def adjacent_mines(row, col)\n 0\n end",
"def row_for(p, r)\n if p <= 1\n cell(0)\n elsif p.odd?\n if r == p - 1\n row(p)\n else\n row_for(p - 1, r)\n col(p, r)\n end\n else\n if r == 0\n row(p)\n else\n col(p, r)\n row_for(p - 1, r - 1)\n end\n end\n end",
"def mineLocation field\n location=[]\n field.each_with_index do |row,index|\n if row.include?(1)\n location << index\n row.each_with_index do |col, idx|\n if col==1\n location << idx\n end\n end\n end\n end\n return location\nend",
"def attempt_solution(row, col)\n end",
"def potential_positions\n (0...@all_rotations.size).map do |rot_index|\n shape = @all_rotations[rot_index]\n extent = horiz_extent(shape)\n (0-extent[0][email protected]_columns-extent[1]).map do |x|\n [x, lowest_fit(shape, x), rot_index]\n end\n end.reduce(:+)\n end",
"def get_row(board,row)\n\tboard[row-1]\nend",
"def row_to_px row_number\n\n # Row 0 starts 5 units below the top of the grid.\n # Each row afterward is 20 units lower.\n grid.top.shift_down(5).shift_down(20 * row_number)\n end",
"def calc_coordinate(cell_name)\n col = COLUMNS.index(cell_name.slice /[A-Z]+/)\n row = (cell_name.slice /\\d+/).to_i - 1 # rows in drawings start with 0\n [row, col]\n end",
"def get_index(position:)\n row = (position - 1) / 3\n col = (position - 1) % 3\n return row, col\n end",
"def board_value(s, rw)\n value = 0\n for i in 1..8\n for j in 1..8\n if s[[i, j]] == rw + 1\n # regular pieces worh 1 point\n value = value + 1\n elsif s[[i, j]] == rw + 2\n value = value - 1\n elsif s[[i, j]] == rw + 3\n # kings worth 2 points\n value = value + 2\n elsif s[[i, j]] == rw + 4\n value = value - 2\n end\n end\n end\n value \nend",
"def safe_access(x, y, matrix)\n height = matrix.length\n width = matrix[0].length\n \n if (x >= width) || (x < 0) || (y >= height) || (y < 0)\n return 0\n end\n return matrix[y][x]\nend",
"def min_coordinates\n\t\t\treturn @min_coordinates if @min_coordinates\n\n\t\t\t# Initialize\n\t\t\t# Convert to square matrix by adding zero filled rows or columns.\n\t\t\tif @width < @height\n\t\t\t\tm = @matrix.map do |row|\n\t\t\t\t\trow.dup.fill(0, @width, @height - @width)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tm = @matrix.map {|row| row.dup}\n\t\t\t\t(@width - @height).times do\n\t\t\t\t\tm << Array.new(@width, 0)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 1\n\t\t\tm.each do |row|\n\t\t\t\tmin = row.min\n\t\t\t\tnext row.dup if min.zero?\n\t\t\t\[email protected] {|i| row[i] -= min}\n\t\t\tend\n\n\t\t\t# Step 2\n\t\t\[email protected] do |j|\n\t\t\t\tmin = m.map{|row| row[j]}.min\n\t\t\t\tnext if min.zero?\n\t\t\t\tm.each{|row| row[j] -= min}\n\t\t\tend\n\n\t\t\tloop do\n\t\t\t\t# Step 3\n\t\t\t\tassign, cover = assign_or_cover(m)\n\t\t\t\tif assign\n\t\t\t\t\treturn @min_coordinates = assign.sort.select do |i, j|\n\t\t\t\t\t\ti < @height and j < @width\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Step 4\n\t\t\t\trows_cover, cols_cover = cover\n\t\t\t\t# complement set\n\t\t\t\trows_cover_cmp = (0...@size).to_a - rows_cover\n\t\t\t\tcols_cover_cmp = (0...@size).to_a - cols_cover\n\n\t\t\t\tmin = Float::INFINITY\n\t\t\t\trows_cover_cmp.each do |i|\n\t\t\t\t\tcols_cover_cmp.each do |j|\n\t\t\t\t\t\tv = m[i][j]\n\t\t\t\t\t\tmin = v if v < min\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\trows_cover_cmp.each do |i|\n\t\t\t\t\tcols_cover_cmp.each do |j|\n\t\t\t\t\t\tm[i][j] -= min\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\trows_cover.each do |i|\n\t\t\t\t\tcols_cover.each do |j|\n\t\t\t\t\t\tm[i][j] += min\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def position_result\n hurdle_match.rank.index(self) + 1\n end",
"def discover_points # step 1\r\n x = 0\r\n y = 0\r\n @image_arr.each do |row|\r\n x = 0\r\n row.each do |cell|\r\n if cell == 1 # discovered the cell is 1\r\n @ordinal_arr.push([y,x]) # this is where i push the ordinals.\r\n puts \"#{y},#{x}\"\r\n end\r\n x = x + 1\r\n end\r\n y = y + 1\r\n puts \"\" \r\n end\r\n end",
"def player_index\n\t\t\[email protected]_index do |row|\n\t\t\t\t@grid[row].each_index do |col|\n\t\t\t\t\tif @grid[row][col].respond_to?(:resident) && Person === @grid[row][col].resident\n\t\t\t\t\t\treturn [row, col]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tnil\n\t\tend",
"def line_and_column(pos); end",
"def current_line_pos\n pos - col\n end",
"def execute(m,row,col)\n for i in 0..m.size-1\n aux = m[i][col] \n if aux != 0\n for j in 1..m[0].size-1\n if i != row \n m[i][j] -= (aux * m[row][j]).to_f\n m[i][j] = 0 if m[i][j] > -0.001 && m[i][j] < 0.001\n end \n end\n if i != row \n print \"L#{i} = L#{i}-#{aux<0 ? '('+aux.to_s+')': aux}L#{row} \\n\".italic.blue\n #print_matrix(m,row,col, i)\n end \n end\n end\n m\nend",
"def get_cols_index(col)\n i = @cols.size - 1\n\n @cols.reverse_each do |column|\n if col >= (Integer(column[:attributes][:min])-1)\n if col <= (Integer(column[:attributes][:max])-1)\n break\n end\n end\n i -= 1\n end\n if i < 0\n i = @cols.size #effectively nil\n end\n i\n end",
"def line_pos(row)\n (row > 0 ? src.split(\"\\n\")[0..(row - 1)].inject(0) { |pos, line| pos + line.length + 1 } : 0)\n end",
"def [](pos) #pos = [1,2]\n # x, y = pos\n x = pos[0]\n y = pos[1]\n @rows[x][y] \n end",
"def find_at_risk_square(line, board, marker)\n if board.position_values.values_at(*line).count(marker) == 2\n mark = board.position_values.select { |k, v| line.include?(k) && v == Board::INITIAL_MARKER }\n mark.keys.first\n end\n end",
"def position(idx)\n pos = []\n\n dim.times do |i|\n if i < dim - 1\n row_length = @dimensions.drop(i+1).reduce(&:*)\n pos << idx / row_length\n idx -= pos.last * row_length\n else\n pos << idx\n end\n end\n\n pos\n end",
"def row_col\n f = lambda do |board ,mark|\n board.any? { |row| row.all? {|cell| cell == mark } } end\n\n return :X if (f.call(@grid ,:X) || f.call(@grid.transpose,:X))\n return :O if (f.call(@grid ,:O) || f.call(@grid.transpose,:O))\n end",
"def getArrayIndex(row, col)\n index = 0\n case row\n when '1'\n if col == 'A'\n index = 0\n elsif col == 'D'\n index = 1\n else index = 2\n end\n when '2'\n if col == 'B'\n index = 3\n elsif col == 'D'\n index = 4\n else index = 5\n end\n when '3'\n if col == 'C'\n index = 6\n elsif col == 'D'\n index = 7\n else index = 8\n end\n when '4'\n if col == 'A'\n index = 9\n elsif col == 'B'\n index = 10\n elsif col == 'C'\n index = 11\n elsif col == 'E'\n index = 12\n elsif col == 'F'\n index = 13\n else index = 14\n end\n when '5'\n if col == 'C'\n index = 15\n elsif col == 'D'\n index = 16\n else\n index = 17\n end\n when '6'\n if col == 'B'\n index = 18\n elsif col == 'D'\n index = 19\n else\n index = 20\n end\n when '7'\n if col == 'A'\n index = 21\n elsif col == 'D'\n index = 22\n else\n index = 23\n end\n end\n return index\n end",
"def get_line_and_col_pos(pos)\n pos = self.size if pos > self.size\n pos = 0 if pos < 0\n\n lpos = get_line_pos(pos)\n\n lpos = @line_ends.size if lpos == nil\n cpos = pos\n cpos -= @line_ends[lpos - 1] + 1 if lpos > 0\n\n return [lpos, cpos]\n end",
"def get_map_pos(scr_x, scr_y)\n return Vector.new((scr_x + @cam.x) / @tile_size.x, (scr_y + @cam.y) / @tile_size.y) unless @isometric\n\n # Gets the position transformed to isometric coordinates\n v = get_isometric_position scr_x, scr_y\n\n # divides by the square size to find the position in the matrix\n Vector.new((v.x * @inverse_square_size).to_i, (v.y * @inverse_square_size).to_i)\n end",
"def take_input\n p 'Which row?'\n row = gets.chomp.to_i\n p 'Which column?'\n column = gets.chomp.to_i\n [row, column]\n end",
"def set_current_row_col(array)\r\n current_s_index = array.locate2d(' ')\r\n @current_row = current_s_index.flatten.first\r\n @current_col = current_s_index.flatten.last\r\n end"
] | [
"0.6720672",
"0.66320103",
"0.6605307",
"0.6501545",
"0.6490829",
"0.64302444",
"0.6409341",
"0.6399118",
"0.6368346",
"0.6364975",
"0.63617074",
"0.63615274",
"0.63504744",
"0.6343769",
"0.62726504",
"0.6261159",
"0.6261159",
"0.62548846",
"0.623341",
"0.6205515",
"0.6203198",
"0.6194379",
"0.61915845",
"0.6167983",
"0.6159625",
"0.61567354",
"0.6144648",
"0.6134508",
"0.61284775",
"0.60964704",
"0.6089358",
"0.6082245",
"0.60819113",
"0.6077393",
"0.605408",
"0.6017592",
"0.60142195",
"0.60078657",
"0.60013175",
"0.59979475",
"0.59894603",
"0.59857965",
"0.59633625",
"0.5956076",
"0.59554857",
"0.59512305",
"0.5950955",
"0.59495723",
"0.5931595",
"0.5921354",
"0.59085554",
"0.5900311",
"0.5892733",
"0.5871105",
"0.5854996",
"0.5852263",
"0.5842351",
"0.5817201",
"0.5813552",
"0.5798351",
"0.5791581",
"0.5789952",
"0.5776985",
"0.5767748",
"0.57512236",
"0.57468116",
"0.574452",
"0.5734231",
"0.573049",
"0.5722884",
"0.5722884",
"0.5722884",
"0.56914103",
"0.5691198",
"0.5688836",
"0.5684946",
"0.567402",
"0.5673961",
"0.56734705",
"0.56698024",
"0.5667315",
"0.565292",
"0.5652261",
"0.564879",
"0.56427675",
"0.5637894",
"0.56308305",
"0.56272435",
"0.5625759",
"0.5615593",
"0.56104016",
"0.5598936",
"0.55961484",
"0.5590359",
"0.55885917",
"0.5578271",
"0.557751",
"0.5575442",
"0.55678105",
"0.5565925"
] | 0.72393626 | 0 |
Find the next move the bot makes to rescue the princess. | def next_move(bot_pos_x, bot_pos_y, princess_position)
case
when princess_position[0] - bot_pos_x < 0 then move = 'UP'
when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'
when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'
when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'
end
move
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_move\n\t\tif @next_move.nil?\n\t\t\t@next_move = determine_next_move\n\t\tend\n\n\t\t@next_move\n\tend",
"def read_next_move\n\t\t\t\tms = read_acpc_matchstate\n\t\t\t\treturn ms[:last_action]\n\t\t\tend",
"def get_next_move\n\t\t\t\tif player_to_act.respond_to?(:get_move)\n\t\t\t\t\t# get the move, write it to the server and continue reading the gamestate\n\t\t\t\t\tmove = nil\n\t\t\t\t\tloop do\n\t\t\t\t\t\tmove = player_to_act.get_move\n\t\t\t\t\t\tbreak if move\n\t\t\t\t\t\t# in case player doesn't have enough info to move, try reading matchstate\n\t\t\t\t\t\tread_acpc_matchstate\n\t\t\t\t\tend\n\t\t\t\t\tsocket_put(action_str(move))\n\t\t\t\tend\n\t\t\t\treturn read_next_move\n\t\t\tend",
"def get_good_move\n loop do\n\t\t @player_move = self.get_player_move\n break if @current_state[@player_move].nil?\n puts \"That position is taken. Try another.\"\n end\n @player_move\n end",
"def next_move\n moves.max{ |a, b| a.rank <=> b.rank }\n end",
"def your_turn\n @your_turn ||= match.next_to_move == current_player_side; \n rescue\n logger.error \"Error computing next to move: #{match.inspect}, #{current_player.inspect}\" and return nil\n end",
"def move \n while true \n choose_next_position \n if [:found, :fail].include? @result\n break \n end\n end\n end",
"def bestmove\n write_to_engine(\"go movetime #{@movetime}\")\n until (move_string = read_from_engine).to_s.size > 1\n sleep(0.25)\n end\n if move_string =~ /^bestmove/\n if move_string =~ /^bestmove\\sa1a1/ # fruit and rybka\n raise EngineResignError, \"Engine Resigns. Check Mate? #{move_string}\"\n elsif move_string =~ /^bestmove\\sNULL/ # robbolita\n raise NoMoveError, \"No more moves: #{move_string}\"\n elsif move_string =~ /^bestmove\\s\\(none\\)\\s/ #stockfish\n raise NoMoveError, \"No more moves: #{move_string}\"\n elsif bestmove = move_string.match(/^bestmove\\s([a-h][1-8][a-h][1-8])([a-z]{1}?)/)\n return bestmove[1..-1].join\n else\n raise UnknownBestmoveSyntax, \"Engine returned a 'bestmove' that I don't understand: #{move_string}\"\n end\n else\n raise ReturnStringError, \"Expected return to begin with 'bestmove', but got '#{move_string}'\"\n end\n end",
"def next_mover\n # if no move has made yet!\n return player unless last_player_id.present?\n # if opponent was not the last mover\n return opponent if last_mover != opponent\n\n # if player wasn't the last mover\n player if last_mover != player\n end",
"def imperative_move\n # if we can win *this turn*, then take it because\n # it rates winning next turn the same as winning in 3 turns\n game.available_moves.each do |move|\n new_game = game.pristine_mark move\n return move if new_game.over? && new_game.winner == player_number\n end\n \n # if we can block the opponent from winning *this turn*, then take it, because\n # it rates losing this turn the same as losing in 3 turns\n if moves_by_rating.all? { |move, rating, game| rating == -1 }\n Game.winning_states do |position1, position2, position3|\n a, b, c = board[position1-1, 1].to_i, board[position2-1, 1].to_i, board[position3-1, 1].to_i\n if a + b + c == opponent_number * 2\n return a.zero? ? position1 : b.zero? ? position2 : position3\n end\n end\n end\n end",
"def pbCheckMove(move)\n if move.is_a?(String) || move.is_a?(Symbol)\n move = getID(PBMoves,move)\n end\n return nil if !move || move<=0\n for i in $Trainer.party\n next if i.egg?\n for j in i.moves\n return i if j.id==move\n end\n end\n return nil\nend",
"def move\n start_show_thinking\n @board.move(best_moves.first)\n stop_show_thinking\n board.last_move\n end",
"def best_move\n find_at_risk_square(mark) ||\n find_at_risk_square(@human.mark) ||\n center_square ||\n corner_play ||\n board.unmarked_keys.sample\n end",
"def get_move(possibles)\n begin\n ch = STDIN.getch\n exit(1) if ch == \"\\u0003\"\n move = ch.to_i - 1\n end until possibles.include? move\n move\n end",
"def best_move_for(player)\n return minimax(player)[1]\n end",
"def get_valid_move\n begin\n puts 'please enter your move: '\n i = gets.chomp.to_i\n if i == 0\n return ki_get_move\n else\n x,y = $keymap[i]\n end\n end until is_valid_move(x,y)\n return x,y\n end",
"def next_move gameboard\n @counter += 1\n @counter = 0 if @counter == gameboard.valid_moves.count\n gameboard.valid_moves[@counter]\n end",
"def next_direction #:nodoc:\n loop do\n direction = @tries.pop\n nx, ny = @maze.move(@x, @y, direction)\n\n if @maze.valid?(nx, ny) && (@maze[@x, @y] & (direction | (direction << Maze::UNDER_SHIFT)) == 0)\n if @maze[nx, ny] == 0\n return direction\n elsif [email protected]?(@maze[nx, ny]) && @maze.weave > 0 && rand(100) < @maze.weave\n # see if we can weave over/under the cell at (nx,ny)\n return direction if @maze.weave_allowed?(@x, @y, nx, ny, direction)\n end\n end\n\n while @tries.empty?\n if @stack.empty?\n @pending = false\n return nil\n else\n @x, @y, @tries = @stack.pop\n end\n end\n end\n end",
"def most_likely_play\n @must_learn = true\n best_move = nil\n max = 0\n\n search_space = SearchSpace.new(@board, @most_alike_board, @color)\n search_space.each do |move|\n prob = probability_of(move)\n return move if prob >= Config::PROBS_THRESHOLD\n if max < prob\n max = prob\n best_move = move\n end\n end\n\n best_move\n end",
"def find_winner(move)\n condition1 = (move / 3).ceil * 3\n condition2 = (move - 1) % 3\n line = players[turn % 2].symbol + players[turn % 2].symbol + players[turn % 2].symbol\n winner_conditions(condition1, condition2, line)\n end",
"def ki_get_move\n field2 = @field.clone\n srand\n\n while true\n tryx, tryy = rand(3), rand(3)\n next unless field2[tryx][tryy].player == 0\n\n field2[tryx][tryy].player = @player\n if check_winner(field2) != nil and check_winner(field2).first.player == @player then\n return tryx, tryy\n end\n\n other = @player == 1 ? 2 : 1\n field2[tryx][tryy].player = other\n if check_winner(field2) != nil and check_winner(field2).first.player == other then\n if rand(10) > 1 then\n return tryx, tryy\n end\n end\n\n field2[tryx][tryy].player = 0\n if rand(10) > 8 then return tryx,tryy end\n end\n end",
"def find_move(board)\n\t\tcell_found = nil\n\t\t\tWIN_COMBINATIONS.each do |combo|\n\t\t\t\thash = Hash.new\n\t\t\t\thash[combo[0]] = board.cells[combo[0]]\n\t\t\t\thash[combo[1]] = board.cells[combo[1]]\n\t\t\t\thash[combo[2]] = board.cells[combo[2]]\n\t\t\t\t# finds a possible win move\n\t\t\tif(hash.values.count(\"O\") == 1 && hash.values.count(\" \") == 2)\n\t\t\t\tcell_found = hash.key(\" \")+1\n\t\t\tend\n\t\tend\n\t\tcell_found\n\tend",
"def find_best_move(brd)\n\n # Shortcircuit first move so 5 is always choosen\n return 5 if empty_squares(brd).count == 9\n\n\n best_val = -INFINITY\n best_move = nil\n\n brd.each do |cell, status|\n if status == INITIAL_MARKER\n brd[cell] = COMPUTER_MARKER\n move_val = minimax(brd, 0, 'player')\n brd[cell] = INITIAL_MARKER\n if move_val > best_val\n best_val = move_val\n best_move = cell\n end\n end\n end\n return best_move\n end",
"def last_move; @last_move ||= match.moves.last; end",
"def winning_move\n win_combo = WIN_COMBINATIONS.find do |combo|\n (@board.cells[combo[0]] == @token && @board.cells[combo[1]] == @token && @board.cells[combo[2]] == \" \") || (@board.cells[combo[0]] == @token && @board.cells[combo[2]] == @token && @board.cells[combo[1]] == \" \") || (@board.cells[combo[1]] == @token && @board.cells[combo[2]] == @token && @board.cells[combo[0]] == \" \")\n end\n if win_combo != nil\n win_cell = win_combo.find do |spot|\n @board.cells[spot] == \" \"\n end\n end\n end",
"def next_turn\n print \"\\nYour move, #{@mover.designation}: \"\n move = get_move\n\n print \"\\nMover = #{@mover.designation}. Move = #{move}.\\n\"\n\n if move == 'Q'.to_i\n @is_active = false\n print \"\\n***** Game halted by user. *****\\n\"\n return\n end\n\n add_good_move(move)\n check_winner\n check_tie_game\n\n print_color_grid\n\n @turn = @turn + 1\n @mover = @player[@turn % 2]\n end",
"def nextMove(n,r,c,grid)\n return false if n == 0 && grid.empty?\n\n bot_position = getBotPosition(n, grid)\n princess_position = findPrincessPosition(n, grid)\n\n bot = bot_position.flatten!\n princess = princess_position.flatten!\n\n return false unless bot[0] == r\n if bot[0] < princess[0]\n puts 'DOWN'\n elsif bot[0] > princess[0]\n puts 'UP'\n elsif bot[1] > princess[1]\n puts 'LEFT'\n elsif bot[1] < princess[1]\n puts 'RIGHT'\n end\nend",
"def winning_move(player)\n count_squares_and_moves(player) do |squares, moves| \n return moves.first if squares == 2 and !moves.empty? \n end\n nil\n end",
"def find_best_move\n return 5 if @board.unmarked_keys.count == 9\n\n bests = { val: -INFINITY, move: nil }\n\n board.squares.each do |cell, square|\n if square.unmarked?\n move_val = simulate_computer_move(cell)\n if move_val > bests[:val]\n bests[:val] = move_val\n bests[:move] = cell\n end\n end\n end\n bests[:move]\n end",
"def get_move(symbol)\n player = players[symbol]\n warning = nil\n num_attempts = 0\n\n while true\n\n num_attempts += 1\n if (num_attempts > 100)\n STDERR.puts \"100 failed attempts to specify a valid move\"\n STDERR.puts \"This probably indicates a logic error\"\n raise \"too many failed attempts to specify a valid move\"\n end\n\n prompt_for_move(warning)\n warning = nil\n\n response = player.readline or raise \"unexpected end of input\"\n\n if response =~ /^ \\s* ([abc]) \\s* ([123]) \\s* $/xi\n x = $1.downcase.tr('abc', '012').to_i\n y = $2.to_i - 1\n\n if get_cell(x, y) == '.'\n return [x, y, symbol.to_s.upcase]\n else\n warning = \"'#{response.chomp}' is already occupied\"\n end\n else\n warning = \"'#{response.chomp}' is not a valid move\"\n end\n\n end\n end",
"def get_move(game_board)\n position = game_board.index(\"\") # get the index of the first open position\n move = @moves[position] # get the corresponding location for the index\n end",
"def next_move gameboard\n result_pairs = []\n\n gameboard.valid_moves.each do |move|\n new_gameboard = gameboard.move move\n result_pairs << { score: new_gameboard.score, move: move } unless gameboard.equal_tile_layout? new_gameboard\n end\n\n result_pairs.sort_by{ |s| s[:score] }.reverse.first[:move]\n end",
"def get_winner_against(move)\n\t\tif move == :r\n\t\t\t:p\n\t\telsif move == :p\n\t\t\t:s\n\t\telse\n\t\t\t:r\n\t\tend\n\tend",
"def best_move(state)\n best_score = -999\n best_move = nil\n dot = (@max_tries / 10).floor\n # Run allowed number of simulations\n print \"Thinking\"\n (1..@max_tries).each_with_index do |try, i|\n print \".\" if i % dot == 0\n simulate(state)\n end\n show_scores(state)\n high_score_move(state)\n end",
"def winning_move(board, token) # this method should return the index to be played\n winning_line = WIN_COMBOS.detect {|combo| tokens_in_line(board, combo).sort == [\" \", token, token]} #winning_line should be something like [2,5,8] or nil\n # find the first empty cell in the winning_line array\n if winning_line != nil\n winning_line.find do |index|\n board.cells[index.to_i] != token\n end\n end\n end",
"def best_move\n\t\tpossible_moves.send(@turn == \"x\" ? :max_by: :min_by) { |idx| minimax(idx) }\n\tend",
"def input_to_index(nextmove)\n nextmovei = nextmove.to_i - 1\nend",
"def get_valid_move\nwhile true\nmove = get_move\nif valid_move?(move)\nreturn move\nelse\nputs \"Position #{ move + 1 } is occupied...Enter a free position\"\nend\nend\nend",
"def next_objective\n next_obj = turn.listen.first\n return unless next_obj\n next_direction = turn.direction_of next_obj\n if turn.feel(next_direction).stairs?\n empty_directions = DIRECTIONS.select do |dir|\n turn.feel(dir).empty?\n end\n empty_directions.first\n else\n next_direction\n end\n end",
"def next_move\n case Direction::DIRECTIONS[direction.current]\n when Direction::DIRECTIONS[0] # NORTH\n {x: 0, y: 1}\n when Direction::DIRECTIONS[1] # EAST\n {x: 1, y: 0}\n when Direction::DIRECTIONS[2] # SOUTH\n {x: 0, y: -1}\n when Direction::DIRECTIONS[3] # WEST\n {x: -1, y: 0}\n end\n end",
"def get_computer_move(board, computer_letter)\n # Straghten out the letters in play\n if computer_letter == 'X'\n player_letter = 'O'\n else\n player_letter = 'X'\n end\n \n # First, check if the computer can win in the next move\n (BOARD_RANGE).each do |i|\n copy = copy_board(board)\n if space_available?(copy, i)\n make_move(copy, computer_letter, i)\n if winner?(copy, computer_letter)\n return i\n end\n end\n end\n \n # Block the player if he is going to win\n (BOARD_RANGE).each do |i|\n copy = copy_board(board)\n if space_available?(copy, i)\n make_move(copy, player_letter, i)\n if winner?(copy, player_letter)\n return i\n end\n end\n end\n \n # Check to see if the player has made a strategic move.\n # If player chose center, take a corner\n if board[4] == player_letter\n move = choose_random_move(board, [0, 2, 6, 8])\n if move != nil\n return move\n end\n end\n\n # If player chose corner, take the center\n if board[0] == player_letter ||\n board[2] == player_letter ||\n board[6] == player_letter ||\n board[8] == player_letter\n\n if space_available?(board, 4)\n return 4\n else\n return choose_random_move(board, [1, 3, 5, 7])\n end\n end\n\n # ...else, the computer will make a strategic move.\n # Take corner first\n move = choose_random_move(board, [0, 2, 6, 8])\n if move != nil\n return move\n end\n \n # Take center\n if space_available?(board, 4)\n return 4\n end\n \n # All else fails, take a side\n choose_random_move(board, [1, 3, 5, 7])\n end",
"def next_move(_n, bot_pos_x, bot_pos_y, princess_position, _grid)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\n end",
"def get_random_next_move(arena)\n head = get_head_coords\n moves = []\n # N\n cell = arena.get(head[:x], head[:y] - 1)\n moves << 'N' if cell == 'empty' || cell[0..3] == 'tail'\n # S\n cell = arena.get(head[:x], head[:y] + 1)\n moves << 'S' if cell == 'empty' || cell[0..3] == 'tail'\n # E\n cell = arena.get(head[:x] + 1, head[:y])\n moves << 'E' if cell == 'empty' || cell[0..3] == 'tail'\n # W\n cell = arena.get(head[:x] - 1, head[:y])\n moves << 'W' if cell == 'empty' || cell[0..3] == 'tail'\n\n # Return any direction or nil\n moves.sample\n end",
"def get_move\n # Fill this in. Sample code:\n # puts\n # display_position\n # move = nil\n # until move != nil\n # puts\n # print \"Enter your move: \"\n # move_string = gets.chomp\n # < interpret move_string as move >\n # if !legal_moves(@current_state).index(move)\n # puts \"That's not a legal move!\"\n # move = nil\n # end\n # end\n # make_move(move)\n end",
"def smart_move(oppo_steps, steps)\n WINNING_LINE.each do |win_line|\n filter_line = win_line.select do |win_num|\n !oppo_steps.include?(win_num)\n end\n if filter_line.size == 1\n return filter_line[0] unless steps.include?(filter_line[0])\n end\n end\n 0\nend",
"def best_move\n best_score = -9999\n current_moves = legal_moves\n # Return nil if no legal moves\n if current_moves.empty?\n return nil\n end\n # Build list of scores for moves\n move_scores = current_moves.map do |move|\n print \"\\rConsidering #{move} \"\n score_state = next_state(move)\n move_score = score(0)\n next_player = score_state.player\n # If alternating moves, use negative of opponent's score\n if next_player != player\n move_score = -move_score\n end\n best_score = move_score if move_score > best_score\n { :move => move, :score => move_score }\n end\n # p move_scores\n # Pick best move\n # Choose randomly if more than one\n best_moves = move_scores.select { |move_score| move_score[:score] == best_score }\n best_moves.sample[:move]\n end",
"def try_move(move)\n\t\tsetup if !ready?\n\n\t\t# gen all possible moves\n\t\tmoves = generate_moves(self.pieces, self.turn)\n\t\treturn nil if moves.length == 0\n\t\tvalid_move = moves.find { | m | m.from == move.from && m.to == move.to }\n\t\treturn nil if valid_move.nil?\n\n\t\t# filter out moves that would leave us in check\n\t\tmoves = filter_for_self_check(self.pieces, moves, self.turn)\n\t\treturn nil if moves.length == 0\n\t\tvalid_move = moves.find { | m | m.from == move.from && m.to == move.to }\n\t\treturn nil if valid_move.nil?\n\n\t\t# perform the move\n\t\tvalid_move = perform_move(valid_move)\n\t\tif valid_move.promoted.nil?\n\t\t\tvalid_move = update_after_move(valid_move)\n\t\tend\n \n\t\t# create a new board and set it equal to this one, then save it\n\t\tnext_board = Board.new\n\t\tnext_board.game = self.game\n\t\tnext_board.set(self.fen)\n\t\tif !next_board.save!\n\t\t\treturn nil\n\t\tend\n\n\t\t# finally return our move to the game model\n\t\treturn valid_move\n\tend",
"def computer_move\n return nil if @current_state.done?\n # Pick best move using minimax algorithm\n move = @current_state.best_move\n # Make the move\n move.display\n make_move(move)\n end",
"def get_move\n print \"#{@name}, please choose r, p, or s: \" \n @move = gets.chomp.downcase\n until is_move_valid(@move) do\n puts \"Sorry, that's not a valid move!\"\n @move = gets.chomp.downcase\n end\n @move\n end",
"def find_next_tunnel\n @position.mark(:minotaurus) \n @position.tunnels.reverse.each { |tunnel|\n if not tunnel.marks.include?(:minotaurus) # timto tunelem minotaur jeste nesel \n tunnel.mark(:minotaurus)\n return tunnel \n end\n }\n \n return @position.tunnels[rand(@position.tunnels.size)] \n end",
"def get_player_move(board)\n \n move = ' '\n \n while not '1 2 3 4 5 6 7 8 9'.split.include?(move) or not is_space_free(board, move.to_i) do \n puts 'What is your next move? (1-9)'\n move = gets.chomp\n if is_space_free(board, move.to_i)\n break\n end\n puts 'The space is already taken!' \n end \n\n @player_moves.push(move.to_i)\n\n return move.to_i\nend",
"def skip_next_move(player_no)\n\t\t@skip_next_move[player_no - 1]\n\tend",
"def findNextState\n # Allow a :catch transition if the explicit value was not found.\n if @state_list[@state][@transition].nil? && !@state_list[@state][:catch].nil?\n @transition = :catch\n end\n\n # Attempt to find a suitable state given the most recent @transition value.\n if !@state_list[@state][@transition].nil?\n transition = @state_list[@state][@transition]\n else\n raise \"Unable to locate a transition from \\\"#{@state}\\\" using the transition \\\"#{@transition}\\\"\"\n end\n\n if !transition.nil? && !transition.wait.nil?\n @wait = transition.wait\n else\n @wait = 0\n end\n\n if !transition.nil? && !transition.retries.nil?\n @retries = transition.retries\n else\n @retries = 0\n end\n\n transition.attempts += 1\n if transition.retries > 0\n if transition.attempts > transition.retries\n raise \"Too many retries\"\n end\n end\n\n @state = transition.to\n end",
"def next_move(player,board,move)\n completed = false;\n blocking = false;\n if(move == 1) #First Move (hard coded)\n puts \"2 0\";\n elsif(move == 2) #Second Move (hard coded)\n if(board[1][1] == 'X')\n puts \"2 2\";\n else\n puts \"1 1\";\n end \n elsif(move == 3) #Third move (hard coded)\n if(board[0][1] == 'O' || board[1][0] == 'O' || board[1][2] == 'O' || board[2][1] == 'O')\n puts \"1 1\";\n elsif(board[1][1] == 'O')\n puts \"0 2\";\n elsif(board[0][2] == 'O' || board[2][2] == 'O')\n puts \"0 0\";\n else\n puts \"2 2\";\n end\n else #Any move after the 3rd\n completed = can_complete(player,board)\n if(completed == false)\n blocking = must_block(player,board);\n if(blocking == false)\n prevent = can_complete(player,board)\n if(move == 4 && (board[0][0] == 'X' || board[0][2] == 'X' || board[2][0] == 'X' || board[2][2] == 'X') && (board[0][1] == 'X' || board[1][0] == 'X' || board[1][2] == 'X' || board[2][1] == 'X'))\n if(board[0][1] == 'X' || board[2][1] == 'X')\n puts \"1 0\";\n else\n puts \"0 1\";\n end\n elsif(move == 4 && ((board[0][0] == 'X' && board[2][2] == 'X') || (board[0][2] == 'X' && board[2][0] == 'X') || (board[0][1] == 'X' && board[2][1] == 'X') || (board[1][0] == 'X' && board[1][2] == 'X')))\n if((board[0][0] == 'X' && board[2][2] == 'X') || (board[0][2] == 'X' && board[2][0] == 'X'))\n puts \"0 1\";\n else\n puts \"0 0\";\n end\n elsif(move == 6 && (board[2][1] == 'X' || board[0][1] == 'X') && (board[1][0] == 'X' || board[1][2] == 'X') && board[2][2] == '_')\n puts \"2 2\";\n elsif(board[0][0] == \"_\")\n puts \"0 0\";\n elsif(board[0][2] == \"_\")\n puts \"0 2\";\n elsif(board[2][2] == \"_\")\n puts \"2 2\";\n elsif(board[2][0] == \"_\")\n puts \"2 0\";\n elsif(board[0][1] == \"_\")\n puts \"0 1\";\n elsif(board[2][1] == \"_\")\n puts \"2 1\";\n elsif(board[1][0] == \"_\")\n puts \"1 0\";\n elsif(board[1][2] == \"_\")\n puts \"1 2\";\n else\n puts \"1 1\";\n end\n end\n end\n end\nend",
"def get_move\n @players[0].get_move(@board)\n end",
"def advance_move_route_index\n @move_route_index += 1 if @move_succeed || @move_route.skippable\n end",
"def next_move(game_state: nil)\n #We add only what is new, just in case the state_delta contains less info...\n new_moves = []\n if @board_state.length < game_state.length\n (@board_state.length...game_state.length).each do |i| \n @board_state << game_state[i] \n new_moves << game_state[i]\n end\n end\n moves = translate_acn(new_moves, board)\n update_board(@board, moves, @score)\n return decide_best_move @board, @score, @depth\n end",
"def move(cakes, last)\n last == 1 ? 2 : 1 # I'm not greedy\n end",
"def handle_one_move(str, sente=nil)\n if (str =~ /^([\\+\\-])(\\d)(\\d)(\\d)(\\d)([A-Z]{2})/)\n sg = $1\n x0 = $2.to_i\n y0 = $3.to_i\n x1 = $4.to_i\n y1 = $5.to_i\n name = $6\n elsif (str =~ /^%KACHI/)\n raise ArgumentError, \"sente is null\", caller if sente == nil\n if (good_kachi?(sente))\n return :kachi_win\n else\n return :kachi_lose\n end\n elsif (str =~ /^%TORYO/)\n return :toryo\n else\n return :illegal\n end\n \n if (((x0 == 0) || (y0 == 0)) && # source is not from hand\n ((x0 != 0) || (y0 != 0)))\n return :illegal\n elsif ((x1 == 0) || (y1 == 0)) # destination is out of board\n return :illegal\n end\n \n if (sg == \"+\")\n sente = true if sente == nil # deprecated\n return :illegal unless sente == true # black player's move must be black\n hands = @sente_hands\n else\n sente = false if sente == nil # deprecated\n return :illegal unless sente == false # white player's move must be white\n hands = @gote_hands\n end\n \n ## source check\n if ((x0 == 0) && (y0 == 0))\n return :illegal if (! have_piece?(hands, name))\n elsif (! @array[x0][y0])\n return :illegal # no piece\n elsif (@array[x0][y0].sente != sente)\n return :illegal # this is not mine\n elsif (@array[x0][y0].name != name)\n return :illegal if (@array[x0][y0].promoted_name != name) # can't promote\n end\n\n ## destination check\n if (@array[x1][y1] &&\n (@array[x1][y1].sente == sente)) # can't capture mine\n return :illegal\n elsif ((x0 == 0) && (y0 == 0) && @array[x1][y1])\n return :illegal # can't put on existing piece\n end\n\n tmp_board = deep_copy\n return :illegal if (tmp_board.move_to(x0, y0, x1, y1, name, sente) == :illegal)\n return :oute_kaihimore if (tmp_board.checkmated?(sente))\n tmp_board.update_sennichite(sente)\n os_result = tmp_board.oute_sennichite?(sente)\n return os_result if os_result # :oute_sennichite_sente_lose or :oute_sennichite_gote_lose\n return :sennichite if tmp_board.sennichite?\n\n if ((x0 == 0) && (y0 == 0) && (name == \"FU\") && tmp_board.uchifuzume?(sente))\n return :uchifuzume\n end\n\n move_to(x0, y0, x1, y1, name, sente)\n\n update_sennichite(sente)\n return :normal\n end",
"def ask_for_move position\n while true\n print \"move: \"\n ans = gets.chomp\n return ans.to_i if ans =~ /^\\d+$/ && position.board[ans.to_i] == \"-\"\n end\n end",
"def next_player_no\n\t\twhile @player_order.first && @skip_next_move[@player_order.first - 1] do\n\t\t\t@skip_next_move[@player_order.first - 1] = false\n\t\t\t@player_order.push(@player_order.first)\n\t\t\t@player_order.shift\n\t\tend\n\t\t@player_order.first\n\tend",
"def get_move\n cols = %w(a b c d e f g h)\n rows = %w(8 7 6 5 4 3 2 1)\n\n from_pos, to_pos = nil, nil\n until from_pos && to_pos\n @display.draw\n if from_pos\n row, col = from_pos\n piece = @display.board[from_pos].class\n puts \"#{piece} at #{cols[col]}#{rows[row]} selected. Where to move to?\"\n to_pos = @display.get_keyboard_input\n else\n @display.reset_errors_notification\n puts \"#{@color.capitalize}'s move\"\n puts 'What piece do you want to move?'\n selection = @display.get_keyboard_input\n from_pos = selection if selection && valid_selection?(selection)\n end\n end\n [from_pos, to_pos]\n end",
"def nextTurn()\r\n index = @players.index(@curplayer)\r\n puts \"index = #{index}\"\r\n if(index == nil)\r\n #this is probably the dealer\r\n return\r\n end\r\n if(index == @players.size - 1) #This is the last player\r\n @curplayer = @dealer #its now the dealer's turn\r\n else #not last persons turn yet\r\n index += 1 #get the next index\r\n if(@players[index].split)\r\n @curplayer = @dealer \r\n else\r\n @curplayer = @players[index] #set the current player to the next one\r\n end\r\n end\r\n @nummoves = 0\r\n end",
"def find_waters_next_step(location,cave)\n \n next_step = [0,0]\n \n if cave[location[:y] + 1][location[:x]] == \" \" # Attempt to flow down\n next_step[1] = 1\n elsif cave[location[:y]][location[:x] + 1] == \" \" # If unable to flow down try to flow right\n next_step[0] = 1\n else # Back carraige return to a ~ once we reach a cave wall\n next_step[1] = -1 # go up one level in the cave\n while cave[location[:y] + next_step[1]][location[:x] + next_step[0] - 1] == \" \"\n next_step[0] += -1\n end\n end\n \n next_step\nend",
"def get_move\n STDOUT.print(\"\\tPlayer #{self.name}/#{self.type} -- \" +\n \"center: #{@move_center.inspect} // corner: #{@move_corner.inspect}\" +\n \" // side: #{@move_side.inspect}\\n\") if $VERBOSE\n # play center\n if rand(2) > 0 && !@move_center.empty? # plus some randomness for IA vs IA\n # maybe a problem - if it the only valid move!\n m = _play_center\n return m if m > 0\n end\n # play opposite corner\n if !@move_corner.empty?\n m = _find_free_opp_corner\n STDOUT.print \"\\tPlayer #{self.name}/#{self.type} trying corner...#{m}\\n\" if $VERBOSE\n return m if m > 0\n end\n # play opposite side\n if !@move_side.empty?\n m = _find_free_side\n STDOUT.print \"\\tPlayer #{self.name}/#{self.type} trying side...#{m}\\n\" if $VERBOSE\n return m if m > 0\n end\n raise ArgumentError,\n \"No more move to play for #{self.name} / #{self.type} /\\n\" +\n \"center: #{@move_center.inspect} // corner: #{@move_corner.inspect} // side: #{@move_side.inspect}\"\n end",
"def input_to_index(player_move)\n input = player_move.to_i\n final_move = input - 1\nend",
"def parse_move\n s0 = @scanner.pos\n s1 = parse_line\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = []\n s3 = parse_comment\n while s3 != :failed\n s2 << s3\n s3 = parse_comment\n end\n parse_pointer\n @reported_pos = s0\n s0 = transform_move(s1, s2)\n end\n s0\n end",
"def prospect_move(total_turns)\n @turns += 1\n if @turns == total_turns\n end_search\n else\n neighbor_index = rand(@curr_location.neighbor_list.length)\n puts \"Heading from #{@curr_location.loc} to #{@curr_location.neighbor_list[neighbor_index]}.\"\n change_curr_location(@map.get_by_name(@curr_location.neighbor_list[neighbor_index]))\n end\n end",
"def pbForgetMove(pkmn,move)\n return 0\n end",
"def pbForgetMove(pkmn,move)\n return 0\n end",
"def pbForgetMove(pkmn,move)\n return 0\n end",
"def parse_moves\n s0 = @scanner.pos\n s1 = parse_firstboard\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n parse_split\n s2 = []\n s3 = parse_move\n while s3 != :failed\n s2 << s3\n s3 = parse_move\n end\n parse_result\n @reported_pos = s0\n s0 = s2.unshift(s1)\n end\n s0\n end",
"def best_move(state)\n player = state[:player]\n best_score = -9999\n legal_moves = legal_moves(state)\n # Return nil if no legal moves\n if legal_moves.empty?\n return nil\n end\n # Build list of scores for moves\n move_scores = legal_moves.map do |move|\n print \"\\rConsidering #{move} \"\n score_state = next_state(state, move)\n move_score = score(score_state)\n next_player = score_state[:player]\n # If alternating moves, use negative of opponent's score\n if next_player != player\n move_score = -move_score\n end\n best_score = move_score if move_score > best_score\n { :move => move, :score => move_score }\n end\n # p move_scores\n # Pick best move\n # Choose randomly if more than one\n best_moves = move_scores.select { |move_score| move_score[:score] == best_score }\n best_moves.sample[:move]\n end",
"def get_move\n while true\n print \"#{@name}, make your move (e.g. e2 e4): \"\n move = gets.chomp.downcase.split\n break if valid_input?(move)\n puts \"Invalid input\"\n end\n return parse_move(move)\n end",
"def first_moves(s)\n s[:m] = s[:unknown_moves][0] # Find first unknown move\n poss_moves = get_poss_next_moves(s)\n return poss_moves\nend",
"def next_move\n minimax(self.id)\n\n @board.board[@choice] = id\n @board.free.delete(@choice)\n p self\n puts \"player #{id + 1} chooses #{@choice}\"\n puts @board\n\n @board.winner || @board.free.empty?\n end",
"def nextp pos, dir\n #It does not allow to step off the edges, so we check them out:\n if (pos<@w && (3..5).include?(dir)) or\n (pos+@w >= @grid.size && [0,1,7].include?(dir)) or\n (pos%@w == 0 && (5..7).include?(dir)) or\n (pos%@w+1 == @w && (1..4).include?(dir))\n return nil\n end\n # Remember: Directions = [[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]]\n # Directions[dir][0] represents the movement in y index. Directions[dir][1] represents the movement in x index\n pos+Directions[dir][0]*@w+Directions[dir][1]\n end",
"def next_move_correct?(ary,attacking = false)\n movement_correct = false\n Possible_moves.each{|move|\n if (@current_position[0]+move[0]) == ary[0] && (@current_position[1]+move[1]) == ary[1]\n movement_correct = true\n break\n end\n }\n movement_correct\n end",
"def next_move_correct?(ary,attacking = false)\n movement_correct = false\n Possible_moves.each{|move|\n if (@current_position[0]+move[0]) == ary[0] && (@current_position[1]+move[1]) == ary[1]\n movement_correct = true\n break\n end\n }\n movement_correct\n end",
"def move(board)\n\t\tif(board.cells[4] == \" \")\n\t\treturn final_cell_move =\t\"5\"\n\t\telse\n\t\t\tif(attack_against_opponent(board) != nil)\n\t\t\t\t return final_cell_move = attack_against_opponent(board)\n\t\t\telsif(defend_against_opponent(board) !=nil)\n\t\t\t\t return final_cell_move = defend_against_opponent(board)\n\t\t\telsif(find_empty_corner(board) != nil)\n\t\t\t\t return final_cell_move = find_empty_corner(board)\n\t\t\t elsif(find_move(board) != nil)\n\t \t\t\t return final_cell_move = find_move(board) # +1\n\t\t\t elsif(all_corners_filled?(board))\n\t\t\t\t return final_cell_move = find_random_cell(board)\n\t\t\tend\n\t\tend\n\tend",
"def get_move(state)\n value = min_max(state, FIXNUM_MIN, FIXNUM_MAX, true)\n result_action\n end",
"def chooseMove\r\n\t\tprint \"\\nEnter your move human: \"\r\n\t\tmove = gets.chomp.to_i\r\n\t\treturn move\r\n\tend",
"def winning_move(board)\n winning_spot = nil\n \n board.empty_position.each do |spot|\n board.place_mark(*spot, marker)\n winning_spot = spot if board.won?\n board[*spot] = nil\n end\n \n winning_spot\n end",
"def next_spot\n\t\tif @location.nil?\n\t\t\tfirst()\t\t\n\t\telse\n\t\t\tmoving()\n\t\tend\n\tend",
"def get_cpu_move(board, player)\n # for the first move, the cpu will pick one of the four corners randomly.\n if board.is_empty then\n if rand(2) == 1 then\n row = 0\n else \n row = 2\n end\n\n if rand(2) == 1 then\n col = 0\n else\n col = 2\n end\n return row, col \n else\n # otherwise, it will find the best move to play that eliminates\n # its chances of losing\n return minimax(board, player)[1]\n end\nend",
"def find_move(db, position_id, move)\r\n\ttry_move = db.execute(\"SELECT id FROM moves WHERE from_id=#{position_id} AND move=\\\"#{move}\\\"\")\r\n\t# Check to see if given move from this position is already defined\r\n\t# If not defined, return nil\r\n\tif try_move.empty?\r\n\t\treturn nil\r\n\tend\r\n\tif try_move.length > 1\r\n\t\tputs \"ERROR! Multiple moves with same name!\"\r\n\t\treturn nil\r\n\tend\r\n\t# If move is known, return its id\r\n\treturn try_move[0][\"id\"]\r\nend",
"def move(board)\n if win?(board)\n (win?(board) + 1).to_s\n elsif block? board\n (block?(board) + 1).to_s\n elsif board.cells[4] == ' '\n \"5\"\n elsif corner? board\n (corner?(board).sample + 1).to_s\n else\n loop do\n move = (((rand*8).round)+1).to_s\n break if board.valid_move?(move)\n end\n return move\n end\n end",
"def get_move(wins, x_pos, o_pos, mark)\n # Use current mark (X/O) to determine current player, then call appropriate method to get position\n mark == \"X\" ? position = win_check(wins, x_pos, o_pos) : position = win_check(wins, o_pos, x_pos)\n # Translate the position's array index to a \"human friendly\" board position and return it\n move = @moves[position]\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_passant?\n #puts \"HELKFDSJLFKD\"\n if curr_piece.can_en_passant?\n #puts \"HOMFDMSKFDFLSJFKDSLFJSDKLF JDSFKLSJFKLEJ FE FJSKLF\"\n rank = move[0][0]\n col = move[1][1]\n captured_pawn_pos = [rank,col]\n #puts captured_pawn_pos.inspect\n @board[captured_pawn_pos] = nil\n end\n end\n @board[move[1]] = curr_piece\n @board[move[0]] = nil\n curr_piece.move_history << move\n curr_piece.pos = move[1]\n #if castling, move rook too\n if curr_piece.class == King && (move[0][1] - move[1][1]).abs == 2\n #find the appropriate rook to move\n start_rank = move[0][0]\n start_file = move[1][1] == 2 ? 0 : 7\n start_pos = [start_rank, start_file]\n rook = @board[start_pos]\n #determine its final location, then move it.\n end_file = start_file == 0 ? 3 : 5\n end_pos = [start_rank, end_file]\n @board[end_pos] = rook\n @board[start_pos] = nil\n rook.move_history << end_pos\n rook.pos = end_pos\n end\n return true\n else\n puts \"Your king is still in check!\" if @board.in_check?(curr_piece.color)\n puts \"Not a legal move for this #{curr_piece.color} #{curr_piece.class}!\"\n puts\n return false\n end\n end",
"def move(board)\r\n puts \"Com #{token} is thinking...\"\r\n @board = board\r\n (min_max(4, token, -Float::INFINITY, Float::INFINITY)[1]+1).to_s\r\n end",
"def peo_moves\n\t\tadjacent = adjacent_peo\n\t\t## direction = 1\n\t\tif adjacent == 0\n\t\t\tpawn_moves(1)\n\t\telsif adjacent == 1\n\t\t\tmoves = cross_moves\n\t\t\tmoves = moves.concat( calculate_single_take(@row+1, @column+1) )\n\t\t\tmoves = moves.concat( calculate_single_take(@row+1, @column-1) )\n\t\telse\n\t\t\tking_moves\n\t\tend\n\tend",
"def get_next_player(start)\n for i in 1..10\n to_check = (start + i)%10 + 10\n if self.players.where(:location => to_check).length == 1\n player = self.players.where(:location => to_check)[0]\n if player.in_hand\n return player.location\n end\n end\n end\n return -10\n end",
"def next_state(state, move)\n position = state[:position]\n player = state[:player]\n result = position.each_with_index.map do |row, x|\n row.each_with_index.map do |value, y|\n ( x >= move[0] && y >= move[1] ) ? 0 : value\n end\n end\n next_player = opponent(player)\n { :position => result, :player => next_player }\n end",
"def next_turn\n if @current_player == @player_1\n @current_player = @player_2\n else\n @current_player = @player_1\n end\n until @current_moves.length == 2\n ask_player_for_move(@current_player)\n end\n end",
"def best_move(good_moves)\n best_move = good_moves.sample\n good_moves.each do |move|\n if @board.piece_at(move.last).value >\n @board.piece_at(best_move.last).value\n best_move = move\n end\n end\n best_move\n end",
"def get_move\n\t\tputs \"Your current bankroll is $#{bankroll}, and your hand is:\"\n\t\[email protected] \n\t\tputs \"Do you wish to fold, see the bet, or raise?\"\n\t\tbegin\n\t\t\tinput = gets.chomp.downcase\n\t\t\traise BadInputError unless ['fold', 'see', 'raise'].include?(input)\n\t\t\tinput.to_sym\n\t\trescue\n\t\t\tputs \"You must input 'fold', 'see', or 'raise'.\"\n\t\t\tretry\n\t\tend\n\tend",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def get_next_present\n if last_turn?\n @game.detect {|f| !f[:final] }\n else\n @game.detect {|f| !f[:finished] }\n end\n end",
"def choose_move\n raise 'No strategy defined.'\n end",
"def retard_minimax(future_board, player_hand)\n available_cards = player_hand.values.compact\n available_spaces = future_board.open_spaces\n possible_moves = available_cards.product(available_spaces)\n value_of_best_move = -10\n\n possible_moves.each do |card, space|\n x, y = space\n value = future_board.next_state(card, x, y).score\n if value > value_of_best_move\n value_of_best_move = value\n end\n end\n\n return value_of_best_move\n end"
] | [
"0.73405904",
"0.71620786",
"0.7159389",
"0.699724",
"0.69579464",
"0.6948939",
"0.6870679",
"0.6718187",
"0.6711911",
"0.670474",
"0.6628625",
"0.660363",
"0.6595676",
"0.6588735",
"0.6576318",
"0.657171",
"0.6542592",
"0.65393806",
"0.653315",
"0.651404",
"0.6513571",
"0.6498821",
"0.6491274",
"0.6462361",
"0.64449877",
"0.6443485",
"0.6428259",
"0.64261013",
"0.64027464",
"0.63994044",
"0.6396503",
"0.63651204",
"0.6348695",
"0.6332803",
"0.63235086",
"0.63028955",
"0.62999994",
"0.6295465",
"0.6292858",
"0.6281838",
"0.6281616",
"0.6273243",
"0.6270181",
"0.6268338",
"0.62557936",
"0.6254213",
"0.6250031",
"0.62255335",
"0.6218905",
"0.6207236",
"0.6194389",
"0.61880314",
"0.61813813",
"0.61803406",
"0.6176824",
"0.61692923",
"0.6163485",
"0.6145818",
"0.61381537",
"0.6125423",
"0.6122899",
"0.6120457",
"0.6115714",
"0.6103866",
"0.6103663",
"0.6084803",
"0.6084314",
"0.6073912",
"0.60712206",
"0.60712206",
"0.60712206",
"0.6045244",
"0.6044341",
"0.6036735",
"0.60256016",
"0.6024482",
"0.60243565",
"0.6018263",
"0.6018263",
"0.6016964",
"0.60160106",
"0.60134125",
"0.6007188",
"0.60037374",
"0.5997741",
"0.5990091",
"0.5981028",
"0.59732383",
"0.5962128",
"0.59507585",
"0.5946911",
"0.5946315",
"0.59400237",
"0.5935094",
"0.593295",
"0.59250695",
"0.592245",
"0.5910101",
"0.59072024",
"0.5905043"
] | 0.63437057 | 33 |
This method is used in .slim files. Processes a markdown file, including nesting other md files and creating a tags list from the metadata of the included files returns an array: [result_html, tags] | def process_md_erb(filename)
renderer = Redcarpet::Render::HTML
markdown ||= Redcarpet::Markdown.new(renderer, md_extensions)
concatenated_md = embed_md_erb(filename)
result_md, metadata = extract_metadata(concatenated_md)
result_html = markdown.render(result_md)
[result_html, metadata]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_markdown\n attachments.each do |att|\n # ~ magic regex ~\n self.markdown = self.markdown.sub(/\\[.+?\\]\\(.+?\\/#{att.file.id}\\/.+?\\)/) do |md_str|\n att.file_attacher.store!\n \"[#{att.file_filename}](#{att.file_url})\"\n end\n end\n self.html = Kramdown::Document.new(self.markdown || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def process_content(path)\n case path.extname\n when '.htm', '.md'\n read_split_content(path.to_s, symbolize_keys: true)\n # when '.md'\n # body, data = read_split_content(path.to_s, symbolize_keys: true)\n # [Kramdown::Document.new(body).to_html, data]\n when '.yml'\n [nil, YAML.load(File.read(path.to_s), symbolize_names: true)]\n end\n end",
"def preprocessMarkdownForHTML(markdown)\n output = \"\"\n inInstructions = false\n \n markdown.split(\"\\n\").each do |line|\n # parse an instructions list\n # use a dummy HTML tag so our final regex doesn't get stuck in an infinite loop replacing itself\n instructionsMatch = line.match(/^>>\\s*(.*?)$/)\n if instructionsMatch\n if not inInstructions\n output += \"<instructions>\\n\"\n end\n output += instructionsMatch[1] + \"\\n\"\n inInstructions = true\n next # don't try to parse anything else\n elsif inInstructions\n output += \"</instructions>\\n\"\n inInstructions = false\n end\n\n # parse headers and page IDs\n headerMatch = line.match(/^(#+)\\s+(.*?)\\s+@@(.*?)$/)\n if headerMatch\n headerLevel = headerMatch[1].length.to_s\n headerTitle = headerMatch[2]\n headerID = headerMatch[3]\n node = nodeWithID(headerID, $doc.toc.rootNode)\n if not node\n puts \"ERROR: Couldn't find node with ID #{headerID}\"\n exit 1\n end\n output += \"<h#{headerLevel}><a name=\\\"#{headerID}\\\">#{node.levelPrefix} #{headerTitle}</a></h#{headerLevel}>\\n\"\n next\n end\n \n # parse links to page IDs and replace with links to the real .htm file\n while 1\n linkMatch = line.match(/\\[.*?\\]\\((@@(.*?))\\)/)\n if linkMatch\n linkID = linkMatch[2]\n linkValue = linkToPageIDFrom(linkID, \"_PAGE_\") # use dummy value\n if not linkValue\n puts \"ERROR: Invalid link ID \\\"#{linkID}\\\"\"\n exit 1\n end\n line[linkMatch[1]] = linkValue\n else\n break\n end\n end\n \n # parse image and label combo\n imgLabelMatch = line.match(/!!\\[(.*?)\\]\\((.*?)\\)/)\n if imgLabelMatch\n label = imgLabelMatch[1]\n imgPath = imgLabelMatch[2]\n \n # read the image and width height to force the size on images for better loading\n # when viewing the files in the boot DVD. there are some issues where anchor jump\n # links don't always jump to the right place on the boot DVD and apparently forcing\n # the image sizes allows the pages to jump properly.\n \t\timgWidth = 0\n \t\timgHeight = 1\n \t\tbegin\n \t\t data = nil\n \t\t if (imgPath =~ /.png$/)\n \t\t data = IO.read($pagesDir + \"/\" + imgPath, 8, 16).unpack('NN')\n\t\t else\n\t\t puts \"ERROR: Unsupported image type: #{imgPath}\"\n\t\t exit 1\n\t end\n \t\t if (data)\n \t\t imgWidth = data[0]\n \t\t imgHeight = data[1]\n\t\t end\n\t\t rescue\n\t end\n imgWidthHeightAttrs = \"\"\n if imgWidth != 0 and imgHeight != 0\n imgWidthHeightAttrs = \" width=\\\"#{imgWidth}\\\" height=\\\"#{imgHeight}\\\"\"\n end\n\n output += \"<p class=\\\"imageAndLabel\\\"><img src=\\\"#{imgPath}\\\" alt=\\\"\" + CGI::escapeHTML(label) + \"\\\"#{imgWidthHeightAttrs}/><br/><em>\" + CGI::escapeHTML(label) + \"</em></p>\\n\"\n next\n end\n \n # parse warning paragraphs\n warningMatch = line.match(/^!!\\s+(.*?)$/)\n if warningMatch\n output += \"<warning>\\n\" + warningMatch[1] + \"\\n<\\/warning>\\n\"\n next\n end\n \n output += line + \"\\n\"\n end\n \n # close off an open instructions div\n if inInstructions\n output += \"</instructions>\\n\"\n end\n \n # Markdown doesn't allow processing of markup within block-level tags such as <div>, so we have to manually process the markup.\n # We call preprocessMarkdownForHTML() to properly process our custom markup within these custom block elements.\n # An extra newline is added to force a paragraph\n while 1\n instructionsMatch = output.match(/(<instructions>)(.*?)(<\\/instructions>)/m)\n if instructionsMatch\n output[instructionsMatch[1]] = \"<div class=\\\"instructions\\\">\"\n output[instructionsMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+instructionsMatch[2]))\n output[instructionsMatch[3]] = \"</div>\"\n else\n break\n end\n end\n \n while 1\n warningMatch = output.match(/(<warning>)\\s*(.*?)(<\\/warning>)/m)\n if warningMatch\n output[warningMatch[1]] = \"<div class=\\\"warning\\\"><div class=\\\"warningBody\\\"><div class=\\\"warningImg\\\"></div><div class=\\\"warningContent\\\">\"\n output[warningMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+warningMatch[2]))\n output[warningMatch[3]] = \"</div></div></div>\"\n else\n break\n end\n end\n \n return output\nend",
"def process_markdown_inside_elements(doc)\n # parse block-level markdown elements in these HTML tags\n block_tags = ['div']\n\n elts = []\n @fragment.each_element('//*[@markdown]') do |e|\n elts << e\n end\n\n d = @fragment.children.first\n if d && HTML_INLINE_ELEMS.include?(first_node_name)\n elts << d unless d.attributes['markdown']\n elts += span_descendents(d)\n end\n\n # find span elements or elements with 'markdown' attribute\n elts.each do |e|\n # should we parse block-level or span-level?\n how = e.attributes['markdown']\n e.attributes.delete('markdown')\n\n next if \"0\" == how # user requests no markdown parsing inside\n parse_blocks = (how == 'block') || block_tags.include?(e.name)\n\n # Select all text children of e\n e.texts.each do |original_text|\n s = CGI.escapeHTML(original_text.value)\n unless s.strip.empty?\n # TODO extract common functionality\n parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)\n # restore leading and trailing spaces\n padding = /\\A(\\s*).*?(\\s*)\\z/.match(s)\n parsed = [padding[1]] + parsed + [padding[2]] if padding\n\n el = doc.md_el(:dummy, parsed)\n\n new_html = \"<dummy>\"\n el.children_to_html.each do |x|\n new_html << x.to_s\n end\n new_html << \"</dummy>\"\n\n newdoc = REXML::Document.new(new_html).root\n\n p = original_text.parent\n newdoc.children.each do |c|\n p.insert_before(original_text, c)\n end\n\n p.delete(original_text)\n end\n end\n end\n end",
"def example_markdown_targets()\n target_files = []\n\n example_dir = File.join(K4_ROOT, 'example')\n ext = 'md'\n filelist = FileList[File.join(example_dir, \"*.#{ext}\")]\n filelist.each do |source_path|\n source_basename = File.basename(source_path)\n next if source_basename =~ /^_/\n\n source_basename = source_basename.gsub(/#{ext}$/, 'html')\n target_path = File.join(example_dir, source_basename)\n # File.delete(target_path) if File.exists?(target_path)\n\n file(target_path) do |t, args|\n puts t.name\n src = File.read(source_path)\n compiler_ = MarkdownCompiler.new(@compiler)\n html_source = compiler_.to_slide(src)\n File.open(target_path, 'w') do |io|\n io.write(html_source)\n end\n end\n target_files << target_path\n end\n return target_files\n end",
"def contents()\n html = Nokogiri::HTML(@markdown_document.to_html())\n\n # Fixup refs to other markdown documents\n html.css(\"a\").each do |anchor|\n anchor[\"href\"] = anchor[\"href\"].sub(%r{\\.md$}, \".html\")\n end\n\n # Since we transform device-specific $device/README.md pages into\n # discrete $device.html, we need to fixup cross-linking into its namespace\n # This could be generalized some more, to be fixed once we have other internal links to mismatched README.md/index.html locations.\n if File.dirname(relative_output) == \"devices\"\n html.css(\"a\").each do |anchor|\n if anchor[\"href\"].match(%r{\\.\\./[^\\.]+$})\n anchor[\"href\"] = anchor[\"href\"].sub(%r{\\.\\./}, \"devices/\") + \".html\"\n end\n end\n end\n\n # Since Nokogiri produces a complete document from our fragment, we\n # have to pick only what's in the body; so strip the body added tags and higher-up tags.\n html\n .at_css(\"body\").to_s()\n .sub(%r{^<body>}, \"\").sub(%r{</body>$}, \"\")\n end",
"def markup_file_contents(contents); end",
"def substitute_markdown_inside_raw_html\n each_element(:raw_html) do |e|\n html = e.parsed_html\n next unless html\n\n html.process_markdown_inside_elements(self)\n end\n end",
"def process_markdown_inside_elements(doc)\n # find span elements or elements with 'markdown' attribute\n elts = @fragment.css(\"[markdown]\")\n\n d = @fragment.children.first\n if d && HTML_INLINE_ELEMS.include?(d.name)\n elts << d unless d.attribute('markdown')\n elts += span_descendents(d)\n end\n\n elts.each do |e|\n how = e['markdown']\n e.remove_attribute('markdown')\n\n next if \"0\" == how # user requests no markdown parsing inside\n parse_blocks = (how == 'block') || BLOCK_TAGS.include?(e.name)\n\n # Select all text children of e\n e.xpath(\"./text()\").each do |original_text|\n s = CGI.escapeHTML(original_text.text)\n unless s.strip.empty?\n parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)\n\n # restore leading and trailing spaces\n padding = /\\A(\\s*).*?(\\s*)\\z/.match(s)\n parsed = [padding[1]] + parsed + [padding[2]] if padding\n\n el = doc.md_el(:dummy, parsed)\n\n # Nokogiri collapses consecutive Text nodes, so replace it by a dummy element\n guard = Nokogiri::XML::Element.new('guard', @fragment)\n original_text.replace(guard)\n el.children_to_html.each do |x|\n guard.before(x.to_s)\n end\n guard.remove\n end\n end\n end\n end",
"def parse_markdown\n self.body_html = markdown.render(body_markdown.to_s)\n self.summary_html = markdown.render(summary_markdown.to_s)\n end",
"def parse_markdown\n self.bio_html = markdown.render(bio_markdown)\n end",
"def parse_html_files\n Find.find(Dir.getwd) do |file|\n if !File.directory? file and File.extname(file) == '.html'\n # exclude and skip if in a bad directory\n # we may be on an html file, but some we just do not want\n current = File.new(file).path\n\n # skip these folders entirely\n if current.match(/(blog|old|draft|archive|font)/i)\n next\n end\n\n # open file, pluck content out by its element(s)\n page = Nokogiri::HTML(open(file));\n\n # grab title\n title = page.css('title').text.to_s;\n title = strip_bad_chars(title)\n\n # for page title, destroy any pipes and MS pipes and return the first match\n title.sub!('Velir | ', '')\n\n # Grab hero title and tagline\n hero = page.css('article.type-centered h2').text\n hero_tagline = page.css('article.type-centered .type-hero').text\n\n # grab the body content\n body = page.css('.outer-wrapper .row .columns').to_html\n body = clean_body(body)\n\n # clean the file path\n path = File.new(file).path\n path.gsub! $base_path, \"/\"\n\n # if we have content, add this as a page to our page array\n if (body.length > 0)\n $count += 1\n puts \"Processing \" + title\n\n # insert into array\n data = {\n 'title' => title,\n 'path' => path,\n 'hero' => hero,\n 'hero_tagline' => hero_tagline,\n 'body' => body,\n }\n\n $pages.push data\n end\n end\n end\n\n write_csv($pages)\n report($count)\nend",
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def render_markdown(file)\n renderer = PygmentizeHTML\n extensions = {:autolink => true, :hard_wrap => true, :space_after_headers => true, :highlight => true, :tables => true, :fenced_code_blocks => true, :gh_blockcode => true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n @file = redcarpet.render file\n end",
"def extractTags()\n line = @lines[@currentLine]\n re = /\\[([^\\[]+)\\]/m\n while line =~ re\n @currentBlock.addTag($~[1])\n line = line.sub(re, '')\n end\n end",
"def process_markdown\n self.data = self.class.convert_markdown(self.data)\n sanitize_html\n end",
"def liquidize_markdown(content, arguments)\n # doc = BlueCloth.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n # :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}))\n doc = ::Kramdown::Document.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}),\n :parse_block_html => true)\n return doc.to_html.html_safe\n end",
"def convertHtmlToMarkdown\n root = pathExports\n n = 1\n Pathname.glob(pathExports() + \"**/*.html\").each do |p|\n puts \"File \" + n.to_s + \": \" + p.to_s\n n = n + 1\n infile = p.to_s\n outfile = p.sub_ext(\".md\").to_s\n command = \"pandoc -f html -t markdown -o #{outfile} #{infile}\"\n puts command\n sh(command)\n end\nend",
"def main\n blog = File.read(FILE_PATH).gsub(/-----[\\r\\n|\\n|\\r]EXTENDED BODY:/, '<!-- more -->')\n articles = split_to_articles(blog)\n headers_and_bodies = split_to_headers_and_bodies(articles)\n\n headers_and_bodies.each do |header_and_body|\n header_and_body[:header] = convert_header(header_and_body[:header])\n header_and_body[:body] = ReverseMarkdown.convert header_and_body[:body]\n end\n\n create_md_file(headers_and_bodies)\nend",
"def parse!\n md = File.read(filename)\n doc = Kramdown::Document.new(md, input: 'GFM')\n\n # extract toc\n toc_start, toc_end = Danger::Toc::Extractor.convert(doc.root).first\n @has_toc = toc_start && toc_end\n @toc = md.split(\"\\n\")[toc_start, toc_end - toc_start - 1].reject(&:empty?) if @has_toc\n\n # construct toc\n @headers = Danger::Toc::Constructors.current.convert(doc.root).first\n end",
"def markdown_to_html\n html = RDiscount.new(File.read file).to_html\n html = syntax_highlight(html) if config.highlighter\n html = prepend_h1(html) if config.autoh1\n html\n end",
"def html_markup_markdown(text); end",
"def block_html(html)\n html.gsub(/<markdown>([\\d\\D]+?)<\\/markdown>/) {|_|\n extensions = {fenced_code_blocks: true}\n renderer = Redcarpet::Markdown.new(WithHighlights, extensions)\n renderer.render(Regexp.last_match[1])\n }\n end",
"def to_markdown\n lines = @bare_content.split(\"\\n\")\n markdown = \"\"\n\n # Using `while` here so we can alter the collection at will\n while current_line = lines.shift\n # If we got us some of them bird tracks...\n if current_line =~ BIRD_TRACKS_REGEX\n # Remove the bird tracks from this line\n current_line = remove_bird_tracks(current_line)\n # Grab the remaining code block\n current_line << slurp_remaining_bird_tracks(lines)\n\n # Fence it and add it to the output\n markdown << \"```haskell\\n#{current_line}\\n```\\n\"\n else\n # No tracks? Just stick it back in the pile.\n markdown << current_line + \"\\n\"\n end\n end\n\n markdown\n end",
"def call\n doc.search('pre').each do |pre|\n process_pre_tag(pre)\n end\n\n doc\n end",
"def parse_markdown_file file_uri, parsed_uris=Set.new\n $logger.info \"Parsing '#{file_uri}'\"\n parsed_uris.add file_uri\n begin\n markdown_text = File.read(file_uri)\n markdown_tree = Kramdown::Document.new(markdown_text)\n rescue Exception => e\n # Continue on even if we can't parse a file\n # because the markdown file could have put in broken links\n # Or if a uri has a # tag in it\n $logger.warn \"Could not read markdown file '#{file_uri}' in '#{FileUtils.pwd}' => #{e}\"\n return false, []\n end\n # A set of uris which are actually references to a real local file\n valid_uris = Set.new [file_uri]\n relative_uris = find_relative_uris markdown_tree\n $logger.debug(\"Detected relative uris in '#{file_uri}': '#{relative_uris}'\")\n relative_uris.each do |uri|\n $logger.debug(\"File '#{uri}' in previously parsed files #{parsed_uris.inspect}: #{parsed_uris.include? uri}\")\n unless parsed_uris.include? uri\n $logger.debug(\"Detected new file in '#{file_uri}' to parse: '#{uri}'\")\n is_valid_markdown, new_valid_uris = parse_markdown_file uri, parsed_uris\n parsed_uris.add uri\n if is_valid_markdown\n $logger.debug(\"Adding file '#{uri}' because it is valid markdown: #{is_valid_markdown}\")\n valid_uris.merge new_valid_uris\n # Even if it's not markdown,\n # If we find a link to a local file (e.g. an image)\n # add it as a valid uri\n elsif File.file?(uri)\n $logger.debug(\"Adding file '#{uri}' because it is found locally.\")\n valid_uris.add uri\n end\n end\n end\n $logger.debug \"Valid uris connected to '#{file_uri}': '#{valid_uris.inspect}'\"\n return true, valid_uris\nend",
"def extract_metadata(file)\n document = parse_kramdown(file)\n toc = ::Kramdown::Converter::Toc.convert(document.root)\n toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t| \n {:id => t.attr[:id], :text => t.value.children.first.value}\n end\n\n metadata = document.root.options[:metadata]\n metadata[:toc] = toc_items\n metadata[:converted] = document.to_html\n metadata[:technologies] = metadata[:technologies].split(\",\").collect {|tech| tech.strip}\n metadata[:images] = find_images(document.root)\n metadata[:author] = metadata[:author].split(',').first if metadata[:author]\n metadata[:commits] = commit_info @repo, Pathname.new(file)\n metadata[:current_tag] = current_tag @repo, Pathname.new(file)\n metadata[:current_branch] = current_branch @repo, Pathname.new(file)\n metadata[:github_repo_url] = repository_url @repo\n metadata[:contributors] = metadata[:commits].collect { |c| c[:author] }.uniq\n metadata[:contributors_email] = metadata[:commits].collect { |c| c[:author_email] }.uniq\n metadata[:contributors].delete(metadata[:author])\n metadata[:product] = @product if @product\n metadata[:experimental] = @experimental\n metadata\n end",
"def recursive_render(markdown)\n Redcarpet::Markdown.new(self.class, @options).render(markdown)\n end",
"def content \n \trenderer = SyntaxRenderer.new(optionize [\n \t:with_toc_data,\n \t#{:hard_wrap,\n \t:xhtml,\n \t:prettify\n \t])\n \n \tmarkdown = Redcarpet::Markdown.new(renderer, optionize([\n \t:fenced_code_blocks,\n \t:no_intra_emphasis,\n \t:tables,\n \t:superscript,\n \t:autolink,\n \t:strikethrough,\n \t:space_after_headers,\n \t:with_toc_data,\n \t:quote,\n \t:lax_spacing\n \t]))\n \n \treturn markdown.render(parse_links(@content)) \n\tend",
"def post_processing_slides( content )\n \n # 1) add slide breaks\n \n if config.slide? # only allow !SLIDE directives fo slide breaks?\n # do nothing (no extra automagic slide breaks wanted)\n else \n if (@markup_type == :markdown && Markdown.lib == 'pandoc-ruby') || @markup_type == :rest\n content = add_slide_directive_before_div_h1( content )\n else\n if config.header_level == 2\n content = add_slide_directive_before_h2( content )\n else # assume level 1\n content = add_slide_directive_before_h1( content )\n end\n end\n end\n\n\n dump_content_to_file_debug_html( content )\n\n # 2) use generic slide break processing instruction to\n # split content into slides\n\n slide_counter = 0\n\n slides = []\n slide_buf = \"\"\n \n content.each_line do |line|\n if line.include?( '<!-- _S9SLIDE_' )\n if slide_counter > 0 # found start of new slide (and, thus, end of last slide)\n slides << slide_buf # add slide to slide stack\n slide_buf = \"\" # reset slide source buffer\n else # slide_counter == 0\n # check for first slide with missing leading SLIDE directive (possible/allowed in takahashi, for example)\n ## remove html comments and whitspaces (still any content?)\n ### more than just whitespace? assume its a slide\n if slide_buf.gsub(/<!--.*?-->/m, '').gsub( /[\\n\\r\\t ]/, '').length > 0\n logger.debug \"add slide with missing leading slide directive >#{slide_buf}< with slide_counter == 0\"\n slides << slide_buf\n slide_buf = \"\"\n else\n logger.debug \"skipping slide_buf >#{slide_buf}< with slide_counter == 0\"\n end\n end\n slide_counter += 1\n end\n slide_buf << line\n end\n \n if slide_counter > 0\n slides << slide_buf # add slide to slide stack\n slide_buf = \"\" # reset slide source buffer \n end\n\n\n slides2 = []\n slides.each do |source|\n slides2 << Slide.new( source, config )\n end\n\n\n puts \"#{slides2.size} slides found:\"\n \n slides2.each_with_index do |slide,i|\n print \" [#{i+1}] \"\n if slide.header.present?\n print slide.header\n else\n # remove html comments\n print \"-- no header -- | #{slide.content.gsub(/<!--.*?-->/m, '').gsub(/\\n/,'$')[0..40]}\"\n end\n puts\n end\n \n \n # make content2 and slide2 available to erb template\n # -- todo: cleanup variable names and use attr_readers for content and slide\n\n ### fix: use class SlideDeck or Deck?? for slides array?\n \n content2 = \"\"\n slides2.each do |slide|\n content2 << slide.to_classic_html\n end\n \n @content = content2\n @slides = slides2 # strutured content\n end",
"def content!\n if File.exist?(file)\n markdown_to_html\n else\n @type = :empty\n \"\"\n end\n end",
"def include(template_file_path, markdown_file_path)\n send(:generate_file, template_file_path, markdown_file_path, __method__) do |input_lines, output_lines|\n send(:include_files, template_file_path, input_lines, output_lines, Inclusions.new)\n end\n end",
"def embed_md_erb(filename) # => markdown string\n ERB.new(File.read(filename)).result(binding)\n end",
"def extract(contents)\n file_text, matches = parse(contents)\n\n extracted_ruby = +''\n\n last_match = [0, 0]\n matches.each_with_index do |(start_index, end_index), index|\n handle_region_before(start_index, last_match.last, file_text, extracted_ruby)\n\n match_marker = \"#{region_start_marker}_#{format('%010d', index + 1)}\" if region_start_marker\n extracted_ruby << extract_match(file_text, start_index, end_index, match_marker)\n\n last_match = [start_index, end_index]\n end\n\n extracted_ruby << file_text[last_match.last..-1].gsub(/./, ' ')\n\n # if we replaced <%== with <%= raw, try to shift the columns back to the\n # left so they match the original again\n extracted_ruby.gsub!(/ raw/, 'raw')\n\n extracted_ruby\n end",
"def process_files(log)\n each_exercise_file do |root, position, original_id, title|\n\n description = markdown(root, 'description') || (log.no_description title; next)\n\n hint = markdown(root, 'hint')\n\n meta = meta(root) || (log.no_meta(title); next)\n\n test_code, test_extension = test_code(root) || (log.no_test title; next)\n\n extra_code, _extra_extension = extra_code(root)\n\n language = language(test_extension) || (log.no_lang(title); next)\n\n expectations = (expectations(root).try { |it| it['expectations'] } || []).map do |e|\n Expectation.new(binding: e['binding'], inspection: e['inspection'])\n end\n\n yield original_id,\n {title: title,\n description: description,\n hint: hint,\n tag_list: meta['tags'],\n locale: meta['locale'],\n language: language,\n expectations: expectations,\n author: @author,\n test: test_code,\n extra_code: extra_code,\n position: position}\n end\n end",
"def traverse_nav_markdown(node)\n\t\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\t node.children.items.each_with_index do |child|\n\n\t\t\t\t items = traverse_nav_markdown(child)\n\t\t\t\t child.children = Map.new unless child.children?\n\t\t\t\t child.children.count = 0 unless child.children.count?\n\t\t\t\t child.children.items = [] unless child.children.items?\n\t\t \n\t\t\t\t child.children.count = items.size\n\t\t\t\t child.children.items = items\t\t\t\t\n\n\t\t\t end\n\t\tend\n\t\n\t\tnode_list = nil\n\t\tif node.children? and node.children.items?\n\t\t\tnode_list = node.children.items\n\t\tend\n\t\n\t\tmarkdowns = Dir.glob(\"#{node.source_path}/*.markdown\")\n\t\n\t\t# if we are at the root node (content source), don't process markdowns here (home.markdown handled separately, special)\n\t\tmarkdowns = [] if node.nav_level == 0\n\t\n\n\t\tif markdowns.size > 0 and node.nav_level > 0\n\n\t\t\t#puts\n\t\t\t#puts \"#{node.source} - #{node.children?}\"\n\t\t\tnode.children = Map.new unless node.children?\n\t\t\tnode.children.count = 0 unless node.children.count?\n\t\t\tnode.children.items = [] unless node.children.items?\n\t\t\t#puts \"#{node.source} - #{node.children?} - #{node.children.count?}\"\n\t\t\n\t\t\tnode_list = node.children.items\n\t\t\t\n\t\t\tmarkdowns.each do |md|\t\t\t\t\t\t\n\t\t\t\tsource = md.gsub(/#{node.source_path}\\//, \"\").gsub(/.markdown/, \"\")\n\t\t\t\n\t\t\t\tis_cbdoc_special_file = source.start_with? \"aaab-\"\n\t\t\t\n\t\t\t\tunless is_cbdoc_special_file\t\t\t\t\n\t\t\t\t\n\t\t\t\t\tif node.link?\n\t\t\t\t\t\tlink = node.link + \"/\" + source \n\t\t\t\t\telse\t\t \n\t\t\t\t\t\tnode.link = \"undefined\"\n\t\t\t\t\t\tputs node.nav_type\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\tsource_path = node.source_path + \"/\" + source\t\t\t \n\n\t\t\t\t\tis_markdown_and_folder = (File.exist?(\"#{source_path}\") && File.directory?(\"#{source_path}\"))\n\t\t\t\n\t\t\t\t\tunless is_markdown_and_folder\t\t \n\t\t\t\t\t\n\t\t\t\t\t\tfull_link = (node.link.start_with?(\"/#{CONTENT_LINK_PREFIX}/\") ?\tlink : \"/#{CONTENT_LINK_PREFIX}/\" + link )\n\t\t\t\t\t\tparent_path = node.source_path\n\t\t\t\t\t\tparent_full_link = (node.link.start_with?(\"/#{CONTENT_LINK_PREFIX}/\") ?\t node.link : \"/#{CONTENT_LINK_PREFIX}/\" + node.link )\n\t\t\t\t\n\t\t\t\t\t\titem = Map.new({\n\t\t\t\t\t\t\tdoctype: \"nav\",\n\t\t\t\t\t\t\tsubtype: \"nav_\" + (node.nav_level + 1).to_s,\n\t\t\t\t\t\t\tnav_type: \"markdown\",\n\t\t\t\t\t\t\tnav_level: node.nav_level + 1,\t\t\t\t\n\t\t\t\t\t\t\tnav_order: 9000,\n\t\t\t\t\t\t\tnav_title: process_navigation_name(source),\n\t\t\t\t\t\t\tsource: source,\n\t\t\t\t\t\t\tlink: link,\n\t\t\t\t\t\t\tfull_link: full_link,\n\t\t\t\t\t\t\tparent: node.source,\n\t\t\t\t\t\t\tparent_nav_title: node.nav_title,\n\t\t\t\t\t\t\tparent_link: node.link,\n\t\t\t\t\t\t\tparent_full_link: parent_full_link,\n\t\t\t\t\t\t\tparent_path: parent_path,\n\t\t\t\t\t\t\tsource_path: source_path,\n\t\t\t\t\t\t\tancestors: [],\n\t\t\t\t\t\t\tancestors_links: [],\n\t\t\t\t\t\t\tsiblings: [],\n\t\t\t\t\t\t\tsiblings_links: [],\n\t\t\t\t\t\t\tdescendants: [],\n\t\t\t\t\t\t\tdescendants_links: []\t\t\t\t \n\t\t\t\t\t\t})\n\t\t\t\t\t\n\t\t\t\t\t\tnode_list << item \n\t\t\t\t\tend\t\t \n\t\t\t\tend\n\t\t\tend\t\t \n\t\tend\n\t\n\t\t#ap node_list\n\t\n\t\tnode_list\n\tend",
"def _find_links_in_markdown_tree markdown_tree_node\n case markdown_tree_node.type\n when :a\n links = [markdown_tree_node.attr['href']]\n when :img\n links = [markdown_tree_node.attr['src']]\n else\n links = []\n end\n markdown_tree_node.children.each { |child| links.concat _find_links_in_markdown_tree child }\n return links\nend",
"def parse_tagfile\n tagfile_sections = tagfile.split(\"\\f\\n\")\n tagfile_sections.shift # first section is blank\n\n tagfile_sections.map do |c_file_section|\n file_name, content = file_name_and_content_for(c_file_section)\n CFile.new(file_name: file_name, content: content, ruby_source_folder: ruby_source_folder)\n end\n end",
"def extract_body(file_path)\n text = File.open(file_path).read\n text.sub!(/---\\n.*?---\\n/m, '')\n Kramdown::Document.new(\n text,\n auto_ids: false,\n enable_coderay: true,\n coderay_line_numbers: nil\n ).to_html\n end",
"def build_mdlinks\n return unless options.Build_Markdown_Links\n\n puts_cyan \"Middlemac is creating `#{options.File_Markdown_Links}`.\"\n\n files_array = []\n out_array = []\n longest_shortcut = 0\n longest_path = 0\n\n Dir.glob(\"#{app.source}/Resources/**/*.erb\").each do |fileName|\n\n # Remove all file extensions and make a shortcut\n base_name = fileName\n while File.extname(base_name) != '' do\n base_name = File.basename( base_name, '.*' )\n end\n next if base_name.start_with?('_') # || base_name == 'index'\n\n if base_name == 'index'\n shortcut = \"[#{File.split(File.split(fileName)[0])[1]}_index]:\"\n\n else\n shortcut = \"[#{base_name}]:\"\n end\n\n # Make a fake absolute path\n path = Pathname.new(fileName).relative_path_from(Pathname.new(app.source))\n path = File::SEPARATOR + File.join(File.dirname(path), base_name) + '.html'\n\n # Get the title, if any\n metadata = YAML.load_file(fileName)\n title = (metadata.is_a?(Hash) && metadata.key?('title')) ? metadata['title'] : ''\n\n files_array << { :shortcut => shortcut, :path => path, :title => title }\n\n longest_shortcut = shortcut.length if shortcut.length > longest_shortcut\n longest_path = path.length if path.length > longest_path\n\n end\n\n files_array = files_array.sort_by { |key| [File.split(key[:path])[0], key[:path]] }\n files_array.uniq.each do |item|\n item[:shortcut] = \"%-#{longest_shortcut}.#{longest_shortcut}s\" % item[:shortcut]\n\n if item[:title].length == 0\n out_array << \"#{item[:shortcut]} #{item[:path]}\"\n else\n item[:path] = \"%-#{longest_path}.#{longest_path}s\" % item[:path]\n out_array << \"#{item[:shortcut]} #{item[:path]} \\\"#{item[:title]}\\\"\"\n end\n end\n\n File.open(options.File_Markdown_Links, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end",
"def markdown\n return if changed_markdown_files.empty?\n\n output = `mdl #{changed_markdown_files.join(' ')}`\n return if output&.empty?\n\n heading('Markdown Linter', output)\n end",
"def parse!(content)\n @children = []\n @content = ''\n\n # Parse all direct children and create new markdown objects\n sections = Section.generate_sections(content)\n\n # No children!\n if sections.empty?\n @content = content\n return\n end\n\n # Populate content prior to found headers\n @content = content[0..sections.first.header_location.begin - 1] if sections.first.header_location.begin > 0\n\n parse_children!(sections)\n end",
"def to_md\n # Usually ruby is extremely readable, but I think \"-1\" means \"give me all the \n # trailing blank lines\" is surprisingly opaque. That's what the -1 does...\n lines = @text.split(\"\\n\", -1)\n lines.collect do |line|\n result = line\n \n # Leave lines that start with 4 spaces alone. These are code blocks and\n # should pass through unchanged.\n unless result =~ /^\\s{4,}/\n \n # Convert headers\n result.sub!(/^(=){1,6}/) { |s| \"#\" * s.length} unless result =~ /^={7,}/\n \n # Convert strong to have two stars\n # The matching pair of stars should start with a single star that is either at\n # the beginning of the line or not following a backslash, have at least one\n # non-star and non-backslash in between, then end in one star\n result.gsub!(/(\\A|[^\\\\\\*])\\*([^\\*]*[^\\*\\\\])\\*/, '\\1**\\2**')\n\n # Convert inline code spans to use backticks\n result.gsub!(/(\\A|[^\\\\])\\+([^\\+]+)\\+/, '\\1`\\2`')\n\n # Convert bare http:, mailto: and ftp: links\n result.gsub!(/(\\A|\\s)(http:|https:|mailto:|ftp:)(\\S*)/, '\\1[\\2\\3](\\2\\3)')\n\n # Convert bare www to an http: link\n result.gsub!(/(\\A|\\s)www\\.(\\S*)/, '\\1[www.\\2](http://www.\\2)')\n\n # Convert link: links to refer to local files\n result.gsub!(/(\\A|\\s)link:(\\S*)/, '\\1[\\2](\\2)')\n\n # Convert multi word labels surrounded by {} with a url\n result.gsub!(/\\{([^\\}]*)\\}\\[(\\S*)\\]/, '[\\1](\\2)')\n\n # Convert one word labels with a url\n result.gsub!(/(\\A|\\s)([^\\{\\s]\\S*)\\[(\\S*)\\]/, '\\1[\\2](\\3)')\n\n end\n \n result\n end.join(\"\\n\")\n end",
"def markdown\n @markdown ||= process_markdown!\n end",
"def tag_manifested_files\n tagmanifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n path\n end\n }\n (acc + files).uniq\n end\n end",
"def recursive_render(markdown)\n Redcarpet::Markdown.new(self.class, REDCARPET_OPTIONS).render(markdown)\n end",
"def parse_tree\n File.open(html_file, 'r') do |file|\n current = nil\n file.each_line do |line|\n line.scan(%r{(<(.*?>.*?)<(\\/.*?)>|<(.*?)>(.*))}).each do |tag|\n if !tag[3].nil? && tag[3].start_with?('/') # ending tag\n current = current.parent\n else\n node = Node.new(tag)\n if @root.nil?\n @root = node\n else\n node.parent = current\n current.childs << node\n end\n @tags << node.tag\n current = node\n current = current.parent if !tag[2].nil? && tag[2].start_with?('/')\n end\n end\n end\n end\n end",
"def build_mdimages\n\n return unless options.Build_Markdown_Images\n\n puts_cyan \"Middlemac is creating `#{options.File_Markdown_Images}`.\"\n\n files_array = []\n out_array = []\n longest_shortcut = 0\n\n Dir.glob(\"#{app.source}/Resources/**/*.{jpg,png,gif}\").each do |fileName|\n\n # Remove all file extensions and make a shortcut\n base_name = fileName\n while File.extname(base_name) != '' do\n base_name = File.basename( base_name, '.*' )\n end\n next if base_name.start_with?('_')\n shortcut = \"#{base_name}\"\n\n # Make a fake absolute path `/Resources/...`. Middleman will convert\n # these to appropriate relative paths later, and this will just\n # magically work in the helpbooks. \n path = File::SEPARATOR + Pathname.new(fileName).relative_path_from(Pathname.new(app.source)).to_s\n\n files_array << { :shortcut => shortcut, :path => path }\n\n # We will format the destination file nicely with spaces.\n # +3 to account for bracketing []:\n longest_shortcut = shortcut.length + 3 if shortcut.length + 3 > longest_shortcut\n\n end\n\n files_array = files_array.uniq.sort_by { |key| [File.split(key[:path])[0], key[:path]] }\n \n # Now add virtual `all-` items for target-specific items for which no `all-` exists.\n # Middlemac will intelligently support target-specific image files, but it will\n # never have the chance unless a markdown reference is present in this file. Of\n # course this only applies if you're using reference notation.\n options.Targets.keys.each do |target|\n \n # Build an array of all files starting with `target-`\n current_set = files_array.select { |item| item[:shortcut].start_with?(\"#{target.to_s}-\") }\n \n # For each of these items, check to see if `all-` exists.\n current_set.each do |item|\n \n seek_for = item[:shortcut].sub(\"#{target.to_s}-\", \"all-\")\n unless files_array.any? { |hash| hash[:shortcut] == seek_for }\n \t\t\t path = item[:path].sub(\"#{target.to_s}-\", \"all-\")\n \t\t\t files_array << { :shortcut => seek_for, :path => path }\n \t\t\tend\n end\n end\n\n # Create the actual output from the files_array.\n files_array.each do |item|\n # Just a reminder to myself that this is a format string. \n shortcut_out = \"%-#{longest_shortcut}.#{longest_shortcut}s\" % \"[#{item[:shortcut]}]:\"\n out_array << \"#{shortcut_out} #{item[:path]}\"\n end\n\n File.open(options.File_Markdown_Images, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def process\n filename = \"index.markdown\"\n markdowns = {filename => []} \n state = :message\n message = [\"\\n\"]\n patch = []\n commit = nil\n (@gitlogp.split(\"\\n\")+[\"DONE\"]).each { |line|\n words=line.split\n if line.slice(0,1)==\" \" || words.length==0\n # commit messages start with 4 spaces, diff contents with 1 space\n if state==:message\n if words[0]==\"OUTPUT_FILE:\"\n filename = words[1]\n markdowns[filename] ||= []\n else\n message << \"#{line.slice(4..-1)}\"\n end\n else\n patch << \" #{line}\" if state==:patch\n end\n elsif words[0]==\"commit\" or words[0]==\"DONE\"\n if !commit.nil?\n # replace the short description line with a named link\n shortlog = message[2]\n message[2] = \"<a name='#{shortlog}'> </a>\"\n markdowns[filename] += message.map {|l|\n if l==\"SHOW_PATCH\"\n (patch+[\"{: .diff}\\n\"]).join(\"\\n\")\n else\n l\n end\n }\n series = tags[commit].slice(-2..-1)\n markdowns[filename] << \"\\n#{tags[commit]}: [view on github](#{@commit_link_base}#{commit}), [download #{series}-#{shortlog}.patch](#{@patch_link_base}/#{series}-#{shortlog}.patch)\\n{: .commit}\\n\"\n end\n \n message=[\"\\n\"]\n patch=[]\n\n commit = words[1]\n state = :message\n elsif [\"Author:\", \"Date:\", \"new\", \"index\", \"---\", \"+++\", '\\\\'].include?(words[0])\n # chomp\n elsif words[0]==\"diff\"\n state = :patch\n left = words[2].slice(2..-1)\n right = words[3].slice(2..-1)\n if left==right\n patch << \" ::: #{right}\"\n else\n patch << \" ::: #{left} -> #{right}\"\n end\n elsif words[0]==\"@@\"\n # git tries to put the function or class name after @@. This\n # works great for C diffs, but it only finds the class name in\n # Ruby, which is usually similar to the file name, Therefore\n # it's distracting cruft. Toss it.\n patch << \" #{words.slice(0,4).join(\" \")}\"\n else\n message << \"#{line.slice(4..-1)}\" if state==:message\n patch << \" #{line}\" if state==:patch \n end\n }\n output = {}\n markdowns.each do |fn, markdown|\n output[fn] = markdown.join(\"\\n\")\n Rails.logger.info(output[fn]) if respond_to? :Rails\n end\n return output\n end",
"def get_content(file_path)\n puts \"getting markdown for: #{file_path}.md\\n\\n\"\n file = File.open(\"data/pages/#{file_path}.md\", \"r\")\n return file.read\nend",
"def markup_code\n return '' unless @token_stream\n\n src = RDoc::TokenStream.to_html @token_stream\n\n # dedent the source\n indent = src.length\n lines = src.lines.to_a\n lines.shift if src =~ /\\A.*#\\ *File/i # remove '# File' comment\n lines.each do |line|\n if line =~ /^ *(?=\\S)/\n n = $&.length\n indent = n if n < indent\n break if n == 0\n end\n end\n src.gsub!(/^#{' ' * indent}/, '') if indent > 0\n\n add_line_numbers(src) if options.line_numbers\n\n src\n end",
"def html_to_markdown(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".html\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n html_content = `pandoc -f html -t markdown \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return html_content\n end",
"def call\n result = self.class.markdown_renderer.result(schema: schema)\n if @html\n result = self.class.html_renderer.result(body: self.class.redcarpet.render(result))\n result.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n result\n end\n end",
"def build\n html = []\n scripts.each do |script|\n code = File.read(script)\n html << %[<div class=\"file\" id=\"#{script}\"><pre>]\n html << highlight(code)\n html << %[</pre></div>]\n end\n text = html.join(\"\\n\")\n text = interlink(text)\n text = garnish(text)\n text\n end",
"def parse(content, open_tags, prev_level, root_level)\n File.open(\"#{file.path}\", \"r\").each_line do |line|\n\n next if /^\\s*$/ === line\n\n line = line.chomp.split(/\\s+/, 3)\n \n level = line.shift.to_i\n \n if prev_level.nil?\n prev_level = root_level = level-1 # not assuming base level is 0\n end\n \n (level..prev_level).to_a.reverse.each do |i|\n content << \"\\t\" * (i - root_level) if content[-1] == ?\\n\n content << \"</#{open_tags.pop}>\\n\"\n end\n \n if line[0][0] == ?@\n xref_id, tag = line\n xref_id.gsub!(/^@(.*)@$/, '\\1')\n id_attr = ' id=\"' + xref_id + '\"'\n value = ''\n else\n tag, value = line\n id_attr = ''\n value ||= ''\n if /^@(\\w+)@$/ === value\n value = \"<xref>#{$1}</xref>\"\n else\n value.gsub!(/&/, '&')\n value.gsub!(/</, '<')\n value.gsub!(/>/, '>')\n end\n end\n \n if tag == 'CONC' || tag == 'CONT'\n content << (tag == 'CONT' ? \"\\n\" : \" \")\n content << value\n level -= 1\n else\n content << \"\\n\" if level > prev_level\n tag.downcase!\n content << \"\\t\" * (level - root_level) + \"<#{tag}#{id_attr}>#{value}\"\n open_tags.push tag\n end\n \n prev_level = level\n end\n content\n end",
"def markdownify(input); end",
"def render_md(site, readme)\n begin\n mkconverter = site.getConverterImpl(Jekyll::Converters::Markdown)\n readme.gsub! \"```\",\"\\n```\"\n readme.gsub! '```shell','```bash'\n return mkconverter.convert(readme)\n rescue\n return 'Could not convert readme.'\n end\nend",
"def process(content, uri, args = \"\")\n html_doc = Nokogiri::HTML(content) do |config| config.noerror end\n\n node = html_doc.xpath(\"//div[@class='markdown-body']\").first\n\n stamp(node, uri, 'github-wiki')\n\n if args.include?(\"reduce-headings\") then\n 5.downto(1) { |level|\n node.xpath(\"//h#{level}\").each { |heading_node|\n heading_node.name = \"h#{level+1}\"\n }\n }\n end\n\n node.to_s\n end",
"def to_markdown\n files = Dir.glob('**/*.html')\n files.each do |f|\n new_f = f.gsub 'html', 'markdown'\n system \"mv #{f} #{new_f}\" if File.file? f\n end\n end",
"def searchable_content(file)\n content = File.read file\n content = CommonMarker.render_html content\n content.remove(/<\\/?[^>]*>/).gsub(\"\\n\", \" \")\n end",
"def writeMarkdown(doc, page)\n\n layers = page[\"children\"].reverse\n pagetitle = page[\"name\"]\n blocks = []\n\n # Let's get the text layers\n text = layers.select do |layer|\n layer[\"type\"] === \"TEXT\"\n end\n\n # Let's get only the frames\n frames = layers.select do |layer|\n layer[\"type\"] === \"FRAME\"\n end\n \n # let's build this\n frames.each do |frame|\n ftitle = self.showTitle?(frame[\"name\"]) ? frame[\"name\"] : nil\n fimage = self.getFrameImage(doc, page[\"name\"], frame)\n ftext = self.getFrameText(text, frame[\"name\"])\n\n blocks.push([ftitle, \"/#{@assetpath}/#{fimage}\", ftext])\n end\n\n\n # Do we have a summary?\n summary = text.select do |layer|\n layer[\"name\"] == \"_summary.md\"\n end\n\n summary = summary.size > 0 ? summary.first[\"characters\"] : nil\n\n # Do we have a tags?\n tags = text.select do |layer|\n layer[\"name\"] == \"_tags\"\n end\n\n tags = tags.size > 0 ? tags.first[\"characters\"] : nil\n menutag = !tags.nil? ? tags.split(\",\").first : nil\n\n \n # Export markdown from erb template\n filename = \"#{doc[\"document\"].parameterize}-#{pagetitle.parameterize}\"\n template = File.read('_plugins/figma-template.md.erb')\n result = ERB.new(template).result(binding)\n\n open(\"#{@pagespath}/#{filename}.md\", \"wb\") { |file|\n file.write(result)\n file.close\n }\n\n [pagetitle, filename, menutag]\n end",
"def all_contents\n yml_filenames = Dir.glob(settings.root + '/contents/*.yml')\n yml_filenames.map { |filename|\n id = filename.match(/\\/contents\\/(.*)\\.yml/)[1]\n content_info(id)\n }\n end",
"def call\n markdown = markdown_renderer.result(schema: schema)\n if @html\n html = markdown_parser.render(markdown)\n html = html_renderer.result(body: html)\n html.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n markdown\n end\n rescue Jdoc::Link::ExampleNotFound => exception\n abort(\"Error: #{exception.to_s}\")\n end",
"def call\n # mode = (context[:gfm] != false) ? :gfm : :markdown\n # html = GitHub::Markdown.to_html(@text, mode)\n # html.rstrip!\n # html\n\n options = context[:redcarpet_options] || {}\n renderer = HtmlWithRouge.new(\n filter_html: options.fetch(:filter_html, false),\n hard_wrap: options.fetch(:hard_wrap, true)\n )\n options.reject! { |k, v| [:filter_html, :hard_wrap].include?(k) }\n markdown = Redcarpet::Markdown.new(renderer, options)\n html = markdown.render(@text)\n html.rstrip!\n html\n end",
"def split_file file\r\n lines = []\r\n has_error = false\r\n File.foreach(file).with_index do |line, line_num|\r\n line_content = line.strip\r\n if line_content.start_with? \"//\" or $ext == \".md\"\r\n line_content.sub!('//', '')\r\n sl = SourceLine.new(file, line_num + 1, line_content)\r\n has_error = sl.parse\r\n lines.push sl\r\n end\r\n end\r\n lines\r\n SourceFile.new(file, lines, has_error)\r\nend",
"def siblings\n # List other markdown files in the same folder.\n\n # Sibling folder.\n folder = File.dirname @absolute_path\n\n Slimdown::Folder.new(folder).pages\n end",
"def process_markup()\n [title,content].each do |text|\n next if !text\n clear_webpage(text).scan(PTN_MARKUP).map{|e|e[0].split(PTN_ELEMENT_SEP)}.flatten.each do |element|\n #debug \"[process_markup] element: \"+element.inspect\n next if !element\n ptn = element.scan(PTN_METADATA)\n #debug \"[process_markup] ptn: \"+ptn.inspect\n if ptn.size > 0\n m[ptn[0][0].to_sym] = parse_value(ptn[0][1])\n else\n create_and_link(element, 'tag' , \"t\")\n #add_tags(element, \"m\")\n end\n end#scan\n end#each\n end",
"def to_html(content)\n case @parser\n when :kramdown, 'kramdown'\n require 'kramdown'\n Kramdown::Document.new(content).to_html\n when :redcarpet, 'redcarpet'\n require 'redcarpet'\n markdown = Redcarpet::Markdown.new(\n Redcarpet::Render::HTML,\n smart: true,\n no_intra_emphasis: true,\n fenced_code_blocks: true,\n autolink: true,\n tables: true,\n with_toc_data: true\n )\n\n # add smartypants support\n Redcarpet::Render::SmartyPants.render markdown.render(content)\n when :rdiscount, 'rdiscount'\n require 'rdiscount'\n RDiscount.new(content).to_html\n when :gfm, :github, :github_markdown, 'gfm', 'github_markdown'\n require 'github/markdown'\n GitHub::Markdown.render(content)\n end\n end",
"def parse_html(data,tag)\n return data.scan(%r{<#{tag}\\s*.*?>(.*?)</#{tag}>}im).flatten\nend",
"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 markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def scan\n comment = RDoc::Comment.new @content, @top_level\n comment.format = 'markdown'\n\n @top_level.comment = comment\n end",
"def process_images\n # Split \"\" into [\"\"]\n # TODO: handle properly escaped values, escaped ) and surrounded by <>\n imgRE = /(!\\[.*?\\]\\()(.+?)(\\))/\n new_content = \"\"\n pos = 0\n source_dir = Pathname.new(@dir)\n out_dir = Pathname.new(\"images\")\n base_url = Pathname.new(\"{{site.baseurl}}\")\n images = []\n while !(i = self.content.index(imgRE, pos)).nil?\n match = self.content.match(imgRE, i)\n url = match[2]\n path = Pathname.new(url)\n # Only replace relative URLs\n next if !path.relative?\n images << path\n new_url = base_url.join(out_dir, source_dir, url).cleanpath.to_s\n # TODO: normalize path to forward-slashes.\n new_image_link = match[1] + new_url + match[3]\n new_content += self.content[pos...i] + new_image_link\n \n pos = i + match[0].length\n end\n # Get any post-URL end content.\n new_content += match.post_match\n self.content = new_content\n\n file_source = Pathname.new(@_pages_dir).join(source_dir)\n # Add images to static files.\n images.each do |path|\n site.static_files << NoteImageFile.new(@site,\n @base,\n file_source.join(path).dirname.to_s,\n path.basename.to_s,\n out_dir.join(source_dir, path).dirname.to_s)\n end\n end",
"def execute\n\n logger = Logger.new(\"/dev/null\")\n logger.level = Logger::WARN\n log_adapter = JerichoLoggerAdapter.new(logger)\n\n\n Dir.glob('./**/*.{jsp,jspf}').each do |path|\n content = File.read(path)\n source = Source.new(content)\n source.setLogger(log_adapter)\n out = OutputDocument.new(source)\n\n tags = source.getAllStartTags\n tags.each do |tag|\n if applicable?(tag)\n process_tag(source, out, tag, path)\n end\n end\n SpacewalkHtmlClean.generate_diff(content, out, path)\n end\n end",
"def work_examples!\n @html.css('pre').each do |pre|\n lines = pre.content.split(\"\\n\")\n first_line = lines.first.to_s.strip\n next unless first_line.match(/^# ([A-Za-z]+)$/i)\n\n sections = split_lines(lines)\n example = Example.new sections\n @examples.push example\n template = Tilt.new(Ifdoc.root('data', 'templates', 'example.haml'))\n\n pre.after(template.render(example))\n pre.remove\n end\n end",
"def parse_page_file(file_path)\n \n result = {}\n metadata = []\n remaining = ''\n \n File.open(file_path) do |file|\n \n while (not file.eof?)\n line = file.readline \n if match = line.match(/\\w*:\\s[\\w|\\s]*/)\n metadata.push(line)\n else\n remaining << line if not line.match(/^\\n|\\n\\r$/)\n break\n end\n end \n \n remaining << file.read # Reads the rest of the document\n\n result = {}\n \n if metadata and metadata.length > 0 \n result = YAML::load(metadata.join)\n end\n \n result.store(:body, remaining) if remaining\n \n end \n \n return result \n \n end",
"def render(path)\n\t\t\tredcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true)\n\t\t\tredcarpet.render(File.read(path))\n\t\tend",
"def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end",
"def markdown(source)\n Open3.popen2('pandoc', '-s', '-f', 'markdown', '-t', 'html') do |stdin, stdout, wait_thr|\n stdin.puts(source)\n stdin.close\n stdout.read\n end\nrescue => e\n STDERR.puts e\n nil\nend",
"def to_html\n return \"\" unless file_name\n return e if e?\n page = render.to_html\n path = File.dirname(file_path)\n # Get child content.\n # A reflexive.\n files(path).each do |file|\n doc = Document.new :base_path => self.base_path, :lang => self.lang, :indent => self.indent, :settings => self.settings, :web_path => self.web_path, :commit => self.commit, :repository => self.repository, :filename => file\n self.browsers << doc\n page += doc.to_html\n end\n dirs(path).each do |dir|\n # Plus one indent from parent. Change h[1-6] tag to h[2-7] if indent is 1.\n doc = Document.new :base_path => dir, :lang => self.lang, :indent => self.indent + 1, :settings => self.settings, :web_path => self.web_path[0..-2] + dir.gsub(self.base_path, \"\"), :commit => self.commit, :repository => self.repository\n self.childs << doc\n page += doc.to_html\n end\n page\n end",
"def parse markdown\n @references = {}\n @unlinked_references = {}\n\n markdown += \"\\n\\n\"\n\n setup_parser markdown, @debug\n peg_parse 'References'\n\n if notes? then\n @footnotes = {}\n\n setup_parser markdown, @debug\n peg_parse 'Notes'\n\n # using note_order on the first pass would be a bug\n @note_order = []\n end\n\n setup_parser markdown, @debug\n peg_parse\n\n doc = result\n\n if notes? and not @footnotes.empty? then\n doc << RDoc::Markup::Rule.new(1)\n\n @note_order.each_with_index do |ref, index|\n label = index + 1\n note = @footnotes[ref]\n\n link = \"{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] \"\n note.parts.unshift link\n\n doc << note\n end\n end\n\n doc.accept @formatter\n\n doc\n end",
"def parse_file(file)\n comment_symbol = \"//\"\n comment_matcher = Regexp.new('^\\\\s*' + comment_symbol + '\\\\s?')\n comment_filter = Regexp.new('(^#![/]|^\\\\s*#\\\\{)')\n\n docs_text = code_text = '';\n has_code = false\n \n if @filename\n #puts \"FILE: #{@filename}\" #debugging\n #get file as one string for class detecting\n f = File.new(@filename)\n text = f.read\n f.close\n \n code = IO.readlines(@filename)\n code.each_with_index do |line, index|\n if comment_matcher.match(line) and !comment_filter.match(line) \n if has_code\n save_section(docs_text, code_text)\n \n #reset docs and code\n docs_text = code_text = ''\n has_code = false\n end\n\n #docs_text += line.sub(comment_matcher, '') + \"\\n\"\n docs_text += line.sub(comment_matcher, '')\n else\n #remove tabs\n #line.gsub!(\"\\t\", \"\")\n line.gsub!(\"\\t\", \" \")\n\n #remove newlines\n line.gsub!(/\\n+/, \"\")\n\n #remove whitespace\n line.gsub!(/$\\s+/, \"\")\n line.gsub!(/^\\s+/, \"\")\n\n line = line.gsub('\\t', \"\").gsub('\\n',\"\").gsub(/\\s+1/,\"\")\n\n has_code = true\n code_text += line + \"\\n\"\n #code_text += line\n \n if line.match(/(class|public|private)\\s+((?!boost)\\w+\\s*)(\\s+|;|:|\\{)?/)\n keyword = $2\n thirdComponent = $3\n #remove all beginning and trailling whitespace\n keyword = keyword.gsub(/^\\s+/, \"\").gsub(/\\s+$/, \"\")\n\n pKeyword = PotionKeyword.new(keyword)\n pKeyword.origin = @filename.split('/').last\n #puts \"\\tChecking #{pKeyword.word}...\" #debugging\n if @master_list_ref.contains_keyword(keyword) == false && thirdComponent != \";\" && keyword.length > 1\n @master_list_ref.keywords << pKeyword \n #puts \"\\tMatched Line: #{line}\" #debugging\n #puts \"\\tAdded #{keyword} to the master list\\n\\n\" #debugging\n end\n end\n end\n end\n\n save_section(docs_text, code_text)\n end\n end",
"def generate(options = {})\n embed_outline(options[:selflink]) if options[:outline]\n\n #if options[:dirmap]\n # md_dir = Pathname.new(@md_file).dirname.expand_path\n # embed_sidebar( Madowu::DirectoryMapper.dirmap(md_dir) )\n #end\n\n if options[:sidebar]\n #lines = File.open( options[:sidebar], \"r\").readlines\n lines = `#{@markdown} #{options[:sidebar]}`.split(\"\\n\")\n embed_sidebar(lines)\n end\n\n result = [\n make_header(options[:css], options[:charset]),\n @markup_lines,\n \"</div></div></body></html>\",\n ''\n ].join(\"\\n\")\n end",
"def process_file(file)\n @first_comment = false\n \n d = CodeFile.create_or_update_by_full_name :name => file.file_relative_name, :full_name => file.file_absolute_name\n\n @containers << d.id\n orig_file = File.new(file.file_absolute_name)\n lines = orig_file.readlines\n CLASSES[file.file_absolute_name].each do |key, klass|\n CLASSES[file.file_absolute_name][key][:line] = lines[klass[:line_no] - 1]\n end if CLASSES[file.file_absolute_name]\n MODULES[file.file_absolute_name].each do |key, mod|\n MODULES[file.file_absolute_name][key][:line] = lines[mod[:line_no] - 1]\n end if MODULES[file.file_absolute_name]\n\n # Process all of the objects that this file contains\n file.method_list.each { |child| process_method(child, file) }\n file.aliases.each { |child| process_alias(child, file) }\n file.constants.each { |child| process_constant(child, file) }\n file.requires.each { |child| process_require(child, file) }\n file.includes.each { |child| process_include(child, file) }\n file.attributes.each { |child| process_attribute(child, file) } \n\n # Recursively process contained subclasses and modules\n @file = file\n RDoc::TopLevel.all_classes_and_modules.each do |child| \n process_type_or_module(child, file) \n end\n \n comment = CodeComment.create_or_update_by_owner_id_and_owner_type_and_owner_type :exported_body => file.comment, :owner_id => d.id, :owner_type => d.class unless file.comment.blank? || Digest::MD5.hexdigest(file.comment) == @first_comment\n @comments << comment.id if comment\n \n end",
"def md_include_html(html)\n res = \"{::options parse_block_html=\\\"true\\\" /}\\n\"\n res << html\n res << \"\\n{::options parse_block_html=\\\"false\\\" /}\\n\"\n return res\nend",
"def parse_codeblocks(html); end",
"def contents_from_html\n types_ids = []\n html = introduction + links\n page = Hpricot(html)\n as = page.search('//a')\n as.each do |a|\n href = a.attributes['href']\n ActiveRecord::Acts::Content.model_types.each do |t|\n underscore = t.underscore\n if href =~ /\\/#{underscore.pluralize}\\/(.+)/ # The URL must be in the form /plural/id\n id = $1.to_i\n types_ids << [t, id]\n end\n end\n end\n\n ret = []\n types_ids.uniq!\n types_ids.each do |t, id|\n klass = t.constantize\n content = klass.find_by_id(id)\n ret << content unless content.nil?\n end\n ret\n end",
"def to_html_fragment\n to_markdown_slices.map do |tagged_markdown|\n tagged_markdown.to_html\n end.join(\"\\n\\n\")\n end",
"def mdrender\n \t@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)\n end",
"def post_processing_slides( content )\r\n \r\n # 1) add slide break \r\n \r\n if (@markup_type == :markdown && @markdown_libs.first == 'pandoc-ruby') || @markup_type == :rest\r\n content = add_slide_directive_before_div_h1( content )\r\n else\r\n content = add_slide_directive_before_h1( content )\r\n end\r\n\r\n dump_content_to_file_debug_html( content )\r\n\r\n # 2) use generic slide break processing instruction to\r\n # split content into slides\r\n\r\n slide_counter = 0\r\n\r\n slides = []\r\n slide_source = \"\"\r\n \r\n content.each_line do |line|\r\n if line.include?( '<!-- _S9SLIDE_' ) or\r\n line.include?( '<!-- _S9TRANSITION_' ) then\r\n if slide_counter > 0 then # found start of new slide (and, thus, end of last slide)\r\n slides << slide_source # add slide to slide stack\r\n slide_source = \"\" # reset slide source buffer\r\n end\r\n slide_counter += 1\r\n end\r\n slide_source << line\r\n end\r\n \r\n if slide_counter > 0 then\r\n slides << slide_source # add slide to slide stack\r\n slide_source = \"\" # reset slide source buffer \r\n end\r\n\r\n ## split slide source into header (optional) and content/body\r\n ## plus check for (css style) classes\r\n\r\n slides2 = []\r\n transition = nil\r\n transitioncount = 0\r\n slides.each do |slide_source|\r\n slide = Slide.new\r\n\r\n ## check for css style classes \r\n from = 0\r\n while (pos = slide_source.index( /<!-- _S9(SLIDE|STYLE|TRANSITION)_(.*?)-->/m, from ))\r\n type = $1.downcase\r\n klass = $2.strip\r\n if $1 == 'TRANSITION'\r\n transition = klass\r\n transitioncount = 0\r\n klass = 'middle'\r\n logger.debug \\\r\n\" adding css classes (plus middle for #{transition}) from pi #{type}: #{klass}\"\r\n slide.transition = transition + '-title'\r\n else\r\n if transition\r\n transitioncount += 1\r\n slide.transition = \"#{transition}[#{transitioncount}]\"\r\n logger.debug \\\r\n\" adding css classes (plus #{transition}) from pi #{type}: #{klass}\"\r\n else\r\n logger.debug \" adding css classes from pi #{type}: #{klass}\"\r\n end\r\n end\r\n\r\n if slide.classes.nil?\r\n slide.classes = klass\r\n else\r\n slide.classes << \" #{klass}\"\r\n end\r\n \r\n from = Regexp.last_match.end(0)\r\n end\r\n \r\n # try to cut off header using non-greedy .+? pattern; tip test regex online at rubular.com\r\n # note/fix: needs to get improved to also handle case for h1 wrapped into div\r\n # (e.g. extract h1 - do not assume it starts slide source)\r\n if slide_source =~ /^\\s*(<h1.*?>.*?<\\/h\\d>)\\s*(.*)/m \r\n slide.header = $1\r\n slide.content = ($2 ? $2 : \"\")\r\n logger.debug \" adding slide with header:\\n#{slide.header}\"\r\n else\r\n slide.content = slide_source\r\n logger.debug \" adding slide with *no* header:\\n#{slide.content}\"\r\n end\r\n slides2 << slide\r\n end\r\n\r\n # for convenience create a string w/ all in-one-html\r\n # no need to wrap slides in divs etc.\r\n \r\n content2 = \"\"\r\n slides2.each do |slide| \r\n content2 << slide.to_classic_html\r\n end\r\n \r\n # make content2 and slide2 available to erb template\r\n # -- todo: cleanup variable names and use attr_readers for content and slide\r\n \r\n @slides = slides2 # strutured content \r\n @content = content2 # content all-in-one \r\n end",
"def gen_fragment(input_file)\n in_header = in_apibody = in_desc = in_example = in_code = nil\n header = apibody = desc = example = last_line = \"\"\n blanks = 0\n sep_line = \"<!-- break -->\\n\"\n stop_line = \"<!-- stop -->\\n\"\n \n lines = IO.readlines(input_file)\n \n use_separator = lines.include? sep_line\n \n lines.each do |line|\n line = line.rstrip + \"\\n\"\n # Skip multiple runs of blank lines\n if line == \"\\n\" and last_line == line\n next\n else\n last_line = line\n end\n \n # detect YAML header\n if line == \"---\\n\"\n in_header = (in_header == nil ? true : false)\n next\n end\n \n # collect YAML header\n if in_header\n header += line\n next\n end\n \n # collect API body\n in_apibody = true if line == \"{% apibody %}\\n\" and in_apibody == nil\n apibody += line if in_apibody\n in_apibody = false if line == \"{% endapibody %}\\n\"\n \n # collect description\n if line == \"# Description #\\n\"\n in_desc = true\n next\n end\n if in_desc\n if line.start_with? \"<img\"\n blanks -= 1\n next\n end\n if use_separator\n if line == sep_line\n in_desc = false\n else\n desc += line\n end\n next\n end\n blanks += 1 if line == \"\\n\"\n if blanks > 1\n in_desc = false\n else\n desc += line\n end\n end\n\n # collect first example\n if line.start_with? \"__Example:\" and in_example == nil\n in_example = true\n example += line\n next\n end\n if in_example\n if line.start_with? \"__Example:\" or line == stop_line\n in_example = false\n else\n example += line\n end\n end\n end\n example.strip!\n apibody.strip!\n desc.strip!\n header = YAML.load(header)\n permalink = header['permalink'].split(\"/\")[-1] + \"/\"\n \n <<-EOS\n## [#{header['command']}](#{permalink}) ##\n\n#{apibody}\n\n#{desc}\n\n#{example}\n\n[Read more about this command →](#{permalink})\n\nEOS\nend",
"def convFile(f)\n\t\t\tdoc = Nokogiri::HTML(File.open(f))\n\t\t\tpage = {}\n\t\t\tpage[:title] = doc.xpath(\"/html/head/title/text()\").to_s\n\t\t\tpage[:fileName] = f.split(\"/\").last.split(\".\")[0]\n\t\t\tpage[:sections] = []\n\t\t\t# files this page relies on. Should be copied to the final directory\n\t\t\tpage[:dependencies] = [] \n\t\t\tdoc.xpath(\"/html/body/table[2]/tr[@valign=\\\"top\\\"]\").each do |e|\n\t\t\t\ts = {}\n\t\t\t\ts[:title] = e.xpath(\"td[1]/b/text()\").to_s.gsub(\" \",\"\").chomp\n\n\t\t\t\t#find the examples\n\t\t\t\te.xpath(\"td[2]/object\").each do |o|\n\t\t\t\t\texec = {}\n\t\t\t\t\tbutton = o.xpath(\"param[@name=\\\"Button\\\"]\").first[\"value\"].to_s\n\t\t\t\t\texec[:buttontext] = button[6..-1]\n\t\t\t\t\tcommand = o.xpath(\"param[@name=\\\"Item1\\\"]\").first[\"value\"].to_s\n\t\t\t\t\tcommarr = command.split(/[,;]/)\n\t\t\t\t\texec[:name] = commarr[2]\n\t\t\t\t\texec[:file] = commarr[1]\n\n\t\t\t\t\ts[:executables] ||= []\n\t\t\t\t\ts[:executables] << exec\n\t\t\t\t\to.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find the code\n\t\t\t\te.xpath(\"td[2]//pre\").each do |o|\n\t\t\t\t\tcode = o.content.to_s\n\t\t\t\t\ts[:code] ||= []\n\t\t\t\t\ts[:code] << code\n\t\t\t\t\to.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find images\n\t\t\t\te.xpath(\"td[2]//img\").each do |o|\n\t\t\t\t\tfile = o[\"src\"]\n\t\t\t\t\ts[:images] ||= []\n\t\t\t\t\ts[:images] << file\n\t\t\t\t\tpage[:dependencies] << file\n\t\t\t\t\t#o.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find links, mostly for processing utility\n\t\t\t\te.xpath(\"td[2]//a\").each do |o|\n\t\t\t\t\tfile = o[\"href\"]\n\t\t\t\t\ts[:links] ||= []\n\t\t\t\t\ts[:links] << file[0..-6] # strip .html\n\t\t\t\tend\n\n\t\t\t\t#format the content\n\t\t\t\tcontent = e.xpath(\"td[2]\").first\n\n\t\t\t\ttextcontent = content.content().to_s\n\t\t\t\tunless textcontent.empty?\n\t\t\t\t\thtml = content.to_s[4..-6].strip # The slice strips the <td> tags\n\t\t\t\t\ts[:raw_content] = html\n\t\t\t\t\ts[:text_content] = textcontent\n\t\t\t\t\ts[:mdown_content] = markdownFormat(html,s[:title] != \"Syntax\") \n\t\t\t\tend\n\t\t\t\tpage[:sections] << s\n\t\t\tend\n\n\t\t\t#It might be a tutorial page such as turing_admin\n\t\t\tif page[:sections].empty?\n\t\t\t\tpage[:htmlcontent] = doc.xpath(\"/html/body\").to_html(:encoding => 'UTF-8')[6..-8]\n\t\t\tend\n\n\t\t\tpage\n\t\tend",
"def markdown(text)\n# coderayified = CodeRayify.new(:filter_html => true,:hard_wrap => true)\n coderayified = PygmentsHTML.new(\n with_toc_data: true,\n hard_wrap: true\n )\n# coderayified = Redcarpet::Render::HTML.new(:filter_html => true,:hard_wrap => true)\n options = {\n :no_intra_emphasis => true,\n :tables => true,\n :fenced_code_blocks => true,\n :autolink => true,\n :strikethrough => true,\n :lax_spacing => true,\n :superscript => true\n }\n markdown_to_html = Redcarpet::Markdown.new(coderayified, options)\n markdown_to_html.render(text).html_safe\n end",
"def load_workset( filename )\n\n md_filename = ''\n asset_files = []\n File.open( filename, 'r').each do |line|\n if /^metadata : /.match( line )\n md_filename = /^metadata : (.*)$/.match( line ).captures[ 0 ]\n end\n\n if /^asset : /.match( line )\n asset_files << /^asset : (.*)$/.match( line ).captures[ 0 ]\n end\n end\n\n return md_filename, asset_files\n end",
"def render_document(content, extension)\n if %w{md mdown markdown}.include?(extension.downcase)\n render_markdown(content)\n else\n content\n end\n end",
"def html_parser(file)\n\n\tpage = Nokogiri::HTML(open(file))\n\n\ttags = page.css(\".started\")\n\ttags.each do |tag| \n\t\t$tweets << {:timestamp => tag.text.strip, :tag => file} \n\tend\n\tp \"Successfully parsed #{file}\"\n\treturn tags\n\nend",
"def slidedown(markdown)\n slides = []\n begin\n slide = nil\n markdown.split(\"\\n\").each do |line|\n case line\n when /^\\#\\s+/\n # New slide\n slides << slide if slide\n title = line[1..-1].strip\n if title =~ /^\\!\\[.*\\]\\(.*\\)/\n # Image slide\n /^\\!\\[.*\\]\\((?<image_url>.*)\\)/ =~ title\n slide = {:image => image_url, :code => []}\n else\n # Normal slide\n slide = {:code => [], :title => title}\n end\n else\n slide[:code] << line\n end\n end\n slides << slide if slide\n end\n\n slides.each do |item|\n item[:code] = item[:code].join(\"\\n\")\n end\n\n result = \"\"\n slides.each_with_index do |slide, i|\n html = \"<header><h2>#{slide[:title]}</h2></header>\"\n cover = false\n if slide[:code].strip == ''\n # Cover slide\n cover = true\n else\n # Normal slide\n html << markdown(slide[:code])\n end\n\n if slide[:image]\n # Pure image slide\n html = \"<div class='slide cover' id='slide_#{i}'><div><section><img src='#{slide[:image]}'/></section></div></div>\"\n else\n # Normal slide\n classes = ['slide']\n classes << 'cover' if cover\n html = \"<div class=\\\"#{classes.join(' ')}\\\" id=\\\"slide_#{i}\\\"><div><section>#{html}</section></div></div>\"\n end\n result << html\n end\n result\n end",
"def md2html\n\t\tbook.toc.each do |source|\n\t\t\ttarget = 'build/raw_html/' + source.ext('html')\n\t\t\tcreate \"source/#{source}\" => target do\n\t\t\t\tinfo \"converting #{source} => #{target}\"\n\t\t\t\tm = Maruku.new IO.read(\"source/#{source}\")\n\t\t\t\tFile.open(target, 'w') do |f|\n\t\t\t\t\tif block_given?\n\t\t\t\t\t\thtml = m.to_filtered_html do |doc|\n\t\t\t\t\t\t\tyield doc\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\thtml = m.to_html\n\t\t\t\t\tend\n\t\t\t\t\tf.write html\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend"
] | [
"0.6584569",
"0.6494559",
"0.6293909",
"0.62119746",
"0.6135725",
"0.60691196",
"0.60310566",
"0.59942216",
"0.5956463",
"0.5938883",
"0.5909148",
"0.5873861",
"0.57966214",
"0.5790085",
"0.578459",
"0.57412416",
"0.5727431",
"0.57046556",
"0.56719977",
"0.5671853",
"0.566561",
"0.5647499",
"0.5646629",
"0.56268996",
"0.55812705",
"0.5571273",
"0.5529173",
"0.54841524",
"0.5481484",
"0.54598963",
"0.5454448",
"0.54483205",
"0.54458064",
"0.54416335",
"0.54347205",
"0.5428305",
"0.5423852",
"0.5418877",
"0.5394406",
"0.5389982",
"0.53728354",
"0.53672117",
"0.53581756",
"0.5338767",
"0.53247744",
"0.532375",
"0.53133357",
"0.53056365",
"0.5284033",
"0.52832794",
"0.5282362",
"0.5279613",
"0.5270673",
"0.5268948",
"0.5268871",
"0.5245309",
"0.5243473",
"0.5226101",
"0.5225588",
"0.52249056",
"0.52210176",
"0.52192545",
"0.52147883",
"0.52054125",
"0.51983804",
"0.5198256",
"0.5183759",
"0.5178977",
"0.5178432",
"0.5176046",
"0.51723206",
"0.51673675",
"0.51673675",
"0.5163891",
"0.51638657",
"0.51556075",
"0.515446",
"0.5140937",
"0.5138621",
"0.51331353",
"0.51237506",
"0.5116556",
"0.51013845",
"0.5097468",
"0.5085405",
"0.507933",
"0.50722164",
"0.5071969",
"0.5071746",
"0.5069222",
"0.50685173",
"0.50573474",
"0.50303173",
"0.5025253",
"0.5022416",
"0.5021628",
"0.50204647",
"0.5018882",
"0.5015411",
"0.5010197"
] | 0.7105307 | 0 |
In .md.erb files, metadata is stored in a custom format: It looks like: METADATA The content of the block has keyval pairs separated by newlines Accepted keyval pairs are: TAGS: This method finds all metadata in a concatenated markdown string and removes it from the result. Returns an Array: [result md, metadata hash] | def extract_metadata(markdown_string)
metadata_results = OpenStruct.new
return markdown_string unless markdown_string.include? "**METADATA**"
result = markdown_string.split("**METADATA**").map do |section|
metadata, content = section.split("****")
parse_metadata_section(section).each do |key,results_array|
metadata_results[key] ||= []
metadata_results[key].concat results_array
end
content
end.join("\n\n")
[result, metadata_results]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_metadata\n YAML_METADATA.match(content) do |match|\n @metadata = YAML.load(match[0])\n @content = content.gsub(YAML_METADATA, \"\")\n end\n end",
"def process_md_erb(filename)\n renderer = Redcarpet::Render::HTML\n markdown ||= Redcarpet::Markdown.new(renderer, md_extensions)\n concatenated_md = embed_md_erb(filename)\n result_md, metadata = extract_metadata(concatenated_md)\n result_html = markdown.render(result_md)\n [result_html, metadata]\n end",
"def clean_markdown(md)\n lines = md.split(\"\\n\")\n cleaned = []\n last_stripped = ''\n\n lines.each do |itm|\n stripped = itm.strip\n\n if stripped.start_with?('* ')\n # make sure there is a blank line before the first line of a UL\n if last_stripped != \"\\n\" && !last_stripped.start_with?('* ')\n cleaned << ''\n end\n\n elsif stripped.start_with?('1. ')\n # make sure there is a blank line before the first line of a OL\n if last_stripped != \"\\n\" && !last_stripped.start_with?('1. ')\n cleaned << ''\n end\n\n elsif stripped.start_with?('>')\n # make sure there is a blank line before the first line of a block quote\n if last_stripped != \"\\n\" && !last_stripped.start_with?('>')\n cleaned << ''\n end\n end\n\n cleaned << itm\n last_stripped = stripped\n end\n\n cleaned.join(\"\\n\")\n end",
"def metadata\n @metadata ||= (\n if md = /\\<\\!\\-\\-\\-(.*?)\\-{2,3}\\>\\s*\\Z/m.match(content)\n YAML.load(md[1])\n else\n {}\n end\n )\n end",
"def extract_metadata(content)\n document = parse_kramdown(content)\n toc = ::Kramdown::Converter::Toc.convert(document.root)\n toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t| \n {:id => t.attr[:id], :text => t.value.children.first.value}\n end\n metadata = document.root.options[:metadata]\n metadata[:toc] = toc_items\n metadata[:converted] = document.to_html\n metadata[:technologies] = metadata[:technologies].split(\",\").collect {|tech| tech.strip}\n metadata[:author] = metadata[:author].split(',').first if metadata[:author]\n metadata[:product] ||= @product\n metadata[:experimental] ||= @experimental\n metadata[:experimental] ||= false\n metadata[:level] = 'Beginner'\n metadata\n end",
"def md(text)\n markdown text.\n gsub(/{{([a-z]+([\\.\\-\\_][a-z]+)*)}}/, '[\\1](/\\1)'). # {{name}} -> [name](/name)\n gsub(/{{([^\\|}]+)\\|([a-z]+([\\.\\-\\_][a-z]+)*)}}/, '[\\1](/\\2)'). # {{link text|name}} -> [link text](/name)\n to_s\n end",
"def extract_metadata(file)\n document = parse_kramdown(file)\n toc = ::Kramdown::Converter::Toc.convert(document.root)\n toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t| \n {:id => t.attr[:id], :text => t.value.children.first.value}\n end\n\n metadata = document.root.options[:metadata]\n metadata[:toc] = toc_items\n metadata[:converted] = document.to_html\n metadata[:technologies] = metadata[:technologies].split(\",\").collect {|tech| tech.strip}\n metadata[:images] = find_images(document.root)\n metadata[:author] = metadata[:author].split(',').first if metadata[:author]\n metadata[:commits] = commit_info @repo, Pathname.new(file)\n metadata[:current_tag] = current_tag @repo, Pathname.new(file)\n metadata[:current_branch] = current_branch @repo, Pathname.new(file)\n metadata[:github_repo_url] = repository_url @repo\n metadata[:contributors] = metadata[:commits].collect { |c| c[:author] }.uniq\n metadata[:contributors_email] = metadata[:commits].collect { |c| c[:author_email] }.uniq\n metadata[:contributors].delete(metadata[:author])\n metadata[:product] = @product if @product\n metadata[:experimental] = @experimental\n metadata\n end",
"def replace_metadata\n message = ''\n begin\n # delete existing metadata\n cmd = \"exiftool -all= '#{@the_file.realpath}'\"\n result = system(cmd)\n raise StandardError.new \"Unable to remove existing file metadata.\" if !(result == true)\n # add new metadata\n # md_as_hash must use exiftool metadata tags, not field names, as hash keys\n # see output of FetchEmbeddedMetadataFromFile service as an example.\n @md_as_hash.each do |k,v|\n new_value = v.strip\n #cmd = \"exiftool -#{k}='#{new_value}' '#{@the_file.realpath}'\"\n #message += `#{cmd}`\n message += %x[exiftool -#{k}=\"#{new_value}\" \"#{@the_file.realpath}\"]\n end\n rescue StandardError => e\n puts e.message\n @md_as_hash = nil\n end\n message\n end",
"def to_md\n # Usually ruby is extremely readable, but I think \"-1\" means \"give me all the \n # trailing blank lines\" is surprisingly opaque. That's what the -1 does...\n lines = @text.split(\"\\n\", -1)\n lines.collect do |line|\n result = line\n \n # Leave lines that start with 4 spaces alone. These are code blocks and\n # should pass through unchanged.\n unless result =~ /^\\s{4,}/\n \n # Convert headers\n result.sub!(/^(=){1,6}/) { |s| \"#\" * s.length} unless result =~ /^={7,}/\n \n # Convert strong to have two stars\n # The matching pair of stars should start with a single star that is either at\n # the beginning of the line or not following a backslash, have at least one\n # non-star and non-backslash in between, then end in one star\n result.gsub!(/(\\A|[^\\\\\\*])\\*([^\\*]*[^\\*\\\\])\\*/, '\\1**\\2**')\n\n # Convert inline code spans to use backticks\n result.gsub!(/(\\A|[^\\\\])\\+([^\\+]+)\\+/, '\\1`\\2`')\n\n # Convert bare http:, mailto: and ftp: links\n result.gsub!(/(\\A|\\s)(http:|https:|mailto:|ftp:)(\\S*)/, '\\1[\\2\\3](\\2\\3)')\n\n # Convert bare www to an http: link\n result.gsub!(/(\\A|\\s)www\\.(\\S*)/, '\\1[www.\\2](http://www.\\2)')\n\n # Convert link: links to refer to local files\n result.gsub!(/(\\A|\\s)link:(\\S*)/, '\\1[\\2](\\2)')\n\n # Convert multi word labels surrounded by {} with a url\n result.gsub!(/\\{([^\\}]*)\\}\\[(\\S*)\\]/, '[\\1](\\2)')\n\n # Convert one word labels with a url\n result.gsub!(/(\\A|\\s)([^\\{\\s]\\S*)\\[(\\S*)\\]/, '\\1[\\2](\\3)')\n\n end\n \n result\n end.join(\"\\n\")\n end",
"def find_metadata\n MAPPING.each do |metaname, pattern|\n metapattern = Regexp.new(\"(#{pattern})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\n if text.match(metapattern)\n value = $2\n if value.match(metapattern)\n value = $2\n end\n meta[metaname] = value.strip\n end\n end\n meta\n end",
"def markdown(s)\n s = s.gsub(/\\*\\/$/,\"\")\n s = s.gsub(/^ ?\\* ?/,\"\")\n s = s.gsub(/^\\/\\*\\*? ?/,\"\")\n s.chop! while s[-1] == \"\\n\" || s[-1] == \" \"\n lines = s.split(\"\\n\")\n newlines = []\n # Fix some markdown\n lines.each{|l|\n # Rewrite RM_Xyz() to RedisModule_Xyz().\n l = l.gsub(/(?<![A-Z_])RM_(?=[A-Z])/, 'RedisModule_')\n # Fix more markdown, except in code blocks indented by 4 spaces, which we\n # don't want to mess with.\n if not l.start_with?(' ')\n # Add backquotes around RedisModule functions and type where missing.\n l = l.gsub(/(?<!`)RedisModule[A-z]+(?:\\*?\\(\\))?/){|x| \"`#{x}`\"}\n # Add backquotes around c functions like malloc() where missing.\n l = l.gsub(/(?<![`A-z.])[a-z_]+\\(\\)/, '`\\0`')\n # Add backquotes around macro and var names containing underscores.\n l = l.gsub(/(?<![`A-z\\*])[A-Za-z]+_[A-Za-z0-9_]+/){|x| \"`#{x}`\"}\n # Link URLs preceded by space or newline (not already linked)\n l = l.gsub(/(^| )(https?:\\/\\/[A-Za-z0-9_\\/\\.\\-]+[A-Za-z0-9\\/])/,\n '\\1[\\2](\\2)')\n # Replace double-dash with unicode ndash\n l = l.gsub(/ -- /, ' – ')\n end\n # Link function names to their definition within the page\n l = l.gsub(/`(RedisModule_[A-z0-9]+)[()]*`/) {|x|\n $index[$1] ? \"[#{x}](\\##{$1})\" : x\n }\n newlines << l\n }\n return newlines.join(\"\\n\")\nend",
"def load_text_metadata\n str = self.client.getmd({}, @address)\n keymap = self.class.md_key_map # subclasses implement this function\n types = self.class.md_type_coercion_map # subclasses might implement this function\n \n # regular expression: matches lines with:\n # 4 whitespace characters at start of line\n # word containing uppercase characters and/or underscores (captured as var 1)\n # colon character immediately after that word\n # one or more whitespace characters\n # any characters following that whitespace, up to end of line (captured as var 2)\n # So, if the string matches, it gets the key as var 1, value as var 2\n re = /^\\W{4}([A-Z_]+):\\s+(.+)$/\n str.each_line do |line|\n md = re.match(line)\n next if md.nil?\n next if md.size < 3 # skip if we didn't get a value for a key (or didn't match)\n \n # insert the metadata value into the @metadata hash\n insert_metadata md[1], md[2], keymap, types\n end\n \n # note that we don't need to run this again\n @metadata_loaded = true\n end",
"def shift_metadata_for str\n meta, line = @metadata.first\n\n if line.nil? || line.empty? || line[0..0] == '#'\n @metadata.shift\n return meta if str.empty?\n end\n\n meta, line = @metadata.first\n\n if str.length > line.length\n\n while str.include? @metadata.first[1] do\n tmp_meta, line = @metadata.shift\n meta = tmp_meta if\n !meta || !meta[:updated_at] ||\n meta && meta[:updated_at] &&\n tmp_meta && tmp_meta[:updated_at] &&\n tmp_meta[:updated_at] > meta[:updated_at]\n end\n\n else\n @metadata.first[1] = line.split(str, 2).last.strip\n @metadata.first[1].gsub!(%r{^:(\\s+|$)}, \"\")\n end\n\n #puts \"#{str} -> #{meta.inspect}\"\n meta\n end",
"def prepare_markdown(text)\n parsed = []\n uses_item_markers = (text =~ /^[-*]/)\n\n text.each_line do |line|\n line.rstrip!\n # Convert headline markers.\n line.sub!(/^(#+)/, @headline)\n\n # Add item markers for those who used plaintext and didn't add them;\n # add headline markers for those who defined different sections and\n # didn't add them.\n if line =~ /^([A-Za-z0-9])/\n line = uses_item_markers ? \"#{@headline} #{line}\" : \"- #{line}\"\n end\n\n # Fixup item markers missing a space.\n line.sub!(/^[-*]([^ ])/, '- \\1')\n parsed << line unless line.empty?\n end\n parsed.join(\"\\n\")\n end",
"def process_markdown\n attachments.each do |att|\n # ~ magic regex ~\n self.markdown = self.markdown.sub(/\\[.+?\\]\\(.+?\\/#{att.file.id}\\/.+?\\)/) do |md_str|\n att.file_attacher.store!\n \"[#{att.file_filename}](#{att.file_url})\"\n end\n end\n self.html = Kramdown::Document.new(self.markdown || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def preprocessMarkdownForHTML(markdown)\n output = \"\"\n inInstructions = false\n \n markdown.split(\"\\n\").each do |line|\n # parse an instructions list\n # use a dummy HTML tag so our final regex doesn't get stuck in an infinite loop replacing itself\n instructionsMatch = line.match(/^>>\\s*(.*?)$/)\n if instructionsMatch\n if not inInstructions\n output += \"<instructions>\\n\"\n end\n output += instructionsMatch[1] + \"\\n\"\n inInstructions = true\n next # don't try to parse anything else\n elsif inInstructions\n output += \"</instructions>\\n\"\n inInstructions = false\n end\n\n # parse headers and page IDs\n headerMatch = line.match(/^(#+)\\s+(.*?)\\s+@@(.*?)$/)\n if headerMatch\n headerLevel = headerMatch[1].length.to_s\n headerTitle = headerMatch[2]\n headerID = headerMatch[3]\n node = nodeWithID(headerID, $doc.toc.rootNode)\n if not node\n puts \"ERROR: Couldn't find node with ID #{headerID}\"\n exit 1\n end\n output += \"<h#{headerLevel}><a name=\\\"#{headerID}\\\">#{node.levelPrefix} #{headerTitle}</a></h#{headerLevel}>\\n\"\n next\n end\n \n # parse links to page IDs and replace with links to the real .htm file\n while 1\n linkMatch = line.match(/\\[.*?\\]\\((@@(.*?))\\)/)\n if linkMatch\n linkID = linkMatch[2]\n linkValue = linkToPageIDFrom(linkID, \"_PAGE_\") # use dummy value\n if not linkValue\n puts \"ERROR: Invalid link ID \\\"#{linkID}\\\"\"\n exit 1\n end\n line[linkMatch[1]] = linkValue\n else\n break\n end\n end\n \n # parse image and label combo\n imgLabelMatch = line.match(/!!\\[(.*?)\\]\\((.*?)\\)/)\n if imgLabelMatch\n label = imgLabelMatch[1]\n imgPath = imgLabelMatch[2]\n \n # read the image and width height to force the size on images for better loading\n # when viewing the files in the boot DVD. there are some issues where anchor jump\n # links don't always jump to the right place on the boot DVD and apparently forcing\n # the image sizes allows the pages to jump properly.\n \t\timgWidth = 0\n \t\timgHeight = 1\n \t\tbegin\n \t\t data = nil\n \t\t if (imgPath =~ /.png$/)\n \t\t data = IO.read($pagesDir + \"/\" + imgPath, 8, 16).unpack('NN')\n\t\t else\n\t\t puts \"ERROR: Unsupported image type: #{imgPath}\"\n\t\t exit 1\n\t end\n \t\t if (data)\n \t\t imgWidth = data[0]\n \t\t imgHeight = data[1]\n\t\t end\n\t\t rescue\n\t end\n imgWidthHeightAttrs = \"\"\n if imgWidth != 0 and imgHeight != 0\n imgWidthHeightAttrs = \" width=\\\"#{imgWidth}\\\" height=\\\"#{imgHeight}\\\"\"\n end\n\n output += \"<p class=\\\"imageAndLabel\\\"><img src=\\\"#{imgPath}\\\" alt=\\\"\" + CGI::escapeHTML(label) + \"\\\"#{imgWidthHeightAttrs}/><br/><em>\" + CGI::escapeHTML(label) + \"</em></p>\\n\"\n next\n end\n \n # parse warning paragraphs\n warningMatch = line.match(/^!!\\s+(.*?)$/)\n if warningMatch\n output += \"<warning>\\n\" + warningMatch[1] + \"\\n<\\/warning>\\n\"\n next\n end\n \n output += line + \"\\n\"\n end\n \n # close off an open instructions div\n if inInstructions\n output += \"</instructions>\\n\"\n end\n \n # Markdown doesn't allow processing of markup within block-level tags such as <div>, so we have to manually process the markup.\n # We call preprocessMarkdownForHTML() to properly process our custom markup within these custom block elements.\n # An extra newline is added to force a paragraph\n while 1\n instructionsMatch = output.match(/(<instructions>)(.*?)(<\\/instructions>)/m)\n if instructionsMatch\n output[instructionsMatch[1]] = \"<div class=\\\"instructions\\\">\"\n output[instructionsMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+instructionsMatch[2]))\n output[instructionsMatch[3]] = \"</div>\"\n else\n break\n end\n end\n \n while 1\n warningMatch = output.match(/(<warning>)\\s*(.*?)(<\\/warning>)/m)\n if warningMatch\n output[warningMatch[1]] = \"<div class=\\\"warning\\\"><div class=\\\"warningBody\\\"><div class=\\\"warningImg\\\"></div><div class=\\\"warningContent\\\">\"\n output[warningMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+warningMatch[2]))\n output[warningMatch[3]] = \"</div></div></div>\"\n else\n break\n end\n end\n \n return output\nend",
"def parse_markdown\n self.bio_html = markdown.render(bio_markdown)\n end",
"def read_metadata(path)\n unless path\n abort \"Must exist a markdown filename which have Yaml Front Matter.\"\n end\n yml, _ = Maliq::FileUtils.retrieveYFM(File.read path)\n return nil if yml.empty?\n YAML.load(yml).to_symkey\n end",
"def contents()\n html = Nokogiri::HTML(@markdown_document.to_html())\n\n # Fixup refs to other markdown documents\n html.css(\"a\").each do |anchor|\n anchor[\"href\"] = anchor[\"href\"].sub(%r{\\.md$}, \".html\")\n end\n\n # Since we transform device-specific $device/README.md pages into\n # discrete $device.html, we need to fixup cross-linking into its namespace\n # This could be generalized some more, to be fixed once we have other internal links to mismatched README.md/index.html locations.\n if File.dirname(relative_output) == \"devices\"\n html.css(\"a\").each do |anchor|\n if anchor[\"href\"].match(%r{\\.\\./[^\\.]+$})\n anchor[\"href\"] = anchor[\"href\"].sub(%r{\\.\\./}, \"devices/\") + \".html\"\n end\n end\n end\n\n # Since Nokogiri produces a complete document from our fragment, we\n # have to pick only what's in the body; so strip the body added tags and higher-up tags.\n html\n .at_css(\"body\").to_s()\n .sub(%r{^<body>}, \"\").sub(%r{</body>$}, \"\")\n end",
"def split_info(object)\n\t\treturn object.match('(\\d+)\\s+(.*).md$') || object.match('(\\d+)\\s+(.*)$') || [object, 0, object]\n\tend",
"def md(text)\n renderer = Redcarpet::Render::HTML.new\n extensions = {filter_html: true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n redcarpet.render(text).html_safe\n end",
"def scan_md(aPattern)\n\t\tresult = []\n\t\tself.scan(aPattern) {|s| result << $~ }\n\t\tresult\n\tend",
"def bulk_pubmed_description\n xml = open(@@eutil_base + \"db=pubmed&id=\" + @id.join(\",\")).read\n id_text = Nokogiri::XML(xml).css(\"PubmedArticle\").map{|n| n.to_xml }.map do |xml|\n parser = PubMedMetadataParser.new(xml)\n array = [ parser.journal_title,\n parser.article_title,\n parser.abstract,\n parser.affiliation,\n parser.authors.map{|n| n.values.compact },\n parser.chemicals.map{|n| n[:name_of_substance] },\n parser.mesh_terms.map{|n| n.values.compact } ]\n [parser.pmid, array.flatten.compact.map{|d| clean_text(d) }.join(\"\\s\")]\n end\n Hash[id_text.flatten] ## NO LONGER WORK WITH < RUBY 2.0\n end",
"def to_markdown\n lines = @bare_content.split(\"\\n\")\n markdown = \"\"\n\n # Using `while` here so we can alter the collection at will\n while current_line = lines.shift\n # If we got us some of them bird tracks...\n if current_line =~ BIRD_TRACKS_REGEX\n # Remove the bird tracks from this line\n current_line = remove_bird_tracks(current_line)\n # Grab the remaining code block\n current_line << slurp_remaining_bird_tracks(lines)\n\n # Fence it and add it to the output\n markdown << \"```haskell\\n#{current_line}\\n```\\n\"\n else\n # No tracks? Just stick it back in the pile.\n markdown << current_line + \"\\n\"\n end\n end\n\n markdown\n end",
"def markdown\n @markdown ||= process_markdown!\n end",
"def extract_meta_data(file_path)\n m = /(\\d{4})-(\\d{2})-(\\d{2})-(.+)\\.md/.match(file_path)\n {\n published_at: Date.new(m[1].to_i, m[2].to_i, m[3].to_i),\n slug: m[4]\n }\n end",
"def parse_markdown\n self.body_html = markdown.render(body_markdown.to_s)\n self.summary_html = markdown.render(summary_markdown.to_s)\n end",
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def dockerfile_metadata(file = nil)\n meta_data = @properties.merge(:repo_name => nil,\n :image_name => nil,\n :file_name => nil,\n :VERSION => nil,\n :maintainer_name => nil,\n :maintainer_email => nil)\n return meta_data unless File.exist?(file)\n meta_data[:file_name] = File.expand_path(file)\n File.open(file, 'r').each do |line|\n [{ :property => :VERSION, :token => '.*#\\sDOCKER-VERSION' },\n { :property => :maintainer_name, :token => '^MAINTAINER',\n :exp => '(.*),\\s(.*)', :field => 1 },\n { :property => :maintainer_email, :token => '^MAINTAINER',\n :exp => '(.*),\\s(.*)', :field => 2 },\n { :property => :image_name, :token => '.*#\\sDOCKER-NAME',\n :exp => '(.*)/(.*)', :field => 2 },\n { :property => :repo_name, :token => '.*#\\sDOCKER-NAME' }].each do |p|\n match_val = match_token(p[:token], line, p)\n meta_data[p[:property]] = match_val unless match_val.nil?\n end\n end\n meta_data\n end",
"def extract_metadata(hash)\n new_metadata = hash.each_with_object({}) do |(k,v), hash|\n if key = k[/^x-ms-meta-(?<key>.*)?/, :key]\n hash[key] = v\n end\n end\n\n metadata.replace(new_metadata)\n end",
"def find_metadata\n versions.each do |v|\n m = v.metadata\n if m.exist?\n return m\n end\n end\n nil\n end",
"def extract_meta\n end",
"def html_markup_markdown(text); end",
"def extractMetadata()\n Logging.LogScriptInfo \"Extract metadata from #{@logFile}...\"\n\n # Get the meta datas from the json report\n metas = { }\n metas['build_date'] = @jsonData['build_date']\n metas['build_time'] = @jsonData['build_time']\n metas['git_revision'] = @jsonData['git_revision']\n metas['options'] = @jsonData['sim']['options']\n metas['overrides'] = @jsonData['sim']['overrides']\n metas['statistics'] = @jsonData['sim']['statistics']\n @jsonData['sim']['players'].each do |player|\n if player['name'] == 'Template'\n metas['player'] = player\n end\n end\n metas['profilesets_overrides'] = { }\n @jsonData['sim']['profilesets']['results'].each do |player|\n next unless player['overrides']\n metas['profilesets_overrides'][player['name']] = player['overrides']\n end\n\n # Timestamps\n metas['build_timestamp'] = DateTime.parse(@jsonData['build_date'] + ' ' + @jsonData['build_time'] + ' ' + Time.now.strftime('%:z')).to_time.to_i\n metas['result_timestamp'] = Time.now.to_i\n\n # Add additional data\n metas.merge!(@additionalMetadata)\n\n return metas\n end",
"def extract_metadata; end",
"def process_markdown_inside_elements(doc)\n # find span elements or elements with 'markdown' attribute\n elts = @fragment.css(\"[markdown]\")\n\n d = @fragment.children.first\n if d && HTML_INLINE_ELEMS.include?(d.name)\n elts << d unless d.attribute('markdown')\n elts += span_descendents(d)\n end\n\n elts.each do |e|\n how = e['markdown']\n e.remove_attribute('markdown')\n\n next if \"0\" == how # user requests no markdown parsing inside\n parse_blocks = (how == 'block') || BLOCK_TAGS.include?(e.name)\n\n # Select all text children of e\n e.xpath(\"./text()\").each do |original_text|\n s = CGI.escapeHTML(original_text.text)\n unless s.strip.empty?\n parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)\n\n # restore leading and trailing spaces\n padding = /\\A(\\s*).*?(\\s*)\\z/.match(s)\n parsed = [padding[1]] + parsed + [padding[2]] if padding\n\n el = doc.md_el(:dummy, parsed)\n\n # Nokogiri collapses consecutive Text nodes, so replace it by a dummy element\n guard = Nokogiri::XML::Element.new('guard', @fragment)\n original_text.replace(guard)\n el.children_to_html.each do |x|\n guard.before(x.to_s)\n end\n guard.remove\n end\n end\n end\n end",
"def extract_mainmatter_as_markdown(file, markdown = nil)\n markdown ||= File.read(file)\n\n begin\n markdown.split(/#!!====+/, 2)[1]\n rescue TypeError => e\n fail \"The YAML mainmatter in #{file} looks to be malformed: #{e}.\"\n end\n end",
"def parse markdown\n @references = {}\n @unlinked_references = {}\n\n markdown += \"\\n\\n\"\n\n setup_parser markdown, @debug\n peg_parse 'References'\n\n if notes? then\n @footnotes = {}\n\n setup_parser markdown, @debug\n peg_parse 'Notes'\n\n # using note_order on the first pass would be a bug\n @note_order = []\n end\n\n setup_parser markdown, @debug\n peg_parse\n\n doc = result\n\n if notes? and not @footnotes.empty? then\n doc << RDoc::Markup::Rule.new(1)\n\n @note_order.each_with_index do |ref, index|\n label = index + 1\n note = @footnotes[ref]\n\n link = \"{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] \"\n note.parts.unshift link\n\n doc << note\n end\n end\n\n doc.accept @formatter\n\n doc\n end",
"def md_to_html\n options = {\n filter_html: true,\n link_attributes: {\n rel: \"nofollow\",\n target: \"_blank\"\n }\n }\n\n extensions = {\n space_after_headers: true,\n autolink: true\n }\n\n renderer = Redcarpet::Render::HTML.new(options)\n markdown = Redcarpet::Markdown.new(renderer, extensions)\n\n self.description = markdown.render(self.description_md)\n end",
"def process_markdown_inside_elements(doc)\n # parse block-level markdown elements in these HTML tags\n block_tags = ['div']\n\n elts = []\n @fragment.each_element('//*[@markdown]') do |e|\n elts << e\n end\n\n d = @fragment.children.first\n if d && HTML_INLINE_ELEMS.include?(first_node_name)\n elts << d unless d.attributes['markdown']\n elts += span_descendents(d)\n end\n\n # find span elements or elements with 'markdown' attribute\n elts.each do |e|\n # should we parse block-level or span-level?\n how = e.attributes['markdown']\n e.attributes.delete('markdown')\n\n next if \"0\" == how # user requests no markdown parsing inside\n parse_blocks = (how == 'block') || block_tags.include?(e.name)\n\n # Select all text children of e\n e.texts.each do |original_text|\n s = CGI.escapeHTML(original_text.value)\n unless s.strip.empty?\n # TODO extract common functionality\n parsed = parse_blocks ? doc.parse_text_as_markdown(s) : doc.parse_span(s)\n # restore leading and trailing spaces\n padding = /\\A(\\s*).*?(\\s*)\\z/.match(s)\n parsed = [padding[1]] + parsed + [padding[2]] if padding\n\n el = doc.md_el(:dummy, parsed)\n\n new_html = \"<dummy>\"\n el.children_to_html.each do |x|\n new_html << x.to_s\n end\n new_html << \"</dummy>\"\n\n newdoc = REXML::Document.new(new_html).root\n\n p = original_text.parent\n newdoc.children.each do |c|\n p.insert_before(original_text, c)\n end\n\n p.delete(original_text)\n end\n end\n end\n end",
"def extract_md_title(item)\n\t\tif (item[:extension] != 'md')\n\t\t\treturn nil\n\t\tend\n\n\t\tcontent = item.raw_content.lines.each{|l|\n\t\t\tif (l.start_with?('# '))\n\t\t\t\treturn l[2..-1].strip()\n\t\t\tend\n\t\t}\n\t\tnil\n\tend",
"def parse_metadata_body(body)\n body.lines.each_with_object({}) do |line, hsh|\n k, v = line.strip.split\n hsh[k.to_sym] = v\n end\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def scan_text_for_meta(text)\r\n # break up the text with some extra newlines to make matching more likely\r\n # and strip out some tags\r\n text.gsub!(/<br/, \"\\n<br\")\r\n text.gsub!(/<p/, \"\\n<p\")\r\n text.gsub!(/<\\/?span(.*?)?>/, '')\r\n text.gsub!(/<\\/?div(.*?)?>/, '')\r\n\r\n meta = {}\r\n metapatterns = META_PATTERNS\r\n is_tag = {}\r\n [\"fandom_string\", \"pairing_string\", \"freeform_string\", \"rating_string\"].each do |c|\r\n is_tag[c.to_sym] = true\r\n end\r\n metapatterns.each do |metaname, pattern|\r\n # what this does is look for pattern: (whatever)\r\n # and then sets meta[:metaname] = whatever\r\n # eg, if it finds Author: Blah The Great it will set meta[:author] = Blah The Great\r\n metapattern = Regexp.new(\"(#{pattern})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\r\n metapattern_plural = Regexp.new(\"(#{pattern.pluralize})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\r\n if text.match(metapattern) || text.match(metapattern_plural)\r\n value = $2\r\n begin\r\n value = eval(\"convert_#{metaname.downcase}(value)\")\r\n rescue NameError\r\n end\r\n value = sanitize_fully(value) if is_tag[metaname]\r\n meta[metaname] = value\r\n end\r\n end\r\n return meta\r\n end",
"def extract(contents)\n file_text, matches = parse(contents)\n\n extracted_ruby = +''\n\n last_match = [0, 0]\n matches.each_with_index do |(start_index, end_index), index|\n handle_region_before(start_index, last_match.last, file_text, extracted_ruby)\n\n match_marker = \"#{region_start_marker}_#{format('%010d', index + 1)}\" if region_start_marker\n extracted_ruby << extract_match(file_text, start_index, end_index, match_marker)\n\n last_match = [start_index, end_index]\n end\n\n extracted_ruby << file_text[last_match.last..-1].gsub(/./, ' ')\n\n # if we replaced <%== with <%= raw, try to shift the columns back to the\n # left so they match the original again\n extracted_ruby.gsub!(/ raw/, 'raw')\n\n extracted_ruby\n end",
"def aws_get_metadata\n murl = 'http://169.254.169.254/latest/meta-data/'\n result = self.aws_get_url(murl)\n metadata = Hash.new()\n\n # TODO this isn't entirely right.. if the element ends in '/', it's actually another level of hash..\n result.split(\"\\n\").each do |element|\n metadata[element] = self.aws_get_url(sprintf('%s%s', murl, element))\n end\n\n metadata\n end",
"def consolidate_metadata(book)\n head = index.at_xpath('/html/head')\n head.css('meta[name]').each { |meta| meta.remove }\n book.metadata.each_pair { |name, content|\n content.split(/\\n/).each { |val|\n meta = Nokogiri::XML::Node.new('meta', index)\n meta['name'] = name\n meta['content'] = val\n head.add_child(meta)\n }\n }\n end",
"def rst_to_md(rst)\n return PandocRuby.convert(rst, :from => :rst, :to => :markdown)\nend",
"def get_document_metadata(d)\n md = []\n begin\n md = d.stuffing_metadata\n rescue\n log_and_print \"WARN: get_document_metadata threw an unknown exception\"\n md = []\n end\n\n if md == nil\n md = []\n end\n \n return md\n end",
"def description_markdown\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, space_after_headers: true)\n markdown.render(description).html_safe\n end",
"def manifest_content\n versions.flat_map(&:ocr_text).compact\n end",
"def metadata(output)\n metadata = {}\n lines = output.split(/\\n/)\n lines.grep(/ {4}.+: .+/).\n map {|l| l.split(':').map(&:strip)}.\n select {|a| a.size == 2}.\n each {|d| metadata[d.first.underscore.to_sym] = d.last}\n metadata\n end",
"def html_to_markdown(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".html\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n html_content = `pandoc -f html -t markdown \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return html_content\n end",
"def markdown\n return if changed_markdown_files.empty?\n\n output = `mdl #{changed_markdown_files.join(' ')}`\n return if output&.empty?\n\n heading('Markdown Linter', output)\n end",
"def render_md(site, readme)\n begin\n mkconverter = site.getConverterImpl(Jekyll::Converters::Markdown)\n readme.gsub! \"```\",\"\\n```\"\n readme.gsub! '```shell','```bash'\n return mkconverter.convert(readme)\n rescue\n return 'Could not convert readme.'\n end\nend",
"def read_metadata\n @metadata =\n if !disabled? && File.file?(metadata_file)\n content = File.binread(metadata_file)\n\n begin\n Marshal.load(content)\n rescue TypeError\n SafeYAML.load(content)\n rescue ArgumentError => e\n Jekyll.logger.warn(\"Failed to load #{metadata_file}: #{e}\")\n {}\n end\n else\n {}\n end\n end",
"def metadata(options: DEFAULT_OPTIONS)\n output = %x(exiftool #{options} -json #{file.path.shellescape})\n json = JSON.parse(output).first\n json = json.except(\"SourceFile\")\n ExifTool::Metadata.new(json.with_indifferent_access)\n end",
"def read_meta(node)\n t = decompress_revision(node)\n return {} unless has_metadata?(t)\n \n mt = t[metadata_start..(metadata_end(t) - 1)]\n mt.split(\"\\n\").inject({}) do |hash, line|\n k, v = line.split(\": \", 2)\n hash[k] = v\n hash\n end\n end",
"def extract_metadata\n raise ArgumentError, \"MIME type unspecified or not configured\" if schema.blank?\n fn = \"extract_#{schema.downcase}_metadata\"\n raise ArgumentError, \"Unsupported metadata standard: #{schema}\" unless respond_to?(fn.to_sym)\n send(fn, metadata_xml)\n end",
"def extract_description\n\t\tparts = self.readme&.parts or return nil\n\t\tdesc_para = parts.find {|part| part.is_a?(RDoc::Markup::Paragraph) }&.text or return nil\n\t\tformatter = RDoc::Markup::ToHtml.new( RDoc::Options.new )\n\t\thtml = formatter.convert( desc_para )\n\n\t\treturn html.gsub( /<.*?>/, '' ).strip\n\tend",
"def to_md\n @md ||= [\n \"[🔙 🏡](#{project_readme_path})\",\n '',\n \"# #{title} (#{year})\",\n '',\n \"By the #{adjective} [#{author}](#{homepage})\",\n '',\n '## Links:',\n '',\n \"- [Purchase #{title}](#{purchase})\",\n '',\n '## Chapter Notes:',\n ''\n ].concat(section_md).concat(image_md).join \"\\n\"\n end",
"def entry_summary(entry=@entry)\n filter(entry.summary, :markdown)\n end",
"def entry_summary(entry=@entry)\n filter(entry.summary, :markdown)\n end",
"def pseudo_parse_markdown(str)\n str = str.gsub(/\\*\\*(.*?)\\*\\*/, C.bold('\\1'))\n str = str.gsub(/_(.*?)_/, C.underscore('\\1'))\n str = str.gsub(/<math>(.*?)<\\/math>/, C.bold('\\1'))\n end",
"def md_erb_files\n Dir.glob(\"**/*.md.erb\").reject do |path|\n [\"license\", \"readme\"].any? do |str|\n path.downcase.ends_with? \"#{str}.md.erb\"\n end\n end\n end",
"def build_content_metadata record, tags\n # TODO: Further enrich the structured data by marking up FAQ accordions, Video Carousels, Image Galleries, etc.\n # Also ItemList metadata for the meditations archive\n # See here: https://developers.google.com/search/docs/data-types/article\n []\n end",
"def liquidize_markdown(content, arguments)\n # doc = BlueCloth.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n # :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}))\n doc = ::Kramdown::Document.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}),\n :parse_block_html => true)\n return doc.to_html.html_safe\n end",
"def prepend_markdown_filter(string)\n str_arr = string.split(\"\\n\").map{ |item| \" #{item}\\n\" }\n mark_line = \"#{string.scan(/^[\\ ]*/).first}:markdown\\n\"\n [[mark_line], str_arr].flatten.join('')\n end",
"def extract_images(markdown_content)\n imgs = {}\n urls = markdown_content.scan(/\\!\\[[^\\]]+\\]\\(([^?)]+)[^)]*\\)/).flatten\n urls.each do |u|\n filename = URI(u).path.split('/').last\n imgs[filename] = u\n end\n imgs\n end",
"def markdown_issues (results, heading)\n message = \"#### #{heading}\\n\\n\"\n\n message << \"File | Line | Reason |\\n\"\n message << \"| --- | ----- | ----- |\\n\"\n\n results.each do |r|\n filename = r['file'].split('/').last\n line = r['line']\n reason = r['reason']\n\n message << \"#{filename} | #{line} | #{reason} \\n\"\n end\n\n message\n end",
"def markdown_heading_parser(content)\n content.gsub(/^.*#.*/) { |heading| \"<h1>#{heading[2..-1]}</h1>\" }\nend",
"def markdown(md_text, options={})\n config = sanitize_config(options[:trusted?] || false)\n filtered = Filters.apply_all_to(md_text)\n Sanitize.clean(RDiscount.new(filtered, :smart).to_html, config).html_safe\n end",
"def extract_multiline(name, page, opts={})\n options = { :scrub => false, :markdown => false }.merge(opts)\n start_el = page.find {|e| e.text =~ /#{name}/i}\n els = [start_el]\n current = start_el.next\n until current.children.find {|c| c.name == 'strong'} do\n els << current\n current = current.next\n end\n if options[:markdown]\n html = els[1..-1].map(&:to_s).join\n ReverseMarkdown.convert(html)\n else\n text = els.map(&:text).join\n standalone = text[/#{name}\\**:[[:space:]](.*)/im, 1]\n options[:scrub] ? scrub(standalone) : standalone.strip\n end\nend",
"def process_markdown\n self.data = self.class.convert_markdown(self.data)\n sanitize_html\n end",
"def tomdoc\n lines = raw.split(\"\\n\")\n\n # remove remark symbol\n if lines.all?{ |line| /^\\s*#/ =~ line }\n lines = lines.map do |line|\n line =~ /^(\\s*#)/ ? line.sub($1, '') : nil\n end\n end\n\n # for some reason the first line is coming in without indention\n # regardless, so we temporary remove it\n first = lines.shift\n\n lines = deindent(lines)\n\n # put first line back\n unless first.nil?\n lines.unshift(first.sub(/^\\s*/,''))\n end\n\n lines.compact.join(\"\\n\")\n end",
"def linkMetadataToResults(metas)\n\n # Go through metadata\n # m - has all metadata combined\n m = {} \n metas.each do |t|\n # Skip metadata from old blobs\n if t.metadata_blob_id != nil && t.devfile_blob_id != t.metadata_blob_id\n next\n end\n \n # n - has metadata of one file \n n = {}\n \n store = m[t.devfile_id]\n \n # Is there already data for this devfile_id\n if store == nil\n # No data for this devfile yet, create it\n n.merge!({t.metadatatype => t.metadata_value})\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => n })\n\n else\n block = store[t.metadatatype]\n\n # Is there already this metadatatype\n if block == nil\n # Create the new metadatatype for this file\n store.merge!({t.metadatatype => t.metadata_value})\n elsif t.metadatatype == \"tag\" or t.metadatatype == \"context_hash\"\n # Add new metadatatype for this file\n store.merge!({t.metadatatype => block + \", \" + t.metadata_value})\n end\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => store }) \n end\n end \n \n \n \n \n # link metadata to right result, with hash\n @results.each do |r|\n mdata = m[r.devfile_id.to_i]\n if mdata != nil\n #puts \"r: #{r.devfile_file_id.to_s}\"\n @metadatas.merge!({r.devfile_id.to_i => mdata})\n end\n end\n \n \n\n \n \n end",
"def markdown(text)\n# coderayified = CodeRayify.new(:filter_html => true,:hard_wrap => true)\n coderayified = PygmentsHTML.new(\n with_toc_data: true,\n hard_wrap: true\n )\n# coderayified = Redcarpet::Render::HTML.new(:filter_html => true,:hard_wrap => true)\n options = {\n :no_intra_emphasis => true,\n :tables => true,\n :fenced_code_blocks => true,\n :autolink => true,\n :strikethrough => true,\n :lax_spacing => true,\n :superscript => true\n }\n markdown_to_html = Redcarpet::Markdown.new(coderayified, options)\n markdown_to_html.render(text).html_safe\n end",
"def ExtractInfoFromFileContents file_contents\ndata = file_contents.split('|')\n# Remove the first line\n# Remove the project_name from data\n# Remove the line below project_name\ndata = data.drop(3)\n\n# Now, everything is in 3-tuple <key, value, \"\\n\">\ndata.shift\nproject_name = data.first\nproject_name = project_name.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nrepo_url = data.first\nrepo_url = repo_url.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nhead_sha = data.first\nhead_sha = head_sha.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nnum_commits = data.first\nnum_commits = num_commits.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nnum_merges = data.first\nnum_merges = num_merges.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nreverts_msg = data.first\nreverts_msg = reverts_msg.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nreverts_complete = data.first\nreverts_complete = reverts_complete.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nreverts_partial = data.first\nreverts_partial = reverts_partial.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\ncps_complete = data.first\ncps_complete = cps_complete.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\ncps_partial = data.first\ncps_partial = cps_partial.gsub(/\\s+/, \"\")\ndata = data.drop(2)\n\nproject_name_repo_url_head_sha_combined = project_name + \"\\n\" + repo_url + \"\\n\" + head_sha\nreturn [project_name_repo_url_head_sha_combined, num_commits, num_merges, reverts_msg, reverts_complete, reverts_partial, cps_complete, cps_partial]\n\nend",
"def load_workset( filename )\n\n md_filename = ''\n asset_files = []\n File.open( filename, 'r').each do |line|\n if /^metadata : /.match( line )\n md_filename = /^metadata : (.*)$/.match( line ).captures[ 0 ]\n end\n\n if /^asset : /.match( line )\n asset_files << /^asset : (.*)$/.match( line ).captures[ 0 ]\n end\n end\n\n return md_filename, asset_files\n end",
"def markdown(txt)\n options = %i[\n hard_wrap filter_styles autolink\n no_intraemphasis fenced_code gh_blockcode\n ]\n doc = Nokogiri::HTML(Redcarpet.new(txt, *options).to_html)\n doc.search('//pre[@lang]').each do |pre|\n pre.replace Albino.colorize(pre.text.rstrip, pre[:lang])\n end\n doc.xpath('//body').to_s.gsub(%r{</?body>}, '').html_safe\n end",
"def markdown_body\n self[:markdown_body]\n end",
"def read_post(path)\n chunks = IO.read(path).split(/^---\\s*$/)\n\n metadata = YAML.load(\"---\\n\" + chunks[1])\n\n [metadata, chunks[2]]\nend",
"def markdown\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)\n end",
"def find_chunks(text)\n meta_info = text.scan(CHUNK_REGEXP)\n returning(chunks = []) do\n split = text.split(CHUNK_REGEXP)\n split.shift\n split.each_with_index do |lines, idx| \n chunks << PrettyDiff::Chunk.new(meta_info[idx], lines)\n end\n end\n end",
"def process\n filename = \"index.markdown\"\n markdowns = {filename => []} \n state = :message\n message = [\"\\n\"]\n patch = []\n commit = nil\n (@gitlogp.split(\"\\n\")+[\"DONE\"]).each { |line|\n words=line.split\n if line.slice(0,1)==\" \" || words.length==0\n # commit messages start with 4 spaces, diff contents with 1 space\n if state==:message\n if words[0]==\"OUTPUT_FILE:\"\n filename = words[1]\n markdowns[filename] ||= []\n else\n message << \"#{line.slice(4..-1)}\"\n end\n else\n patch << \" #{line}\" if state==:patch\n end\n elsif words[0]==\"commit\" or words[0]==\"DONE\"\n if !commit.nil?\n # replace the short description line with a named link\n shortlog = message[2]\n message[2] = \"<a name='#{shortlog}'> </a>\"\n markdowns[filename] += message.map {|l|\n if l==\"SHOW_PATCH\"\n (patch+[\"{: .diff}\\n\"]).join(\"\\n\")\n else\n l\n end\n }\n series = tags[commit].slice(-2..-1)\n markdowns[filename] << \"\\n#{tags[commit]}: [view on github](#{@commit_link_base}#{commit}), [download #{series}-#{shortlog}.patch](#{@patch_link_base}/#{series}-#{shortlog}.patch)\\n{: .commit}\\n\"\n end\n \n message=[\"\\n\"]\n patch=[]\n\n commit = words[1]\n state = :message\n elsif [\"Author:\", \"Date:\", \"new\", \"index\", \"---\", \"+++\", '\\\\'].include?(words[0])\n # chomp\n elsif words[0]==\"diff\"\n state = :patch\n left = words[2].slice(2..-1)\n right = words[3].slice(2..-1)\n if left==right\n patch << \" ::: #{right}\"\n else\n patch << \" ::: #{left} -> #{right}\"\n end\n elsif words[0]==\"@@\"\n # git tries to put the function or class name after @@. This\n # works great for C diffs, but it only finds the class name in\n # Ruby, which is usually similar to the file name, Therefore\n # it's distracting cruft. Toss it.\n patch << \" #{words.slice(0,4).join(\" \")}\"\n else\n message << \"#{line.slice(4..-1)}\" if state==:message\n patch << \" #{line}\" if state==:patch \n end\n }\n output = {}\n markdowns.each do |fn, markdown|\n output[fn] = markdown.join(\"\\n\")\n Rails.logger.info(output[fn]) if respond_to? :Rails\n end\n return output\n end",
"def markdown(text)\n return \"\" unless text\n\n CommonMarker.render_doc(text, :SMART).to_html([:NOBREAKS]).html_safe\n end",
"def get_metadata_string\n str = \"\"\n @keywords.keys.map{|e| e.to_s}.sort.each do |k|\n str << k.to_s + \" => \" + @keywords[k.to_sym].to_s + \"\\n\"\n end\n str\n end",
"def get_attachments_metadata(node)\n files_md = {}\n md_list = FileTableKeys\n md_list.delete(RawContent)\n md_fields = md_list.join(\"`, `\")\n \n model_key = node.my_GlueEnv.model_key\n sql = \"SELECT `#{md_fields}` FROM `#{@file_table_name}`\n WHERE `#{NodeName}` = '#{node.__send__(model_key.to_sym)}'\"\n sth = @dbh.prepare(sql)\n rtn = []\n sth.execute\n while row=sth.fetch do\n rtn << row.to_h\n end\n #rtn\n sth.finish\n objects = rtn\n objects.each do |object|\n obj_md = object \n #speputs \"Obj It: #{obj_md.inspect}\"\n obj_md_file_modified = obj_md[\"modified_at\"]\n obj_md_content_type = obj_md[\"content_type\"]\n new_md = {:content_type => obj_md_content_type, :file_modified => obj_md_file_modified}\n new_md.merge(obj_md) #where does the original metadata go?\n #p new_md.keys\n files_md[obj_md[\"basename\"]] = new_md\n #puts \"Obj METADATA: #{new_md.inspect}\"\n end\n files_md\n end",
"def markdown(source)\n Open3.popen2('pandoc', '-s', '-f', 'markdown', '-t', 'html') do |stdin, stdout, wait_thr|\n stdin.puts(source)\n stdin.close\n stdout.read\n end\nrescue => e\n STDERR.puts e\n nil\nend",
"def metadata\n hash.inject([]){ |list, data| list << MetaData.new(data[0], data[1][0]) }\n end",
"def parse_metadata_section(metadata_string)\n metadata_string.split(\"\\n\").reduce({}) do |result, line|\n key, val = line.split(\": \")\n if [key, val].none? { |str| str.blank? }\n result[key.strip.downcase.to_sym] = val.strip.split(\", \")\n end\n result\n end\n end",
"def markdownToHTML(markdown)\n output = \"\"\n IO.popen($mmdPath, \"w+\") do |f|\n f.print markdown\n f.close_write\n output = f.gets(nil)\n end\n return output\nend",
"def meta_data\n return if @meta_end.nil?\n\n cur, meta_end, @meta_end = tell, @meta_end, nil\n seek 0\n return YAML.load(self)\n\n ensure\n @meta_end = meta_end if defined? meta_end and meta_end\n seek cur if defined? cur and cur\n end",
"def yaml_metadata\n if single_post?\n\n # if we were to merge config to data, the default options would\n # take precedence\n data = Jekyll::Utils.deep_merge_hashes @config, single_post.data\n single_post.merge_data! data\n\n\n # we extract the excerpt because it serializes as an object and\n # breaks pandoc\n metadata = single_post.data.reject{ |k| k == 'excerpt' }\n\n if @config['date_format']\n metadata['date'] = metadata['date'].strftime(@config['date_format'])\n else\n metadata.delete('date')\n end\n else\n # we have to use this fugly syntax because jekyll doesn't do\n # symbols\n metadata = {\n 'date' => @config['date_format'] ? Date.today.strftime(@config['date_format']) : nil,\n 'title' => @title,\n 'author' => nil,\n 'papersize' => papersize,\n 'sheetsize' => sheetsize,\n 'signature' => signature\n }\n end\n\n # fix page sizes, pandoc uses 'A4' while printer.rb uses\n # 'a4paper'\n %w[papersize sheetsize].each do |size|\n metadata[size] = fix_size metadata[size]\n end\n\n metadata.to_yaml << \"\\n---\\n\"\n end",
"def create_md tool\n \n original = tool[1].split(\"\\n\")\n new = []\n note = false\n\n # Cambia las rutas y < y > por código HTML\n def diple l\n return l.gsub('de +++YAML+++ en <http://pecas.cliteratu.re>', 'de [+++YAML+++](yaml.html)')\n .gsub('de JavaScript en <http://pecas.cliteratu.re>', 'de [JavaScript](js.html)')\n .gsub('Lista de acrónimos: <https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages>', '[Lista de acrónimos](https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages)')\n .gsub('<','<').gsub('>','>')\n end\n\n # Agrega versalitas\n def smallcaps l\n return l.gsub(/([A-Z]{3,})/, '+++\\1+++')\n end\n\n # Cambia comillas por sintaxis para línea de código\n def to_code l\n return l.gsub(/«(.+?)»/, '`\\1`')\n end\n\n # Añade líneas de código en las opciones\n def to_code_option l\n return l.gsub(/^(\\S+)/, '`\\1`')\n end\n\n new.push('# ' + $l_g_pc_docs_creation + '`' + tool[0] + '`')\n\n original.each_with_index do |l, i|\n\n l = to_code(diple(smallcaps(l)))\n\n if l =~ /^\\S/\n # Encabezados 2\n if l !~ /^Nota/ && i != 1\n new.push('## ' + l + \"\\n\\n\")\n # Párrafos\n else\n # Notas\n if l =~ /^Nota/\n if !note\n new.push(\"--- {.espacio-arriba3}\\n\\n\")\n note = true\n new.push(l + ' {.espacio-arriba3}')\n else\n new.push(l + ' {.espacio-arriba1 .sin-sangria}')\n end \n # Descripción\n else\n # Esto servirá para crear «herramientas.md»\n $tools_md[\"#{tool[0]}\"] = [tool[0], l.gsub(/^\\S+\\s+/, '')]\n new.push(l)\n end\n end\n else\n if l.strip != ''\n l = l.strip\n\n # Opciones de Pecas\n if l =~ /^-/\n new.push('* ' + to_code_option(l))\n # Comandos de Pecas\n elsif l =~ /^pc-/\n new.push('```')\n new.push(l)\n new.push('```')\n # Explicaciones\n elsif l =~ /^[A-Z]/\n new.push(\"\\n\" + l)\n # Dependencias / Tipos\n else\n # Evita que se quede como línea de código el tipo y su descripción\n l_final = []\n l.split(/\\s+/).each_with_index do |ll, i|\n # Solo la primera palabra se va como código\n if i == 0\n l_final.push('* `' + ll + '`')\n # El resto de las palabras se quedan como texto\n else\n l_final.push(ll)\n end\n end\n new.push(l_final.join(' '))\n end\n # Líneas en blanco\n else\n new.push(l)\n end\n end\n end\n\n\tarchivo = File.new(Dir.pwd + '/md/' + tool[0] + '.md', 'w:UTF-8')\n\tarchivo.puts new\n\tarchivo.close\nend",
"def markdown( text )\n Kramdown::Document.new( text ).to_html\n end",
"def metadata(filepath)\n metadata = {}\n metadata.merge!(author(filepath))\n metadata.merge!(title(filepath))\n metadata.merge!(serie(filepath))\n metadata\n end",
"def parse!(content)\n @children = []\n @content = ''\n\n # Parse all direct children and create new markdown objects\n sections = Section.generate_sections(content)\n\n # No children!\n if sections.empty?\n @content = content\n return\n end\n\n # Populate content prior to found headers\n @content = content[0..sections.first.header_location.begin - 1] if sections.first.header_location.begin > 0\n\n parse_children!(sections)\n end",
"def markdown_to_text(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".txt\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n text_content = `pandoc -f markdown -t text \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return text_content\n end"
] | [
"0.6789341",
"0.6440488",
"0.61502534",
"0.6017993",
"0.5928651",
"0.5889146",
"0.58474535",
"0.5843077",
"0.57650805",
"0.57554",
"0.573926",
"0.5713302",
"0.56963176",
"0.5654637",
"0.5628647",
"0.55616385",
"0.55475855",
"0.55433655",
"0.5529663",
"0.5503852",
"0.5475491",
"0.5471466",
"0.54692924",
"0.54630774",
"0.5427167",
"0.5389355",
"0.53510654",
"0.53508955",
"0.53495437",
"0.53388596",
"0.53152716",
"0.53108287",
"0.5292383",
"0.5288597",
"0.52853423",
"0.52660763",
"0.52613944",
"0.52477187",
"0.52299523",
"0.5203822",
"0.5162493",
"0.51557887",
"0.51467127",
"0.51467127",
"0.5139023",
"0.51262385",
"0.5124623",
"0.5123953",
"0.51223266",
"0.51173335",
"0.5107385",
"0.5106496",
"0.5097932",
"0.5087575",
"0.5077577",
"0.5074228",
"0.50703037",
"0.50690216",
"0.5051072",
"0.5043496",
"0.5030255",
"0.50300515",
"0.5029668",
"0.5029668",
"0.50112706",
"0.5008801",
"0.50069636",
"0.50045776",
"0.5001435",
"0.4994586",
"0.49911427",
"0.49904683",
"0.49843603",
"0.49737355",
"0.4958769",
"0.4944131",
"0.49349692",
"0.49345022",
"0.4933382",
"0.49332887",
"0.49268216",
"0.4922615",
"0.4920296",
"0.49111155",
"0.49037224",
"0.48995352",
"0.4897452",
"0.4892861",
"0.48894948",
"0.48828593",
"0.48812577",
"0.48775542",
"0.4877531",
"0.48766425",
"0.48752296",
"0.48706967",
"0.4864016",
"0.48581576",
"0.48558944",
"0.4854607"
] | 0.7501597 | 0 |
Get results of parsing a single metadata section Returns a hash | def parse_metadata_section(metadata_string)
metadata_string.split("\n").reduce({}) do |result, line|
key, val = line.split(": ")
if [key, val].none? { |str| str.blank? }
result[key.strip.downcase.to_sym] = val.strip.split(", ")
end
result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_metadata; end",
"def aws_get_metadata\n murl = 'http://169.254.169.254/latest/meta-data/'\n result = self.aws_get_url(murl)\n metadata = Hash.new()\n\n # TODO this isn't entirely right.. if the element ends in '/', it's actually another level of hash..\n result.split(\"\\n\").each do |element|\n metadata[element] = self.aws_get_url(sprintf('%s%s', murl, element))\n end\n\n metadata\n end",
"def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end",
"def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end",
"def read_meta(node)\n t = decompress_revision(node)\n return {} unless has_metadata?(t)\n \n mt = t[metadata_start..(metadata_end(t) - 1)]\n mt.split(\"\\n\").inject({}) do |hash, line|\n k, v = line.split(\": \", 2)\n hash[k] = v\n hash\n end\n end",
"def section_metadata\n [section_metadata_one, section_metadata_two, section_metadata_three]\n end",
"def metadata(output)\n metadata = {}\n lines = output.split(/\\n/)\n lines.grep(/ {4}.+: .+/).\n map {|l| l.split(':').map(&:strip)}.\n select {|a| a.size == 2}.\n each {|d| metadata[d.first.underscore.to_sym] = d.last}\n metadata\n end",
"def parse_metadata(metadata)\n\t{\n :name => metadata[:name],\n :url => metadata[:href],\n :catalog_name => \"utah.gov\",\n :catalog_url => @base_uri,\n :org_type => \"governmental\",\n :organization => { :name => \"Utah\" },\n\n\t}\n end",
"def metadata\n Hash.from_xml(self[:metadata])['hash']\n end",
"def extract_meta\n end",
"def read_meta_info\n if meta_info_file_pathname.exist?\n inode, bytes_read = meta_info_file_pathname.read.strip.split(':').map(&:to_i)\n {\n inode: inode,\n bytes_read: bytes_read\n }\n else\n {\n inode: nil,\n bytes_read: 0\n }\n end\n end",
"def extract_metadata(markdown_string)\n metadata_results = OpenStruct.new\n return markdown_string unless markdown_string.include? \"**METADATA**\"\n result = markdown_string.split(\"**METADATA**\").map do |section|\n metadata, content = section.split(\"****\")\n parse_metadata_section(section).each do |key,results_array|\n metadata_results[key] ||= []\n metadata_results[key].concat results_array\n end\n content\n end.join(\"\\n\\n\")\n [result, metadata_results]\n end",
"def parse_metadata\n meta=Hash.new\n meta['hostname'][email protected]\n meta['name'][email protected]\n meta['spoof'][email protected]\n meta['type'][email protected]\n meta['name2'][email protected]\n meta['units'][email protected]\n [email protected]\n\n case slope\n when 0\n meta['slope']= 'zero'\n when 1\n meta['slope']= 'positive'\n when 2\n meta['slope']= 'negative'\n when 3\n meta['slope']= 'both'\n when 4\n meta['slope']= 'unspecified'\n end\n\n meta['tmax'][email protected]\n meta['dmax'][email protected]\n [email protected]\n meta['nrelements']=nrelements\n unless nrelements.nil?\n extra={}\n for i in 1..nrelements\n [email protected]\n extra[name][email protected]\n end\n meta['extra']=extra\n end\n return meta\n end",
"def metadata_hash\n @metadata_hash ||= YAML.load(@chunked_source.metadata) || {}\n rescue Psych::SyntaxError\n msg = \"Bad metadata hash - are you sure it's valid YAML?\\n#{@chunked_source.metadata}\"\n raise SyntaxError, msg\n end",
"def metadata\n @metadata ||= (\n if md = /\\<\\!\\-\\-\\-(.*?)\\-{2,3}\\>\\s*\\Z/m.match(content)\n YAML.load(md[1])\n else\n {}\n end\n )\n end",
"def extractMetadata()\n Logging.LogScriptInfo \"Extract metadata from #{@logFile}...\"\n\n # Get the meta datas from the json report\n metas = { }\n metas['build_date'] = @jsonData['build_date']\n metas['build_time'] = @jsonData['build_time']\n metas['git_revision'] = @jsonData['git_revision']\n metas['options'] = @jsonData['sim']['options']\n metas['overrides'] = @jsonData['sim']['overrides']\n metas['statistics'] = @jsonData['sim']['statistics']\n @jsonData['sim']['players'].each do |player|\n if player['name'] == 'Template'\n metas['player'] = player\n end\n end\n metas['profilesets_overrides'] = { }\n @jsonData['sim']['profilesets']['results'].each do |player|\n next unless player['overrides']\n metas['profilesets_overrides'][player['name']] = player['overrides']\n end\n\n # Timestamps\n metas['build_timestamp'] = DateTime.parse(@jsonData['build_date'] + ' ' + @jsonData['build_time'] + ' ' + Time.now.strftime('%:z')).to_time.to_i\n metas['result_timestamp'] = Time.now.to_i\n\n # Add additional data\n metas.merge!(@additionalMetadata)\n\n return metas\n end",
"def metadata\n @data[:metadata]\n end",
"def read_metadata; end",
"def get_metadata\n doc = download_ais(@program_id)\n streamUri = (doc/\"//streamuri\").text\n @metadata[:fileType] = streamUri[-3..-1]\n @metadata[:programName] = (doc/\"//brandtitle\").text\n @metadata[:episodeId] = (doc/\"//programmenumber\").text\n\n assetInfo = download_asset(@program_id)\n @metadata[:episodeNumber] = (assetInfo/\"//episodenumber\").text\n @metadata[:seriesNumber] = (assetInfo/\"//seriesnumber\").text\n @metadata[:episodeInfo] = (assetInfo/\"//episodeinfo\").text\n @metadata[:episodeTitle] = (assetInfo/\"//episodetitle\").text\n @metadata[:brandTitle] = (assetInfo/\"//brandtitle\").text\n @metadata[:epId] = (assetInfo/\"//programmeid\").text\n @metadata[:imagePath] = (assetInfo/\"//imagepath\").text\n\n @metadata[:title1] = (assetInfo/\"//title1\").text\n @metadata[:title2] = (assetInfo/\"//title2\").text\n\n #progGuideUrl is used to pull out metadata from the CH4 website\n progGuideUrl = (assetInfo/\"//episodeguideurl\").text\n\n begin\n #read program guide to get additional metadata\n seriesInfo = download_progguide(progGuideUrl)\n\n synopsisElem = seriesInfo.at(\"//meta[@name='synopsis']\")\n @metadata[:description] = synopsisElem.nil? ? \"\" : synopsisElem['content']\n rescue\n @log.error \"Unable to read program guide data - the video file will not be fully tagged\"\n @log.debug \"Program Guide URL: #{progGuideUrl}\"\n end\n end",
"def meta\n @meta ||= begin\n arr = @header_str.split(/\\r?\\n/)\n arr.shift\n arr.inject({}) do |hash, hdr|\n key, val = hdr.split(/:\\s+/, 2)\n hash[key.downcase] = val\n hash\n end\n end\n end",
"def extract_metadata\n YAML_METADATA.match(content) do |match|\n @metadata = YAML.load(match[0])\n @content = content.gsub(YAML_METADATA, \"\")\n end\n end",
"def get_aws_metadata(response)\n metadata = {}\n response.each do |key, value|\n if key =~ /^#{METADATA_PREFIX}(.*)$/oi\n metadata[$1] = value\n end\n end\n return metadata\n end",
"def metadata\n output = shell!(\"ffprobe -v quiet -print_format json -show_format -show_streams #{file.path.shellescape}\")\n json = JSON.parse(output)\n json.with_indifferent_access\n end",
"def metadata\n output = shell!(\"ffprobe -v quiet -print_format json -show_format -show_streams #{file.path.shellescape}\")\n json = JSON.parse(output)\n json.with_indifferent_access\n end",
"def metadata\n hash.inject([]){ |list, data| list << MetaData.new(data[0], data[1][0]) }\n end",
"def metadata\n self[:metadata] || {}\n end",
"def metadata\n @meta_data\n end",
"def fetch_metadata\n {\n \"public_fqdn\" => fetch_metadata_item(\"getFullyQualifiedDomainName.txt\"),\n \"local_ipv4\" => fetch_metadata_item(\"getPrimaryBackendIpAddress.txt\"),\n \"public_ipv4\" => fetch_metadata_item(\"getPrimaryIpAddress.txt\"),\n \"region\" => fetch_metadata_item(\"getDatacenter.txt\"),\n \"instance_id\" => fetch_metadata_item(\"getId.txt\"),\n }\n end",
"def metadata\n @metadata ||= {}\n end",
"def metadata\n @metadata ||= {}\n end",
"def extract_metadata(content)\n document = parse_kramdown(content)\n toc = ::Kramdown::Converter::Toc.convert(document.root)\n toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t| \n {:id => t.attr[:id], :text => t.value.children.first.value}\n end\n metadata = document.root.options[:metadata]\n metadata[:toc] = toc_items\n metadata[:converted] = document.to_html\n metadata[:technologies] = metadata[:technologies].split(\",\").collect {|tech| tech.strip}\n metadata[:author] = metadata[:author].split(',').first if metadata[:author]\n metadata[:product] ||= @product\n metadata[:experimental] ||= @experimental\n metadata[:experimental] ||= false\n metadata[:level] = 'Beginner'\n metadata\n end",
"def parse_meta\n meta = Hash.new\n meta[@data[0][0]] = @data[0][1]\n meta[@data[0][2]] = @data[0][3]\n meta[@data[0][4]] = @data[0][5]\n meta[@data[0][6]] = @data[0][7]\n meta[@data[1][0]] = @data[1][1]\n meta[@data[1][2]] = @data[1][3]\n meta[@data[1][4]] = @data[1][5]\n meta[@data[1][6]] = @data[1][7]\n meta[@data[1][8]] = @data[1][9]\n meta[@data[1][10]] = @data[1][11]\n meta[@data[1][12]] = @data[1][13]\n # This is some cleanup that needs to happen because of an oddity (bug?) in \n # the WF/CSV files in version 5.5.1.\n if [\"5.5.0\",\"5.5.1\"].include? meta[\"AppVersion\"]\n day = Hash.new\n hour = Hash.new\n minu = Hash.new\n sec = Hash.new\n meta.each do |k,v|\n if !k.nil?\n if k.include? \"Day\"\n d = k.split(/([0-9]+)/) \n day[d[0]] = d[1]\n h = v.split(/([0-9]+)/) \n hour[h[0]] = h[1]\n meta.delete(k)\n elsif k.include? \"Minu\"\n m = k.split(/([0-9]+)/) \n minu[m[0]] = m[1]\n s = v.split(/([0-9]+)/) \n sec[s[0]] = s[1]\n meta.delete(k)\n end\n else\n meta.delete(k)\n end\n end \n meta.merge! day\n meta.merge! hour\n meta.merge! minu \n meta.merge! sec\n end \n return meta\n end",
"def parse_metadata(io)\n current_pos = io.pos\n io.rewind\n \n metadata = {}\n line = io.readline\n unless line =~ /MIME-Version: (\\d+\\.\\d+) \\(Generated by Mascot version (\\d+\\.\\d+)\\)/\n raise \"could not parse mime-version or mascot-version: #{line}\"\n end\n metadata[:mime_version] = $1\n metadata[:mascot_version] = $2\n \n line = io.readline\n unless line =~ /Content-Type: (.*?); boundary=(.*)/\n raise \"could not parse content-type: #{line}\"\n end\n metadata[:content_type] = $1\n metadata[:boundary] = $2\n \n io.pos = current_pos\n metadata\n end",
"def metadata\n @metadata ||= lambda { read_metadata }.call\n end",
"def metadata\n @metadata ||= lambda { read_metadata }.call\n end",
"def metadata\n value_of(:metadata, JSON.method(:pretty_generate), '{}')\n end",
"def parse_metadata(io)\n # Simon Chiang wrote this\n current_pos = io.pos\n io.rewind\n\n metadata = {}\n line = io.readline\n unless line =~ /MIME-Version: (\\d+\\.\\d+) \\(Generated by Mascot version (\\d+\\.\\d+)\\)/\n raise \"could not parse mime-version or mascot-version: #{line}\"\n end\n metadata[:mime_version] = $1\n metadata[:mascot_version] = $2\n\n line = io.readline\n unless line =~ /Content-Type: (.*?); boundary=(.*)/\n raise \"could not parse content-type: #{line}\"\n end\n metadata[:content_type] = $1\n metadata[:boundary] = $2\n\n io.pos = current_pos\n metadata\n end",
"def meta_data\n return if @meta_end.nil?\n\n cur, meta_end, @meta_end = tell, @meta_end, nil\n seek 0\n return YAML.load(self)\n\n ensure\n @meta_end = meta_end if defined? meta_end and meta_end\n seek cur if defined? cur and cur\n end",
"def metadata\n attributes['metadata'] ||= {}\n attributes['metadata']\n end",
"def parse_meta(parsed_query)\n hoge = [[], {}]\n\n parsed_query.each do |token|\n if token =~ /^(.+?):(.+)$/\n hoge[1][Regexp.last_match[1]] = Regexp.last_match[2]\n else\n hoge[0] << token\n end\n end\n\n hoge\n end",
"def parse_metadata_body(body)\n body.lines.each_with_object({}) do |line, hsh|\n k, v = line.strip.split\n hsh[k.to_sym] = v\n end\n end",
"def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end",
"def get_metadata\n get_state.map do |get_state_resp|\n metadata = get_state_resp.dig(:data, :identity_state, :metadata)\n if metadata\n metadata.transform_values { |val| Utils.parse_string_or_byte_val(val) }\n else\n metadata\n end\n end\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 parsed\n return @parsed if instance_variable_defined? :@parsed\n\n if source =~ /^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m\n { metadata: YAML.load($1), content: $' }\n else\n { metadata: {}, content: source }\n end\n end",
"def parse_data(metadata)\n data=Hash.new\n data['hostname'][email protected]\n\n [email protected]\n data['name']=metricname\n\n data['spoof'][email protected]\n data['format'][email protected]\n\n metrictype=name_to_type(metricname,metadata)\n\n if metrictype.nil?\n # Probably we got a data packet before a metadata packet\n #puts \"Received datapacket without metadata packet\"\n return nil\n end\n\n data['val']=parse_value(metrictype)\n\n # If we received a packet, last update was 0 time ago\n data['tn']=0\n return data\n end",
"def metadata\n @metadata ||= Mash.new\n end",
"def general_metadata_hash\r\n metadata = Hash.new\r\n metadata[:filename] = @datafile.file_file_name\r\n metadata[:downloads] = 0\r\n\r\n metadata[:title] = clean_string(general_metadata_sheet[*WBF[:meta_title_pos]])\r\n metadata[:abstract] = clean_string(general_metadata_sheet[*WBF[:meta_abstract_pos]])\r\n metadata[:comment] = clean_string(general_metadata_sheet[*WBF[:meta_comment_pos]])\r\n metadata[:usagerights] = clean_string(general_metadata_sheet[*WBF[:meta_usagerights_pos]])\r\n metadata[:published] = clean_string(general_metadata_sheet[*WBF[:meta_published_pos]])\r\n metadata[:spatialextent] = clean_string(general_metadata_sheet[*WBF[:meta_spatial_extent_pos]])\r\n metadata[:temporalextent] = clean_string(general_metadata_sheet[*WBF[:meta_temporalextent_pos]])\r\n metadata[:taxonomicextent] = clean_string(general_metadata_sheet[*WBF[:meta_taxonomicextent_pos]])\r\n metadata[:design] = clean_string(general_metadata_sheet[*WBF[:meta_design_pos]])\r\n metadata[:dataanalysis] = clean_string(general_metadata_sheet[*WBF[:meta_dataanalysis_pos]])\r\n metadata[:circumstances] = clean_string(general_metadata_sheet[*WBF[:meta_circumstances_pos]])\r\n return metadata\r\n end",
"def find_metadata\n MAPPING.each do |metaname, pattern|\n metapattern = Regexp.new(\"(#{pattern})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\n if text.match(metapattern)\n value = $2\n if value.match(metapattern)\n value = $2\n end\n meta[metaname] = value.strip\n end\n end\n meta\n end",
"def metadata\n if any? && metadata_schema\n response = api('request',\n :uri => \"hm://metadata/#{resource_name}s\",\n :batch => true,\n :payload => map {|resource| {:uri => resource.metadata_uri}},\n :response_schema => metadata_schema\n )\n response['result']\n else\n []\n end\n end",
"def get_section_info section_header\n\t\t\tsection_info = {}\n\n\t\t\t# index of name string in .shstrtab\n\t\t\tpos = 0\n\t\t\tsection_info[:name_idx] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# section type\n\t\t\tsection_info[:type] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# section flags\n\t\t\tsection_info[:flags] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# address when section loaded to memory.\n\t\t\tsection_info[:va_address] = section_header[pos, @address_size].to_i\n\t\t\tpos += @address_size\n\n\t\t\t# offset position of this secion in file.\n\t\t\tsection_info[:offset] = section_header[pos, @offset_size].to_i\n\t\t\tpos += @offset_size\n\n\t\t\t# section size\n\t\t\tsection_info[:size] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# Index of related section\n\t\t\tsection_info[:related_section_idx] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# Depends on section type.\n\t\t\tsection_info[:info] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# Allignment size.\n\t\t\tsection_info[:addr_align] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tpos += ELF_SIZE_WORD\n\n\t\t\t# Section entry size (used when section has struct table)\n\t\t\tsection_info[:entry_size] = section_header[pos, ELF_SIZE_WORD].to_i\n\t\t\tsection_info\n\t\tend",
"def hash\n @hash ||= opts[:parser].parse(data.to_s.gsub(/\\<!\\[CDATA\\[([^\\]]+)\\]\\]\\>/) {$1})\n end",
"def read_summary(fname)\n hash={}\n # Read file\n File.open(fname,'r') do |f|\n # Loop over line\n f.each_line do |line|\n line.chomp!\n index,content = line.split(/\\s*==\\s*/)\n hash[index] = content # index:id, content:path\n end\n end\n return hash\nend",
"def data\n data = Jhead.call(@match, @pattern).split(\"\\n\\n\").map { |p| p.split(\"\\n\") }\n data.map! do |p|\n h = Hash.new\n p.each do |l|\n #OPTIMIZE for the moment, ignore line:\n # \"======= IPTC data: =======\" and its following lines.\n break if l == \"======= IPTC data: =======\"\n if l =~ /(.+?)\\s*:\\s*(.+)/\n h[parse_tag $1] = parse_value $2\n end\n end\n h\n end\n\n data.size == 1 ? data.first : data\n end",
"def metadata_each\n rhGet(ForjDefault.dump(), :sections).each { | section, hValue |\n next if section == :default\n hValue.each { | key, value |\n yield section, key, value\n }\n }\n end",
"def metadata_as_h\n if metadata.nil? || metadata[:items].nil? || metadata[:items].empty?\n return {}\n end\n\n Hash[metadata[:items].map { |item| [item[:key], item[:value]] }]\n end",
"def metadata\n {\n title: flickr_title,\n description: description\n }\n end",
"def get_metadata_response(metadata)\n if metadata.respond_to?(:has_key?)\n listing = []\n metadata.keys.sort.each do |key|\n value = metadata[key]\n if value.respond_to?(:has_key?)\n listing << key + '/'\n else\n listing << key\n end\n end\n return listing.join(\"\\n\")\n end\n return metadata\n end",
"def metadata\n @metadata\n end",
"def meta_information\n @meta_hash ||= {}\n end",
"def metadata\n return @metadata\n end",
"def metadata\n return @metadata\n end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def convert_result_to_hash(custom_metadata)\n request = {}\n document = REXML::Document.new(custom_metadata)\n REXML::XPath.each(document, \"//customMetadataResponse/data/customMetadata[namespace=\\\"urn:nexus/user#\\\"]\") do |row|\n request[row.elements[\"key\"].text.strip] = row.elements[\"value\"].text.strip\n end\n request\n end",
"def get_metadata\n if (@document == nil)\n return false\n end\n \n @msdata = get_document_metadata(@document)\n #md_index = get_md_index() #Gets metadata index for (ace/dec) sorting \n #sort_metadata(md_index) #Sorts metadata (ace/dec)\n end",
"def extract_metadata(file)\n document = parse_kramdown(file)\n toc = ::Kramdown::Converter::Toc.convert(document.root)\n toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t| \n {:id => t.attr[:id], :text => t.value.children.first.value}\n end\n\n metadata = document.root.options[:metadata]\n metadata[:toc] = toc_items\n metadata[:converted] = document.to_html\n metadata[:technologies] = metadata[:technologies].split(\",\").collect {|tech| tech.strip}\n metadata[:images] = find_images(document.root)\n metadata[:author] = metadata[:author].split(',').first if metadata[:author]\n metadata[:commits] = commit_info @repo, Pathname.new(file)\n metadata[:current_tag] = current_tag @repo, Pathname.new(file)\n metadata[:current_branch] = current_branch @repo, Pathname.new(file)\n metadata[:github_repo_url] = repository_url @repo\n metadata[:contributors] = metadata[:commits].collect { |c| c[:author] }.uniq\n metadata[:contributors_email] = metadata[:commits].collect { |c| c[:author_email] }.uniq\n metadata[:contributors].delete(metadata[:author])\n metadata[:product] = @product if @product\n metadata[:experimental] = @experimental\n metadata\n end",
"def extract_metadata(hash)\n new_metadata = hash.each_with_object({}) do |(k,v), hash|\n if key = k[/^x-ms-meta-(?<key>.*)?/, :key]\n hash[key] = v\n end\n end\n\n metadata.replace(new_metadata)\n end",
"def parseData(result, type, data)\n if (type == \"crc\")\n if (data =~ /^0x(.*)$/)\n data = $1\n end\n elsif (type == \"docs\")\n data =~ /^(\\d+)\\/(\\d+)$/ or die \"Invalid doc entry #{data}\"\n result[\"unique_docs\"] = $1.to_i\n result[\"meta_entries\"] = $2.to_i\n return\n elsif (type == \"bytes\")\n data =~ /^(\\d+)\\/(\\d+)$/ or die \"Invalid bytes entry #{data}\"\n result[\"unique_docs_size\"] = $1.to_i\n result[\"utilized_file_size\"] = $2.to_i\n return\n elsif (type == \"trusted\" || type == \"active\" || type == \"ready\")\n result[type] = (data =~ /^true$/i ? true : false)\n return\n end\n result[type] = data\n end",
"def metadata\n msg['metadata']||{}\n end",
"def diphot_metadata_to_h\n File.open(@qualified_filename, 'r') do |fd|\n diff = fd.readline.chomp\n reference = fd.readline.chomp\n @obj_metadata = { 'diff' => diff, 'reference' => reference }\n end\n end",
"def metadata\n return unless self[:metadata]\n\n self[:metadata].deep_symbolize_keys\n end",
"def meta_data\n return nil unless success?\n\n @meta_data\n end",
"def load_text_metadata\n str = self.client.getmd({}, @address)\n keymap = self.class.md_key_map # subclasses implement this function\n types = self.class.md_type_coercion_map # subclasses might implement this function\n \n # regular expression: matches lines with:\n # 4 whitespace characters at start of line\n # word containing uppercase characters and/or underscores (captured as var 1)\n # colon character immediately after that word\n # one or more whitespace characters\n # any characters following that whitespace, up to end of line (captured as var 2)\n # So, if the string matches, it gets the key as var 1, value as var 2\n re = /^\\W{4}([A-Z_]+):\\s+(.+)$/\n str.each_line do |line|\n md = re.match(line)\n next if md.nil?\n next if md.size < 3 # skip if we didn't get a value for a key (or didn't match)\n \n # insert the metadata value into the @metadata hash\n insert_metadata md[1], md[2], keymap, types\n end\n \n # note that we don't need to run this again\n @metadata_loaded = true\n end",
"def metadata(filepath)\n metadata = {}\n metadata.merge!(author(filepath))\n metadata.merge!(title(filepath))\n metadata.merge!(serie(filepath))\n metadata\n end",
"def mediainfo(filename)\n\n puts(\"Running mediainfo on #{filename}\") if @debug\n metadata = {}\n output = %x[mediainfo --full '#{filename}']\n\n lines = output.split(/$/)\n\n lines.each do |line|\n line.gsub! /^$\\n/, ''\n line.strip!\n\n if (line =~ /duration\\s+:\\s+(\\d+)/i && metadata[:duration] == nil)\n duration = $1.to_i\n metadata[:duration] = duration / 1000\n end\n if (line =~ /scan type\\s+:\\s+interlaced/i)\n metadata[:interlaced] = true\n end\n if (line =~ /width\\s+:\\s+1440/i)\n metadata[:needs_scaling] = true\n end\n end\n\n metadata\nend",
"def hash\n return unless doc_value?\n result['doc']['hash']\n end",
"def to_exif_hash\n return {} if @output.empty?\n meta = @output.scan(/exif:([^=]+)=([^\\n]+)/)\n Hash[meta]\n end",
"def meta_to_hash(text)\n hash = {}\n return hash if text.nil?\n result_list = []\n\n text.split(/\\n/).each do |meta|\n # split by the first ':' string\n list = meta.split /^(.*?):/\n\n # ignore the empty string element\n list.delete_at(0)\n\n unless list.empty?\n list.map(&:strip!)\n # downcase the first item to make it easy\n result_list << [list[0].downcase, list[1]]\n hash = Hash[*result_list.flatten]\n end\n end\n hash\n end",
"def metadata\n @page.metadata\n end",
"def metadata\n api_get(\"$metadata\").body\n end",
"def read_metadata\n @metadata =\n if !disabled? && File.file?(metadata_file)\n content = File.binread(metadata_file)\n\n begin\n Marshal.load(content)\n rescue TypeError\n SafeYAML.load(content)\n rescue ArgumentError => e\n Jekyll.logger.warn(\"Failed to load #{metadata_file}: #{e}\")\n {}\n end\n else\n {}\n end\n end",
"def metadata_info\n @metadata = Chef::Cookbook::Metadata.new\n @metadata.from_file(File.join(@opts[:path], 'metadata.rb'))\n end",
"def find_metadata\n versions.each do |v|\n m = v.metadata\n if m.exist?\n return m\n end\n end\n nil\n end",
"def linkMetadataToResults(metas)\n\n # Go through metadata\n # m - has all metadata combined\n m = {} \n metas.each do |t|\n # Skip metadata from old blobs\n if t.metadata_blob_id != nil && t.devfile_blob_id != t.metadata_blob_id\n next\n end\n \n # n - has metadata of one file \n n = {}\n \n store = m[t.devfile_id]\n \n # Is there already data for this devfile_id\n if store == nil\n # No data for this devfile yet, create it\n n.merge!({t.metadatatype => t.metadata_value})\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => n })\n\n else\n block = store[t.metadatatype]\n\n # Is there already this metadatatype\n if block == nil\n # Create the new metadatatype for this file\n store.merge!({t.metadatatype => t.metadata_value})\n elsif t.metadatatype == \"tag\" or t.metadatatype == \"context_hash\"\n # Add new metadatatype for this file\n store.merge!({t.metadatatype => block + \", \" + t.metadata_value})\n end\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => store }) \n end\n end \n \n \n \n \n # link metadata to right result, with hash\n @results.each do |r|\n mdata = m[r.devfile_id.to_i]\n if mdata != nil\n #puts \"r: #{r.devfile_file_id.to_s}\"\n @metadatas.merge!({r.devfile_id.to_i => mdata})\n end\n end\n \n \n\n \n \n end",
"def metadata\n log \"retrieving container metadata from #{container_path}\"\n response = storage_client.head(container_path)\n custom = {}\n response.each_capitalized_name { |name|\n custom[name] = response[name] if name[/\\AX-Container-Meta-/]\n }\n {\n :objects => response[\"X-Container-Object-Count\"].to_i,\n :bytes => response[\"X-Container-Bytes-Used\"].to_i,\n :custom => custom,\n }\n end",
"def extract_metadata!(data = {})\n data.tap do |d|\n file = File.open(@file)\n d[:filesize] = file.size\n file.close\n\n d[:content_type] = MIME::Types.type_for(@file).first.to_s\n end\n end",
"def read_metadata\n metadata = { :variable_set => read_variable_set }\n set_key_map metadata[:variable_set]\n\n metadata\n end",
"def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end",
"def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end",
"def extract_key_metadata\n @ns = @doc.collect_namespaces # nokogiri cant resolve nested namespaces, fixes\n pid = @doc.xpath('//foxml:digitalObject/@PID', @ns).to_s\n # remove 'york:' prefix; is always 'york:' complicates choice of separators\n pid = pid.gsub 'york:', ''\n @key_metadata[:pid] = pid\n get_current_dc_version\n multi_value_elements = %w[creator publisher subject description contributor]\n single_value_elements = %w[title date]\n single_value_elements.each do |sve|\n extract_single_valued_element(sve)\n end\n multi_value_elements.each do |mve|\n extract_multivalued_element(mve)\n end\n extract_qualification_names\n # extract_qualification_levels\n extract_modules\n extract_rights\n @key_metadata\n end",
"def get_idp_metadata\n return false if @settings.idp_metadata.nil?\n \n # Look up the metdata in cache first\n id = Digest::MD5.hexdigest(@settings.idp_metadata)\n\n uri = URI.parse(@settings.idp_metadata)\n if uri.scheme == \"http\"\n response = Net::HTTP.get_response(uri)\n meta_text = response.body\n elsif uri.scheme == \"https\"\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n # Most IdPs will probably use self signed certs\n #http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n get = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(get)\n meta_text = response.body\n end\n testo_response = meta_text.sub!(' xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"', '')\n doc = REXML::Document.new(testo_response)\n extract_certificate(doc)\n return doc\n\n # USE OF CACHE WITH CERTIFICATE\n # lookup = @cache.read(id)\n # if lookup != nil\n # Logging.debug \"IdP metadata cached lookup for #{@settings.idp_metadata}\"\n # doc = REXML::Document.new( lookup )\n # extract_certificate( doc )\n # return doc\n # end\n \n # Logging.debug \"IdP metadata cache miss on #{@settings.idp_metadata}\"\n # # cache miss\n # if File.exists?(@settings.idp_metadata)\n # fp = File.open( @settings.idp_metadata, \"r\")\n # meta_text = fp.read\n # else\n # uri = URI.parse(@settings.idp_metadata)\n # if uri.scheme == \"http\"\n # response = Net::HTTP.get_response(uri)\n # meta_text = response.body\n # elsif uri.scheme == \"https\"\n # http = Net::HTTP.new(uri.host, uri.port)\n # http.use_ssl = true\n # # Most IdPs will probably use self signed certs\n # #http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n # http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n # get = Net::HTTP::Get.new(uri.request_uri)\n # response = http.request(get)\n # meta_text = response.body\n # end\n # end\n # # Add it to the cache\n # @cache.write(id, meta_text, @settings.idp_metadata_ttl )\n # doc = REXML::Document.new( meta_text )\n # extract_certificate(doc)\n # return doc\n end",
"def metadata\n return @metadata unless @metadata.nil?\n @metadata = fetch_metadata\n configure_with_metadata(@metadata)\n @metadata\n end",
"def meta_data\n @meta_data ||= @internal_struct[:meta_data]\n end",
"def metadata\n @manifest_options[:metadata] || {}\n end"
] | [
"0.68426186",
"0.683919",
"0.6795711",
"0.6795711",
"0.67125195",
"0.66991884",
"0.6635327",
"0.66267294",
"0.66212165",
"0.6597764",
"0.65353304",
"0.6511194",
"0.6503749",
"0.6473436",
"0.6381361",
"0.6379911",
"0.6377388",
"0.636003",
"0.63443315",
"0.6333173",
"0.63248307",
"0.62846166",
"0.6273597",
"0.6273597",
"0.6203863",
"0.6200924",
"0.6192525",
"0.61916524",
"0.6179545",
"0.616804",
"0.6128065",
"0.6120809",
"0.6087563",
"0.6075636",
"0.6075636",
"0.60666114",
"0.6058898",
"0.60476404",
"0.60214484",
"0.6020149",
"0.601835",
"0.6018348",
"0.60156536",
"0.6007923",
"0.59992146",
"0.5998011",
"0.599491",
"0.5961412",
"0.59587187",
"0.59460163",
"0.59368104",
"0.5925199",
"0.5902476",
"0.5884237",
"0.58807415",
"0.58586687",
"0.5857669",
"0.5855203",
"0.58349746",
"0.58334404",
"0.58328015",
"0.58328015",
"0.58210593",
"0.58210593",
"0.58210593",
"0.58210593",
"0.58210593",
"0.58210593",
"0.58210593",
"0.5817788",
"0.58162457",
"0.5797911",
"0.5795018",
"0.5789734",
"0.57875854",
"0.57784736",
"0.576907",
"0.5767359",
"0.57633597",
"0.57568866",
"0.57465833",
"0.5741668",
"0.57387936",
"0.5738192",
"0.57327104",
"0.57326126",
"0.57242084",
"0.57145834",
"0.5714085",
"0.571183",
"0.5710944",
"0.5710018",
"0.57079625",
"0.5700428",
"0.5700428",
"0.56915265",
"0.5689537",
"0.5687132",
"0.5684356",
"0.56841666"
] | 0.6635717 | 6 |
Extensions to Redcarpet's markdown renderer | def md_extensions
# empty for now
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markdown(text) # Define method markdown with redcarpet gem\n\t\tRedcarpet::Markdown.new(Redcarpet::Render::HTML).render(text)\n end",
"def markdown\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)\n end",
"def html_markup_markdown(text); end",
"def mdrender\n \t@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)\n end",
"def markdown(text)\n# coderayified = CodeRayify.new(:filter_html => true,:hard_wrap => true)\n coderayified = PygmentsHTML.new(\n with_toc_data: true,\n hard_wrap: true\n )\n# coderayified = Redcarpet::Render::HTML.new(:filter_html => true,:hard_wrap => true)\n options = {\n :no_intra_emphasis => true,\n :tables => true,\n :fenced_code_blocks => true,\n :autolink => true,\n :strikethrough => true,\n :lax_spacing => true,\n :superscript => true\n }\n markdown_to_html = Redcarpet::Markdown.new(coderayified, options)\n markdown_to_html.render(text).html_safe\n end",
"def md(text)\n renderer = Redcarpet::Render::HTML.new\n extensions = {filter_html: true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n redcarpet.render(text).html_safe\n end",
"def markdown(text)\n BlueCloth.new(text).to_html\n end",
"def render_markdown\n return if self.markdown.nil?\n\n render_as = Redcarpet::Render::HTML\n engine = Redcarpet::Markdown.new(render_as, :autolink => true,\n :space_after_headers => true)\n self.content = engine.render(self.markdown)\n end",
"def markdown(text)\n render_options = {\n filter_html: true,\n hard_wrap: true,\n link_attributes: { rel: 'nofollow' }\n # no_images: true\n }\n renderer = Redcarpet::Render::HTML.new(render_options)\n\n extensions = {\n autolink: true,\n fenced_code_blocks: true,\n lax_spacing: true,\n no_intra_emphasis: true,\n }\n Redcarpet::Markdown.new(renderer, extensions).render(text).html_safe\n end",
"def markdown(text)\n renderer = HTMLwithPygments.new(:hard_wrap => true)\n options = {\n :fenced_code_blocks => true,\n :no_intra_emphasis => true,\n :autolink => true,\n :strikethrough => true,\n :lax_html_blocks => true,\n :superscript => true,\n :space_after_headers => true\n }\n Redcarpet::Markdown.new(renderer, options).render(text).html_safe\n end",
"def markdown\n @markdown ||= Redcarpet::Markdown.new(\n Blogelator::HTMLRenderer,\n autolink: true,\n disable_indented_code_blocks: true,\n fenced_code_blocks: true,\n space_after_headers: true\n )\n end",
"def markdown\n @markdown ||= Redcarpet::Markdown.new(\n Blogelator::HTMLRenderer,\n autolink: true,\n disable_indented_code_blocks: true,\n fenced_code_blocks: true,\n space_after_headers: true\n )\n end",
"def render_markdown(text)\n Redcarpet::Markdown.new(\n SupermarketRenderer,\n autolink: true,\n fenced_code_blocks: true,\n tables: true,\n no_intra_emphasis: true,\n strikethrough: true,\n superscript: true\n ).render(\n text\n ).html_safe # rubocop:todo Rails/OutputSafety\n end",
"def markdown(text)\n BlueCloth::new(text).to_html\nend",
"def markdown(text)\n BlueCloth::new(text).to_html\n end",
"def markdown(text)\n\t\tBlueCloth::new(text).to_html\n\tend",
"def markdown(text)\n coderayified = CodeRayify.new(:filter_html => true, \n :hard_wrap => true,\n :coderay_default_lang => 'ruby'\n )\n options = {\n :fenced_code_blocks => true,\n :no_intra_emphasis => true,\n :autolink => true,\n }\n markdown_to_html = Redcarpet::Markdown.new(coderayified, options)\n markdown_to_html.render(text).html_safe\n end",
"def markdown(content)\n renderer = CodeRayify.new(hard_wrap: true, filter_html: true)\n options = {\n autolink: true,\n no_intra_emphasis: true,\n fenced_code_blocks: true,\n lax_html_block: true,\n strikethrough: true,\n superscript: true,\n underline: true,\n disable_indented_code_blocks: true,\n }\n\n Redcarpet::Markdown.new(renderer, options).render(content).html_safe\n end",
"def simple_markdown(text)\n simple_format markdown text\n end",
"def initialize_markdown_renderer\n @markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML,\n autolink: true,\n fenced_code_blocks: true\n end",
"def render_markdown(file)\n renderer = PygmentizeHTML\n extensions = {:autolink => true, :hard_wrap => true, :space_after_headers => true, :highlight => true, :tables => true, :fenced_code_blocks => true, :gh_blockcode => true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n @file = redcarpet.render file\n end",
"def call\n # mode = (context[:gfm] != false) ? :gfm : :markdown\n # html = GitHub::Markdown.to_html(@text, mode)\n # html.rstrip!\n # html\n\n options = context[:redcarpet_options] || {}\n renderer = HtmlWithRouge.new(\n filter_html: options.fetch(:filter_html, false),\n hard_wrap: options.fetch(:hard_wrap, true)\n )\n options.reject! { |k, v| [:filter_html, :hard_wrap].include?(k) }\n markdown = Redcarpet::Markdown.new(renderer, options)\n html = markdown.render(@text)\n html.rstrip!\n html\n end",
"def markdown(text)\n renderer = Redcarpet::Render::SmartyHTML\n options = {\n autolink: true,\n no_intra_emphasis: true,\n fenced_code_blocks: true,\n lax_html_blocks: true,\n strikethrough: true,\n superscript: true\n }\n Redcarpet::Markdown.new(renderer, options).render(text).html_safe\n end",
"def recursive_render(markdown)\n Redcarpet::Markdown.new(self.class, @options).render(markdown)\n end",
"def print_markdown(txt)\n Markdown::Processor.instance.render(txt)\n end",
"def markdownify(input); end",
"def markdown(text)\n Redcarpet::Markdown.new(\n Redcarpet::Render::HTML,\n autolink: true,\n tables: true\n ).render(text).html_safe # rubocop:disable Rails/OutputSafety\n end",
"def render_md page, content\n markdown(content || self.body) # HACK\n end",
"def render_md page, content\n markdown(content || self.body) # HACK\n end",
"def markdown(text)\n BlueCloth::new(text).to_html.html_safe\n end",
"def render_markdown(str)\n renderer = Redcarpet::Markdown.new(\n Redcarpet::Render::HTML.new(hard_wrap: true),\n autolink: true, tables: true)\n renderer.render(str)\n end",
"def markdown(text)\n sanitize BlueCloth::new(text).to_html\n end",
"def markdown(text)\n coderayified = CodeRayify.new(filter_html: true, hard_wrap: true)\n options = {\n link_attributes: { rel: 'nofollow', target: '_blank' },\n space_after_headers: true,\n fenced_code_blocks: true,\n no_intra_emphasis: true,\n autolink: true,\n strikethrough: true,\n lax_html_blocks: true,\n superscript: true\n }\n markdown = Redcarpet::Markdown.new(coderayified, options)\n markdown.render(text).html_safe\n end",
"def render_markdown(markdown)\n settings.markdown_renderer.render(markdown)\n end",
"def set_markdown_renderer\n @markdown = Redcarpet::Markdown.new(Pants,\n :autolink => true,\n :disable_indented_code_blocks => true,\n :fenced_code_blocks => true,\n :lax_spacing => true,\n :no_intra_emphasis => true,\n :space_after_headers => true,\n :tables => true)\n\n end",
"def markdown(text)\n options = [:filter_html, :hard_wrap, :autolink, :no_intraemphasis, :gh_blockcode, :fenced_code]\n syntax_highlighter(Redcarpet.new(text, *options).to_html).html_safe\n end",
"def markdown(text)\n options = {\n filter_html: true,\n hard_wrap: true, \n link_attributes: { rel: 'nofollow', target: \"_blank\" },\n space_after_headers: true, \n fenced_code_blocks: true\n }\n\n extensions = {\n autolink: true,\n superscript: true,\n disable_indented_code_blocks: true\n }\n\n renderer = Redcarpet::Render::HTML.new(options)\n markdown = Redcarpet::Markdown.new(renderer, extensions)\n\n markdown.render(text).html_safe\n end",
"def markdown( text )\n Kramdown::Document.new( text ).to_html\n end",
"def render_markdown(text)\n html_renderer.render(text).html_safe if text.present?\n end",
"def kss_markdown(text)\n require 'redcarpet'\n Redcarpet::Markdown.new(\n Redcarpet::Render::HTML,\n autolink: true,\n tables: true,\n fenced_code_blocks: true,\n strikethrough: true,\n hard_wrap: true,\n space_after_headers: true,\n underline: true\n ).render(text).html_safe\n end",
"def render_markdown\n return @render if @render\n @render = Markdown.new(:content => content, :indent => self.indent, :path => self.commit ? \"/commits/#{self.commit.id}#{self.web_path}\" : self.web_path)\n @render\n end",
"def markdown(text)\n renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: false, with_toc_data: false)\n options = {\n autolink: true,\n no_intra_emphasis: true,\n fenced_code_blocks: true,\n lax_html_blocks: true,\n tables: true,\n strikethrough: true,\n superscript: true,\n xhtml: true\n }\n Redcarpet::Markdown.new(renderer, options).render(text).html_safe\n end",
"def render_md(site, readme)\n begin\n mkconverter = site.getConverterImpl(Jekyll::Converters::Markdown)\n readme.gsub! \"```\",\"\\n```\"\n readme.gsub! '```shell','```bash'\n return mkconverter.convert(readme)\n rescue\n return 'Could not convert readme.'\n end\nend",
"def recursive_render(markdown)\n Redcarpet::Markdown.new(self.class, REDCARPET_OPTIONS).render(markdown)\n end",
"def html\n Markdown.render(self.content)\n end",
"def html\n Markdown.render(self.content)\n end",
"def markdown(content)\n @markdown_renderer ||= CodeRayify.new(:filter_html => true, :hard_wrap => true)\n \n @markdown_options ||= {\n :fenced_code_blocks => true,\n :no_intra_emphasis => true,\n :autolink => true,\n :lax_html_blocks => true,\n }\n \n @markdown ||= Redcarpet::Markdown.new(@markdown_renderer, @markdown_options)\n @markdown.render(content).html_safe\n end",
"def show\n @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)\n end",
"def formatter(content)\n #render_options = {hard_wrap: true, filter_html: true, safe_links_only: true}\n #markdown_options = {no_intraemphasis: true, autolink: true, superscript: true}\n #markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(render_options),markdown_options)\n #return markdown.render(content).html_safe\n return markdown_to_html(content) unless content.nil?\n end",
"def call\n result = self.class.markdown_renderer.result(schema: schema)\n if @html\n result = self.class.html_renderer.result(body: self.class.redcarpet.render(result))\n result.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n result\n end\n end",
"def markdown_inline_renderer\n Redcarpet::Markdown.new(InlineRenderer, tables: false)\n end",
"def call\n markdown = markdown_renderer.result(schema: schema)\n if @html\n html = markdown_parser.render(markdown)\n html = html_renderer.result(body: html)\n html.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n markdown\n end\n rescue Jdoc::Link::ExampleNotFound => exception\n abort(\"Error: #{exception.to_s}\")\n end",
"def markdown\n @markdown ||= process_markdown!\n end",
"def markdown(txt)\n options = %i[\n hard_wrap filter_styles autolink\n no_intraemphasis fenced_code gh_blockcode\n ]\n doc = Nokogiri::HTML(Redcarpet.new(txt, *options).to_html)\n doc.search('//pre[@lang]').each do |pre|\n pre.replace Albino.colorize(pre.text.rstrip, pre[:lang])\n end\n doc.xpath('//body').to_s.gsub(%r{</?body>}, '').html_safe\n end",
"def markdown(text)\n sanitize(BlueCloth::new(text).to_html)\n end",
"def markdown(text)\n coderay_options = {\n filter_html: true,\n hard_wrap: true,\n safe_links_only: true,\n with_toc_data: true,\n prettify: true\n }\n\n redcarpet_options = {\n autolink: true,\n disable_indented_code_blocks: false,\n fenced_code_blocks: true,\n highlight: true,\n lax_html_blocks: true,\n lax_spacing: true,\n no_intra_emphasis: true,\n strikethrough: true,\n superscript: true,\n tables: true\n }\n\n coderayified = CodeRayify.new(coderay_options)\n markdown_to_html = Redcarpet::Markdown.new(coderayified, redcarpet_options)\n markdown_to_html.render(text).html_safe\n end",
"def markdown(text)\n htmlcoderay = HTMLWithCoderay.new(filter_html: true,\n hard_wrap: true)\n options = {\n fenced_code_blocks: true,\n no_intra_emphasis: true,\n autolink: true,\n lax_html_blocks: true,\n tables: true,\n strikethrough: true,\n superscript: true,\n underline: true,\n highlight: true,\n footnotes: true,\n with_toc_data: true\n }\n\n markdown_to_html = Redcarpet::Markdown.new(htmlcoderay, options)\n begin\n markdown_to_html.render(text).html_safe\n rescue ArgumentError => e\n \"<h1>Error in Markdown: #{e.message}</h1><p>#{@blog.body}</p>\".html_safe\n end\n end",
"def markdown_extra?\n true\n end",
"def markdown(text)\n raw sanitize Markdown.new(text).to_html\n end",
"def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end",
"def description_html\n Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(description)\n end",
"def markdown(text)\n Markdown.new(text, :hard_wrap, :autolink).to_html.html_safe\n end",
"def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def to_html\n determine_markdown_renderer\n @markdown.to_html\n end",
"def description_html\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :no_links => true, :hard_wrap => true)\n markdown.render(description).html_safe\n end",
"def description_html\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :no_links => true, :hard_wrap => true)\n markdown.render(description).html_safe\n end",
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def markdown_command_html\n if self.markdown_command \n self.markdown_command\n else\n self.markdown_command = MARKDOWN_RENDERER.render(self.command)\n end\n end",
"def description_markdown\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, space_after_headers: true)\n markdown.render(description).html_safe\n end",
"def markdown(text)\n return \"\" unless text\n\n CommonMarker.render_doc(text, :SMART).to_html([:NOBREAKS]).html_safe\n end",
"def kss_markdown(input)\n markdown = ::Redcarpet::Markdown.new(::Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)\n markdown.render(input)\n end",
"def markdown_title\n render_as_markdown title\n end",
"def render(path)\n\t\t\tredcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true)\n\t\t\tredcarpet.render(File.read(path))\n\t\tend",
"def markdown(text)\n return if text.blank?\n\n extensions = {\n superscript: true,\n disable_indented_code_blocks: true,\n fenced_code_blocks: true\n }\n render_options = {\n filter_html: true,\n no_images: true,\n no_styles: true,\n safe_links_only: true,\n space_after_headers: true\n }\n\n renderer = Redcarpet::Render::HTML.new(render_options)\n m = Redcarpet::Markdown.new(renderer, extensions)\n sanitize(m.render(text))\n end",
"def liquidize_markdown(content, arguments)\n # doc = BlueCloth.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n # :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}))\n doc = ::Kramdown::Document.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}),\n :parse_block_html => true)\n return doc.to_html.html_safe\n end",
"def markdown(s)\n s = s.gsub(/\\*\\/$/,\"\")\n s = s.gsub(/^ ?\\* ?/,\"\")\n s = s.gsub(/^\\/\\*\\*? ?/,\"\")\n s.chop! while s[-1] == \"\\n\" || s[-1] == \" \"\n lines = s.split(\"\\n\")\n newlines = []\n # Fix some markdown\n lines.each{|l|\n # Rewrite RM_Xyz() to RedisModule_Xyz().\n l = l.gsub(/(?<![A-Z_])RM_(?=[A-Z])/, 'RedisModule_')\n # Fix more markdown, except in code blocks indented by 4 spaces, which we\n # don't want to mess with.\n if not l.start_with?(' ')\n # Add backquotes around RedisModule functions and type where missing.\n l = l.gsub(/(?<!`)RedisModule[A-z]+(?:\\*?\\(\\))?/){|x| \"`#{x}`\"}\n # Add backquotes around c functions like malloc() where missing.\n l = l.gsub(/(?<![`A-z.])[a-z_]+\\(\\)/, '`\\0`')\n # Add backquotes around macro and var names containing underscores.\n l = l.gsub(/(?<![`A-z\\*])[A-Za-z]+_[A-Za-z0-9_]+/){|x| \"`#{x}`\"}\n # Link URLs preceded by space or newline (not already linked)\n l = l.gsub(/(^| )(https?:\\/\\/[A-Za-z0-9_\\/\\.\\-]+[A-Za-z0-9\\/])/,\n '\\1[\\2](\\2)')\n # Replace double-dash with unicode ndash\n l = l.gsub(/ -- /, ' – ')\n end\n # Link function names to their definition within the page\n l = l.gsub(/`(RedisModule_[A-z0-9]+)[()]*`/) {|x|\n $index[$1] ? \"[#{x}](\\##{$1})\" : x\n }\n newlines << l\n }\n return newlines.join(\"\\n\")\nend",
"def markdown_to_html(src)\n render_options = {\n prettify: true,\n }\n renderer = MdRenderer.new(render_options)\n extensions = {\n no_intra_emphasis: true,\n autolink: true,\n tables: true,\n fenced_code_blocks: true,\n strikethrough: true,\n underline: true,\n quote: true,\n footnotes: true,\n }\n md = ::Redcarpet::Markdown.new(renderer, extensions)\n html = md.render(src)\n return html\n end",
"def markdown_to_html(src)\n render_options = {\n prettify: true,\n }\n renderer = MarkdownRenderer.new(render_options)\n extensions = {\n no_intra_emphasis: true,\n autolink: true,\n tables: true,\n fenced_code_blocks: true,\n strikethrough: true,\n underline: true,\n quote: true,\n footnotes: true,\n }\n md = ::Redcarpet::Markdown.new(renderer, extensions)\n html = md.render(src)\n return html\n end",
"def block_html(html)\n html.gsub(/<markdown>([\\d\\D]+?)<\\/markdown>/) {|_|\n extensions = {fenced_code_blocks: true}\n renderer = Redcarpet::Markdown.new(WithHighlights, extensions)\n renderer.render(Regexp.last_match[1])\n }\n end",
"def md_to_html\n options = {\n filter_html: true,\n link_attributes: {\n rel: \"nofollow\",\n target: \"_blank\"\n }\n }\n\n extensions = {\n space_after_headers: true,\n autolink: true\n }\n\n renderer = Redcarpet::Render::HTML.new(options)\n markdown = Redcarpet::Markdown.new(renderer, extensions)\n\n self.description = markdown.render(self.description_md)\n end",
"def markdown text\n markdown = Redcarpet::Markdown.new HTMLWithVideos, autolink: true, space_after_headers: true, no_intra_emphasis: true, superscript: true\n return markdown.render(text).html_safe\n end",
"def sprinkle_markdown_magic(column)\n require 'bluecloth'\n \n validates_markdown_syntax column\n define_method \"#{column}_html\" do\n markup = self.send(column)\n BlueCloth.new(markup).to_html unless markup.blank?\n end\n end",
"def content \n \trenderer = SyntaxRenderer.new(optionize [\n \t:with_toc_data,\n \t#{:hard_wrap,\n \t:xhtml,\n \t:prettify\n \t])\n \n \tmarkdown = Redcarpet::Markdown.new(renderer, optionize([\n \t:fenced_code_blocks,\n \t:no_intra_emphasis,\n \t:tables,\n \t:superscript,\n \t:autolink,\n \t:strikethrough,\n \t:space_after_headers,\n \t:with_toc_data,\n \t:quote,\n \t:lax_spacing\n \t]))\n \n \treturn markdown.render(parse_links(@content)) \n\tend",
"def render\n return @markdown unless $yart_installed\n\n lines = @markdown.split(\"\\n\")\n return @markdown unless yart_snippet?(lines)\n\n yart_lines = extract_yart_lines(lines)\n yart_snippet = yart_lines[1..-2].join(\"\\n\")\n raise YART_PARSE_ERROR if yart_snippet.include?(\"YART.parse\")\n\n html = YART.parse { eval(yart_snippet) }\n @markdown.sub!(yart_lines.join(\"\\n\"), html)\n\n render\n end",
"def markdown(text)\n return '' if text.nil? || text.empty?\n Wink::Markdown.new(text, :smart).to_html\n end",
"def markdown(text)\n return '' if text.nil? || text.empty?\n Wink::Markdown.new(text, :smart).to_html\n end",
"def markdown_to_html(content)\n render_options = {hard_wrap: true, filter_html: true, safe_links_only: true}\n markdown_options = {no_intraemphasis: true, autolink: true, superscript: true, fenced_code_blocks: true }\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(render_options),markdown_options)\n return markdown.render(content).html_safe\n end",
"def designer_markdown text, options = {}\n return if text.blank?\n Kramdown::Document.new(text, {\n syntax_highlighter_opts: {\n line_numbers: nil\n }\n }.merge(options)).to_html\n end",
"def markdown\n return if changed_markdown_files.empty?\n\n output = `mdl #{changed_markdown_files.join(' ')}`\n return if output&.empty?\n\n heading('Markdown Linter', output)\n end",
"def to_html\n @markdown_class.new(@markdown).to_html\n end",
"def markdown_to_html\n html = RDiscount.new(File.read file).to_html\n html = syntax_highlight(html) if config.highlighter\n html = prepend_h1(html) if config.autoh1\n html\n end",
"def to_html\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true)\n html = markdown.render(content)\n html = markdown_extention_youtube_links(html)\n return html.html_safe\n end",
"def md(text)\n markdown text.\n gsub(/{{([a-z]+([\\.\\-\\_][a-z]+)*)}}/, '[\\1](/\\1)'). # {{name}} -> [name](/name)\n gsub(/{{([^\\|}]+)\\|([a-z]+([\\.\\-\\_][a-z]+)*)}}/, '[\\1](/\\2)'). # {{link text|name}} -> [link text](/name)\n to_s\n end",
"def to_markdown\n @to_markdown\n end",
"def traite_as_markdown\n @as_markdown ||= RDiscount.new(raw_code)\n end",
"def markdown_output_html\n \n if self.markdown_output\n self.markdown_output\n else\n self.markdown_output = MARKDOWN_RENDERER.render(self.output)\n end\n end",
"def markdown_desc_text(intro_text)\n result = '<p><em>' + intro_text + ' using ' + link_to(\"markdown syntax\", \"http://daringfireball.net/projects/markdown/syntax\") + '.</em></p>'\n result.html_safe\n end",
"def bio_html\n return nil unless bio.present?\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :no_links => true, :hard_wrap => true)\n markdown.render(bio).html_safe\n end",
"def embed_md_erb(filename) # => markdown string\n ERB.new(File.read(filename)).result(binding)\n end"
] | [
"0.81267416",
"0.8101759",
"0.80778104",
"0.80389714",
"0.79952765",
"0.7814983",
"0.7721974",
"0.77175796",
"0.771666",
"0.77165115",
"0.7710892",
"0.7710892",
"0.7708709",
"0.77014035",
"0.769753",
"0.76561254",
"0.7646463",
"0.76455903",
"0.7639899",
"0.7627906",
"0.76154697",
"0.76003003",
"0.7564635",
"0.7559216",
"0.75465125",
"0.7543484",
"0.75317323",
"0.75313586",
"0.75313586",
"0.7524457",
"0.7506562",
"0.7501895",
"0.74989694",
"0.7466944",
"0.7463707",
"0.74588716",
"0.7452015",
"0.7448688",
"0.744501",
"0.7442081",
"0.7434209",
"0.7428899",
"0.7428317",
"0.7385597",
"0.7377518",
"0.7377518",
"0.7362036",
"0.7350889",
"0.73402953",
"0.73354656",
"0.733386",
"0.72964424",
"0.7292496",
"0.729191",
"0.72844636",
"0.7272998",
"0.7264418",
"0.7230495",
"0.72302675",
"0.719231",
"0.71922207",
"0.7192108",
"0.7191177",
"0.71709925",
"0.71709925",
"0.7153076",
"0.7146911",
"0.7146911",
"0.7120927",
"0.7116011",
"0.7114054",
"0.7098217",
"0.709787",
"0.70957875",
"0.7084285",
"0.70814735",
"0.70247203",
"0.70125294",
"0.7012252",
"0.7008265",
"0.69951516",
"0.69737506",
"0.69706476",
"0.69637597",
"0.695694",
"0.6922886",
"0.6912611",
"0.6912611",
"0.69098246",
"0.69015765",
"0.6897029",
"0.68032277",
"0.6797297",
"0.67808217",
"0.67591876",
"0.67567474",
"0.66942763",
"0.6671306",
"0.6650421",
"0.6637998",
"0.6614461"
] | 0.0 | -1 |
Embed a markdown file in another markdown file Concatenates markdown. Doesn't convert to html. | def embed_md_erb(filename) # => markdown string
ERB.new(File.read(filename)).result(binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_markdown\n files = Dir.glob('**/*.html')\n files.each do |f|\n new_f = f.gsub 'html', 'markdown'\n system \"mv #{f} #{new_f}\" if File.file? f\n end\n end",
"def render_markdown(file)\n renderer = PygmentizeHTML\n extensions = {:autolink => true, :hard_wrap => true, :space_after_headers => true, :highlight => true, :tables => true, :fenced_code_blocks => true, :gh_blockcode => true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n @file = redcarpet.render file\n end",
"def process_markdown\n attachments.each do |att|\n # ~ magic regex ~\n self.markdown = self.markdown.sub(/\\[.+?\\]\\(.+?\\/#{att.file.id}\\/.+?\\)/) do |md_str|\n att.file_attacher.store!\n \"[#{att.file_filename}](#{att.file_url})\"\n end\n end\n self.html = Kramdown::Document.new(self.markdown || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def markdown(source)\n Open3.popen2('pandoc', '-s', '-f', 'markdown', '-t', 'html') do |stdin, stdout, wait_thr|\n stdin.puts(source)\n stdin.close\n stdout.read\n end\nrescue => e\n STDERR.puts e\n nil\nend",
"def include(template_file_path, markdown_file_path)\n send(:generate_file, template_file_path, markdown_file_path, __method__) do |input_lines, output_lines|\n send(:include_files, template_file_path, input_lines, output_lines, Inclusions.new)\n end\n end",
"def markdownify(input); end",
"def build_mdlinks\n return unless options.Build_Markdown_Links\n\n puts_cyan \"Middlemac is creating `#{options.File_Markdown_Links}`.\"\n\n files_array = []\n out_array = []\n longest_shortcut = 0\n longest_path = 0\n\n Dir.glob(\"#{app.source}/Resources/**/*.erb\").each do |fileName|\n\n # Remove all file extensions and make a shortcut\n base_name = fileName\n while File.extname(base_name) != '' do\n base_name = File.basename( base_name, '.*' )\n end\n next if base_name.start_with?('_') # || base_name == 'index'\n\n if base_name == 'index'\n shortcut = \"[#{File.split(File.split(fileName)[0])[1]}_index]:\"\n\n else\n shortcut = \"[#{base_name}]:\"\n end\n\n # Make a fake absolute path\n path = Pathname.new(fileName).relative_path_from(Pathname.new(app.source))\n path = File::SEPARATOR + File.join(File.dirname(path), base_name) + '.html'\n\n # Get the title, if any\n metadata = YAML.load_file(fileName)\n title = (metadata.is_a?(Hash) && metadata.key?('title')) ? metadata['title'] : ''\n\n files_array << { :shortcut => shortcut, :path => path, :title => title }\n\n longest_shortcut = shortcut.length if shortcut.length > longest_shortcut\n longest_path = path.length if path.length > longest_path\n\n end\n\n files_array = files_array.sort_by { |key| [File.split(key[:path])[0], key[:path]] }\n files_array.uniq.each do |item|\n item[:shortcut] = \"%-#{longest_shortcut}.#{longest_shortcut}s\" % item[:shortcut]\n\n if item[:title].length == 0\n out_array << \"#{item[:shortcut]} #{item[:path]}\"\n else\n item[:path] = \"%-#{longest_path}.#{longest_path}s\" % item[:path]\n out_array << \"#{item[:shortcut]} #{item[:path]} \\\"#{item[:title]}\\\"\"\n end\n end\n\n File.open(options.File_Markdown_Links, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def content!\n if File.exist?(file)\n markdown_to_html\n else\n @type = :empty\n \"\"\n end\n end",
"def markdown\n return if changed_markdown_files.empty?\n\n output = `mdl #{changed_markdown_files.join(' ')}`\n return if output&.empty?\n\n heading('Markdown Linter', output)\n end",
"def html_markup_markdown(text); end",
"def process_md_erb(filename)\n renderer = Redcarpet::Render::HTML\n markdown ||= Redcarpet::Markdown.new(renderer, md_extensions)\n concatenated_md = embed_md_erb(filename)\n result_md, metadata = extract_metadata(concatenated_md)\n result_html = markdown.render(result_md)\n [result_html, metadata]\n end",
"def markdownToHTML(markdown)\n output = \"\"\n IO.popen($mmdPath, \"w+\") do |f|\n f.print markdown\n f.close_write\n output = f.gets(nil)\n end\n return output\nend",
"def html_to_markdown(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".html\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n html_content = `pandoc -f html -t markdown \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return html_content\n end",
"def main\n blog = File.read(FILE_PATH).gsub(/-----[\\r\\n|\\n|\\r]EXTENDED BODY:/, '<!-- more -->')\n articles = split_to_articles(blog)\n headers_and_bodies = split_to_headers_and_bodies(articles)\n\n headers_and_bodies.each do |header_and_body|\n header_and_body[:header] = convert_header(header_and_body[:header])\n header_and_body[:body] = ReverseMarkdown.convert header_and_body[:body]\n end\n\n create_md_file(headers_and_bodies)\nend",
"def links_aide_markdown\n @links_aide_markdown ||= begin\n File.read(markdown_links_file)\n end\n end",
"def call\n markdown = markdown_renderer.result(schema: schema)\n if @html\n html = markdown_parser.render(markdown)\n html = html_renderer.result(body: html)\n html.gsub(/id=\"(.+)\"/) {|text| text.tr(\"/:\", \"\") }\n else\n markdown\n end\n rescue Jdoc::Link::ExampleNotFound => exception\n abort(\"Error: #{exception.to_s}\")\n end",
"def markdown(text)\n Markdown.new(text, :hard_wrap, :autolink).to_html.html_safe\n end",
"def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end",
"def include_generated(file_name, opts={})\n File.read(\"#{@md_output_dir}/#{file_name}\") unless hide_content?(opts)\n end",
"def render_md page, content\n markdown(content || self.body) # HACK\n end",
"def render_md page, content\n markdown(content || self.body) # HACK\n end",
"def convertHtmlToMarkdown\n root = pathExports\n n = 1\n Pathname.glob(pathExports() + \"**/*.html\").each do |p|\n puts \"File \" + n.to_s + \": \" + p.to_s\n n = n + 1\n infile = p.to_s\n outfile = p.sub_ext(\".md\").to_s\n command = \"pandoc -f html -t markdown -o #{outfile} #{infile}\"\n puts command\n sh(command)\n end\nend",
"def markdown(text)\n BlueCloth::new(text).to_html\nend",
"def mdrender\n \t@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)\n end",
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def markdown_to_html\n html = RDiscount.new(File.read file).to_html\n html = syntax_highlight(html) if config.highlighter\n html = prepend_h1(html) if config.autoh1\n html\n end",
"def markup_file_contents(contents); end",
"def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end",
"def md_include_html(html)\n res = \"{::options parse_block_html=\\\"true\\\" /}\\n\"\n res << html\n res << \"\\n{::options parse_block_html=\\\"false\\\" /}\\n\"\n return res\nend",
"def markdown_extra?\n true\n end",
"def render(path)\n\t\t\tredcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true)\n\t\t\tredcarpet.render(File.read(path))\n\t\tend",
"def cache_markdown_content\n self.markdown_content = GitHub::Markdown.render(content)\n end",
"def markdown(text)\n BlueCloth::new(text).to_html\n end",
"def example_markdown_targets()\n target_files = []\n\n example_dir = File.join(K4_ROOT, 'example')\n ext = 'md'\n filelist = FileList[File.join(example_dir, \"*.#{ext}\")]\n filelist.each do |source_path|\n source_basename = File.basename(source_path)\n next if source_basename =~ /^_/\n\n source_basename = source_basename.gsub(/#{ext}$/, 'html')\n target_path = File.join(example_dir, source_basename)\n # File.delete(target_path) if File.exists?(target_path)\n\n file(target_path) do |t, args|\n puts t.name\n src = File.read(source_path)\n compiler_ = MarkdownCompiler.new(@compiler)\n html_source = compiler_.to_slide(src)\n File.open(target_path, 'w') do |io|\n io.write(html_source)\n end\n end\n target_files << target_path\n end\n return target_files\n end",
"def markdown(text)\n BlueCloth.new(text).to_html\n end",
"def render_md(site, readme)\n begin\n mkconverter = site.getConverterImpl(Jekyll::Converters::Markdown)\n readme.gsub! \"```\",\"\\n```\"\n readme.gsub! '```shell','```bash'\n return mkconverter.convert(readme)\n rescue\n return 'Could not convert readme.'\n end\nend",
"def print_markdown(txt)\n Markdown::Processor.instance.render(txt)\n end",
"def markdown_to_text(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".txt\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n text_content = `pandoc -f markdown -t text \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return text_content\n end",
"def preprocessMarkdownForHTML(markdown)\n output = \"\"\n inInstructions = false\n \n markdown.split(\"\\n\").each do |line|\n # parse an instructions list\n # use a dummy HTML tag so our final regex doesn't get stuck in an infinite loop replacing itself\n instructionsMatch = line.match(/^>>\\s*(.*?)$/)\n if instructionsMatch\n if not inInstructions\n output += \"<instructions>\\n\"\n end\n output += instructionsMatch[1] + \"\\n\"\n inInstructions = true\n next # don't try to parse anything else\n elsif inInstructions\n output += \"</instructions>\\n\"\n inInstructions = false\n end\n\n # parse headers and page IDs\n headerMatch = line.match(/^(#+)\\s+(.*?)\\s+@@(.*?)$/)\n if headerMatch\n headerLevel = headerMatch[1].length.to_s\n headerTitle = headerMatch[2]\n headerID = headerMatch[3]\n node = nodeWithID(headerID, $doc.toc.rootNode)\n if not node\n puts \"ERROR: Couldn't find node with ID #{headerID}\"\n exit 1\n end\n output += \"<h#{headerLevel}><a name=\\\"#{headerID}\\\">#{node.levelPrefix} #{headerTitle}</a></h#{headerLevel}>\\n\"\n next\n end\n \n # parse links to page IDs and replace with links to the real .htm file\n while 1\n linkMatch = line.match(/\\[.*?\\]\\((@@(.*?))\\)/)\n if linkMatch\n linkID = linkMatch[2]\n linkValue = linkToPageIDFrom(linkID, \"_PAGE_\") # use dummy value\n if not linkValue\n puts \"ERROR: Invalid link ID \\\"#{linkID}\\\"\"\n exit 1\n end\n line[linkMatch[1]] = linkValue\n else\n break\n end\n end\n \n # parse image and label combo\n imgLabelMatch = line.match(/!!\\[(.*?)\\]\\((.*?)\\)/)\n if imgLabelMatch\n label = imgLabelMatch[1]\n imgPath = imgLabelMatch[2]\n \n # read the image and width height to force the size on images for better loading\n # when viewing the files in the boot DVD. there are some issues where anchor jump\n # links don't always jump to the right place on the boot DVD and apparently forcing\n # the image sizes allows the pages to jump properly.\n \t\timgWidth = 0\n \t\timgHeight = 1\n \t\tbegin\n \t\t data = nil\n \t\t if (imgPath =~ /.png$/)\n \t\t data = IO.read($pagesDir + \"/\" + imgPath, 8, 16).unpack('NN')\n\t\t else\n\t\t puts \"ERROR: Unsupported image type: #{imgPath}\"\n\t\t exit 1\n\t end\n \t\t if (data)\n \t\t imgWidth = data[0]\n \t\t imgHeight = data[1]\n\t\t end\n\t\t rescue\n\t end\n imgWidthHeightAttrs = \"\"\n if imgWidth != 0 and imgHeight != 0\n imgWidthHeightAttrs = \" width=\\\"#{imgWidth}\\\" height=\\\"#{imgHeight}\\\"\"\n end\n\n output += \"<p class=\\\"imageAndLabel\\\"><img src=\\\"#{imgPath}\\\" alt=\\\"\" + CGI::escapeHTML(label) + \"\\\"#{imgWidthHeightAttrs}/><br/><em>\" + CGI::escapeHTML(label) + \"</em></p>\\n\"\n next\n end\n \n # parse warning paragraphs\n warningMatch = line.match(/^!!\\s+(.*?)$/)\n if warningMatch\n output += \"<warning>\\n\" + warningMatch[1] + \"\\n<\\/warning>\\n\"\n next\n end\n \n output += line + \"\\n\"\n end\n \n # close off an open instructions div\n if inInstructions\n output += \"</instructions>\\n\"\n end\n \n # Markdown doesn't allow processing of markup within block-level tags such as <div>, so we have to manually process the markup.\n # We call preprocessMarkdownForHTML() to properly process our custom markup within these custom block elements.\n # An extra newline is added to force a paragraph\n while 1\n instructionsMatch = output.match(/(<instructions>)(.*?)(<\\/instructions>)/m)\n if instructionsMatch\n output[instructionsMatch[1]] = \"<div class=\\\"instructions\\\">\"\n output[instructionsMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+instructionsMatch[2]))\n output[instructionsMatch[3]] = \"</div>\"\n else\n break\n end\n end\n \n while 1\n warningMatch = output.match(/(<warning>)\\s*(.*?)(<\\/warning>)/m)\n if warningMatch\n output[warningMatch[1]] = \"<div class=\\\"warning\\\"><div class=\\\"warningBody\\\"><div class=\\\"warningImg\\\"></div><div class=\\\"warningContent\\\">\"\n output[warningMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+warningMatch[2]))\n output[warningMatch[3]] = \"</div></div></div>\"\n else\n break\n end\n end\n \n return output\nend",
"def to_html\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true)\n html = markdown.render(content)\n html = markdown_extention_youtube_links(html)\n return html.html_safe\n end",
"def markdown\n @markdown ||= process_markdown!\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end",
"def embed(fname, hash=nil)\n if not @root_dir.nil?\n fname = File.join(@root_dir, fname)\n end\n File.open(fname) do |f|\n tmpl = f.read()\n process_string(tmpl, fname, hash)\n end\n end",
"def markdown(text)\n BlueCloth::new(text).to_html.html_safe\n end",
"def markdown_to_html(src)\n render_options = {\n prettify: true,\n }\n renderer = MdRenderer.new(render_options)\n extensions = {\n no_intra_emphasis: true,\n autolink: true,\n tables: true,\n fenced_code_blocks: true,\n strikethrough: true,\n underline: true,\n quote: true,\n footnotes: true,\n }\n md = ::Redcarpet::Markdown.new(renderer, extensions)\n html = md.render(src)\n return html\n end",
"def markdown(text)\n\t\tBlueCloth::new(text).to_html\n\tend",
"def markdown(text)\n raw sanitize Markdown.new(text).to_html\n end",
"def md(text)\n renderer = Redcarpet::Render::HTML.new\n extensions = {filter_html: true}\n redcarpet = Redcarpet::Markdown.new(renderer, extensions)\n redcarpet.render(text).html_safe\n end",
"def markdown_cheatsheet\n File.read(Rails.root.join('markdown.md'))\n end",
"def render\n return @markdown unless $yart_installed\n\n lines = @markdown.split(\"\\n\")\n return @markdown unless yart_snippet?(lines)\n\n yart_lines = extract_yart_lines(lines)\n yart_snippet = yart_lines[1..-2].join(\"\\n\")\n raise YART_PARSE_ERROR if yart_snippet.include?(\"YART.parse\")\n\n html = YART.parse { eval(yart_snippet) }\n @markdown.sub!(yart_lines.join(\"\\n\"), html)\n\n render\n end",
"def fileset_embed_markup(file_name)\n fileset = fileset(file_name)\n #emb_markup = fileset[\"embed_code\"] unless fileset[\"noid\"].empty?\n noid = fileset[\"noid\"]\n embed_markup = \"\"\n unless noid.empty?\n # Found fileset. Determine the embed link from the\n # \"Embed Code\" property. This will give the correct host.\n # If fileset has no property, then it can't be embedded.\n external_res = fileset['external_resource_url']\n fmarkup = fileset['embed_code']\n unless fmarkup.nil? or fmarkup.empty?\n if external_res.nil? or external_res.strip.empty?\n embed_doc = Nokogiri::XML::DocumentFragment.parse(fmarkup)\n iframe_node = embed_doc.xpath(\"descendant-or-self::*[local-name()='iframe']\").first\n embed_link = iframe_node['src']\n ititle = iframe_node['title']\n title = HTMLEntities.new.encode(ititle)\n\n href = fileset['link'][12..-3]\n #title = fileset['title'].nil? ? \"\" : fileset['title']\n\n link_uri = URI(embed_link)\n link_scheme_host = link_uri.scheme + \"://\" + link_uri.host\n\n embed_markup = sprintf(RESOURCE_EMBED_MARKUP, link_scheme_host, noid, noid, noid, noid, embed_link, title)\n else\n embed_markup = fmarkup\n end\n end\n end\n return embed_markup\n end",
"def render_markdown\n return @render if @render\n @render = Markdown.new(:content => content, :indent => self.indent, :path => self.commit ? \"/commits/#{self.commit.id}#{self.web_path}\" : self.web_path)\n @render\n end",
"def build_mdimages\n\n return unless options.Build_Markdown_Images\n\n puts_cyan \"Middlemac is creating `#{options.File_Markdown_Images}`.\"\n\n files_array = []\n out_array = []\n longest_shortcut = 0\n\n Dir.glob(\"#{app.source}/Resources/**/*.{jpg,png,gif}\").each do |fileName|\n\n # Remove all file extensions and make a shortcut\n base_name = fileName\n while File.extname(base_name) != '' do\n base_name = File.basename( base_name, '.*' )\n end\n next if base_name.start_with?('_')\n shortcut = \"#{base_name}\"\n\n # Make a fake absolute path `/Resources/...`. Middleman will convert\n # these to appropriate relative paths later, and this will just\n # magically work in the helpbooks. \n path = File::SEPARATOR + Pathname.new(fileName).relative_path_from(Pathname.new(app.source)).to_s\n\n files_array << { :shortcut => shortcut, :path => path }\n\n # We will format the destination file nicely with spaces.\n # +3 to account for bracketing []:\n longest_shortcut = shortcut.length + 3 if shortcut.length + 3 > longest_shortcut\n\n end\n\n files_array = files_array.uniq.sort_by { |key| [File.split(key[:path])[0], key[:path]] }\n \n # Now add virtual `all-` items for target-specific items for which no `all-` exists.\n # Middlemac will intelligently support target-specific image files, but it will\n # never have the chance unless a markdown reference is present in this file. Of\n # course this only applies if you're using reference notation.\n options.Targets.keys.each do |target|\n \n # Build an array of all files starting with `target-`\n current_set = files_array.select { |item| item[:shortcut].start_with?(\"#{target.to_s}-\") }\n \n # For each of these items, check to see if `all-` exists.\n current_set.each do |item|\n \n seek_for = item[:shortcut].sub(\"#{target.to_s}-\", \"all-\")\n unless files_array.any? { |hash| hash[:shortcut] == seek_for }\n \t\t\t path = item[:path].sub(\"#{target.to_s}-\", \"all-\")\n \t\t\t files_array << { :shortcut => seek_for, :path => path }\n \t\t\tend\n end\n end\n\n # Create the actual output from the files_array.\n files_array.each do |item|\n # Just a reminder to myself that this is a format string. \n shortcut_out = \"%-#{longest_shortcut}.#{longest_shortcut}s\" % \"[#{item[:shortcut]}]:\"\n out_array << \"#{shortcut_out} #{item[:path]}\"\n end\n\n File.open(options.File_Markdown_Images, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def simple_markdown(text)\n simple_format markdown text\n end",
"def markdown_to_html(src)\n render_options = {\n prettify: true,\n }\n renderer = MarkdownRenderer.new(render_options)\n extensions = {\n no_intra_emphasis: true,\n autolink: true,\n tables: true,\n fenced_code_blocks: true,\n strikethrough: true,\n underline: true,\n quote: true,\n footnotes: true,\n }\n md = ::Redcarpet::Markdown.new(renderer, extensions)\n html = md.render(src)\n return html\n end",
"def generate(options = {})\n embed_outline(options[:selflink]) if options[:outline]\n\n #if options[:dirmap]\n # md_dir = Pathname.new(@md_file).dirname.expand_path\n # embed_sidebar( Madowu::DirectoryMapper.dirmap(md_dir) )\n #end\n\n if options[:sidebar]\n #lines = File.open( options[:sidebar], \"r\").readlines\n lines = `#{@markdown} #{options[:sidebar]}`.split(\"\\n\")\n embed_sidebar(lines)\n end\n\n result = [\n make_header(options[:css], options[:charset]),\n @markup_lines,\n \"</div></div></body></html>\",\n ''\n ].join(\"\\n\")\n end",
"def render_markdown\n return if self.markdown.nil?\n\n render_as = Redcarpet::Render::HTML\n engine = Redcarpet::Markdown.new(render_as, :autolink => true,\n :space_after_headers => true)\n self.content = engine.render(self.markdown)\n end",
"def html\n Markdown.render(self.content)\n end",
"def html\n Markdown.render(self.content)\n end",
"def markdown(text)\n sanitize BlueCloth::new(text).to_html\n end",
"def new_embed\n definitions = files.map do |f|\n path = f[0].split(\"/\")[8..-1].join(\"/\")\n line = f[1]\n \"[`#{path}#L#{line}`](#{GITHUB_URL}/tree/#{GIT_VERSION}/lib/#{path}#L#{line})\"\n end.join(\"\\n\")\n\n Discordrb::Webhooks::Embed.new(\n color: 0xff0000,\n url: github_pages_url,\n title: \"[View on Git Docs]\",\n description: definitions,\n footer: {text: \"discordrb v#{Discordrb::VERSION}@#{GIT_VERSION}\", icon_url: RUBY_TACO},\n ).tap { |e| yield e if block_given? }\n end",
"def render_document(content, extension)\n if %w{md mdown markdown}.include?(extension.downcase)\n render_markdown(content)\n else\n content\n end\n end",
"def combine(file,chapter)\n\t`ffmpeg -f concat -i \"#{file}\" -c copy chapters/Chapter\"#{chapter}\".aiff`\nend",
"def link_include_file(file); end",
"def link_include_file(file); end",
"def render_markdown(markdown)\n settings.markdown_renderer.render(markdown)\n end",
"def wrap_preview(preview_html)\n output_file_content =<<CONTENT\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"refresh\" content=\"#{@refresh_rate}\">\n <style type=\"text/css\">\n #{IO.read(Resources.expand_path(File.join('css','github.css')))}\n #{IO.read(Resources.expand_path(File.join('css','github2.css')))}\n\n html, .markdown-body {\n overflow: inherit;\n }\n .markdown-body h1 {\n margin-top: 0;\n }\n .readme-content {\n width: #{@preview_width}px;\n }\n\n /* hack in an anchor icon */\n .markdown-body h1:hover a.anchor, .markdown-body h2:hover a.anchor, .markdown-body h3:hover a.anchor, .markdown-body h4:hover a.anchor, .markdown-body h5:hover a.anchor, .markdown-body h6:hover a.anchor {\n padding: 8px 13px;\n margin: 0px 0px 12px -27px;\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAdCAIAAADU74AfAAAYHWlDQ1BJQ0MgUHJvZmlsZQAAWAmtWWdYFEuz7pmNwC45ZyTnnCXnnKOoLDmDS0YJIiJJAQmigCgggigYSSIgiCgiSYKiIAoKKCoGQJLcgaPnnO/57v1353lm5t3qt6urq3p6pmoBYL9NCgsLgmkBCA6JINsa6fI6u7jy4qYABDCAgJw8JM/wMB1ra3Pwfx4rYwgbOZ5J7uj6P2n/ewOdl3e4JwCQNdLs4RXuGYzg2wCgmjzDyBEAYHb0CURHhO3gHAQzkhEDEVy5g33/wk072OMv3LfLsbfVQzjTAOAJJBLZFwDiIiLnjfL0RfRQEwDA0od4+Ycg3XgRrOnpR/ICgN0d4UgEB4fu4CwEi3j8S4/vvzCJ5PG3ThLJ92/811yQnsjA+v7hYUGk2N0f/5+X4KBIxF+7BzdyJYQH2pkhd2bEbzGeJAM7BLMi+JSft4n5b3lVWISu7W95q3+EiT2CGRHOiF+kscNvPB8Z6KCDYE5EvhkYarbDR/wEs4Z4WFohmB7BAp7heojvd8aCleL87J1+c8y9vPUNEIysItiZHGr7h+8XHmX3Rx4X56dn+YcfQDLdiTc1ws8gkRG0aw9c5B1ktDPuHkR+NSzCesfOnbH6Q4Isf88FnvUhG+5wduTr3uG7892xzS/Cz94YkSM2o2gjyPY7HGSOKE4ff0MTBCO2oWT8yMZ/5NphQbtrGumLsidH2u74QQDBPt4hDjs+3JFneJH0d3yL+ARVAgwBCZCBN/AAIWAB8AJzoAf0f195EXkIIvMEoSAIOcm8NH9aMO8xQ5i3mFHMNObFHxnS8zcP+AMvBP+l61/9EbkdiAOfEK3eIPzPaGh2tCZaHW2OXLWRUw6tglb909a/2Lj4B/+21RfpK/lbt+5v66MQjVt/eAf9k8l/8O8+Hn/3+G+bDMEs4gHfPwyZWpkFmc0//f+ZMdYAq481xhpiRVFpqFuoHtR91GNUK6oR8KLaUU2oPtS9Hfzbrj+jkBDJjld2PBwOzBAveoPI3V8hf8b7Dy9F/s34rYFajFoR2CK9QkAg0ub/9wiOu1b7/5eWSIThgYwYgHDN/o7Hb7vQQoh3FdG6aA3Ez4iP0cxodiCJVkA8roPWQmKgiEj/ieJ/zkYS+Ox6O2p3LoHgPTKP4AjvmAhkLQG90LBYsr+vXwSvDrJbekvwmoR4SknwysnIKoCdvXeHA8B32909FWIe+EdGCgJARQ4ASt1/ZKHI2qwrQB6Hs//IhJDnjE0VgJu2npHkqL/0oXduGEAJaJCngg1wA34ggnhEDigBdaANDIApsAL2wAUcQNawHwhGLI4GR8BRkAoyQQ4oAOdAGagA1eAauAkaQSu4Dx6CJ2AQjIKXYBq8Ax/BElgBGxAE4SAixACxQTyQICQOyUEqkCZkAJlDtpAL5A75QiFQJHQEOgZlQqehc9BFqAa6ATVD96HH0BD0AnoDLUDfoHUYBRNgRpgLFoKlYRVYBzaD7eH9sC98CI6DU+BTcBFcDl+FG+D78BN4FJ6GP8LLKICiQjGj+FCSKBWUHsoK5YryQZFRCagMVCGqHFWHakHW4jPUNGoRtYbGohnQvGhJJJLGaAe0J/oQOgGdhT6HrkY3oB+gn6HfoJfQvzBEDCdGHKOGMcE4Y3wx0ZhUTCGmCnMH0408z+8wK1gslhkrjFVGVrsLNgB7GJuFLcXWYzuwQ9gZ7DIOh2PDieM0cFY4Ei4Cl4o7i7uKa8cN497hfuKp8Dx4Obwh3hUfgk/GF+Kv4Nvww/g5/AYFLYUghRqFFYUXRSxFNkUlRQvFAMU7ig1KOkphSg1Ke8oAyqOURZR1lN2Uryi/U1FR7aFSpbKh8qdKoiqiuk71iOoN1RqBniBG0CO4ESIJpwiXCR2EF4TvRCJRiKhNdCVGEE8Ra4hdxCniT2oGailqE2ov6kTqYuoG6mHqzzQUNII0OjQHaOJoCmlu0QzQLNJS0ArR6tGSaBNoi2mbacdpl+kY6GTprOiC6bLortA9ppunx9EL0RvQe9Gn0FfQd9HPMKAY+Bn0GDwZjjFUMnQzvGPEMgozmjAGMGYyXmPsZ1xiomdSYHJkimEqZrrHNM2MYhZiNmEOYs5mvsk8xrzOwsWiw+LNks5SxzLMssrKwarN6s2awVrPOsq6zsbLZsAWyJbL1sg2yY5mF2O3YY9mP8/ezb7IwcihzuHJkcFxk2OCE+YU47TlPMxZwdnHuczFzWXEFcZ1lquLa5GbmVubO4A7n7uNe4GHgUeTx58nn6ed5wMvE68ObxBvEe8D3iU+Tj5jvki+i3z9fBt7hPc47EneU79nkp+SX4Xfhz+fv5N/SYBHwELgiECtwIQghaCKoJ/gGcEewVUhYSEnoRNCjULzwqzCJsJxwrXCr0SIIloih0TKRUZEsaIqooGipaKDYrCYopifWLHYgDgsriTuL14qPiSBkVCVCJEolxiXJEjqSEZJ1kq+kWKWMpdKlmqU+iwtIO0qnSvdI/1LRlEmSKZS5qUsvaypbLJsi+w3OTE5T7liuRF5oryhfKJ8k/xXBXEFb4XzCs8VGRQtFE8odipuKSkrkZXqlBaUBZTdlUuUx1UYVaxVslQeqWJUdVUTVVtV19SU1CLUbqp9UZdUD1S/oj6/V3iv997KvTMaezRIGhc1pjV5Nd01L2hOa/FpkbTKtd5q82t7aVdpz+mI6gToXNX5rCujS9a9o7uqp6YXr9ehj9I30s/Q7zegN3AwOGcwZbjH0New1nDJSNHosFGHMcbYzDjXeNyEy8TTpMZkyVTZNN70gRnBzM7snNlbczFzsnmLBWxhapFn8cpS0DLEstEKWJlY5VlNWgtbH7K+a4O1sbYptnlvK2t7xLbHjsHuoN0VuxV7Xfts+5cOIg6RDp2ONI5ujjWOq076Tqedpp2lneOdn7iwu/i7NLniXB1dq1yX9xnsK9j3zk3RLdVtbL/w/pj9jw+wHwg6cO8gzUHSwVvuGHcn9yvumyQrUjlp2cPEo8RjyVPP84znRy9tr3yvBW8N79Pecz4aPqd95n01fPN8F/y0/Ar9Fv31/M/5fw0wDigLWA20CrwcuB3kFFQfjA92D24OoQ8JDHkQyh0aEzoUJh6WGjZ9SO1QwaElshm5KhwK3x/eFMGIfOT2RYpEHo98E6UZVRz1M9ox+lYMXUxITF+sWGx67FycYdylw+jDnoc7j/AdOXrkTbxO/MUEKMEjoTORPzEl8V2SUVL1UcqjgUefJsskn07+cczpWEsKV0pSysxxo+O1qdSp5NTxE+onytLQaf5p/eny6WfTf2V4ZfRmymQWZm5meWb1npQ9WXRy+5TPqf5spezzOdickJyxXK3c6tN0p+NOz+RZ5DXk8+Zn5P8oOFjwuFChsOwM5ZnIM9NF5kVNZwXO5pzdPOd3brRYt7i+hLMkvWS11Kt0+Lz2+boyrrLMsvUL/heeXzS62FAuVF5Yga2Iqnhf6VjZc0nlUk0Ve1Vm1dblkMvT1bbVD2qUa2qucF7JroVrI2sXrrpdHbymf62pTrLuYj1zfeZ1cD3y+ocb7jfGbprd7LylcqvutuDtkjsMdzIaoIbYhqVGv8bpJpemoWbT5s4W9ZY7d6XuXm7lay2+x3Qvu42yLaVtuz2ufbkjrGPxvu/9mc6DnS+7nLtGHtg86O8263700PBhV49OT/sjjUetj9UeN/eq9DY+UXrS0KfYd+ep4tM7/Ur9DQPKA02DqoMtQ3uH2oa1hu8/03/2cMRk5Mmo5ejQmMPY83G38ennXs/nXwS9+DoRNbHxMukV5lXGJO1k4RTnVPlr0df100rT997ov+l7a/f25YznzMfZ8NnNdynvie8L53jmaubl5lsXDBcGP+z78O5j2MeNxdRPdJ9KPot8vv1F+0vfkvPSu6/kr9vfsr6zfb/8Q+FH57L18tRK8MrGasZPtp/VayprPetO63Mb0Zu4zaIt0a2WX2a/Xm0Hb2+Hkcik3W8BFHKFfXwA+HYZyYtcAGAYRL4pqP/KjXYZyOcuhHAQ7AhJQR/hB6hjaDuMNlYYx45npeCh1KCyJAQSc6ibaRbpJOm9GSoYZ5jFWGJZ29lpOJw4K7m+8+zlTeF7yk8nYCt4UuiJCBCVF/MRPyPRK7kqLSJjI5skVys/qggrySrvV8lQbVB7s5eooaLprpWufUPnlR5eX8nA0zDHqMl4yhQyEzA3sgiwzLa6bf3c5qcds728g5VjsNNJ5zqXJ65v9i25re7fOAjcKUlsHpKeOl623gd9vH1Jfnb+ewN4A6HA6aD24Ashx0L9wqwPqZB5w/HhXyLGItuiqqPzYhJig+JcDpsc0YhXTlBKVE3SOWqW7HTMOyXi+PHU/BOVabfSOzL6MseyXp+cO/Up+1vOcu7K6eW85fz1QvQZpiKJs0bnPIsTS4pK6863lz25MHJxony6YqHyRxXqMlO1WI3uFbfa6Kv5127WDdV/vUF3U/6W3e3wOzkNNY0tTfebu1o67t5tvXOvvq2mvaKj9H5BZ0bXkQcB3XYPlXpYe9YeTT8e6H34pKvv/tPW/vqBosHwIb1h4vCzZ8UjPqOKY5ix8fHq51EvtCewEz3I+lJ8NTeZO6U+NfP65LT69Mc3ZW9tZ1Az9bMOs2vv8t9LvG+fs52bnT++IL0w+6H6Y8ii/OLyp/rPnl/ovtxZsl56//XIN5ZvD79n/whZJq34IOtodr17S2p7ezf+/NB1OAAlh5pH38AkYZ1xGnhJCmFKYao9BBmiGrUNjSdtAl0ZfRvDAhMtswoLiTWN7Tb7FCcVlzz3Pp4k3ot87Xte8i8LUgnxCCuKmIi6i8WK50nckOyTmpdBy/LJ7ZV3VYhQzFSqVG5Wear6Vu3HXqwGh6asloV2kE627nW9Qf1PhngjLmM5EwNTBzNP8xCLGMsEq2PWx21SbdPsMuyzHDIcU5xinf1c7F3192m5Ge53PRB9sMD9OqnTo9ez2+uOd4nPYV8nPxl/gv9iwGBgS1BNcHFIdmhyGPmQG1k7nCd8I2I08lpUarRHjEGsTJzAYa4jbPFMCbSJ2MSVpLdHe5NvHCtIiT6+P9X0hH6aeTop42jmpayHJ6dOfc5ezlnNXT79PW8p/1PBYuHnMz/P0p5TLQ4pqSrtPz9TtnDh3cXX5S8qhiofXWqrar3cW/3pCl/t/qsl117UM163vJGG7F5rd6QavBqLm4ZbMHcVWg/eO95W1d7a0Xb/SmdOV/yD6O6kh9k9pY8qHp/vPfUkss/uqWQ/un9i4OZg5lDAsM0zgxGDUZsxj/HI5ykvTkzEv/R5pTfJPrk41fz6xLTzG8m3+LfvZ7pmS98deq89R5gbma9YSPzg/9Fr0e9T8OewL2FLYV/J36K+x/6IXvZfMVqlWb310+DnkzXXtU/rg5uErYnd+IuDB5AZ9Bz2RmFR2Whx9AAmDiuNXcBdwvtRSFOsUfZSlRGiibbUcjTUNCu0L+g66GsY8hjjmXyZbVk0WEXZmNg22ec5hjnbuOq4K3iKeQv58vdk86cKRAmShAyEeYV/ivSJlomFixtL8EnCkgtS49KPZFpkr8gVyScpuCuqKmGVBpQLVJxV2VRfqJWqe+2V08BqTGk2aGVr++no6wrp0eoD/e8Gc4ZjRneNC028TQVNp82KzK0scBZdlsesTKxZrT/YtNnm2fnZqzsQHaYcrzkdcTZ1YXJ57Vq9LxR5/6/tv3cg6aCeO959iFTiEei514vgNeF92eeQr4rvpl+7f1KAdiAI7Ag6GqwXgg7pDj0ephP281At2QV5Z9dEWEX8iCyK2hs1FZ0UwxVzL9Y9jjlu4nDtkWPxzgkiCSuJXUl5R32T9Y+JpbAep0oFqT9OzKQ9Ta/PyMokZSmcxJ2cOHU9OyMnMNfoNP3ph3n78hbz4wp0CnXPpJ3Fn8soni1lOy9XpnpB9aJiuXSFSCXfJbYqusuU1RQ1NMhK0rjqfu1E3bX6Z9c3b4rccr19+s5QI2OTS3NJy3gr5p5om1G7R0fi/fOdbV2vH2w/5OvRe+T7OKv3xpOxvq1+0YF9g2eGpp7JjZwc/Txu97x5gu9lwaT0a+o30bOZ87GfLL+trNnsxP+vGtnOOwGrBEAekmc6nkTOBQByGwEQugsACyUA1kQA7FUBfKIOwEZ1AAo8/vf7AwJogEdyTmbAA0SBApJpmgNXJN+OAelIRnkVtIFhJDvehOghUUgbyQ/DoZNIPtgNzcAQzAfrwl7wCSTLG4bXUfwoC1Qcqho1jsaj1dDB6Ar0Cww9xgzJyLqwEFYbm4TtxGFwprgc3HM8Hz4I30yBo3CiqKZYp7SgvEi5SmVJVU1AEzwIXURBYjrxM7U9dSuS6eTSAtpDtLN0LnQD9Ib09xhUGBoY1Ri7mGyZZpgjWbAshaxCrE1slmzz7GkcshwznGVcHtzi3D95HvIW8HntUeDH8r8UuCWYLRQkbCYiLkoUXRIbFb8rcV4yQcpNWlWGUWZJ9qncFfl0BT9FUyUpZSblbZVPqlNqw+q9e7s1Hmj2aPVrT+jM667oAwMsss/hjfEmFKYEM0ZzPgsFS0urEOt8m1bbd/ZEBwVHF6d45wsuD1zn3Kj2yxxwPHjEvZLU7/HTS8Dbzue4b6vfeoBe4NmgtRDP0OFDhuTWCIXI+mjJmBtxew8PxocmciaNJeenmB9fOZGfLpHRneV9iin7de7TvMmC7SLec6ol5ucPXogtv1A5cVmy5sJVmbrpGxdvH2ikaq5r3d8u3snTbfiovI8wIDK0MpI7LvJi6NX512feDr93X1j7RP/l6jfwQ2ZFdXV7LWO9aWNk8+5Wxa+wbeXd/WOnikyJ1NI4gBBSa9ACFsANqS0kgFxQCZrBAFI32IKYIWnIFPJBKgLlSBXgLYyGhWFzmAyfg7vgLyhOlBnqCKoeNYvUvmzRmehuDITRwBzG3MVsYrWwx7CPcbQ4F9wl3De8Dj4P/55CnSKPYpHSEIn5JpUz1W0kEyYTRoiqxAvUVNQx1HM0LjT9tIa0HXSadO30evS9DHYMk0hmus6UzSzG/ITlECszawObDdt79lgOIkclpzbnLFcutykPNc8k7y2+U3v8+XUFWAU+Ct4TyhH2EdEVFRSjF8dLYCTxUtTS9DJ0snjZNbl5+XGFXsX7SveVe1Veqn5Tp94ro2Gj6a8VoU3W8dN11jPSVzVQMFQxMjI+aJJgetGsx3zJksPKwDoQeafl252xL3DId7zg1O781VVxX5Lb0wPcByPcBzz4PX28Crzv+PT7zvptBDAHygfZB0eFnAvtCPtAZgk3jIiKvBw1EUMbaxGXffh5vFBCfOLMUd9jtCm9qRFp2PQTmeistFMc2V25yXnOBXpn1M+qF6uXqpaJXkSXP6yMquK4fK/Go5bp6mRd9/WBm8t3ZBuPND9ppWnT7yB3Vj1Y6NF9fLNPtr9kcHL4x8jXsbnnMxPzr368ht5QzjC+E5gzXihcVP6S8b1qNWitfyNls2vrx6+13fjDyNNPh1SbJIEmsEGqYvGgEFwHfeADRIHUhiwgMlQEdUAfYGZYH46Aq+AJFB3KBJWC6kBtIZWZOHQLehOjg8nAjGNFsUexkzhNXDkejw/Fj1CoUpRSwkgtZJRKn+ouQZVwn2hNfE+dTMNH00HrRrtCl0MvSf+UIYSRyFjNpMv0ijmWhZuln/UUmwe7LocYJyPnBtckdxPPad5gPvM9MvysAliBNcGvQl+Ev4tsiVGLC0hoS7pLJUmXyjTJPpP7rsCuaKKUrNylSlBzU7+ugUO+Vdt09ujm6TMb1Bm5mtCZDpmfswy1drCVs5twcHXsczZ2ebbPx+3ngWPuECnMY9RL2bvEl8LvaABlYEWwRSgIaySHRnBHdkVHxnod/pxQmRR7dCx5MwU+jk+lPSGfFp4+kumQtXAqLUcq90VeWoF64deimnMHSihLL5cpX7hXrlXRcUm/qrfaumak1v7qYJ1hffMNkZtnbuPvxDdsNqW3CN0dvJfcrtSx0FnywOohuufu4/An4n2z/ecHnYcZnw2PZo+bPt+euPrKanL+deT01tvkWdS75Dl4/tgH9MfExc+fDb/ELpV+Pfkt8rv+99UfV5Ytl1+u+K2srEatLvx0+zmwprdWu05cD1sf3lDcKNr4ummyWb65sWW/de0X6pfzr6vb0LbD9pWd+If7yCP1SuSACLpI+XFqe/u7EAC40wBs5W5vb5Rvb29VIMnGKwA6gv7632WHjEVq9SWvd1Cv2GjSzv3fx/8ACJO/f7b+X80AAAGbaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA1LjEuMiI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjI3PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjI5PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Ck5zsgcAAAEqSURBVEgN7VS7joNADEz4AR6ClpI/gQIJGgqgpqRDfCYFlLzhB2jo4YazsiKrKHe6rK7CBRqvxyPveMV93/eb0JCEqh1il6IYSy8fLx//7sC/vJ6+7+M41jTt/ghVVcMwrOsak/u+jxIIoL2+CP5m56iqyjCMl1QIFUXRNA1VQQP53Ev4xh2laYoGz/OGYWClaZqCIMB5kiQ4RAkEpCAzDgO8omVZoOKCxJBlGek4jvM8A5imSefkAMhMiIEfNqPrOoQkSdq2DWBZFnzfB69o2zYa8jzHXACO4+CbZRmWhCnWdUWKEggARAZ4CjYtgfNmsM2yLGnMp57v5LebgW7XdVEU4cW4rou0bVs8HUVRmChKIIDGTUPpcRdGFQJ4Hz8XvRQ/9/BQEO/jF3oLKusHZ04pAAAAAElFTkSuQmCC')\n no-repeat\n left center;\n }\n .markdown-body h1:hover a.anchor .octicon-link, .markdown-body h2:hover a.anchor .octicon-link, .markdown-body h3:hover a.anchor .octicon-link, .markdown-body h4:hover a.anchor .octicon-link, .markdown-body h5:hover a.anchor .octicon-link, .markdown-body h6:hover a.anchor .octicon-link {\n display: none;\n }\n </style>\n </head>\n <body class=\"markdown-body\" style=\"padding:10px 40px;\">\n <div class=\"readme-content\">\n #{preview_html}\n </div>\n </body>\nCONTENT\n output_file_content\n end",
"def markdown(s)\n s = s.gsub(/\\*\\/$/,\"\")\n s = s.gsub(/^ ?\\* ?/,\"\")\n s = s.gsub(/^\\/\\*\\*? ?/,\"\")\n s.chop! while s[-1] == \"\\n\" || s[-1] == \" \"\n lines = s.split(\"\\n\")\n newlines = []\n # Fix some markdown\n lines.each{|l|\n # Rewrite RM_Xyz() to RedisModule_Xyz().\n l = l.gsub(/(?<![A-Z_])RM_(?=[A-Z])/, 'RedisModule_')\n # Fix more markdown, except in code blocks indented by 4 spaces, which we\n # don't want to mess with.\n if not l.start_with?(' ')\n # Add backquotes around RedisModule functions and type where missing.\n l = l.gsub(/(?<!`)RedisModule[A-z]+(?:\\*?\\(\\))?/){|x| \"`#{x}`\"}\n # Add backquotes around c functions like malloc() where missing.\n l = l.gsub(/(?<![`A-z.])[a-z_]+\\(\\)/, '`\\0`')\n # Add backquotes around macro and var names containing underscores.\n l = l.gsub(/(?<![`A-z\\*])[A-Za-z]+_[A-Za-z0-9_]+/){|x| \"`#{x}`\"}\n # Link URLs preceded by space or newline (not already linked)\n l = l.gsub(/(^| )(https?:\\/\\/[A-Za-z0-9_\\/\\.\\-]+[A-Za-z0-9\\/])/,\n '\\1[\\2](\\2)')\n # Replace double-dash with unicode ndash\n l = l.gsub(/ -- /, ' – ')\n end\n # Link function names to their definition within the page\n l = l.gsub(/`(RedisModule_[A-z0-9]+)[()]*`/) {|x|\n $index[$1] ? \"[#{x}](\\##{$1})\" : x\n }\n newlines << l\n }\n return newlines.join(\"\\n\")\nend",
"def markdown( text )\n Kramdown::Document.new( text ).to_html\n end",
"def <<(embed)\n raise ArgumentError, 'Embeds and files are mutually exclusive!' if @file\n\n @embeds << embed\n end",
"def to_md\n @md ||= [\n \"[🔙 🏡](#{project_readme_path})\",\n '',\n \"# #{title} (#{year})\",\n '',\n \"By the #{adjective} [#{author}](#{homepage})\",\n '',\n '## Links:',\n '',\n \"- [Purchase #{title}](#{purchase})\",\n '',\n '## Chapter Notes:',\n ''\n ].concat(section_md).concat(image_md).join \"\\n\"\n end",
"def render_markdown(text)\n html_renderer.render(text).html_safe if text.present?\n end",
"def parse_markdown\n self.bio_html = markdown.render(bio_markdown)\n end",
"def render_document(content, extension, repo_loc = \"\", version = \"\")\n doc = begin\n if %w(md mdown markdown).include?(extension.downcase)\n render_markdown(content)\n else\n content\n end\n end.gsub(/src=\"(?!http)(.+)\"/, %(src=\"https://github.com/#{repo_loc}/raw/#{version}/\\\\1\")).html_safe\n end",
"def markdown_output_html\n \n if self.markdown_output\n self.markdown_output\n else\n self.markdown_output = MARKDOWN_RENDERER.render(self.output)\n end\n end",
"def texte_aide_markdown\n @texte_aide_markdown ||= begin\n File.read(markdown_file)\n end\n end",
"def markdown\n md = view_context.markdown(@target.body.present? ? @target.body : @target.title)\n view_context.shapado_auto_link(md).html_safe\n end",
"def render_localized_markdown(file)\n path = Rails.root.join('config', 'locales', file.to_s,\n \"#{file}.#{I18n.locale}.md\")\n\n # Fall back to English if we have to\n unless File.exist?(path)\n if I18n.locale != :en\n path = Rails.root.join('config', 'locales', file.to_s,\n \"#{file}.en.md\")\n end\n end\n\n # Give up if we can't find it\n unless File.exist?(path)\n fail I18n::MissingTranslationData.new(I18n.locale,\n \"localized_markdown.#{file}\",\n {})\n end\n\n render_to_string(file: path, layout: false).html_safe\n end",
"def convert!\n merged_contents = []\n @files.each do |file|\n markup = Markup.new file, @remove_front_matter\n html = convert_image_urls markup.render, file.filename\n if @merge\n html = \"<div class=\\\"page-break\\\"></div>#{html}\" unless merged_contents.empty?\n merged_contents << html\n else\n output_pdf(html, file)\n end\n end\n\n unless merged_contents.empty?\n html = merged_contents.join\n output_pdf(html, nil)\n end\n end",
"def markdown text\n markdown = Redcarpet::Markdown.new HTMLWithVideos, autolink: true, space_after_headers: true, no_intra_emphasis: true, superscript: true\n return markdown.render(text).html_safe\n end",
"def include file\n @master.puts \"\\\\i #{file}\"\n end",
"def to_html_fragment\n to_markdown_slices.map do |tagged_markdown|\n tagged_markdown.to_html\n end.join(\"\\n\\n\")\n end",
"def markdown(text)\n sanitize(BlueCloth::new(text).to_html)\n end",
"def writeMarkdown(doc, page)\n\n layers = page[\"children\"].reverse\n pagetitle = page[\"name\"]\n blocks = []\n\n # Let's get the text layers\n text = layers.select do |layer|\n layer[\"type\"] === \"TEXT\"\n end\n\n # Let's get only the frames\n frames = layers.select do |layer|\n layer[\"type\"] === \"FRAME\"\n end\n \n # let's build this\n frames.each do |frame|\n ftitle = self.showTitle?(frame[\"name\"]) ? frame[\"name\"] : nil\n fimage = self.getFrameImage(doc, page[\"name\"], frame)\n ftext = self.getFrameText(text, frame[\"name\"])\n\n blocks.push([ftitle, \"/#{@assetpath}/#{fimage}\", ftext])\n end\n\n\n # Do we have a summary?\n summary = text.select do |layer|\n layer[\"name\"] == \"_summary.md\"\n end\n\n summary = summary.size > 0 ? summary.first[\"characters\"] : nil\n\n # Do we have a tags?\n tags = text.select do |layer|\n layer[\"name\"] == \"_tags\"\n end\n\n tags = tags.size > 0 ? tags.first[\"characters\"] : nil\n menutag = !tags.nil? ? tags.split(\",\").first : nil\n\n \n # Export markdown from erb template\n filename = \"#{doc[\"document\"].parameterize}-#{pagetitle.parameterize}\"\n template = File.read('_plugins/figma-template.md.erb')\n result = ERB.new(template).result(binding)\n\n open(\"#{@pagespath}/#{filename}.md\", \"wb\") { |file|\n file.write(result)\n file.close\n }\n\n [pagetitle, filename, menutag]\n end",
"def to_html\n @markdown_class.new(@markdown).to_html\n end",
"def liquidize_markdown(content, arguments)\n # doc = BlueCloth.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n # :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}))\n doc = ::Kramdown::Document.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}),\n :parse_block_html => true)\n return doc.to_html.html_safe\n end",
"def substitute_markdown_inside_raw_html\n each_element(:raw_html) do |e|\n html = e.parsed_html\n next unless html\n\n html.process_markdown_inside_elements(self)\n end\n end",
"def parse_markdown\n self.body_html = markdown.render(body_markdown.to_s)\n self.summary_html = markdown.render(summary_markdown.to_s)\n end",
"def markdown_extention_youtube_links(html)\n html = html.gsub /<a\\shref=\"http:\\/\\/www\\.youtube\\.com\\/watch\\?v=(.*).*\".*>.*<\\/a>/o, \n \"<p><iframe class=\\\"youtube-player\\\" src=\\\"http://www.youtube.com/embed/\\\\1\\\"></iframe></p>\"\n return html\n end",
"def md_to_html\n options = {\n filter_html: true,\n link_attributes: {\n rel: \"nofollow\",\n target: \"_blank\"\n }\n }\n\n extensions = {\n space_after_headers: true,\n autolink: true\n }\n\n renderer = Redcarpet::Render::HTML.new(options)\n markdown = Redcarpet::Markdown.new(renderer, extensions)\n\n self.description = markdown.render(self.description_md)\n end",
"def create!\n new_file = \"#{next_number}-#{strip_title}.md\"\n @path = File.join(@dir, new_file)\n File.open(@path, 'w') do |file|\n file.write initial_content\n end\n\n new_file\n end",
"def markdown(text) # Define method markdown with redcarpet gem\n\t\tRedcarpet::Markdown.new(Redcarpet::Render::HTML).render(text)\n end",
"def markdown(text)\n# coderayified = CodeRayify.new(:filter_html => true,:hard_wrap => true)\n coderayified = PygmentsHTML.new(\n with_toc_data: true,\n hard_wrap: true\n )\n# coderayified = Redcarpet::Render::HTML.new(:filter_html => true,:hard_wrap => true)\n options = {\n :no_intra_emphasis => true,\n :tables => true,\n :fenced_code_blocks => true,\n :autolink => true,\n :strikethrough => true,\n :lax_spacing => true,\n :superscript => true\n }\n markdown_to_html = Redcarpet::Markdown.new(coderayified, options)\n markdown_to_html.render(text).html_safe\n end",
"def markdown(doc)\n doc = Nokogiri::HTML(doc)\n if doc.at(\"body\").nil?\n doc = \"\"\n else\n doc = ReverseMarkdown.convert(doc.at(\"body\").inner_html)\n end\n end",
"def make_me_some_markdown\n\tputs \"write the name of the markdown file\"\n\tfile = gets.chomp.downcase\n\tputs `touch #{file}.md`\nend",
"def markdown(text)\n coderayified = CodeRayify.new(:filter_html => true, \n :hard_wrap => true,\n :coderay_default_lang => 'ruby'\n )\n options = {\n :fenced_code_blocks => true,\n :no_intra_emphasis => true,\n :autolink => true,\n }\n markdown_to_html = Redcarpet::Markdown.new(coderayified, options)\n markdown_to_html.render(text).html_safe\n end",
"def embed(src, mime_type, label)\nend",
"def extension\n 'md'\n end",
"def markdown\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)\n end"
] | [
"0.64110047",
"0.61663574",
"0.61309576",
"0.60383177",
"0.602433",
"0.5994981",
"0.5969158",
"0.5955647",
"0.5946289",
"0.59067684",
"0.58571017",
"0.58539855",
"0.58489794",
"0.5847564",
"0.5843688",
"0.5843653",
"0.58358675",
"0.58303547",
"0.58190703",
"0.5738081",
"0.5738081",
"0.5732826",
"0.5725858",
"0.57210636",
"0.5715594",
"0.5693668",
"0.5679781",
"0.5645809",
"0.564578",
"0.5631707",
"0.5622477",
"0.56117624",
"0.5591053",
"0.5587273",
"0.5578871",
"0.55784357",
"0.5570272",
"0.55674416",
"0.556571",
"0.5563557",
"0.55490845",
"0.554712",
"0.554712",
"0.55281985",
"0.5525841",
"0.55158997",
"0.5515559",
"0.55028856",
"0.5502241",
"0.54998165",
"0.5486805",
"0.5483751",
"0.5483211",
"0.54800916",
"0.54793465",
"0.54788005",
"0.54475826",
"0.54398036",
"0.54345286",
"0.54345286",
"0.5432454",
"0.54307926",
"0.5412114",
"0.5380658",
"0.53796315",
"0.53796315",
"0.53684",
"0.53416824",
"0.53395265",
"0.53289163",
"0.5319236",
"0.5317151",
"0.5316123",
"0.53155905",
"0.53013796",
"0.5296827",
"0.5287102",
"0.52842313",
"0.5282309",
"0.52787936",
"0.52657205",
"0.5264014",
"0.5249773",
"0.52497244",
"0.5242353",
"0.52416384",
"0.5233041",
"0.52204907",
"0.52188134",
"0.52177733",
"0.5211866",
"0.52070683",
"0.5201769",
"0.5192054",
"0.51892745",
"0.5182271",
"0.5167619",
"0.51664704",
"0.5162682",
"0.516244"
] | 0.6912467 | 0 |
A list of .md.erb file paths Ignores readme and license | def md_erb_files
Dir.glob("**/*.md.erb").reject do |path|
["license", "readme"].any? do |str|
path.downcase.ends_with? "#{str}.md.erb"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def erb_path\n \"#{File.dirname(__FILE__)}/markdown_doc.erb\"\n end",
"def templates() = templates_path.glob('**/*.erb')",
"def public_txt_files\n template 'humans.txt.tt', 'public/humans.txt'\n template 'robots.txt.tt', 'public/robots.txt', force: true\n end",
"def path\n @absolute_path.sub(%r{^#{Slimdown.config.location}/(.*)\\.md}, '\\1')\n end",
"def files\n paths = %W{html/#{slug}.html html/*_fragment.html images/**/* config/*\n html/stylesheets/custom.css}\n Dir[*paths].map do |path|\n BookFile.new(path) unless File.directory?(path)\n end.compact\n end",
"def files\n templates.map(&:filename)\n end",
"def page_files\n @page_files ||= (Dir.glob (Pathname.pwd.join(\"pages\", \"*.md\"))).sort\n end",
"def scheme_and_files\n Dir.glob(File.join(File.dirname(__FILE__), \"fixtures\", \"htmls\", \"*.html\")).map do |file|\n\t \"https://newsdict.blog/#{File.basename(file)}\"\n end\n end",
"def src_filelist\n FileList['lib/**/*.rb'].concat ['README.rdoc']\nend",
"def list\n Dir.glob(\"#{@path}/**/*\").select{|path| File.file?(path) }.map do |path|\n path.sub Regexp.new(\"^#{@path}\\/\"), ''\n end\n end",
"def build_mdlinks\n return unless options.Build_Markdown_Links\n\n puts_cyan \"Middlemac is creating `#{options.File_Markdown_Links}`.\"\n\n files_array = []\n out_array = []\n longest_shortcut = 0\n longest_path = 0\n\n Dir.glob(\"#{app.source}/Resources/**/*.erb\").each do |fileName|\n\n # Remove all file extensions and make a shortcut\n base_name = fileName\n while File.extname(base_name) != '' do\n base_name = File.basename( base_name, '.*' )\n end\n next if base_name.start_with?('_') # || base_name == 'index'\n\n if base_name == 'index'\n shortcut = \"[#{File.split(File.split(fileName)[0])[1]}_index]:\"\n\n else\n shortcut = \"[#{base_name}]:\"\n end\n\n # Make a fake absolute path\n path = Pathname.new(fileName).relative_path_from(Pathname.new(app.source))\n path = File::SEPARATOR + File.join(File.dirname(path), base_name) + '.html'\n\n # Get the title, if any\n metadata = YAML.load_file(fileName)\n title = (metadata.is_a?(Hash) && metadata.key?('title')) ? metadata['title'] : ''\n\n files_array << { :shortcut => shortcut, :path => path, :title => title }\n\n longest_shortcut = shortcut.length if shortcut.length > longest_shortcut\n longest_path = path.length if path.length > longest_path\n\n end\n\n files_array = files_array.sort_by { |key| [File.split(key[:path])[0], key[:path]] }\n files_array.uniq.each do |item|\n item[:shortcut] = \"%-#{longest_shortcut}.#{longest_shortcut}s\" % item[:shortcut]\n\n if item[:title].length == 0\n out_array << \"#{item[:shortcut]} #{item[:path]}\"\n else\n item[:path] = \"%-#{longest_path}.#{longest_path}s\" % item[:path]\n out_array << \"#{item[:shortcut]} #{item[:path]} \\\"#{item[:title]}\\\"\"\n end\n end\n\n File.open(options.File_Markdown_Links, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def example_markdown_targets()\n target_files = []\n\n example_dir = File.join(K4_ROOT, 'example')\n ext = 'md'\n filelist = FileList[File.join(example_dir, \"*.#{ext}\")]\n filelist.each do |source_path|\n source_basename = File.basename(source_path)\n next if source_basename =~ /^_/\n\n source_basename = source_basename.gsub(/#{ext}$/, 'html')\n target_path = File.join(example_dir, source_basename)\n # File.delete(target_path) if File.exists?(target_path)\n\n file(target_path) do |t, args|\n puts t.name\n src = File.read(source_path)\n compiler_ = MarkdownCompiler.new(@compiler)\n html_source = compiler_.to_slide(src)\n File.open(target_path, 'w') do |io|\n io.write(html_source)\n end\n end\n target_files << target_path\n end\n return target_files\n end",
"def copy_markdown_files\n %w[AUTHORS.md CODE_OF_CONDUCT.md TODO.md].map { |f| copy_file(f, f) }\n end",
"def read patterns\n Dir[*patterns].uniq.map do |f|\n filename = File.join(Dir.pwd, f)\n\n @files ||= []; @files << filename\n STDERR.puts filename\n\n case File.extname(filename)\n when '.erb'\n Dir.chdir File.dirname(filename) do\n ERB.new(File.read(File.basename(filename))).result(binding)\n end\n else\n File.read filename\n end\n end.join(\"\\n\")\nend",
"def plantuml_files\n site.static_files.select { |file| converter.matches(file.extname) }\n end",
"def templates\n Dir.glob(::Webby.path('examples') / '*').sort\n end",
"def html_files\n @site.static_files.select { |file| HTML_EXTENSIONS.include? file.extname }\n end",
"def find\n list = Dir.glob(File.join(@pages_folder, '**/*'))\n list.map! { |name| name.gsub(@pages_folder + '/', '')}\n list.map { |name| name.force_html_extension }\n end",
"def index (path = \".\")\n files = Array.new\n # search path and fill with files\n Dir.foreach(path) do |entry|\n if File.file?(path + \"/\" + entry)\n if entry.length > 5 && entry[-5..-1] == \".whip\"\n files.push(Whip::File.new(path + \"/\" + entry, path + \"/\" + entry[0...entry.rindex(\".\")] + \".html\"))\n end \n end\n end\n return files\n end",
"def file_listings_html_string(file_paths, folder_name)\n file_paths.map do |path|\n dist_file_name = file_name_from_path(sanitize_path(path))\n dist_final_path = public_path(folder_name, dist_file_name)\n next file_listing_html_string(dist_final_path, dist_file_name)\n end.join(\"<br>\")\n end",
"def files_for_erb\n return Dir.chdir( base ) { Dir.glob( '*.erb' ) }\n end",
"def files\n files_in_path.map do |file|\n TemplateFile.from_full_path(@path, file) unless File.directory?(file)\n end.compact\n end",
"def readme\n template 'README.md.erb', 'README.md'\n # This is here, because if --skip_tests is added, it skips running the gitignore function\n # => since all projects have a readme this should just overwrite the gitignore file\n copy_file 'dotfiles/gitignore', '.gitignore', force: true\n end",
"def files\n { 'branches_without_pulls.md' => { content: report } }\n end",
"def files\n @files = Dir[File.join(root(:site), '**', '*')].inject([]) do |a, match|\n # Make sure its the canonical name\n path = File.expand_path(match)\n file = path.gsub /^#{Regexp.escape root(:site)}\\/?/, ''\n ext = File.extname(file)[1..-1]\n \n if ignored_files.include?(path) or File.directory?(match)\n # pass\n elsif not get_renderer(ext).nil? # Has a renderer associated\n fname = file.chomp(\".#{ext}\")\n fname += get_renderer(ext).default_ext unless File.basename(fname).include?('.')\n a << fname\n else\n a << file\n end\n a\n end\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def templates\n file_list '{templates,puppet}/**/*.{erb,epp}'\n end",
"def show_readme\n readme 'lib/generators/cms/fortress/templates/README'\n end",
"def doc_file_path\n \"#{@structure[:working_path]}/docs/#{@structure[:full_relation_name]}.md\"\n end",
"def site_files\n exclude = %r/tmp$|bak$|~$|CVS|\\.svn/o\n\n rgxp = %r/\\A#{template}\\/?/\n paths = Hash.new {|h,k| h[k] = []}\n\n Find.find(template) do |p|\n next if exclude =~ p\n\n if test(?d, p)\n paths[p.sub(rgxp, '')]\n next\n end\n dir = ::File.dirname(p).sub(rgxp, '')\n paths[dir] << p.sub(rgxp, '')\n end\n\n paths\n end",
"def template_files\r\n \t[].concat(@templates)\r\n end",
"def doc( path )\n get \"#{path}.html\" do\n password_protected!\n \n endpoint = path.split('/').last\n \n template_path = File.join( VIEW_PATH, \"#{endpoint}.md\" )\n rendered = GitHub::Markup.render( template_path )\n\n erb :layout, :locals => { :content => rendered }\n end\nend",
"def files_post_erbed\n return files_for_erb.map { |e| src_path( erbed_filename( e ) ) }\n end",
"def path\n File.join(doc.path, \"#excerpt\")\n end",
"def template_paths(name)\r\n \[email protected]([]) do |list, path|\r\n \t\tfile_name = File.basename(path)\r\n \t\tfile_name[0, name.length] == name.to_s ? list << path : list\r\n \tend\r\n end",
"def view_paths; end",
"def view_paths; end",
"def view_paths; end",
"def process_content(path)\n case path.extname\n when '.htm', '.md'\n read_split_content(path.to_s, symbolize_keys: true)\n # when '.md'\n # body, data = read_split_content(path.to_s, symbolize_keys: true)\n # [Kramdown::Document.new(body).to_html, data]\n when '.yml'\n [nil, YAML.load(File.read(path.to_s), symbolize_names: true)]\n end\n end",
"def paths; end",
"def paths; end",
"def paths; end",
"def paths; end",
"def paths; end",
"def document_entries\n entries.select{ |f| File.file?(File.join(path,f)) }\n end",
"def files\n cli_arguments.each_with_index do |filename, index|\n if Dir.exist?(filename)\n cli_arguments[index] = Dir[\"#{filename}/**/*.md\"]\n end\n end\n cli_arguments.flatten!\n cli_arguments\n end",
"def pathTemplates\n \"./templates/\"\nend",
"def template_files\n Pathname.glob(staged_root.join(\"**\", \"*.erb\")).select(&:file?)\n end",
"def dir_files(dir_path)\n Dir[File.join(dir_path, '*')].to_a.map { |path| Docfile.new(path) }\n end",
"def markdown_cheatsheet\n File.read(Rails.root.join('markdown.md'))\n end",
"def templates_for(file); end",
"def pathSourceDoc\n\t\"./documentation/\"\nend",
"def document_files\n allowed_formats = \n if not parsers.empty?\n parsers.collect do |filetype, parser| \n \".\" + parser.file_extension_name\n end.join(\"|\")\n elsif not parser.nil?\n \".\" + parser.file_extension_name\n end\n\n allowed_formats = Regexp.new(allowed_formats)\n \n \tFileUtils.collect_files_from(docs_path).select do |document_filename|\n \t document_filename =~ allowed_formats\n end\n end",
"def readme(path)\n log File.read(find_in_source_paths(path))\n end",
"def readme(path)\n log File.read(find_in_source_paths(path))\n end",
"def readme(path)\n log File.read(find_in_source_paths(path))\n end",
"def pages_slim\n Dir[src_path.join('pages', '**', '*.slim').to_s]\n end",
"def textfiles\n textdir = datadir \"snippets\"\n Dir.entries(textdir).reject { |f|\n f =~ /^\\./ or f =~ /fail/\n }.each { |f|\n yield File.join(textdir, f)\n }\n end",
"def posts\n Dir[\"#{posts_dir}/**\"].select {|e| e !~ /~$/ }\n end",
"def help_text\n build_html do\n p <<P1\nThis page is a simple presentation of the paths that match the file\nthat was searched for an the fileset that the file was shipped in.\nP1\n end\n end",
"def pages_data\n\n config_data = get_config_data\n\n all_data_files = Dir.glob(\"../#{ROOT_DIR}/lib/views/source/#{config_data[\"templates_page\"]}/**/*.json\")\n\n pageData_files = []\n\n all_data_files.map { |data| \n\n data_name = data.split(\"/\")[-1]\n pageData_files.push(\n {\n \"file_name\": data_name,\n \"link_name\": data_name.sub(\"~\", \"__\").chomp(\".json\"),\n \"label\": data_name.sub(\"~\", \" \").chomp(\".json\")\n }\n )\n }\n\n return pageData_files\n end",
"def node_files_path()\n return File.join(@base_path, 'pages')\n end",
"def files\n return [] unless meta?\n filename = meta['path'] + '/' + meta['filename']\n [\n Inch::Utils::CodeLocation.new('', filename, meta['lineno'])\n ]\n end",
"def formatted_file_list(title, source_files); end",
"def docs\n unless @docs\n @docs = []\n content().each_line do |l|\n next unless l =~ %r{/usr/share/doc/packages}\n @docs << l\n end\n end\n @docs\n end",
"def copy_or_fetch\n filename_pattern = File.join self.class.source_root, \"*\" #/*.html.#{template_engine}\"\n Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|\n directory f.to_s, \"app/views/#{f}\"\n end\n end",
"def definition_file_paths; end",
"def find_all_generated_release_notes\n Dir[\"#{File.dirname(@erb_file)}/markdown/Rel_Notes_*.md*\"]. # some are .md, some are .md.erb\n map { |f| File.basename(f).split('.').first }. # eg Rel_Notes_3_11_6\n sort_by { |f| f.split('_').map(&:to_i) }. # eg [0, 0, 3, 11, 6]\n reverse # newest first\n end",
"def show_asset_files\n display_collection_of_folders_docs_tasks\n end",
"def find_files()\n require 'find'\n directory = File.dirname(__FILE__) + '/../templates/' + @template\n @files = Array.new()\n Find.find(directory) do |f|\n if FileTest.file?f\n @files.push(f)\n end\n end\n @files\n end",
"def create_docs\n directory 'templates/docs', 'docs'\nend",
"def static_files; end",
"def templates_dir\n \"#{RdocInfo.config[:templates_dir]}\"\n end",
"def support_rdoc_document_file!\n IO.read(\".document\").gsub(/^[ \\t]*#.+/m, '').split(/\\s+/)\n rescue Errno::ENOENT\n []\n end",
"def files_omit\n %w(map.html)\nend",
"def generate_file_files\n template_file = @template_dir + 'file-page.html.erb'\n debug_msg \"Generating file documentation\"\n @all_files.each do |file|\n debug_msg \" file #{file.path}\"\n outfile = @output_dir + file.path\n @file = file\n self.render_template(template_file, binding(), outfile)\n end\n end",
"def files() = files_path.glob('**/*')",
"def get_template_text(path, base_path)\n [path, \"#{base_path}/#{path}\"].each do |p|\n begin\n t = self.view_paths.find_template(p, 'html') # FIXME: format ?\n rescue ActionView::MissingTemplate\n t = nil\n end\n return [t.source, t.path, t.base_path] if t\n end\n nil\n end",
"def help\n path = Dir[src_path('README')].first || Dir[src_path('README.md')].first || Dir[src_path('README.markdown')].first\n if path\n File.read path\n end\n end",
"def static_files\n source = File.dirname(assets_path)\n asset_files.map do |file|\n dir = File.dirname(file)\n file_name = File.basename(file)\n Jekyll::StaticFile.new @site, source, dir, file_name\n end\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def template_files path\n exts = template_engines.keys.map{|e| \".\" << e if e }.join(\",\")\n Dir[\"#{path}{#{exts}}\"]\n end",
"def find_other_post (utilHash)\n fileList = []\n if (utilHash[\"technical\"])\n fileList += Dir[utilHash[\"blog_path\"] + \"t*.html\"]\n end\n if (utilHash[\"cultural\"])\n fileList += Dir[utilHash[\"blog_path\"] + \"c*.html\"]\n end\n return fileList\nend",
"def find_readme repo_dir\n files = Dir.entries(repo_dir).sort\n files.each { |f| return f if f.downcase.include? 'readme' }\n return ''\nend",
"def available_page_templates\n dirname = Rails.root.join('app/' + Option.theme_full_dir)\n templates = []\n Dir.foreach(dirname) do |filename|\n if filename.length > 19 + 1 && filename.slice(0, 9) == 'template_' && filename.slice(-10, 10) == '.html.haml'\n templates << filename.slice(9, filename.length - 19)\n end\n end\n templates\n end",
"def fs_to_doc_path(fs_path)\n fs_path.gsub /(README)?\\.md$/, \"\"\n end",
"def file_list files\n files.map { |gf| link_to_file(gf) }.join(', ').gsub(/\"/, \"'\")\n end",
"def generate_html_views\n selective_copy 'app/views/kublog/posts/*.html.erb'\n end",
"def existing_resource_snippets_paths\n Dir[\"#{snippets_path}/*#{template_ext}\"].reject { |path| File.basename(path).start_with?('_') }\n end",
"def source_files; end",
"def all\n Dir.chdir(content_dir) do\n files = Dir.glob(File.join(\"**\", \"*#{SOURCE_FILE_EXT}\")).delete_if {|p| p =~ Regexp.new(\"\\\\.[0-9]+\\\\#{SOURCE_FILE_EXT}$\")}\n files.collect {|f| Page.new(uri_from_path(f), File.open(f, 'r') {|b| b.read})}\n end\n end",
"def support_rdoc_document_file!(file = '.document')\n return [] unless use_document_file\n File.read(file).gsub(/^[ \\t]*#.+/m, '').split(/\\s+/)\n rescue Errno::ENOENT\n []\n end"
] | [
"0.7057528",
"0.7057528",
"0.68402666",
"0.6676598",
"0.6528362",
"0.6495087",
"0.6491898",
"0.6486261",
"0.63012654",
"0.6300635",
"0.6262226",
"0.62137765",
"0.61862236",
"0.6184075",
"0.61706054",
"0.6164567",
"0.6157253",
"0.61545193",
"0.6151136",
"0.6150876",
"0.61372316",
"0.61250216",
"0.61225325",
"0.6099682",
"0.607547",
"0.6072357",
"0.6058071",
"0.60561305",
"0.60561305",
"0.60558736",
"0.60558426",
"0.6053483",
"0.6053169",
"0.6036433",
"0.6027478",
"0.60028106",
"0.6002279",
"0.5997093",
"0.5991797",
"0.5991797",
"0.5991797",
"0.59784085",
"0.5974492",
"0.5974492",
"0.5974492",
"0.5974492",
"0.5974492",
"0.5971549",
"0.59615374",
"0.5946996",
"0.5946218",
"0.59407467",
"0.59358263",
"0.5922273",
"0.59218603",
"0.59193623",
"0.5918594",
"0.5918594",
"0.590612",
"0.59053975",
"0.5901739",
"0.5900443",
"0.588885",
"0.5888065",
"0.5875745",
"0.58555955",
"0.58539706",
"0.58506316",
"0.58489907",
"0.5838381",
"0.5835479",
"0.5829714",
"0.582956",
"0.58263814",
"0.58235943",
"0.58075637",
"0.5802903",
"0.5796219",
"0.57889163",
"0.57822436",
"0.5779961",
"0.57795423",
"0.57781154",
"0.5770586",
"0.5770586",
"0.5770586",
"0.5770586",
"0.5770586",
"0.5770586",
"0.57651997",
"0.57578635",
"0.5751644",
"0.5744562",
"0.57438445",
"0.5736082",
"0.5735668",
"0.57289374",
"0.5725325",
"0.57141656",
"0.5700091"
] | 0.756004 | 0 |
Transform /my/path/name.txt into 'name' | def file_title(path)
filename_from_path(path).split(".")[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name_from_file_name(file)\n file.sub!('/', '').sub!('.jpg', '').gsub!(/[-_]/, ' ').split.map(&:capitalize).join ' '\n end",
"def file_to_name(file)\n return file.split(\"_\").map(&:capitalize).join\n end",
"def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end",
"def filename(name)\n # Reemplaza letras con acentos y ñ\n filename = name.gsub('á','a').gsub('é','e').gsub('í','i').gsub('ó','o').gsub('ú','u').gsub('ñ','n').downcase\n return filename\nend",
"def sanitize_file_name_as_name\n sanitized_name_array = name.split('.')\n sanitized_name_array.pop if sanitized_name_array.length > 1\n self.name = sanitized_name_array.join('.').tr('-_', ' ').split.map(&:capitalize)*' '\n end",
"def name_to_file(name)\n array = name.scan(/[A-Z][a-z]*/)\n raise TypeError, Ajaila::Messager.warning(\"The name of variable should start with capital letter: \\\"table:MyTable\\\"\") if array == []\n return array.map(&:downcase).join(\"_\")\n end",
"def rename_out fileName\r\n name = fileName.split('/')[-1]\r\n name = name.split('\\\\')[-1]\r\n return \"Code_From_#{name.gsub(/\\./,'_')}.html\"\r\n end",
"def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end",
"def sterilize(file_name)\n f = file_name.dup\n f.gsub!(/[\\s]/, '_')\n PATTERNS.each { |p| f.gsub!(p, '_') }\n f\n end",
"def file_name name\n File.basename(name).sub(/\\.[^\\.]*/, '')\n end",
"def file_name name\n File.basename(name).sub(/\\.[^\\.]*/, '')\n end",
"def normalize_filename\n self.name = Pathname.normalize_filename(name)\n end",
"def normalize_content_name(name)\n return if name.nil?\n\n if name.start_with?(@annotations_directory.name)\n \"#{full_name}/#{name}\"\n elsif name.start_with?(\"/#{@annotations_directory.full_name}\")\n name.slice(1, name.length)\n else\n nil\n end\n end",
"def name\n @name ||= File.basename(file).chomp(File.extname(file))\n end",
"def extract_name_from_text(text); end",
"def process(name)\n return unless name\n\n self.ext = File.extname(name)\n self.basename = name[0..-ext.length - 1].gsub(%r!\\.*\\z!, \"\")\n end",
"def proper_filename(file)\n file.gsub(/[^\\w]/,'_')\n end",
"def file_name\n name.underscore\n end",
"def process(name)\n self.ext = File.extname(name)\n self.basename = name.split('.')[0..-2].first\n end",
"def get_converted(line)\n tokens = line.split(/[ ;]/)\n name = tokens[-1].split(/_/)\n name[1..-1].each(&:capitalize!)\n [tokens[-1], name.join]\nend",
"def filename(name)\n @filename = name.downcase.strip.gsub(' ', '-')\n end",
"def sanitize(name)\n name = name.force_encoding(Encoding::UTF_8)\n name = name.gsub(\"\\\\\", \"/\") # work-around for IE\n name = File.basename(name)\n name = name.gsub(sanitize_regexp, \"_\")\n name = \"_#{name}\" if name =~ /\\A\\.+\\z/\n name = \"unnamed\" if name.size == 0\n return name.mb_chars.to_s\n end",
"def transliterate_file_name\n\t\t\tfile_names = Array.new\n\t\t\[email protected] { |a| file_names << a if a.match(/_file_name{1}$/) }\n\t\t\tfile_names.each do |local_file_name|\n\t\t\t\tif self.send(local_file_name).present? && self.send(local_file_name+'_changed?')\n\t\t\t\t\textension = File.extname(send(local_file_name)).gsub(/^\\.+/, '')\n\t\t\t\t\tfilename = send(local_file_name).gsub(/\\.#{extension}$/, '')\n\t\t\t\t\tself.send(local_file_name.gsub(/_file_name{1}$/, '')).instance_write(:file_name, \"#{transliterate(filename)}.#{transliterate(extension)}\")\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def sanitize(name)\n name = name.scrub\n name = name.tr(\"\\\\\", \"/\") # work-around for IE\n name = File.basename(name)\n name = name.gsub(sanitize_regexp, \"_\")\n name = \"_#{name}\" if name =~ /\\A\\.+\\z/\n name = \"unnamed\" if name.size.zero?\n name.mb_chars.to_s\n end",
"def file_name\n # file = full_name\n # file = file.gsub('::', '/')\n # file = file.gsub('#' , '/')\n # file = file.gsub('.' , '-')\n # #file = File.join(output, file + '.html')\n # file\n WebRI.entry_to_path(full_name)\n end",
"def infer_name_from_contents(obj, opts={})\n begin\n File.split(obj).last.split('.')[0..-2].join('.').titleize\n rescue\n nil\n end\n end",
"def parse_name(name)\n words = name.path_to_name.strip.split(/\\s+/)\n first = words.shift\n { first: first, last: words.join('-') }\n end",
"def get_file_name(chatname)\n parse_chatname(chatname) + '.txt'\n end",
"def updateName(name)\n name_array = name.split(\"\\\\\")\n return name_array[0]\nend",
"def normal_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tfirstname = firstpart.gsub(/[[:upper:]]\\./, '').strip\n\t\t\tfirstname + ' ' + lastname\n\t\tend",
"def name\n @name ||= filename.split(\".\").first.sub(/^_/, \"\")\n end",
"def process(name)\n # ignore directory\n name = File.basename(name)\n self.ext = File.extname(name)\n self.basename = name[0 .. -self.ext.length-1]\n self.basename.gsub!(/\\.#{@lang}/, '') unless @lang.empty?\n end",
"def sanitize_filename\n name = self.strip\n #--- get only the filename, not the whole path\n name.gsub! /^.*(\\\\|\\/)/, ''\n\n #--- Finally, replace all non alphanumeric, underscore or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n return name\n end",
"def file_name\n \"#{name.downcase.gsub(/\\s/, '')}.jpg\"\n end",
"def get_tourney_name(id)\n output = \"\"\n File.open(\"#{get_tourney_dir(id)}/tourneyinfo\", \"r\") do |f|\n output = f.read.split(\"\\n\")[0].split(\":\")[1].gsub(\" \", \"\").downcase\n end\n return output\nend",
"def parse_name\n name = ''\n content = file_content\n\n s = content.index(NAME_START_DELIMITER)\n e = content.index(NAME_END_DELIMITER)\n\n unless s.nil?\n s += NAME_START_DELIMITER.size\n name = content[s..e-1].strip\n end\n\n return name\n end",
"def copy_name_to_lowercase_name\n self.lowercase_name = File.basename(self.github_url.to_s).presence || name.to_s.downcase.parameterize\n end",
"def extract_file_name(diff_file_name)\n file_name = diff_file_name.to_s.split(\"/\")\n # Remove the first part of \"--- a\"\n file_name.shift\n # Re-join the remaining parts\n file_name = file_name.join('/')\n return file_name\n end",
"def new_file name\n raise \"Not a Valid Directory\" unless valid_directory?\n\n file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}_#{name}.txt\"\n \"#{output_directory_path}#{file_name}\"\n end",
"def file_name(s)\n s.gsub(/[\\s\\\\\\/]/, '_')\n end",
"def name\n @name ||= File.basename(path)\n end",
"def name\n @name ||= File.basename(path)\n end",
"def path_to_name(path, prefix='')\n #return nil if file.to_s.index(/[.]/) # TODO: rejection filter\n path = path.to_s\n path = path.sub(prefix.to_s.chomp('/') + '/', '')\n #path = path.gsub('/', '_')\n path\n end",
"def name\n path.gsub(/\\./,'_').gsub(%r{/}, '.').gsub(%r{(^\\.|\\.$)},'')\n end",
"def prepare_name(name)\n name.to_s.upcase\n end",
"def name_to_dir(name)\n s = \"\"\n name.each_char do |c|\n if (c =~ /[-A-Za-z0-9_|\\[\\]]/) != nil\n s += c\n else\n c2 = TAG_NAME_MAP[c]\n if not c2\n msg = \"Bad character '#{c}' in tag '#{name}'\"\n puts(\"*** #{msg}\")\n raise Exception.new(msg)\n end\n s += \"#{c2}\"\n end\n end\n s\n end",
"def to_name\n basename.to_s.sub extname, ''\n end",
"def get_raw_filename (file)\n\t\n\t\t# convert to string\n\t\tfile = get_filename(file)\n\t\t# remove extension\n\t\tfile.sub(get_ext(file), \"\")\n\t\t\n\tend",
"def split_name(name)\n file_name = File.basename(name)\n mres = /^([^\\/\\.]+)\\.(.+)$/i.match(file_name)\n mres.nil? ? [file_name, ''] : [mres[1], mres[2]]\n end",
"def file_to_pagename(filename)\n\t\tfilename.chomp(\".md\").gsub('_', ' ').capitalize\n\tend",
"def file_to_pagename(filename)\n\t\tfilename.chomp(\".md\").gsub('_', ' ').capitalize\n\tend",
"def get_lowercase_name(file_path)\n filename = File.basename(file_path)\n basedir = File.dirname(file_path)\n\n # Make sure the file is all lowercase, for consistency\n filename.downcase!\n new_path = File.join(basedir, filename)\n file_path = new_path\n\n return file_path\nend",
"def translate_name(name)\nreversed_name = name.split(' ').reverse\nnew_first = reversed_name[0].chars.map {|x|\n x.next\n }\nnew_last = reversed_name[1].chars.map {|x|\n x.next\n }\nnew_name = \"#{new_first.join} #{new_last.join}\"\nend",
"def projectizeName(filename)\n return ApplicationController.projectizeName(filename)\n end",
"def to_title(file)\n # Strip .md if it exists\n title = file.gsub(/.md$/, '')\n\n title = title.gsub(/-/, ' ')\n title = title.gsub(/([A-Z][a-z])/, ' \\1').strip\n title = title.split.map { |word| word[0].upcase+word[1..99999] }.join(' ')\n return title\n end",
"def normalize_filename(locality)\n return locality.gsub!(/[^0-9A-Za-z.\\-]/, '_')\n end",
"def to_title(file_slug)\n file_slug.gsub(/[^\\p{Word}+]/u, ' ').gsub(/\\b\\w/){$&.upcase}\n end",
"def nameparts(f)\n File.basename(f).scan(/([^_]+)_([\\d]+)([^\\.]*)/)[0]\nend",
"def name\n @name ||= File.basename(path)\n end",
"def name = (name)",
"def sanitize_as_filename\n self.gsub(/^.*(\\\\|\\/)/, '').transliterate.downcase.gsub(/[^a-z0-9\\. ]/, ' ').strip.gsub(/[ ]+/, '-')\n end",
"def sanitize_filename(file_name)\r\n\t\tjust_filename = File.basename(file_name)\r\n\t\tjust_filename.sub(/[^\\w\\.\\-]/, '_')\r\n\tend",
"def normalize(name); end",
"def name\n @name ||= ::File.basename(@path)\n end",
"def normalize(filename)\n str_strip(filename) + \".html\"\n end",
"def fix_name(title)\n result = String.new( title )\n # Replace all invalid characters\n for substitution in $INVALID_CHARS_FOR_FILENAME\n result.gsub!(substitution[0], substitution[1])\n end\n result\nend",
"def basename_to_title(basename)\n basename.gsub(/[\\-_]/, \" \").capitalize\n end",
"def normalised_name(path)\n path == '/' ? '/' : File.basename(path)\n end",
"def normalize_name(name, prefix)\n handlers = Template::Handlers.extensions.join('|')\n name = name.to_s.gsub(/\\.(?:#{handlers})$/, '')\n\n parts = name.split('/')\n return parts.pop, [prefix, *parts].compact.join(\"/\")\n end",
"def parse_name_file file\r\n #name_file = \"#{@giorno_flusso}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".xml\" \r\n name_file = case file\r\n when /OffertePubbliche/ then \"#{@giorno}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".zip\" \r\n when /MGP/ then \"#{@giorno}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".xml\" \r\n when /MI1/ then \"#{@giorno}\" + \"#{file.gsub \"MI1_\",\"MI1\"}\" + \".xml\"\r\n when /MI2/ then \"#{@giorno}\" + \"#{file.gsub \"MI2_\",\"MI2\"}\" + \".xml\"\r\n when /MI3/ then \"#{@giorno}\" + \"#{file.gsub \"MI3_\",\"MI3\"}\" + \".xml\" \r\n when /MI4/ then \"#{@giorno}\" + \"#{file.gsub \"MI4_\",\"MI4\"}\" + \".xml\" \r\n when /MI5/ then \"#{@giorno}\" + \"#{file.gsub \"MI5_\",\"MI5\"}\" + \".xml\" \r\n end\r\n name_file\r\n end",
"def build_converted_file_name(source, from_lang, to_lang)\n # Get components of filename\n dirname = File.dirname(source)\n basename = File.basename(source, \".*\")\n extname = File.extname(source)\n\n # Blank out the from language\n basename.sub! Regexp.new(\"_#{from_lang}\", \"i\"), \"\"\n \n \"#{dirname}/#{basename}_#{to_lang}#{extname}\"\n end",
"def main_name(path)\n File.basename(path).sub(/\\.[^\\.]+$/,'')\n end",
"def normalize_name(name)\n return name.to_s if !name.is_a?(String) && !name.is_a?(MatchData)\n name = name.captures.compact.join('-') if name.is_a?(MatchData)\n name.split('-').map { |s| s[/\\A[0-9]\\Z/].nil? ? s : \"0#{s}\" }.join('-').upcase\nrescue\n name.to_s\nend",
"def mangle_name(name)\r\n name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').gsub(/([a-z\\d])([A-Z])/,'\\1 \\2')\r\n end",
"def get_filename(line)\n parts = line.split(\" \")\n filename_b = parts[3]\n filename_b[2..-1]\n end",
"def get_name(path_name)\n resume_file_name = path_name.downcase.split('/').last\n # Replace 'resume' with whatever comes after the name in that folder\n end_index = resume_file_name.index('resume')\n # This is for the nonanalytics folder\n # first_index = resume_file_name.index(\"_\")\n # end_index = resume_file_name.index('_', first_index + 1)\n name = resume_file_name[0, end_index - 1]\n return name\nend",
"def file_name(name)\r\n return name.to_s.downcase + '.rb' if name.kind_of?(Symbol)\r\n return ext_name(name).downcase + '.rb'\r\n end",
"def sanitize_filename(value)\n # get only the filename, not the whole path\n just_filename = value.gsub(/^.*(\\\\|\\/)/, '')\n # Finally, replace all non alphanumeric, underscore or periods with underscore\n just_filename.gsub(/[^\\w\\.\\-]/,'_') \n end",
"def object_name\n @name ||= File.split(@source_path).last.gsub('.txt', '')\n end",
"def basename(name)\n if name =~ /.*\\/(.*)/\n name = $1\n end\n name\n end",
"def generate_file_name\n file_name = attachment.instance_read(:file_name).slugged_filename\n attachment.instance_write :file_name, file_name\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def format_name(name)\n name.split(' ').join('_')\n end",
"def create_file_name(name)\r\n if name.match(/(.*)\\.([^\\.]*)/)\r\n fname, fext = $1, $2\r\n else\r\n fname, fext = name, \"dat\"\r\n end\r\n fname = fname.slugerize\r\n fext = fext.slugerize\r\n hash = Time.now.usec % 814949\r\n return \"#{hash.to_s(16)}_#{fname}.#{fext}\"\r\n end",
"def filename\n return @filename if @filename\n name.downcase.gsub(/\\W/, '_').squeeze('_')\n end",
"def name_to_verilog(name)\n # name = name.to_s\n # # Convert special characters.\n # name = name.each_char.map do |c|\n # if c=~ /[a-z0-9]/ then\n # c\n # elsif c == \"_\" then\n # \"__\"\n # else\n # \"_\" + c.ord.to_s\n # end\n # end.join\n # # First character: only letter is possible.\n # unless name[0] =~ /[a-z_]/ then\n # name = \"_\" + name\n # end\n # return name\n name = name.to_s\n vname = @@hdr2verilog[name]\n unless vname then\n # Shall we change the string?\n if name.match?(/^[_a-zA-Z][_a-zA-Z0-9]*$/) then\n # No, just clone\n vname = name.clone\n else\n # Yes, ensure it is a verilog-compatible name.\n vname = \"_v#{@@hdr2verilog.size}_#{name.split(/[^a-zA-Z_0-9]/)[-1]}\"\n end\n @@hdr2verilog[name] = vname\n end\n return vname\n end",
"def scrubbed_name\n extension = @fileName.split(\".\")[@fileName.split(\".\").length-1]\n \n if @season.to_i < 10\n season_string = \"S0{#@season}\"\n else\n season_string = \"S#{@season}\"\n end\n \n if @episode.to_i < 10\n episode_string = \"E0#{@episode}\"\n else\n episode_string = \"E#{@episode}\"\n end \n \n [@name.gsub(\" \",\".\"),[season_string,episode_string].join(\"\"),extension].join(\".\")\n end",
"def name\n ::File.basename(path)\n end",
"def format_name(name)\n names = name.split(\" \")\n formatted_names = []\n names.each do |singleName|\n singleName = singleName.downcase\n singleName[0] = singleName[0].upcase\n formatted_names << singleName\n end\n return formatted_names.join(\" \")\nend",
"def base_part_of(file_name)\n name = File.basename(file_name)\n name.gsub(/[^\\w._-]/, '')\n end",
"def base_part_of(file_name)\n name = File.basename(file_name)\n name.gsub(/[^\\w._-]/, '')\n end",
"def name_to_dir(name)\n name.gsub(/[^-A-Za-z0-9_|\\[\\]]/, \"_\")\n end",
"def file_name\n File.basename(file_path)\n end",
"def to_initials(name)\n parts = name.split(\" \")\n initials = \"\"\n parts.each { |part| initials += part[0] }\n return initials\nend",
"def file_names(b_name)\n array = b_name.chars\n array.map! do |letter|\n letter = '_' if letter == ' '\n letter\n end\n array.join\nend",
"def path_and_name(path)\n match = path.match(/(.+)\\/(.+$)/)\n [match[1], match[2].split('.').max_by(&:length).underscore.humanize.titlecase]\n end",
"def to_title(file_slug)\n if file_slug == 'index' && !@pointer['id'].index('/').nil?\n file_slug = @pointer['id'].split('/')[-2]\n end\n\n file_slug.gsub(/[^\\p{Word}+]/u, ' ').gsub(/\\b\\w/){$&.upcase}\n end",
"def generate_name_target(opts={})\n # check if file already renamed to YYYYMMDD-hhss-AAA[AAA] format\n if (/^(\\d{8}-\\d{4}_\\w{3,6}_)(.*)/ =~ @name)\n name_clean = $2 \n # check if file already renamed in YYYYMMDD-hhss format \n elsif (/^(\\d{8}-\\d{4}_)(.*)/ =~ @name) \n name_clean = $2\n # for all others just rename\n else\n name_clean = @name\n end\n return opts[:date_time_original].strftime('%Y%m%d-%H%M')+\"_#{opts[:author_nikname]}_#{name_clean}\" \n end",
"def _prepareName ( name )\n name.to_s.gsub /[\\W]/, ''\n end",
"def sanitized_filename(filename)\n filename.strip.tap do |name|\n # NOTE: File.basename doesn't work right with Windows paths on Unix\n # get only the filename, not the whole path\n name.sub! /\\A.*(\\\\|\\/)/, ''\n # Finally, replace all non alphanumeric, underscore\n # or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n end\n end",
"def get_trunc_name name\n name[0..3].downcase\n end"
] | [
"0.6706654",
"0.6523925",
"0.6345981",
"0.62749",
"0.62706864",
"0.6213187",
"0.6210752",
"0.62034154",
"0.61876065",
"0.6168698",
"0.6168698",
"0.6151321",
"0.6125011",
"0.6112734",
"0.6105802",
"0.60909456",
"0.6074677",
"0.6055076",
"0.60114884",
"0.5935425",
"0.5928453",
"0.5925673",
"0.590461",
"0.5902956",
"0.58912456",
"0.58811224",
"0.58758193",
"0.58552027",
"0.58467644",
"0.584345",
"0.5829877",
"0.5812646",
"0.58020806",
"0.57996565",
"0.5790652",
"0.5785451",
"0.57706845",
"0.57639027",
"0.57579356",
"0.5753255",
"0.5743646",
"0.5743646",
"0.57427216",
"0.5738263",
"0.57287514",
"0.57198757",
"0.57018185",
"0.5672887",
"0.5655624",
"0.56528884",
"0.56528884",
"0.5638395",
"0.56377167",
"0.563488",
"0.5627106",
"0.56180286",
"0.56000066",
"0.55921775",
"0.557935",
"0.55746996",
"0.5572484",
"0.55679846",
"0.556185",
"0.5549891",
"0.55495065",
"0.5547406",
"0.553944",
"0.553784",
"0.5533139",
"0.55286837",
"0.55097204",
"0.5509055",
"0.55042315",
"0.54988676",
"0.54987556",
"0.5485102",
"0.5483257",
"0.546902",
"0.54556984",
"0.54511625",
"0.5449738",
"0.5449728",
"0.5449728",
"0.5447247",
"0.5441591",
"0.54298306",
"0.54255944",
"0.54224133",
"0.54176444",
"0.5416486",
"0.5416486",
"0.5414248",
"0.54095495",
"0.5406684",
"0.5406301",
"0.5404319",
"0.5403799",
"0.54016966",
"0.5400909",
"0.53962755",
"0.538479"
] | 0.0 | -1 |
Runs a specified shell command in a separate thread. If it exceeds the given timeout in seconds, kills it. Returns any output produced by the command (stdout or stderr) as a String. Uses Kernel.select to wait up to the tick length (in seconds) between checks on the command's status If you've got a cleaner way of doing this, I'd be interested to see it. If you think you can do it with Ruby's Timeout module, think again. | def run_with_timeout(command, timeout, tick)
output = ''
begin
# Start task in another thread, which spawns a process
stdin, stderrout, thread = Open3.popen2e(command)
# Get the pid of the spawned process
pid = thread[:pid]
start = Time.now
while (Time.now - start) < timeout and thread.alive?
# Wait up to `tick` seconds for output/error data
Kernel.select([stderrout], nil, nil, tick)
# Try to read the data
begin
output << stderrout.read_nonblock(4096)
rescue IO::WaitReadable
# A read would block, so loop around for another select
rescue EOFError
# Command has completed, not really an error...
break
end
end
# Give Ruby time to clean up the other thread
sleep 1
if thread.alive?
# We need to kill the process, because killing the thread leaves
# the process alive but detached, annoyingly enough.
Process.kill("TERM", pid)
end
ensure
stdin.close if stdin
stderrout.close if stderrout
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_with_timeout(command, timeout, tick)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(4096)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 0.1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n output = \"Process timed out\"\n end\n ensure\n stdin.close if stdin\n stderrout.close if stderrout\n end\n return output\n end",
"def run_with_timeout(directory, command, timeout, tick)\n output = \"\"\n exit_code = 1\n\n Open3.popen2e(command, chdir: directory) do |_stdin, stderrout, thread|\n pid = thread.pid\n\n start = Time.now\n while ((Time.now - start) < timeout) && thread.alive?\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(BUFFER_SIZE)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n exit_code = wait_thread.value\n break\n end\n\n sleep(0.5)\n end\n\n exit_code = wait_thread.value\n\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n exit_code = 5\n end\n end\n\n [output, exit_code]\nend",
"def run_with_timeout(command, target_output, timeout = SOLVER_TIMEOUT, tick = 0.5)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n print '.'\n\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(BUFFER_SIZE)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n output = 'SHIT'\n break\n end\n\n break if target_output =~ output\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n end\n ensure\n stdin.close if stdin\n stderrout.close if stderrout\n end\n return output\nend",
"def run_with_timeout(command, timeout, tick, inputs)\n output = ''\n output_error = []\n begin\n # Start task in another thread, which spawns a process\n stdin, stdout, stderr, thread = Open3.popen3(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n inputs.each{|i| stdin.puts(i)}\n \n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stdout], nil, nil, tick)\n # Try to read the data\n begin\n output << stdout.read_nonblock(4096)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n \n \n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n print \"gets here\"\n return nil\n end\n stderr.each{|x| output_error << x}\n ensure\n stderr.close if stderr\n stdin.close if stdin\n stdout.close if stdout\n end\n return [output, output_error]\n end",
"def run_with_timeout(env, command, timeout=60*60*4, tick=2)\n out = \"\"\n err = \"\"\n begin\n # Start task in another thread, which spawns a process\n stdin, stdout, stderr, thread = Open3.popen3(env, command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n rs, = Kernel.select([stdout, stderr], nil, nil, tick)\n # Try to read the data\n begin\n if !rs.nil?\n rs.each { |r|\n if r == stdout\n out << stdout.read_nonblock(4096)\n elsif r == stderr \n err << stderr.read_nonblock(4096)\n end\n }\n end\n\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n end\n ensure\n stdin.close if stdin\n stdout.close if stdout\n stderr.close if stderr\n end\n return out.force_encoding(\"UTF-8\"), err.force_encoding(\"UTF-8\"), thread.value\nend",
"def with_timeout(cmd, timeout)\n\n\n # popen2e combines stdout and stderr into one IO object\n i, oe, t = Open3.popen2e(cmd) # stdin, stdout+stderr, thread\n t[:timed_out] = false\n i.close\n\n # Purposefully NOT using Timeout.rb because in general it is a dangerous API!\n # http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html\n Thread.new do\n sleep timeout\n if t.alive?\n suppress(Errno::ESRCH) do # 'No such process' (possible race condition)\n # NOTE: we are assuming the command will create ONE process (not handling subprocs / proc groups)\n Process.kill('TERM', t.pid)\n t[:timed_out] = true\n end\n end\n end\n\n t.value # wait for process to finish, one way or the other\n out = oe.read(10000)\n out = \"*** Empty output ***\" if out.nil?\n oe.close\n\n if t[:timed_out]\n out << \"\\n\" unless out.blank?\n out << \"*** Process failed to complete after #{timeout} seconds ***\"\n end\n\n out\n end",
"def exec_with_timeout(cmd, timeout)\n begin\n # stdout, stderr pipes\n rout, wout = IO.pipe\n rerr, werr = IO.pipe\n stdout, stderr = nil\n status = false\n\n pid = Process.spawn(*cmd, pgroup: true, :out => wout, :err => werr)\n\n Timeout.timeout(timeout) do\n Process.waitpid(pid)\n # close write ends so we can read from them\n wout.close\n werr.close\n\n stdout = rout.readlines.join\n stderr = rerr.readlines.join\n status = true\n end\n\n rescue Timeout::Error\n # Try to determine why the kill does not tidy the chrome processes\n # Also whether a kill was actually issued!\n puts \"WARN: timeout scanning #{cmd[-1]} #{pid}\"\n $stderr.puts \"WARN: #{Time.now} timeout scanning #{cmd[-1]} #{pid}\"\n stderr = 'Timeout'\n # try using less drastic kill\n Process.kill(-2, pid) # INT\n Process.kill(-15, pid) # TERM\n Process.detach(pid)\n ensure\n wout.close unless wout.closed?\n werr.close unless werr.closed?\n # dispose the read ends of the pipes\n rout.close\n rerr.close\n end\n return stdout, stderr, status\nend",
"def run_command(command, timeout)\n Open3.popen2(command, :pgroup=>true) do |_, stdout, wait_thr|\n pid = wait_thr.pid\n pgid = Process.getpgid(pid)\n @omicli_pgids << pgid\n deadline = Time.now + timeout\n sleep 0.5 until Time.now > deadline or !wait_thr.status\n if wait_thr.status\n begin\n `pkill -TERM -g #{pgid}`\n sleep 1\n if wait_thr.status\n `pkill -KILL -g #{pgid}`\n end\n rescue => e\n log_error(\"Failed to kill process(es) for command '#{command}'. #{e}\")\n end\n OMS::Log.error_once(\"Telemetry failed with process timeout '#{command}'\")\n @omicli_pgids.pop\n return ''\n else\n @omicli_pgids.pop\n return stdout.read\n end\n end\n end",
"def timeboxed2(*cmd, timeout: 1.0, term_timeout: 1.0, **opts)\n result = \"\"\n deadline = Time.now + timeout\n status = Open3.popen2(*cmd, **opts) do |_, out, waiter|\n until out.closed?\n if deadline < Time.now\n kill_gracefully(waiter, timeout: term_timeout)\n break\n end\n\n begin\n result << out.read_nonblock(4096)\n rescue EOFError # instead of checking out.eof? because that may block!\n break\n rescue IO::WaitReadable\n if (remaining = deadline - Time.now) >= 0\n IO.select([out], [], [], remaining).nil?\n end\n end\n end\n waiter.value\n end\n [result, status]\nend",
"def run(s, maxt = 10*60, errorIsOnStdout=false)\n begin\n pid, cmdin, cmdout, cmderr = Open4.popen4(s)\n rescue Exception => e\n $stderr << 'Execution of '+s+' has failed :' + e.to_s\n raise \"run failed\"\n end\n\n begin\n Timeout::timeout(maxt) do |t|\n a = Process.waitpid2(pid)\n if a[1].exitstatus != 0\n $stderr << 'Error while executing ' + s\n errorMessage = (errorIsOnStdout ? cmdout.read : cmderr.read)\n raise errorMessage.gsub(/\\n/, ' ')\n end\n end\n rescue Timeout::Error => e\n $stderr << 'Execution of '+s+' has timed out. Killing subprocess'\n begin\n Process.kill('KILL', pid)\n cmdout.close; cmdin.close; cmderr.close\n rescue Object => e\n $stderr << 'Failed killing process : ' + e.to_s\n end\n raise \"timeout\"\n end\n\n out = cmdout.read\n cmdout.close; cmdin.close; cmderr.close\n out\nend",
"def run_command(command, options={})\n timeout = options[:timeout] || 7200\n\n # default to adding a nice 13 if nothing specified\n nice = if options.key?(:nice)\n (options[:nice] == 'n') ? '' : \"nice -n #{options[:nice]} \"\n else\n 'nice -n 19 '\n end\n\n echo_return = (options.key?(:echo_return) && !options[:echo_return]) ? '' : '; echo $?'\n\n cmd = \"#{nice}#{command}#{echo_return}\"\n\n logger.info \"run_command: #{cmd}\"\n begin\n result = Timeout::timeout(timeout) {\n Open3::popen3(cmd) do |i,o,e|\n out_str = \"\"\n err_str = \"\"\n i.close # important!\n o.sync = true\n e.sync = true\n o.each{|line|\n out_str << line\n line.chomp!\n logger.debug \"stdout: #{line}\"\n }\n e.each { |line|\n err_str << line\n line.chomp!\n logger.debug \"stderr: #{line}\"\n }\n return out_str, err_str\n end\n }\n rescue Timeout::Error => toe\n logger.error \"run_command:Timeout Error - running command, took longer than #{timeout} seconds to execute: '#{cmd}'\"\n raise toe\n end\n end",
"def exec_cmd_in_context(command, timeout = nil, environment = {})\n timeout ||= 600\n environment = Hash[ environment.map{ |k, v| [k.to_s, v.to_s] } ]\n environment['LC_ALL'] = ENV['LC_ALL'] unless environment.key?('LC_ALL')\n\n @logger.info(\"Executing: '#{command}'\")\n @logger.debug(\"\\n\\ttimeout: #{timeout}\\n\\tenvironment: #{environment}\")\n\n shell_out = Mixlib::ShellOut.new(\n command, timeout: timeout, environment: environment)\n shell_out.live_stream = STDOUT\n\n shell_out.run_command\n shell_out.invalid! if shell_out.exitstatus != 0\n @logger.info(shell_out.stdout)\n shell_out.stdout.split(\"\\n\")\n end",
"def shell_command(cmd)\n # Send the command to the session's stdin.\n shell_write(cmd + \"\\n\")\n\n timeo = 5\n etime = ::Time.now.to_f + timeo\n buff = \"\"\n\n # Keep reading data until no more data is available or the timeout is\n # reached.\n while (::Time.now.to_f < etime and (self.respond_to?(:ring) or ::IO.select([rstream], nil, nil, timeo)))\n res = shell_read(-1, 0.01)\n buff << res if res\n timeo = etime - ::Time.now.to_f\n end\n\n buff\n end",
"def execute_cmd(cmd, timeout = new_resource.cmd_timeout)\n Chef::Log.debug('Executing: ' + cmd)\n begin\n shell_out(cmd, :timeout => timeout)\n rescue Mixlib::ShellOut::CommandTimeout\n raise CommandTimeout, command_timeout_error_message\n end\n end",
"def exec!(command, timeout=nil)\n logger.info(\"Executing: #{command}\")\n stderr,stdout = '', ''\n stdout, stderr = timeout_execution(timeout, \"exec!(#{command})\") do\n @connection_pool.exec(command)\n end\n logger.info(\"STDERR: #{stderr}\") unless stderr.empty?\n logger.info(\"STDOUT: #{stdout}\") unless stdout.empty?\n logger.info(\"Executing done\")\n stdout\n end",
"def shell_command(cmd, timeout = 1800)\n # insert random marker\n strm = Rex::Text.rand_text_alpha(15)\n endm = Rex::Text.rand_text_alpha(15)\n\n # Send the shell channel's stdin.\n shell_write(\";'#{strm}'\\n\" + cmd + \"\\n'#{endm}';\\n\")\n\n etime = ::Time.now.to_f + timeout\n\n buff = \"\"\n # Keep reading data until the marker has been received or the 30 minture timeout has occured\n while (::Time.now.to_f < etime)\n res = shell_read(-1, timeout)\n break unless res\n timeout = etime - ::Time.now.to_f\n\n buff << res\n if buff.include?(endm)\n # if you see the end marker, read the buffer from the start marker to the end and then display back to screen\n buff = buff.split(/#{strm}\\r\\n/)[-1]\n buff = buff.split(endm)[0]\n buff.gsub!(/(?<=\\r\\n)PS [^>]*>/, '')\n return buff\n end\n end\n buff\n end",
"def execute_cmd(cmd, timeout = new_resource.cmd_timeout)\n Chef::Log.debug('Executing: ' + cmd)\n begin\n shell_out(cmd, :timeout => timeout)\n rescue Mixlib::ShellOut::CommandTimeout\n raise CommandTimeout, command_timeout_error_message(cmd)\n end\n end",
"def execute\n begin\n rout, wout = IO.pipe\n rerr, werr = IO.pipe\n stdout, stderr = nil\n\n pid = Process.spawn(command_line, :pgroup => true, :out => wout, :err => werr)\n Timeout.timeout(timeout) do\n Process.wait(pid)\n\n wout.close\n werr.close\n\n stdout = rout.readlines.join\n stderr = rerr.readlines.join\n end\n rescue Timeout::Error\n Process.kill(-9, pid)\n Process.detach(pid)\n ensure\n wout.close unless wout.closed?\n werr.close unless werr.closed?\n\n rout.close\n rerr.close\n end\n stdout\n end",
"def execute_shell_with_retry(command, shell, &block)\n retryable(:tries => @max_tries, :on => EXCEPTIONS, :sleep => 10) do\n @logger.debug(\"#{shell} executing:\\n#{command}\")\n begin\n output = session.send(shell, command) do |out, err|\n block.call(:stdout, out) if block_given? && out\n block.call(:stderr, err) if block_given? && err\n end\n rescue Exception => ex\n raise Timeout::Error if ex.message =~ /execution expired/ # received not friendly timeout, raise a more friendly error\n raise # didn't include execution expired, so raise for retryable to handle\n end\n @logger.debug(\"Output: #{output.inspect}\")\n return output\n end\n end",
"def non_blocking_operation ( msg_value = nil, cmd_value= \"\", timeout_value = 600, force = false)\r\n\t$log.info(\"Running '#{msg_value}'\" + \"\\t...\") if !msg_value.nil?\r\n\t$pid = nil\r\n\texit_status = nil\r\n\t$log.info(\"#{cmd_value}\")\r\n\tbegin\r\n\t\tTimeout.timeout(timeout_value) do\r\n\t\t\tstdin, stdout_err, wait_thr = Open3.popen2e(cmd_value)\r\n\t\t\t$pid = wait_thr.pid\r\n\t\t\tstdin.close\r\n\t\t\twhile line = stdout_err.gets\r\n\t\t\t\t$log.info(line)\r\n\t\t\tend\r\n\t\t\tstdout_err.close\r\n\t\t\texit_status = wait_thr.value\r\n\t\tend\r\n\trescue Timeout::Error\r\n\t\t$log.error(\"Process Timeout Error!\")\r\n\t\t$log.error(\"Killing Process...\")\r\n\t\tProcess.kill 9, $pid\r\n\t\tProcess.wait $pid\r\n\t\t$log.error(\"Process Killed!\")\r\n\trescue StandardError => e\r\n\t\tputs \"Rescued: #{e.inspect}\"\r\n\tend\r\n\r\nend",
"def popen_with_timeout(cmd, timeout=DEFAULT_PROCESS_TIMEOUT, path=\"/tmp\")\n raise \"Commands must be provided as an array of strings\" unless cmd.is_a?(Array)\n\n # inherit our environment\n vars = ENV\n\n # save the current working directory\n vars['PWD'] = path\n \n FileUtils.mkdir_p(path) unless File.directory?(path)\n\n begin\n # Create pipes we can read \n rout, wout = IO.pipe\n rerr, werr = IO.pipe\n\n pid = Process.spawn(vars, *cmd, out: wout, err: werr, chdir: path, pgroup: true)\n # stderr and stdout pipes can block if stderr/stdout aren't drained: https://bugs.ruby-lang.org/issues/9082\n # Mimic what Ruby does with capture3: https://github.com/ruby/ruby/blob/1ec544695fa02d714180ef9c34e755027b6a2103/lib/open3.rb#L257-L273\n out_reader = Thread.new { rout.read }\n err_reader = Thread.new { rerr.read }\n \n # close write ends so we could read them\n wout.close\n werr.close\n \n # wait for completion\n status = process_wait_with_timeout(pid, timeout)\n\n # Don't copy `popen` which merges stderr into output\n cmd_output = out_reader.value\n err_output = err_reader.value \n \n # return stdout, stderr and exit status\n [cmd_output, err_output, status.exitstatus]\n \n rescue Errno::ENOENT => e\n raise SystemResourceMissing, e\n\n rescue TimeoutError => e\n kill_process_group_for_pid(pid)\n raise e\n \n ensure\n wout.close unless wout.closed?\n werr.close unless werr.closed?\n\n # rout is shared with out_reader. To prevent an exception in that\n # thread, kill the thread before closing rout. The same goes for rerr\n # below.\n out_reader.kill if out_reader\n rout.close\n\n err_reader.kill if err_reader\n rerr.close\n end\n end",
"def get_cmd(command,sleep_time,timeout,tries)\n msg=''\n ret=tries\n success=nil\n if(not(ret))\n ret=1\n end\n $queue.synchronize do\n $rx_messages.clear()\n end\n while(ret>0 and (not(success)))\n ret=ret-1\n $serial_port.synchronize do\n $serialport.write(command)\n end\n now=Time.now().to_f\n while((not(success)) and Time.now().to_f-now<=timeout)\n $queue.synchronize do\n if($rx_messages.length>0)\n msg=$rx_messages.pop()\n success=true\n end\n end\n sleep(0.1)\n end\n end\n if(success)\n sleep(sleep_time)\n return(msg)\n else\n return(nil)\n end\nend",
"def run_command(command, options={})\n timeout = options[:timeout] || 7200\n \n # default to adding a nice 19 if nothing specified\n nice = if options.key?(:nice)\n !options[:nice] ? '' : \"nice -n #{options[:nice].to_i} \"\n else\n 'nice -n 19 '\n end\n \n echo_return = (options.key?(:echo_return) && !options[:echo_return]) ? '' : '; echo $?'\n \n cmd = \"#{nice}#{command}#{echo_return}\"\n \n # logger.info \"google_speech - run_command: #{cmd}\"\n begin\n result = Timeout::timeout(timeout) {\n Open3::popen3(cmd) do |i,o,e|\n out_str = \"\"\n err_str = \"\"\n i.close # important!\n o.sync = true\n e.sync = true\n o.each{|line|\n out_str << line\n line.chomp!\n # logger.debug \"stdout: #{line}\"\n }\n e.each { |line| \n err_str << line\n line.chomp!\n # logger.debug \"stderr: #{line}\"\n }\n return out_str, err_str\n end\n }\n rescue Timeout::Error => toe\n # logger.debug \"run_command:Timeout Error - running command, took longer than #{timeout} seconds to execute: '#{cmd}'\"\n raise toe\n end\n end",
"def run(cmd)\n rtn = nil\n\n Open3.popen3(cmd) do |_, o, e, t|\n out_reader = Thread.new { o.read }\n err_reader = Thread.new { e.read }\n\n rtn = [out_reader.value, err_reader.value, t.value]\n end\n\n rtn\nend",
"def sys(str, log = nil)\n puts [str, log && log.color(:yellow)].compact.join(' > ')\n\n cmd = [str, log].compact.join(' > ')\n\n pid = Process.spawn(cmd)\n begin\n Timeout::timeout(TIMELIMIT) do\n Process.wait(pid)\n end\n rescue Timeout::Error\n puts \"command out of time, re-Run\".bright\n system(\"pkill -TERM -P #{pid}\")\n sys(str, log)\n end\nend",
"def run_simple(cmd, fail_on_error = true, exit_timeout = nil, io_wait_timeout = nil)\n command = run(cmd, exit_timeout, io_wait_timeout)\n @last_exit_status = process_monitor.stop_process(command)\n\n @timed_out = command.timed_out?\n\n if fail_on_error\n expect(command).to have_finished_in_time\n expect(command).to be_successfully_executed\n end\n end",
"def launch_command(command, description)\n puts \"Je lance #{command}\"\n @log_file.puts \"\\n============================================\"\n @log_file.puts \"Lancement du test #{description}\"\n @log_file.puts '============================================'\n\n begin\n Timeout::timeout(@delay_before_timeout) { @log_file.puts `#{command}` }\n rescue Timeout::Error\n # TODO: in this case, a zombie shell still exists. How to remove it?\n `killall memcheck-x86-li`\n puts \"*** Test arrêté, exécution trop longue (> #{@delay_before_timeout} sec) ***\"\n @log_file.puts \"*** Test arrêté, exécution trop longue (> #{@delay_before_timeout} sec) ***\"\n end\n end",
"def time_exec(command)\n res = `(/usr/bin/time #{command}) 3>&1 1>/dev/null 2>&3`\n raise \"Expected '#{command}' to run successfully\" unless $?.success?\n\n regex = (RUBY_PLATFORM =~ /linux/) \\\n ? /.*([\\d\\.]{5,})elapsed.*/ \\\n : /.*([\\d\\.]{4,}) real.*/\n regex.match(res) { |md| return md[1].to_f * 1000 }\n\n raise \"Timing '#{command}' failed\"\nend",
"def exec(command)\n cmd = Open3.popen3(command) do |i, o, e|\n i.close\n t0 = Thread.new do\n o.each_line do |line|\n $stdout.puts \" \" << line\n end\n end\n t1 = Thread.new do\n e.each_line do |line|\n $stderr.puts \" \" << line\n end\n end\n t0.join\n t1.join\n end\n end",
"def sh command, sleep_interval = nil, attempts = 3\n # success=%x(#{command} 1> /dev/null)\n success = Open3.popen3(\"#{command}\") do |stdin, stdout, stderr, wait_thr|\n wait_thr.value.success?\n end\n if attempts > 1\n unless success\n sleep sleep_interval if sleep_interval\n sh command, sleep_interval, attempts-1\n end\n else\n raise RuntimeError, \"Failed to execute [ #{command} ]\" unless success\n end\nend",
"def set_timeout timeout\r\n command 'setTimeout', timeout\r\n end",
"def set_timeout timeout\r\n command 'setTimeout', timeout\r\n end",
"def timeout_cli\n @cli_executor.timeout_cli\n end",
"def timeout_cli\n @cli_executor.timeout_cli\n end",
"def run_once(command, timeout = nil)\n exec!(command,timeout) \n rescue NoFreeConnectionError => ex\n ex\n end",
"def command_interactive(cmd)\n puts String.starline.blue\n puts (\"$ #{cmd}\".blue + \" 2>&1\".yellow)\n\n stdout_empty = true\n \n start = Time.now\n begin\n PTY.spawn( cmd ) do |stdin, stdout, pid|\n begin\n puts \"* * STDOUT & STDERR\".starfill.blue\n stdin.each { |line| \n stdout_empty = false\n puts \" * \".blue + line\n }\n rescue Errno::EIO\n end\n Process.wait(pid)\n end\n rescue PTY::ChildExited\n puts \" * Strange, the child process exited...\".starsaround.red\n end\n finish = Time.now\n\n puts \" * \".blue + \"STDOUT: none\".black if stdout_empty\n\n diff = finish - start\n puts String.starline.blue\n if diff > 5 then puts (\" * \".blue + (\"exec time: %.2f sec\" % diff))\n else puts (\" * \".blue + (\"exec time: %.2f sec\" % diff).black)\n end\n\n if $?.exitstatus === 0 then puts (\" * \".blue + \"exit code: #{$?.exitstatus}\".black)\n else puts \" * exit code: #{$?.exitstatus}\".starsaround.red\n end\n\n if $?.exitstatus != 0\n unless $!.nil?\n raise SystemCallError.new(\"Execution of `#{cmd}` failed with error code: #{$!.exitstatus}\")\n else\n raise SystemCallError.new(\"Execution of `#{cmd}` failed\")\n end\n end\nend",
"def wait_until_done\n return if !running?\n send_eof\n\n # TODO: handle case where command doesn't exit.\n start = Time.now\n @standard_output.read_until_eof(timeout)\n @standard_error.read_until_eof(timeout - (Time.now - start))\n pid, @status = Process::waitpid2(@pid)\n @pid = nil\n end",
"def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)\n cmd = execute_cmd(cmd, timeout)\n cmd.error!\n cmd\n end",
"def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)\n cmd = execute_cmd(cmd, timeout)\n cmd.error!\n cmd\n end",
"def blocking_popen(command)\n output_text = \"\"\n IO.popen(command) do |io|\n output_text = io.read\n end\n return $?.exitstatus, output_text\n end",
"def shell_command_token_unix(cmd, timeout = 10, absolute_timeout = 30)\n set_shell_token_index(timeout)\n token = ::Rex::Text.rand_text_alpha(5)\n\n # Send the command to the session's stdin. + \\n to enter it\n cmd.strip!\n # avoid syntax errors like\n # bash: syntax error near unexpected token `;'\n command = if cmd.end_with? '&'\n \"#{cmd}; sleep 1; echo #{token}\"\n else\n \"#{cmd};echo #{token}\"\n end\n\n sleep_len = command.length * 0.0001\n timeout += sleep_len.to_i\n absolute_timeout += sleep_len.to_i\n\n # cause another prompt to appear (just in case)\n shell_write(command)\n before_enter(token)\n enter_command\n out = shell_read_until_token(token, @shell_token_index, timeout, absolute_timeout)\n\n # cause another prompt to appear (just in case)\n # second try\n if out.nil?\n enter_command\n out = shell_read_until_token(token, @shell_token_index, timeout, absolute_timeout)\n end\n #\n return nil if out.nil?\n\n first_line = out.to_s.index(\"\\n\")\n if first_line.nil?\n first_line = 0\n else\n first_line += 1\n end\n out[0, first_line] = ''\n # out = do_encoding(out)\n out.gsub!(\"\\r\\n\", \"\\n\")\n # remove console colors\n # out = remove_colors(out)\n out\n end",
"def sync( timeout = TIMEOUT, &proc)\n while true do\n line = timed_readline(timeout)\n Puppet.debug \"#{line}\"\n break if line =~ SUCCESS_SYNC_STRING\n fail 'command in deamon failed.' if line =~ FAILED_SYNC_STRING\n proc.call(line) if proc\n end\n end",
"def timed_sh(command)\n sh \"time #{command}\"\nend",
"def command_output_each_line(command, options)\n Open3::popen3(command, options) do |_, stdout, stderr, wait_thread|\n loop do\n check_output_with_timeout(stdout)\n\n begin\n yield stdout.readline\n rescue EOFError\n break\n end\n end\n status = wait_thread.value.exitstatus\n if status > 0\n message = \"Bot <#{command}> exited with status #{status}: #{stderr.read}\"\n raise RuntimeError.new(message)\n end\n end\nend",
"def shell_command_token(cmd, timeout = 10, absolute_timeout = 30)\n output = if platform =~ /win/\n shell_command_token_win32(cmd, timeout)\n else\n shell_command_token_unix(cmd, timeout, absolute_timeout)\n end\n output\n end",
"def exec(command, options={}, args=[])\n options[:boom] = true if (options[:boom].nil?)\n options[:stderr_redirect] = StdErrRedirect::NONE if (options[:stderr_redirect].nil?)\n options[:background_exec] = BackgroundExec::NONE if (options[:background_exec].nil?)\n # build command line\n command_line = [\n @tool_executor_helper.background_exec_cmdline_prepend( options ),\n command.strip,\n args,\n @tool_executor_helper.stderr_redirect_cmdline_append( options ),\n @tool_executor_helper.background_exec_cmdline_append( options ),\n ].flatten.compact.join(' ')\n\n @streaminator.stderr_puts(\"Verbose: #{__method__.to_s}(): #{command_line}\", Verbosity::DEBUG)\n\n shell_result = {}\n\n # depending on background exec option, we shell out differently\n time = Benchmark.realtime do\n if (options[:background_exec] != BackgroundExec::NONE)\n shell_result = @system_wrapper.shell_system( command_line, options[:boom] )\n else\n shell_result = @system_wrapper.shell_backticks( command_line, options[:boom] )\n end\n end\n shell_result[:time] = time\n\n #scrub the string for illegal output\n unless shell_result[:output].nil?\n shell_result[:output] = shell_result[:output].scrub if \"\".respond_to?(:scrub)\n shell_result[:output].gsub!(/\\033\\[\\d\\dm/,'')\n end\n\n @tool_executor_helper.print_happy_results( command_line, shell_result, options[:boom] )\n @tool_executor_helper.print_error_results( command_line, shell_result, options[:boom] )\n\n # go boom if exit code isn't 0 (but in some cases we don't want a non-0 exit code to raise)\n raise ShellExecutionException.new(shell_result) if ((shell_result[:exit_code] != 0) and options[:boom])\n\n return shell_result\n end",
"def run_cmd(cmd, timing_metric=nil, log_errors=true)\n ret = \"\"\n exit_code = 0\n start = Time.now.to_i\n timestamp = Time.now.to_s\n plugin_state = {\n :cmd => cmd,\n :timing_metric => timing_metric,\n :start_time => start,\n :log_errors => log_errors\n }\n raise_event(:run_command_start, plugin_state)\n log_and_stream \"<div class='command'><h4>#{timestamp}: Running #{cmd}</h4>\\n<p class='output'>\"\n time = Benchmark.measure do\n Open3.popen3(cmd) do |inn, out, err, wait_thr|\n output = \"\"\n until out.eof?\n # raise \"Timeout\" if output.empty? && Time.now.to_i - start > 300\n chr = out.read(1)\n output << chr\n ret << chr\n if chr == \"\\n\" || chr == \"\\r\"\n log_and_stream output + \"<br>\"\n output = \"\"\n end\n end\n error_message = nil\n log_and_stream(output) unless output.empty?\n\n error_message = err.read unless err.eof?\n if (log_errors) then\n log_and_stream(\"<span class='stderr'>STDERR: #{error_message}</span><br>\") unless error_message.nil?\n else\n log_and_stream(\"STDERR:\" + error_message + \"<br>\") unless error_message.nil?\n end\n\n unless error_message.nil? then\n plugin_state[:error_message] = error_message\n raise_event(:run_command_error, plugin_state)\n end\n\n # Log non-zero exits\n if wait_thr.value.exitstatus != 0 then\n log_and_stream(\"<span class='stderr'>DANGER! #{cmd} had an exit value of: #{wait_thr.value.exitstatus}</span><br>\")\n exit_code = wait_thr.value.exitstatus\n end\n end\n end\n log_and_stream \"</p>\"\n log_and_stream \"<h5>Time: #{time}</h5></div>\"\n plugin_state[:exit_code] = exit_code\n plugin_state[:stdout] = ret\n plugin_state[:time] = time.real\n raise_event(:run_command_end, plugin_state)\n return { :stdout => ret, :exit_code => exit_code }\n end",
"def run(command, chdir: nil)\n chdir_label = \" (#{chdir})\" if chdir\n puts \"Running command: #{command}#{chdir_label}\"\n read, write = IO.pipe\n options = { [:out, :err] => write }\n options[:chdir] = chdir if chdir\n pid = spawn command, options\n output_lines = []\n thread =\n Thread.new do\n while line = read.readline # rubocop:disable Lint/AssignmentInCondition\n # Output lines as the program runs\n puts \"| #{line}\"\n # Store the output for later\n output_lines << line\n end\n rescue EOFError\n # Do nothing, nothing to read anymore\n end\n _pid, status = Process.wait2 pid\n write.close\n thread.join\n output = output_lines.join\n raise CommandFailed.new(command, output) unless status.success?\n\n puts\n output\nend",
"def get_from_shell_cmd(cmd, proc_id)\n stdout, stderr, status = Open3.capture3(cmd)\n if not status.success?\n cancel_job(\"error executing command '#{cmd}' - #{stderr}\", proc_id)\n end\n return stdout.strip!\nend",
"def run_cmd(cmd)\n ret = \"\"\n start = Time.now.to_i\n log_and_stream \"<div class='command'><h4>Running #{cmd}</h4><p class='output'>\"\n time = Benchmark.measure do\n Open3.popen3(cmd) do |inn, out, err|\n output = \"\"\n until out.eof?\n # raise \"Timeout\" if output.empty? && Time.now.to_i - start > 300\n chr = out.read(1)\n output << chr\n ret << chr\n if chr == \"\\n\" || chr == \"\\r\"\n log_and_stream output + \"<br>\"\n output = \"\"\n end\n end\n log_and_stream(output) unless output.empty?\n log_and_stream(\"<span class='stderr'>STDERR: #{err.read}</span><br>\") unless err.eof?\n end\n end\n log_and_stream \"</p>\"\n log_and_stream \"<h5>Time: #{time}</h5></div>\"\n return ret\n end",
"def run_with_status(*args)\n _print_command(*args)\n args.last.delete :errexit if args.last.is_a? Hash\n args.last.delete :xtrace if args.last.is_a? Hash\n pid = Process.spawn(*args)\n return Process.wait2(pid).last\nend",
"def _run_command(command)\n require \"posix-spawn\"\n\n pid, stdin, stdout, stderr = POSIX::Spawn.popen4(command)\n Process.waitpid(pid)\n\n # $?.exitstatus contains exit status do something with it if non zero raise error maybe\n end",
"def run(*params)\n opts = params.extract_options!\n command = Array.wrap(params).join(' ')\n info command unless opts[:quiet]\n\n begin\n cmdrunner = Mixlib::ShellOut.new(command, timeout: opts[:timeout] || Conveyor::Foreman.instance.config[:command_timeout] || 600)\n cmdrunner.run_command()\n\n info cmdrunner.stdout.chomp unless cmdrunner.stdout.chomp.length == 0\n\n \t\t\t\tif cmdrunner.error!\n \terror \"Error running: `#{command}`\", cmdrunner.stderr.chomp\n \[email protected]!\n \t\t\t\telse\n \t\t\t\t\tif cmdrunner.stderr.chomp.length > 0\n \t\t\t\t\t\twarning \"Error output recieved, but no error code recieved\"\n \t\t\t\t\t\twarning cmdrunner.stderr.chomp\n \t\t\t\t\tend\n \t\t\t\tend\n\n return !cmdrunner.error!\n rescue Mixlib::ShellOut::CommandTimeout => e\n error e.class, e.message, \"Command: #{command}\"\n # raise e unless opts[:ignore_error]\n rescue => e\n error e.class, e.message, e.backtrace.join(\"\\n\")\n # raise e unless opts[:ignore_error]\n end\n end",
"def pty(cmd)\n PTY.spawn cmd do |r,w,pid|\n Signal.trap(\"INT\"){ puts \"{killed}\"; Process.kill(\"INT\",pid) }\n begin\n r.sync\n s = r.read_nonblock(4096)\n $stderr.write(s.gsub(/\\n/,\"\\n| \"))\n rescue IO::WaitReadable\n IO.select([r])\n retry\n rescue Errno::EID => e\n # ignore\n ensure\n ::Process.wait pid\n Signal.trap(\"INT\", \"DEFAULT\")\n end\n end\nend",
"def stream_output(command)\n puts command\n exit_status = nil\n Open3.popen3(command) do |stdin, stdout, stderr, wait_thread|\n stdout.each { |line| puts line }\n stderr.each { |line| puts line }\n exit_status = wait_thread.value.to_i\n end\n raise %Q(The command \"#{command}\" failed.) unless exit_status == 0\nend",
"def async_system(cmd, timeout = 10, &callback)\n deferrable = EM::DefaultDeferrable.new\n EM.system cmd do |output, status|\n deferrable.succeed(output, status)\n end\n deferrable.timeout timeout\n deferrable.errback { }\n deferrable.callback(&callback)\n end",
"def run_test(cmd)\n tStart = Time.now\n @out = \"-- #{tStart.strftime('[%H:%M:%S]')} running: [#{cmd}] \"\n begin\n status = Timeout::timeout(@test.timeout.to_i) {\n output = `#{cmd} 2>&1`\n\t @test.output = output\n @exit_status = case @test.output\n when /#{@config['test_exit_message_passed']}/ then @config['test_exit_message_passed']\n when /#{@config['test_exit_message_failed']}/ then @config['test_exit_message_failed']\n else @config['test_exit_message_failed']\n end\n }\n rescue Timeout::Error => e\n @test.output << \"\\n\\n[ TERMINATED WITH TIMEOUT (#{@test.timeout.to_s}) ]\"\n @exit_status = @config['test_exit_message_failed']\n rescue => e\n @test.output << \"\\n\\n[ ERROR ]\\n\\n\"\n @test.output << e.inspect\n @exit_status = @config['test_exit_message_failed']\n ensure\n @obj.p(@out.to_s + @exit_status.to_s)\n @obj.p(@output) if @config['output_on']\n end\n tFinish = Time.now\n @test.execution_time = tFinish - tStart\nend",
"def exec_shell(command, error_message, options = {})\n puts \"Running command: #{command}\" unless options[:silent] == true\n result = `#{command}`\n if options[:dont_fail_on_error] == true\n puts error_message unless $?.success?\n else\n fail_script_unless($?.success?, \"#{error_message}\\nShell failed: #{command}\\n#{result}\")\n end\n\n return result\n end",
"def run()\n stdout_file = Tempfile::new(\"rbatch_tmpout\",RBatch::tmp_dir)\n stderr_file = Tempfile::new(\"rbatch_tmperr\",RBatch::tmp_dir)\n pid = spawn(@cmd_str,:out => [stdout_file,\"w\"],:err => [stderr_file,\"w\"])\n if @opt[:timeout] != 0\n timeout(@opt[:timeout]) do\n begin\n status = Process.waitpid2(pid)[1] >> 8\n rescue Timeout::Error => e\n raise(CmdException,\"Command timeout (over \" + @opt[:timeout] + \" sec)\" )\n end\n end\n else\n status = Process.waitpid2(pid)[1] >> 8\n end\n result = RBatch::CmdResult.new(stdout_file,stderr_file,status,@cmd_str)\n if @opt[:raise] && status != 0\n raise(CmdException,\"Command exit status is not 0. result: \" + result.to_s)\n end\n return result\n end",
"def send_blocking_command(command, _timeout, &block); end",
"def run_command(shell, whether_show_log=true, whether_reject_empty=true)\n result = IO.popen(shell) do |stdout| \n stdout.readlines#.reject(&method) \n end.map { |l| l.is_a?(String) ? string_format(l) : l }\n status = $?.exitstatus.zero?\n if !status or whether_show_log\n shell = string_format(shell).split(/\\n/).map { |line| \"\\t`\" + line + \"`\" }.join(\"\\n\")\n resstr = (result || [\"bash: no output\"]).map { |line| \"\\t\\t\" + line }.join\n puts \"%s\\n\\t\\t==> %s\\n%s\\n\" % [shell, status, resstr]\n end\n return result.unshift(status)\n end",
"def run_command(shell, whether_show_log=true, whether_reject_empty=true)\n result = IO.popen(shell) do |stdout| \n stdout.readlines#.reject(&method) \n end.map { |l| l.is_a?(String) ? string_format(l) : l }\n status = $?.exitstatus.zero?\n if !status or whether_show_log\n shell = string_format(shell).split(/\\n/).map { |line| \"\\t`\" + line + \"`\" }.join(\"\\n\")\n result = [\"bash: no output\"] if result.empty?\n if result.length > 100\n resstr = \"\\t\\tbash: output line number more than 100 rows.\"\n else\n resstr = result.map { |line| \"\\t\\t\" + line }.join\n end\n puts \"%s\\n\\t\\t==> %s\\n%s\\n\" % [shell, status, resstr]\n end\n return result.unshift(status)\n end",
"def cmd_on_trgt_exec(session,cmdexe,opt,verbose)\n\tr=''\n\tsession.response_timeout=120\n\tif verbose == 1\n\t\tbegin\n\t\t\tprint_status \"\\tRunning command #{cmdexe}\"\n\t\t\tr = session.sys.process.execute(cmdexe, opt, {'Hidden' => true, 'Channelized' => true})\n\t\t\twhile(d = r.channel.read)\n\t\t\t\tprint_status(\"\\t#{d}\")\n\t\t\tend\n\t\t\tr.channel.close\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error Running Command #{cmdexe}: #{e.class} #{e}\")\n\t\tend\n\telse\n\t\tbegin\n\t\t\tprint_status \"\\trunning command #{cmdexe}\"\n\t\t\tr = session.sys.process.execute(cmdexe, opt, {'Hidden' => true, 'Channelized' => false})\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error Running Command #{cmdexe}: #{e.class} #{e}\")\n\t\tend\n\tend\nend",
"def run_linux_admin(cmd, timeout=30)\n require 'linux_admin'\n require 'timeout'\n begin\n Timeout::timeout(timeout) {\n log(:info, \"Executing #{cmd} with timeout of #{timeout} seconds\")\n result = LinuxAdmin.run(cmd)\n log(:info, \"--> Inspecting output: #{result.output.inspect}\")\n log(:info, \"--> Inspecting error: #{result.error.inspect}\") unless result.error.blank? \n log(:info, \"--> Inspecting exit_status: #{result.exit_status.inspect}\")\n return result\n }\n rescue => timeout\n log(:error, \"Error executing '#{cmd}'\")\n log(:error, \"'#{timeout.class}' '#{timeout}' \\n#{timeout.backtrace.join(\"\\n\")}\")\n return false\n end\n end",
"def run(command)\n display command.join(\" \")\n\n IO.popen(command + [err: %i[child out]]) do |io|\n __display(io.read(128), partial: true, verbose: true) until io.eof?\n end\n\n fail StandardError, \"Error running '#{command.join(\" \")}'\" unless $?.success?\n end",
"def cmdline cmdline, args = nil\n args ||= {}\n\n if args[:async].is_a? Proc\n async = false\n async_proc = args[:async]\n else\n async = args[:async].to_s.boolean false\n async_proc = nil\n end\n\n if args[:exitstatus].nil?\n exitstatus = [0]\n else\n exitstatus = args[:exitstatus].to_array\n end\n\n expired = args[:expired].to_i\n\n if not args[:invisible]\n if block_given?\n yield LOG_CMDLINE(cmdline, nil), nil, nil\n end\n end\n\n begin\n stdin, stdout_and_stderr, wait_thr = Open3.popen2e cmdline.locale\n\n if async\n sleep 1\n end\n\n begin\n thr = Thread.new do\n str = ''\n\n loop do\n eof = false\n\n thread = Thread.new do\n if stdout_and_stderr.eof?\n if not str.empty?\n str = str.utf8.rstrip\n\n if block_given?\n begin\n yield str, stdin, wait_thr\n rescue Errno::EPIPE => e\n end\n end\n\n if not async_proc.nil?\n if async_proc.call str\n async = true\n end\n end\n\n str = ''\n end\n\n eof = true\n end\n end\n\n if thread.join(1).nil?\n if not str.empty?\n str = str.utf8.rstrip\n\n if block_given?\n begin\n yield str, stdin, wait_thr\n rescue Errno::EPIPE => e\n end\n end\n\n if not async_proc.nil?\n if async_proc.call str\n async = true\n end\n end\n\n str = ''\n end\n end\n\n thread.join\n\n if eof\n break\n end\n\n str << stdout_and_stderr.readpartial(4096)\n lines = str.lines\n\n str = ''\n wait_thr[:last] = ''\n\n if lines.last !~ /[\\r\\n]$/\n wait_thr[:last] = lines.pop.to_s\n end\n\n lines.each do |line|\n line = line.utf8.rstrip\n\n if block_given?\n begin\n yield line, stdin, wait_thr\n rescue Errno::EPIPE => e\n end\n end\n\n if not async_proc.nil?\n if async_proc.call str\n async = true\n end\n end\n end\n\n str = wait_thr[:last].to_s\n end\n end\n\n status = true\n\n time = Time.now\n\n loop do\n alive = false\n\n thr.join 5\n\n if wait_thr[:async]\n async = true\n end\n\n if async or not wait_thr.alive?\n thr.exit\n else\n if expired > 0\n if Time.now - time > expired\n thr.exit\n\n LOG_ERROR 'cmdline execute expired: %s' % expired\n\n status = nil\n end\n end\n end\n\n if thr.alive?\n alive = true\n end\n\n if not alive\n break\n end\n end\n\n if async\n if not wait_thr.alive?\n if not exitstatus.include? wait_thr.value.exitstatus\n status = false\n end\n end\n else\n begin\n if not exitstatus.include? wait_thr.value.exitstatus\n status = false\n end\n rescue\n LOG_EXCEPTION $!\n\n status = false\n end\n end\n\n status\n rescue\n LOG_EXCEPTION $!\n\n false\n ensure\n if not wait_thr.nil?\n if not wait_thr.alive? or not async\n [stdin, stdout_and_stderr].each do |io|\n if not io.closed?\n io.close\n end\n end\n\n wait_thr.join\n end\n end\n end\n rescue\n LOG_EXCEPTION $!\n\n false\n end\n end",
"def shell_command_token_win32(cmd, timeout=10)\n # read any pending data\n buf = shell_read(-1, 0.01)\n token = ::Rex::Text.rand_text_alpha(32)\n\n # Send the command to the session's stdin.\n # NOTE: if the session echoes input we don't need to echo the token twice.\n shell_write(cmd + \"&echo #{token}\\n\")\n res = shell_read_until_token(token, 1, timeout)\n # I would like a better way to do this, but I don't know of one\n res.reverse!.chomp!.reverse! # the presence of a leading newline is not consistent\n res\n end",
"def execute(command, testcase, params={})\n if params[:exceptiononfailure].nil?\n if params[:exitcode]\n exceptiononfailure = false\n else\n exceptiononfailure = true\n end\n else\n exceptiononfailure = params[:exceptiononfailure]\n end\n\n testcase_output(\"#{@short_hostname}$ #{command}\", testcase) if not params[:noecho]\n # wrap command in order to see stderr when command is not found\n if params[:nostderr]\n command = \"( #{command} ) 2>/dev/null\"\n else\n command = \"( #{command} ) 2>&1\"\n end\n\n stdout = IO.popen(command)\n data = \"\"\n batch_lines = \"\"\n interval_start = Time.now.to_i\n while line = stdout.gets\n duration = Time.now.to_i - interval_start\n batch_lines = batch_lines + line\n\n # only send back output through DRb once every 2 seconds to avoid using up all resources\n if duration > 2\n testcase_output(batch_lines, testcase, false) if not params[:noecho]\n batch_lines = \"\"\n interval_start = Time.now.to_i\n end\n data = data + line;\n end\n testcase_output(batch_lines, testcase, false) if not params[:noecho]\n stdout.close\n\n maxsize = 200*1024\n if (data.length < maxsize)\n output = data\n else\n output = data[-maxsize..-1] + \"\\n\\nStdout buffer for command '#{command}' was too large, last #{maxsize/1024}KB returned\\n\"\n end\n\n if exceptiononfailure && $?.exitstatus != 0\n ex = ExecuteError.new(\"non-zero exit status (#{$?.exitstatus.to_i}) from #{command}\")\n ex.output = output\n raise ex\n end\n\n # check that the output won't be too large for passing\n # through DRb, setting 100kb as a hard limit\n if params[:exitcode]\n return [$?.exitstatus.to_s, output]\n else\n return output\n end\n end",
"def wait_for_digit(timeout=-1)\n response = AGIResponse.new\n command_str = \"WAIT FOR DIGIT #{timeout}\"\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n else\n response.success = true\n response.data = response.native.chr\n end\n return response\n end",
"def exec!(command, status: T.unsafe(nil), &block); end",
"def wait(options = {})\n timeout = options[:timeout] || 3\n ret = \"\"\n begin\n timeout(timeout) do\n ret = waitfor(/\\(gdb\\)/)\n end\n rescue TimeoutError\n #TODO: stop it\n raise ContinueTimeoutError, \"timeout after #{timeout} seconds\"\n end\n ret\n end",
"def execute_command(command, &blk)\n so, se = nil\n\n time_obj = Time.now\n ts = time_obj.to_i\n dt = time_obj.strftime(\"%Y-%m-%d\")\n\n tmp_dir_base = @config.get(PATRIOT_TMP_DIR_KEY, DEFAULT_PATRIOT_TMP_DIR)\n\n # the forked variable is used for checking whether fork invocation hangs.\n # (due to https://redmine.ruby-lang.org/issues/5240 ?)\n forked = false\n until forked\n cid = do_fork(command, dt, ts, tmp_dir_base)\n tmpdir = tmp_dir(cid, dt, ts, tmp_dir_base)\n i = 0\n # If fork hangs, output directory would not be created.\n # wait at most 5 seconds for the directory created.\n until forked || i > 5\n sleep(1)\n forked = File.exist?(tmpdir)\n i = i+1\n end\n # fork hanged, kill the hanged process.\n unless forked\n # check whether cid is id of child process to avoid to kill unrelated processes\n begin\n if Process.waitpid(cid, Process::WNOHANG).nil?\n @logger.warn(\"forked process :#{cid} hanged. kill #{cid}\")\n Process.kill(\"KILL\", cid)\n @logger.warn(\"SIGKILL sent to #{cid}\")\n Process.waitpid(cid)\n @logger.warn(\"#{cid} is killed\")\n else\n raise ExternalCommandException, \"#{cid} is not a child of this\"\n end\n rescue Exception => e\n @logger.warn \"failed to kill hanged process #{cid}\"\n raise e\n end\n end\n end\n\n @logger.info \"executing #{command}: results stored in #{tmpdir}\" \n pid, status = Process.waitpid2(cid)\n so = File.join(tmpdir, \"#{cid.to_i}#{STDOUT_SUFFIX}\")\n se = File.join(tmpdir, \"#{cid.to_i}#{STDERR_SUFFIX}\")\n\n @logger.info \"#{command} is finished\" \n return so if status.exitstatus == 0\n @logger.warn \"#{command} end with exit status #{status.exitstatus}\" \n if block_given?\n yield(status, so, se)\n else\n max_err_size = @config.get(MAX_ERROR_MSG_SIZE_KEY, DEFAULT_MAX_ERROR_MSG_SIZE)\n err_size = File.stat(se).size\n err_msg = \"#{command}\\n#{se} :\"\n if err_size < max_err_size\n File.open(se){|f| err_msg = \"#{err_msg}\\n#{f.read}\"}\n else\n err_msg = \"#{err_msg} \\n the size of stderr is #{err_size} (> #{max_err_size}\" \n end\n raise ExternalCommandException, err_msg\n end\n end",
"def time_command(command)\n before = Time.new\n result = system command\n after = Time.new\n return result, after - before\n end",
"def ps_exec(command, tmp_file, c_time, output_file)\n encoding_options = {\n :invalid => :replace, # Replace invalid byte sequences\n :undef => :replace, # Replace anything not defined in ASCII\n :replace => '', # Use a blank for those replacements\n :universal_newline => false # Always break lines with \\n\n }\n print_status(\"Sending command to client...\")\n client.sys.process.execute(command, nil, {'Hidden' => 'true', 'Channelized' => true})\n sleep(c_time)\n log_file = client.fs.file.new(tmp_file, \"rb\")\n begin\n while ((data = log_file.read) != nil)\n data.strip!\n print_line(data.encode(::Encoding.find('ASCII'), encoding_options))\n end\n rescue EOFError\n ensure\n log_file.close\n end\n client.sys.process.execute(\"cmd /c del #{tmp_file}\", nil, {'Hidden' => 'true', 'Channelized' => true})\n end",
"def ptywrap(command)\n last_line = ''\n\n PTY.spawn(command) do |r, w, pid|\n begin\n r.each do |line|\n @logger.info line\n last_line = line\n\n status = PTY.check pid\n unless status.nil?\n raise RuntimeError,\n \"Docker build has not finished successfully, see #{@log_file}\"\\\n unless status.exitstatus.eql? 0\n end\n end\n rescue Errno::EIO\n end\n end\n\n last_line\n end",
"def shell_read_until_token(token, wanted_idx = 0, timeout = 5, absolute_timeout = 30)\n timeout = 5 if timeout.nil?\n if timeout > absolute_timeout\n absolute_timeout = timeout + absolute_timeout\n end\n\n parts_needed = if wanted_idx.zero?\n 2\n else\n 1 + (wanted_idx * 2)\n end\n buf = ''\n timeout_count = timeout\n # Read until we get the data between two tokens or absolute timeout.\n begin\n ::Timeout.timeout(absolute_timeout) do\n loop do\n if timeout_count <= 0\n # puts \"TIMEOUT=0\"\n vprint_debug(\"got timeout during reading from shell\")\n vprint_debug(\"last data: #{buf.dump}\")\n break\n end\n\n if (tmp = shell_read(-1, 1)) # BUG\n\n if tmp.empty?\n vprint_debug(\"shell_read() is empty: timeoutcount=#{timeout_count}|#{$ERROR_INFO}\") # XXX for testing\n timeout_count -= 1\n # sleep 0.5\n Rex::ThreadSafe.select(nil, nil, nil, 0.5)\n next\n end\n\n timeout_count = timeout\n # buf << do_encoding_terminal(tmp)\n buf << tmp\n #########################\n if wanted_idx.zero?\n break if buf.match(token)\n else\n parts = buf.split(token, -1)\n break if parts.length == parts_needed\n end\n\n else\n timeout_count -= 0.1\n # sleep 1\n Rex::ThreadSafe.select(nil, nil, nil, 0.1)\n end\n end\n\n return nil if buf.empty?\n parts = buf.split(token, -1)\n if parts.length == parts_needed\n output = parts[wanted_idx].to_s\n # \"Token found\"\n else\n # \"Token NOT found\"\n ################\n # try to recover\n if parts.length > 1\n # i = 0\n vprint_debug(\"...recovering output...\")\n parts.length.times do |i|\n if parts[i].to_s.end_with?(\"echo \")\n vprint_debug(\"...found...\")\n output = parts[i + 1]\n end\n end\n end\n end\n return nil if output.nil?\n return output\n end\n rescue\n vprint_debug(\"shell_read_until_token(): read timeout #{$ERROR_INFO}\") # XXX for testing\n return buf\n # nothing, just continue\n end\n # failed to get any data or find the token!\n nil.to_s\n end",
"def shell_command_token_unix(cmd, timeout=10)\n # read any pending data\n buf = shell_read(-1, 0.01)\n set_shell_token_index(timeout)\n token = ::Rex::Text.rand_text_alpha(32)\n\n # Send the command to the session's stdin.\n shell_write(cmd + \";echo #{token}\\n\")\n shell_read_until_token(token, @shell_token_index, timeout)\n end",
"def time(command)\n start = Time.now\n system(command)\n Time.now - start\nend",
"def cmd_exec(session,cmdexe,opt,verbose)\n\tr=''\n\tsession.response_timeout=120\n\tif verbose == 1\n\t\tbegin\n\t\t\tprint_status \"\\tRunning command #{cmdexe}\"\n\t\t\tr = session.sys.process.execute(cmdexe, opt, {'Hidden' => true, 'Channelized' => true})\n\t\t\twhile(d = r.channel.read)\n\n\t\t\t\tprin_status(\"\\t#{d}\")\n\t\t\tend\n\t\t\tr.channel.close\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error Running Command #{cmd}: #{e.class} #{e}\")\n\t\tend\n\telse\n\t\tbegin\n print_status \"\\trunning command #{cmdexe}\"\n r = session.sys.process.execute(cmdexe, opt, {'Hidden' => true, 'Channelized' => false})\n r.close\n rescue ::Exception => e\n print_status(\"Error Running Command #{cmd}: #{e.class} #{e}\")\n end\n\tend\nend",
"def run_command\n\n #\n # Create pipes to capture stdout and stderr,\n #\n stdout_read, stdout_write = IO.pipe\n stderr_read, stderr_write = IO.pipe\n open_streams = [ stdout_read, stderr_read ]\n\n begin\n\n #\n # Set cwd, environment, appname, etc.\n #\n create_process_args = {\n :app_name => ENV['COMSPEC'],\n :command_line => \"cmd /c #{command}\",\n :startup_info => {\n :stdout => stdout_write,\n :stderr => stderr_write\n },\n :environment => inherit_environment.map { |k,v| \"#{k}=#{v}\" },\n :close_handles => false\n }\n create_process_args[:cwd] = cwd if cwd\n\n #\n # Start the process\n #\n process = Process.create(create_process_args)\n begin\n\n #\n # Wait for the process to finish, consuming output as we go\n #\n start_wait = Time.now\n while true\n wait_status = WaitForSingleObject(process.process_handle, 0)\n case wait_status\n when WAIT_OBJECT_0\n # Get process exit code\n exit_code = [0].pack('l')\n unless GetExitCodeProcess(process.process_handle, exit_code)\n raise get_last_error\n end\n @status = ThingThatLooksSortOfLikeAProcessStatus.new\n @status.exitstatus = exit_code.unpack('l').first\n\n return self\n when WAIT_TIMEOUT\n # Kill the process\n if (Time.now - start_wait) > timeout\n raise Chef::Exceptions::CommandTimeout, \"command timed out:\\n#{format_for_exception}\"\n end\n\n consume_output(open_streams, stdout_read, stderr_read)\n else\n raise \"Unknown response from WaitForSingleObject(#{process.process_handle}, #{timeout*1000}): #{wait_status}\"\n end\n\n end\n\n ensure\n CloseHandle(process.thread_handle)\n CloseHandle(process.process_handle)\n end\n\n ensure\n #\n # Consume all remaining data from the pipes until they are closed\n #\n stdout_write.close\n stderr_write.close\n\n while consume_output(open_streams, stdout_read, stderr_read)\n end\n end\n end",
"def exec(cmd)\n\t\tbegin\n\t\t\tout = cmd_exec(cmd).chomp\n\t\trescue ::Timeout::Error => e\n\t\t\tvprint_error(\"#{@peer} - #{e.message} - retrying...\")\n\t\t\tretry\n\t\trescue EOFError => e\n\t\t\tvprint_error(\"#{@peer} - #{e.message} - retrying...\")\n\t\t\tretry\n\t\tend\n\tend",
"def pick_timeout!\n @timeout = (ENV['TIMEOUT'] || DEFAULT_TIME_LIMIT).to_i\n $stdout.puts \"TIMEOUT=#{@timeout}\"\n $stdout.flush\n end",
"def pick_timeout!\n @timeout = (ENV['TIMEOUT'] || DEFAULT_TIME_LIMIT).to_i\n $stdout.puts \"TIMEOUT=#{@timeout}\"\n $stdout.flush\n end",
"def pick_timeout!\n @timeout = (ENV['TIMEOUT'] || DEFAULT_TIME_LIMIT).to_i\n $stdout.puts \"TIMEOUT=#{@timeout}\"\n $stdout.flush\n end",
"def wait_for_condition script, timeout\r\n command 'waitForCondition', script, timeout\r\n end",
"def wait_for_condition script, timeout\r\n command 'waitForCondition', script, timeout\r\n end",
"def run_cmd(cmd,token=true)\n opts = {'Hidden' => true, 'Channelized' => true, 'UseThreadToken' => token}\n process = session.sys.process.execute(cmd, nil, opts)\n res = \"\"\n while (d = process.channel.read)\n break if d == \"\"\n res << d\n end\n process.channel.close\n process.close\n return res\n end",
"def enter_command\n shell_write(\"\\n\")\n wait_length = 0.1\n Rex::ThreadSafe.select(nil, nil, nil, wait_length)\n end",
"def run_ssh(host, shell_command, ssh_timeout = 60)\n begin\n # define basic query\n ssh_query = {\n :ssh_host => host,\n :ssh_auth_type => :password, # password is set on ssh method (default per os during provisioning)\n :ssh_timeout => ssh_timeout,\n :ssh_debug => @debug,\n :ssh_command => shell_command\n }\n\n # instantiate the ssh method and pull the command status\n $evm.instantiate(SSH_INSTANCE_PATH + '?' + ssh_query.to_query)\n status = $evm.root['ssh_command_status']\n\n # pull and inspect our results if we succeeded\n if status\n results = $evm.root['ssh_results']\n return results\n else\n log(:error, \"run_ssh: Command #{shell_command} failed. Returning nil.\")\n return nil\n end\n rescue => err\n log(:error, \"run_ssh: Unable to run command: #{shell_command}. Returning nil.\")\n return nil\n end\nend",
"def system_run(cmd, o={})\n opts = {:quiet => false, :sysread => 1024}.merge(o)\n buf = \"\"\n ddputs(\"Running command: #{cmd}\")\n Open3.popen3(cmd) do |stdout, stdin, stderr|\n begin\n while (chunk = stdin.readpartial(opts[:sysread]))\n buf << chunk\n unless chunk.nil? || chunk.empty?\n $stdout.write(chunk) #if debugging? || verbose?\n end\n end\n err = stderr.readlines\n $stderr.write_nonblock(err)\n rescue SystemCallError => error\n err = stderr.readlines\n $stderr.write_nonblock(err)\n rescue EOFError => error\n err = stderr.readlines\n $stderr.write_nonblock(err)\n # used to do nothing\n end\n end\n buf\n end",
"def execute(command, options = { })\n defaults = { :out_console => true }\n options = defaults.merge(options)\n # open a new channel and configure a minimal set of callbacks, then run\n # the event loop until the channel finishes (closes)\n last_exit = -1\n channel = session.open_channel do |ch|\n\n #request pty for sudo stuff and so\n ch.request_pty do |ch, success|\n raise \"Error requesting pty\" unless success\n end\n \n ch.exec \"#{command}\" do |ch, success|\n raise \"could not execute command\" unless success\n\n\n # \"on_data\" is called when the process writes something to stdout\n ch.on_data do |c, data|\n STDOUT.print data if options[:out_console]\n\n end\n\n # \"on_extended_data\" is called when the process writes something to stderr\n ch.on_extended_data do |c, type, data|\n STDOUT.print data if options[:out_console]\n end\n\n channel.on_request(\"exit-signal\") do |ch, data|\n last_exit = data.read_long\n end\n\n channel.on_request(\"exit-status\") do |ch,data|\n last_exit = data.read_long\n end\n\n end\n end\n channel.wait\n last_exit\n end",
"def process_shell_command\n command_line.set_prompt ':!'\n cmd = command_line.get_command(prompt: ':!')[1..-1]\n execute_external_command pause: true do\n system cmd\n end\n rescue Interrupt\n ensure\n command_line.clear\n command_line.noutrefresh\n end",
"def exec(command, input = nil)\n result = command_results.build\n result.start! command, input\n exit_code = nil\n ssh_channel = @net_ssh.open_channel do |channel|\n channel.exec command do |_, success|\n if success\n channel.send_data input if input\n channel.eof!\n channel.on_data do |_, data|\n result.append_to_stdout! data\n end\n channel.on_extended_data do |_, type, data|\n result.append_to_stderr! data if type == :stderr\n end\n channel.on_request 'exit-status' do |_, data|\n exit_code = data.read_long\n end\n channel.on_request 'exit-signal' do |_, data|\n # TODO(pwnall): ammend CommandResult to record this properly\n exit_code = data.read_long\n end\n else\n # TODO(pwnall): ammend CommandResult to record this properly\n exit_code = 255\n channel.close\n end\n end\n end\n ssh_channel.wait\n result.completed! exit_code || 0\n end",
"def execute_with_exit_code(command)\n exit_code = nil\n session.open_channel do |channel|\n channel.request_pty\n\n channel.exec(command) do |_ch, _success|\n channel.on_data do |_ch, data|\n logger << data\n end\n\n channel.on_extended_data do |_ch, _type, data|\n logger << data\n end\n\n channel.on_request(\"exit-status\") do |_ch, data|\n exit_code = data.read_long\n end\n end\n end\n session.loop\n exit_code\n end",
"def run_command(command)\n time_start = Time.now\n begin\n result = `#{ command }`\n rescue\n result = 'Get an error when try to run command'\n end\n time_finished = Time.now\n duration = time_finished - time_start\n { start_time: time_start, finished_time: time_finished, duration: duration, result: result }\n end",
"def checkTimeout\n\tt = Time.now\n\tret = t.to_i\n\ttimeoutMsgs = operateMsgPool(CHECK_MESSAGE, ret.to_s)\n\ti = 0\n\twhile (i < timeoutMsgs.length)\n\t cm_cmc_msg = timeoutMsgs.at(i) \n\t cmstr = cm_cmc_msg.marshallMsg\n\t @communicator.sendCommand(CM_PORT, cm_cmc_msg.ipaddr, cmstr)\n\t i = i + 1\n\tend\n end",
"def exec_command(command)\n log = ''\n puts \"\\n=> Executing \\\"#{command}\\\"\"\n log += \"\\n\\n=> Executing \\\"#{command}\\\"\\n\"\n Open3.popen2e(command) { |stdin, stdout_and_stderr, wait_thr|\n stdout_and_stderr.each {|line|\n puts line\n log += line\n }\n }\n return log\nend",
"def execute_quiet(command, error_message)\n # Ladies and gentleman: More debug, please!\n puts command if @debug\n return_value = -1\n\n Open3.popen3(environment, command) do |_stdin, stdout, stderr, wait_thread|\n Thread.new do\n stdout.each do |line|\n @last_output << line.strip\n puts line unless @quiet\n end\n end\n\n Thread.new do\n stderr.each do |line|\n @last_error << line\n puts line unless @quiet\n end\n end\n\n _stdin.close\n\n return_value = wait_thread.value\n\n if @strict and return_value.exitstatus != 0\n dump_error_message(command)\n fail error_message\n end\n end\n\n puts \"Program exited with status #{return_value.exitstatus}.\" if @debug\n\n return_value.exitstatus == 0\n end",
"def shell_read(length=nil, timeout=1)\n\t\tshell_init\n\n\t\tlength = nil if length < 0\n\t\tbegin\n\t\t\trv = nil\n\t\t\t# Meterpreter doesn't offer a way to timeout on the victim side, so\n\t\t\t# we have to do it here. I'm concerned that this will cause loss\n\t\t\t# of data.\n\t\t\tTimeout.timeout(timeout) {\n\t\t\t\trv = @shell.channel.read(length)\n\t\t\t}\n\t\t\tframework.events.on_session_output(self, rv) if rv\n\t\t\treturn rv\n\t\trescue ::Timeout::Error\n\t\t\treturn nil\n\t\trescue ::Exception => e\n\t\t\tshell_close\n\t\t\traise e\n\t\tend\n\tend",
"def run\n out = \"\"\n\n begin\n PTY.spawn(command) do |stdout, stdin, pid|\n begin\n stdout.each do |line|\n out << line.strip+\"\\n\"\n print line if @tee\n end\n rescue Errno::EIO\n #Errno:EIO error probably just means that the process has finished giving output\n end\n Process.wait(pid)\n end\n rescue PTY::ChildExited\n # The child process has exited.\n end\n\n if $?.exitstatus == 0\n return Parser.parse(out) if @parse\n return out\n else\n raise \"httperf exited with status #{$?.exitstatus}\\n\\nhttperf output:\\n--------------\\n#{out}\"\n end\n end"
] | [
"0.81469893",
"0.7946549",
"0.78772396",
"0.7831198",
"0.77707744",
"0.7172078",
"0.71152586",
"0.69348264",
"0.6767639",
"0.63780695",
"0.6231993",
"0.6161322",
"0.61484355",
"0.6127456",
"0.60837674",
"0.6047761",
"0.60357475",
"0.6031448",
"0.59493357",
"0.59354496",
"0.58814126",
"0.5841487",
"0.5820529",
"0.58191866",
"0.58075345",
"0.58049273",
"0.5730683",
"0.57095915",
"0.5666344",
"0.5655716",
"0.559637",
"0.559637",
"0.5578198",
"0.5578198",
"0.556885",
"0.5566193",
"0.55537134",
"0.5552479",
"0.5552479",
"0.546394",
"0.5448187",
"0.5444607",
"0.5425153",
"0.54219246",
"0.54161775",
"0.54078686",
"0.5391924",
"0.5386318",
"0.5382299",
"0.5379748",
"0.5362521",
"0.5358113",
"0.53517073",
"0.5349096",
"0.53406966",
"0.5334869",
"0.53328186",
"0.5331408",
"0.5328737",
"0.5328171",
"0.532618",
"0.5325741",
"0.5323331",
"0.53206223",
"0.53144866",
"0.53024304",
"0.52826864",
"0.5275369",
"0.5262362",
"0.5249201",
"0.524582",
"0.5236873",
"0.52320254",
"0.52236795",
"0.52184796",
"0.5215159",
"0.5214752",
"0.51924485",
"0.5175434",
"0.5163323",
"0.51628226",
"0.5157294",
"0.5157294",
"0.5157294",
"0.51468086",
"0.51468086",
"0.5145084",
"0.51374656",
"0.5130012",
"0.51288325",
"0.5121216",
"0.5116792",
"0.5116709",
"0.5116656",
"0.51148105",
"0.511407",
"0.5113606",
"0.51104265",
"0.5107182",
"0.51052517"
] | 0.8100713 | 1 |
It is required by google FullCalender js | def allDay
FALSE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service\n Googlecal::Base.service\n end",
"def g_cal\n @g_cal ||= Google::Calendar.new(\n :client_id => @client_id,\n :client_secret => @secret,\n :calendar => @calendar_id,\n :redirect_url => \"urn:ietf:wg:oauth:2.0:oob\" # this is what Google uses for 'applications'\n )\n end",
"def get_google_calendar\n result = Gandalf::GoogleApiClient.get_google_calendar(self.apps_cal_id)\n result.data\n end",
"def event_requirement; end",
"def initialize_calendar\n javascript_tag \"setTimeout('Calendar.initCalendar()', 250);\"\n end",
"def update_calendar(opts = {})\n end",
"def insert_calendar(opts = {})\n end",
"def event_calendar_options\n { \n #year: @year,\n #month: @month,\n first_day_of_week: 1,\n width: 300,\n height: 350,\n #event_strips: @event_strips,\n #month_name_text: I18n.localize(@shown_month, :format => \"%B %Y\"),\n #previous_month_text: \"<< \" + month_link(@shown_month.prev_month),\n #next_month_text: month_link(@shown_month.next_month) + \" >>\"\n }\n end",
"def qualified_event; end",
"def qualified_event; end",
"def event_calendar_opts\n {\n\n :year => @year,\n :month => @month,\n :abbrev => true,\n :first_day_of_week => 1, # See note below when setting this\n :show_today => true,\n :show_header => true,\n :month_name_text => @shown_month.strftime(\"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.prev_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\",\n :event_strips => @event_strips,\n\n # it would be nice to have these in the CSS file\n # but they are needed to perform height calculations\n\n :use_all_day => true,\n :use_javascript => true,\n :link_to_day_action => \"day\"\n\n\n }\n end",
"def has_calendar?\n \t\t!calendar.nil?\n \tend",
"def event_calendar_opts(calendar)\n { \n :year => @calendar.year,\n :month => @calendar.month,\n :event_strips => @calendar.event_strips,\n :month_name_text => I18n.localize(@calendar.date, :format => \"%B %Y\"),\n :previous_month_text => month_link(@calendar.date.last_month),\n :next_month_text => month_link(@calendar.date.next_month),\n :use_all_day => true\n }\n end",
"def event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => @shown_month.strftime(\"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.last_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\",\n :first_day_of_week => @first_day_of_week,\n :abbrev => (0..-1),\n :event_height => 18,\n :event_margin => 2,\n :event_padding_top => 3,\n :use_javascript => true,\n :use_all_day => true\n }\n end",
"def event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.prev_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\",\n :use_all_day => true\n }\n end",
"def event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.last_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\",\n :use_all_day => true,\n :link_to_day_action => true\n }\n end",
"def event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => month_link(@shown_month.prev_month),\n :next_month_text => month_link(@shown_month.next_month),\n :first_day_of_week => @first_day_of_week\n }\n end",
"def features\n ['calendar-access', 'calendar-proxy']\n end",
"def event_calendar_opts\n {\n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< #{month_link(@shown_month.prev_month)}\",\n :next_month_text => \"#{month_link(@shown_month.next_month)} >>\",\n :use_all_day => true\n }\n end",
"def event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :first_day_of_week => @first_day_of_week,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.prev_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\" }\n end",
"def event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< \" + month_link_prev(@shown_month.prev_month),\n :next_month_text => month_link_next(@shown_month.next_month) + \" >>\" ,\n \n :abbrev => true,\n :first_day_of_week => 0, # See note below when setting this\n :show_today => true,\n :show_header => true,\n \n # it would be nice to have these in the CSS file\n # but they are needed to perform height calculations\n :width => nil,\n :height => 500, \n :day_names_height => 18,\n :day_nums_height => 18,\n :event_height => 18,\n :event_margin => 1,\n :event_padding_top => 1,\n \n :use_all_day => false,\n :use_javascript => true,\n :link_to_day_action => false\n }\n end",
"def create_google_calendar\n unless self.apps_cal_id\n result = Gandalf::GoogleApiClient.insert_google_calendar({\n \"summary\" => self.name\n })\n self.apps_cal_id = result.data.id\n self.save!\n end\n end",
"def clear_calendar\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 event_calendar_opts\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.prev_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\",\n :first_day_of_week => 1,\n :height => 400,\n :event_height => 24,\n :event_margin => 1,\n :event_padding_top => 0,\n :day_names_height => 30\n }\n end",
"def is_default_calendar=(value)\n @is_default_calendar = value\n end",
"def patch_calendar(opts = {})\n update_calendar(opts)\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 is_default_calendar\n return @is_default_calendar\n end",
"def event_calendar_options\n { \n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => @shown_month.strftime(\"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.last_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\",\n :event_width => 110\n }\n end",
"def event_calendar_opts\n {\n :height => 600,\n :event_height => 90,\n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"<< \" + month_link(@shown_month.prev_month),\n :next_month_text => month_link(@shown_month.next_month) + \" >>\" }\n end",
"def to_ical_event(set_alarm = true)\n $version = \"0214.2\"\n e = Icalendar::Event.new\n k=0\n evt_url = \"https://riclife.palladius.eu/events/#{id}\"\n my_description = # \"[repetition_magic_string: '#{repetition_magic_string}']\" + \n \"#evt_url: #{evt_url}\"\n begin\n e.summary = ical_summary() # \"[#{calendar.abbrev rescue '_BOH_'}] #{summary}\"\n e.dtstart = DateTime.parse(tstart.to_s)\n e.dtend = DateTime.parse(tend.to_s) \n e.location = venue.address rescue \"(Venue Unknown)\"\n e.klass = self.private ? \"PRIVATE\" : \"PUBLIC\"\n e.ip_class = e.klass\n e.description = full_description(my_description) rescue \"Err rendering full_description: #{$!}\"\n attendees.each{ |x| \n k += 1\n e.add_attendee( x.full_mail(\" (Attendee #{k})\") ) rescue nil\n } # attendee\n e.add_attendee( creator.full_mail(\" (Creator)\") ) rescue nil\n e.alarm do # allarme funge!!!\n action \"DISPLAY\" # This line isn't necessary, it's the default\n summary \"Alarm notification Riccardo\"\n trigger \"-P1DT0H0M0S\" # 1 day before\n end if set_alarm\n e.geo = Icalendar::Geo.new(venue.lat , venue.lng) if (defined?(venue.lat) && defined?(venue.lng) )\n e.url = evt_url\n if repeats # repeats, per comodita lo faccio weekly...\n puts(\"Aggiungo una rrule..\")\n e.add_recurrence_rule(repetition_magic_string()) \n end\n rescue\n e.description = \"Event.to_ical_event(ver=#{$version}) Some exception:\\nMsgErr= ''#{$!}'' \\n\\nMsgCall='''#{caller.join(\"\\n -- \")}'''\"\n end\n return e\n end",
"def event_calendar_opts\n {\n :year => @year,\n :month => @month,\n :event_strips => @event_strips,\n :month_name_text => I18n.localize(@shown_month, :format => \"%B %Y\"),\n :previous_month_text => \"« #{month_link(@shown_month.prev_month)}\",\n :next_month_text => \"#{month_link(@shown_month.next_month)} »\",\n :link_to_day_action => \"day\"\n }\n end",
"def calendar_view\n return @calendar_view\n end",
"def calendar\n get '/gtfs/calendar'\n end",
"def from_google\n @calendars = get_calendar(current_user).to_a\n @calendar_days = @calendars.group_by {|e| \n if e.start.date_time != nil \n e.start.date_time.strftime(\"%Y-%m-%d\").to_time\n end\n }\n @today = Time.now.strftime(\"%Y-%m-%d\").to_time\n @tomorrow = Time.now.tomorrow.strftime(\"%Y-%m-%d\").to_time\n end",
"def appointment_complete\n end",
"def create_google_calendar_event(params)\n event = cal.create_event do |e|\n e.title = params[:title]\n e.start_time = params[:start_time]\n e.end_time = params[:end_time]\n end\n end",
"def validate_event; end",
"def more_advanced_date\n \tnil\n end",
"def create\n @event = Event.new(event_params)\n @event.user_id = current_user.id\n\n respond_to do |format|\n if @event.save\n cal = Google::Calendar.new(:username => '[email protected]',\n :password => 'iloverails',\n :app_name => 'GDG-Aracaju')\n\n event = cal.create_event do |e|\n e.title = \"#{@event.description} criado por: #{@event.user.email}\"\n e.start_time = @event.dt_begin\n e.end_time = @event.dt_end\n end\n\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def all_day ; true ; end",
"def unobtrusive_datepicker_includes\n #javascript 'datepicker'\n #stylesheet 'datepicker'\n end",
"def use_dates\n @use_dates || true\n end",
"def calendar_exceptions\n get '/gtfs/calendarDate'\n end",
"def fullcalendarify\n\t\t{\n\t\t\tid: id,\n\t\t\tstart: start_date.iso8601,\n\t\t\tend: end_date.iso8601,\n\t\t\ttitle: title + (showtime ? \"\\n#{start_date.strftime \"%l:%M %p\"} - #{end_date.strftime \"%l:%M %p\"}\" : \"\"),\n\t\t\turl: \"/events/#{id}\",\n\t\t\tcolor: color\n\t\t}\n\tend",
"def filter_events\n frm.button(:name=>\"eventSubmit_doCustomdate\").click\n Calendar.new(@browser)\n end",
"def event_start_for_solr\n # return event_start.iso8601[0,19]+'Z'\n start_date = event_start\n\t \n start_date = entry_deadline if is_opportunity?\n \n\t return FinderHelper.date_for_solr_ymd(start_date)\n end",
"def calender_params\n params.fetch(:calender, {})\n end",
"def iCal\n \n @task = Task.find(params[:id])\n # Create a calendar with an event (standard method)\n cal = Icalendar::Calendar.new\n cal.event do |e|\n e.dtstart = Icalendar::Values::Date.new(@task.date)\n e.summary = \"#{@task.category} #{@task.title}\"\n e.ip_class = \"PRIVATE\"\n end\n\n cal.publish\n render text: cal.to_ical, content_type: 'text/calendar'\n \nend",
"def add_event(doc, n, *args)\r\n# p 'Add event ' + args[1][0..199]\r\n new_event = CalendarEvent.find_or_initialize_by_pageextsourceID(:pageextsourceID => doc.xpath(\"//item//id\")[n].text, \r\n :event_type => 'ce', :event_title => args[1][0..199],\r\n :cbody => doc.xpath(\"//item//description\")[n].text, \r\n :postdate => DateTime.parse(doc.xpath(\"//item//pubDate\")[n].text),\r\n :eventstartdate => args[2], :eventstarttime => args[2], :eventenddate => args[3], :eventendtime => args[3],\r\n :contentsourceURL => args[5][0..99], \r\n :location => doc.xpath(\"//item//xCal:location\")[n].text,\r\n :mapplacename => doc.xpath(\"//item//xCal:adr//xCal:x-calconnect-venue-name\")[n].text[0..59],\r\n :mapstreet => doc.xpath(\"//item//xCal:adr//xCal:x-calconnect-street\")[n].text[0..39],\r\n :mapcity => doc.xpath(\"//item//xCal:adr//xCal:x-calconnect-city\")[n].text[0..39],\r\n :mapstate => doc.xpath(\"//item//xCal:adr//xCal:x-calconnect-region\")[n].text[0..24],\r\n :mapzip => doc.xpath(\"//item//xCal:adr//xCal:x-calconnect-postalcode\")[n].text[0..9],\r\n :mapcountry => doc.xpath(\"//item//xCal:adr//xCal:x-calconnect-country\")[n].text[0..39],\r\n :contactphone => doc.xpath(\"//item//phone\")[n].text[0..14],\r\n :contentsourceID => args[4], :localGMToffset => args[6], :endGMToffset => args[6],\r\n :subscriptionsourceID => args[4]) \r\n new_event.longitude, new_event.latitude = doc.xpath(\"//item//geo:long\")[n].text.to_f, doc.xpath(\"//item//geo:lat\")[n].text.to_f \r\n new_event.imagelink = doc.xpath(\"//item//images//url\")[n].text rescue nil\r\n new_event.save(:validate=>false)\r\n end",
"def add_google_info(access_token)\n if self.google_id.blank?\n if self.start_time.present? && self.title.present?\n google_event = Google::Event.search_by_date_range(\n access_token,\n self.start_time,\n (self.start_time + 1.minutes),\n self.google_calendar_id\n )\n if !google_event['error'] && items = google_event['data']['items']\n event = items.select{|item| item['title'] == self.title}.first\n if event\n self.details = event['details']\n self.google_id = event['id']\n end\n end\n end\n end\n end",
"def events_calendar_display\n\n if params[:category_id]\n current_category = Category.find(params[:category_id])\n if params[:id]\n the_date = Time.parse(params[:id])\n else\n the_date = parse_params_date_or_now_date\n end\n else\n #get the current category or use the general category\n if(controller_name == \"categories\" && params[:id])\n current_category = Category.find(params[:id])\n else\n current_category = categories_not_to_display.first\n end\n the_date = parse_params_date_or_now_date\n end\n\n\n \n \n complete = \"$('spinner-cal').hide(); \" + \"$('the-cal').show()\"\n loading = \"$('spinner-cal').show(); \" + \"$('the-cal').hide(); \"\n\n \n if the_date.year > 2008\n prev_date = \"01-#{the_date.last_month.month}-#{the_date.last_month.year}\"\n prev_month_link = link_to_remote( l(the_date.last_month, :format => 'only_month'),\n :url => { :controller => \"calendar\",\n :action => \"generate\", :category_id => current_category.id, :date => prev_date, :no_day_selection => true},\n :loading => loading, :complete => complete)\n #prev_month_link = link_to( l(the_date.last_month, :format => 'only_month'), category_path(current_category, :date => \"01-#{the_date.last_month.month}-#{the_date.last_month.year}\" ))\n #raise prev_month_link.inspect\n end\n if the_date.year < (Time.now.year+2)\n next_date = \"01-#{the_date.next_month.month}-#{the_date.next_month.year}\"\n next_month_link = link_to_remote( l(the_date.next_month, :format => 'only_month'), :url => { :controller => \"calendar\",\n :action => \"generate\", :category_id => current_category.id, :date => next_date, :no_day_selection => true}, :loading => loading, :complete => complete)\n #next_month_link = link_to( l(the_date.next_month, :format => 'only_month'), category_path(current_category, :date => \"01-#{the_date.next_month.month}-#{the_date.next_month.year}\" ))\n end\n \n calendar(:year => the_date.year, :month => the_date.month, :first_day_of_week => 1, :previous_month_text => prev_month_link, :next_month_text => next_month_link, :the_date => the_date) do |d|\n cell_attrs = {:class => 'day'}\n \n number_of_events = Term.count_occuring_in_the_day(current_category.id, d)\n if number_of_events > 0 \n cell_text = \"<div class='dayEvent'>\"\n cell_text += link_to( \"#{d.mday}\", category_date_path(current_category, :id => \"#{d.day}-#{d.month}-#{d.year}\" ))\n cell_text += \"</div><div class='numberEvent'>#{number_of_events}</div>\"\n\n cell_attrs[:class] = 'specialDay'\n else\n cell_text = \"#{d.mday}<br />\"\n cell_attrs = {:class => 'day'}\n end\n\n # we use the class 'today' if the day is the one selected\n if !params[:no_day_selection]\n if (d.year == the_date.year && d.month == the_date.month && d.day == the_date.day)\n cell_attrs = {:class => 'today'}\n end\n end\n \n [cell_text, cell_attrs]\n end\n\n end",
"def get_calendar(user)\n source = get_page_source(user)\n source.css('svg.js-calendar-graph-svg g g')\n end",
"def insert_calendar_list(opts = {})\n end",
"def events?\n !@calendar_events.empty?\n end",
"def use_event_attributes?; end",
"def search_for_future_calendar_events\n uri = URI.parse(\"https://www.googleapis.com/calendar/v3/calendars/ufbobbo%40gmail.com/events?orderBy=startTime&singleEvents=true&timeMin=#{Time.now.strftime(\"%FT%T%:z\")}&fields=items(id%2Cstart)&key=#{ENV['GOOGLE_API_KEY']}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request).body\n end",
"def get_calendar opt = {}\n calendar = RiCal.Calendar\n subjects = []\n events_list = []\n if opt[:space].nil?\n #Crea la lista de id's de materias que corresponden a la carrera en un año dado\n Materia.find(:all, :conditions => {:codigo_carrera => opt[:career], :anio => opt[:year]}).each do |m|\n subjects << m.codigo.to_i\n end\n #Lo de buscar no reccurrentes diferenciando de los recurrentes es algo que quedo de la vieja busqueda y deberia ser adaptado todo\n # al nuevo objetivo de esta busqueda. Deberia verse que no pertenece a ninguna materia.\n if opt[:all]\n events_list = Evento.find :all, :conditions => \"dtstart > '#{opt[:date]}' AND '#{opt[:date] + 1.day}' > dtstart AND reccurrent = 'f'\"\n events_list += Evento.find :all, :conditions => { :reccurrent => true, :byday => opt[:date].strftime(\"%a\").upcase[0..1]}\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND rdate <> ''\"\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND exdate <> ''\"\n else\n events_list = Evento.find :all, :conditions => \"dtstart > '#{opt[:date]}' AND '#{opt[:date] + 1.day}' > dtstart AND reccurrent = 'f'\" if opt[:year] == 0\n events_list += Evento.find :all, :conditions => { :reccurrent => true, :byday => opt[:date].strftime(\"%a\").upcase[0..1]}\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND rdate <> ''\"\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND exdate <> ''\"\n end\n else\n # Buscar eventos segun un espacio\n events_list = Evento.find(:all, :conditions => \"dtstart > '#{opt[:date]}' AND '#{opt[:date] + 1.day}' > dtstart AND reccurrent = 'f' AND espacio_id = #{opt[:space]}\")\n events_list += Evento.find(:all, :conditions => { :reccurrent => true, :byday => opt[:date].strftime(\"%a\").upcase[0..1], :espacio_id => opt[:space]})\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND rdate <> ''\"\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND exdate <> ''\"\n\n end\n\n # Elimina duplicados\n events_list.uniq!\n\n # Carga al calendario\n events_list.each do |event|\n new_event = RiCal.Event\n new_event.description = event.description || ''\n new_event.dtstart = event.dtstart.strftime '%Y%m%dT%H%M00'\n new_event.dtend = event.dtend.strftime '%Y%m%dT%H%M00'\n new_event.location = event.espacio_id.to_s\n new_event.rrule = \"FREQ=\" + event.freq + \";BYDAY=\" + event.byday + \";INTERVAL=\" + event.interval.to_s + \";UNTIL=\" + event.renddate.strftime('%Y%m%dT%H%M00') if event.reccurrent\n new_event.exdates = event.exdate.to_a\n new_event.rdates = event.rdate.split(',').collect{|e| DateTime.parse e} || ''\n new_event.comment = event.id.to_s\n\n # Analisis de ocurrencia\n if event.reccurrent\n occurrence = new_event.occurrences :count => 1, :starting => opt[:date], :before => opt[:date] + 1\n if occurrence.count > 0\n if event.materia_id.nil? or opt[:all]\n # Agregar el evento sin materia\n calendar.add_subcomponent occurrence[0]\n else\n # Agregar el evento si coincide con alguna materia en subjects\n calendar.add_subcomponent occurrence[0] if subjects.include? event.materia_id #new_event\n end\n end\n else\n if event.materia_id.nil? or opt[:all]\n # Agregar el evento sin discriminarlo\n calendar.add_subcomponent new_event if Date.parse(event.dtstart.year.to_s + '/' + event.dtstart.month.to_s + '/' + event.dtstart.day.to_s) == opt[:date]\n else\n # Agregar el evento si coincide con alguna materia en subjets\n calendar.add_subcomponent new_event if Date.parse(event.dtstart.year.to_s + '/' + event.dtstart.month.to_s + '/' + event.dtstart.day.to_s) == opt[:date] and subjects.include? event.materia_id\n end\n end\n end\n return calendar\n end",
"def gregorian\n end",
"def icalendar_method\n method_property ? method_property.ruby_value : nil\n end",
"def events\n client = Signet::OAuth2::Client.new(client_options)\n client.update!(session[:authorization])\n\n service = Google::Apis::CalendarV3::CalendarService.new\n service.authorization = client\n #controllo se non ho mai loggato con google\n if(!session[:authorization])\n client = Signet::OAuth2::Client.new(client_options)\n redirect_to client.authorization_uri.to_s\n else\n #controllo se il token è scaduto\n response = Net::HTTP.get(URI.parse('https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='+(session[:authorization].first[1])))\n if(response.split[2][1,13] == \"invalid_token\")\n client =●●●●●● Signet::OAuth2::Client.new(client_options)\n redirect_to client.authorization_uri.to_s\n else\n @event_list = service.list_events(params[:calendar_id])\n end\n end\n end",
"def calendar_for(field_id)\n include_calendar_headers_tags\n date_format = I18n.t('date.formats.default', :default => '%Y-%m-%d')\n image_tag(\"calendar.png\", {:id => \"#{field_id}_trigger\", :class => \"calendar-trigger\"}) +\n javascript_tag(\"Calendar.setup({inputField : '#{field_id}', ifFormat : '#{date_format}', button : '#{field_id}_trigger' });\")\n end",
"def set_calendar_name\n calname = course_name\n calname += \" Year #{@course_year}\" unless masters_course?\n @cal.custom_property(\"X-WR-CALNAME\", calname)\n end",
"def new\n @google_calendar = GoogleCalendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @google_calendar }\n end\n end",
"def update_calendar_list(opts = {})\n end",
"def picker_has_calabash_additions\n success_value = \"1\"\n res = query(\"datePicker\", [{hasCalabashAdditions:success_value}])\n screenshot_and_raise \"picker is not visible\" if res.empty?\n res.first.eql? success_value\nend",
"def index\n @events = Event.upcoming.order(:start_time)\n @events_cal = Event.ical(@events) if params[:format] == 'ics'\n end",
"def human_event; end",
"def google_service(refresh_token: nil, auth_client: nil)\n raise Google::Apis::ClientError if refresh_token.nil? && auth_client.nil?\n auth_client = google_auth(refresh_token: refresh_token, scope: Google::Apis::CalendarV3::AUTH_CALENDAR) if (auth_client.nil?)\n service = Google::Apis::CalendarV3::CalendarService.new\n service.client_options.application_name = Rails.application.config.google[:service_application_name]\n service.authorization = auth_client.fetch_access_token![\"access_token\"]\n return service\n end",
"def index\n @events = Event.order(:time).order(:date)\n \n fetch_calendar '[email protected]'\n end",
"def include_calendar_headers_tags\n unless @calendar_headers_tags_included\n @calendar_headers_tags_included = true\n content_for :additional_javascript do\n javascript_include_tag('calendar/calendar') +\n javascript_include_tag(\"calendar/lang/calendar-#{I18n.locale.to_s.downcase}.js\") +\n javascript_include_tag('calendar/calendar-setup') +\n stylesheet_link_tag('calendar')\n end\n end\n end",
"def events_as_ical\n\n calendar = RiCal.Calendar do |cal|\n events.each do |e|\n cal.event do |event|\n event.summary = e.name\n event.dtstart = e.starts_at.getutc\n event.dtend = e.ends_at.getutc\n end\n end\n end\n\n calendar.to_s\n \n end",
"def event_start_end_dates\n esdate and eedate\n end",
"def define_event_helpers; 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 set_google_service\n # Initialize Google Calendar API\n @service = Google::Apis::CalendarV3::CalendarService.new\n # Use google keys to authorize (from local file)\n @service.authorization = google_secret.to_authorization\n @service.authorization.grant_type = \"refresh_token\"\n end",
"def set_calender\n @calender = Calender.find(params[:id] || params[:calender_id])\n end",
"def set_calender\n @calender = Calender.find(params[:id])\n end",
"def get_calendar_list()\n\t\tif([email protected]?)\n\t\t\tresponse = @client.execute(api_method: @service.calendar_list.list)\n\t\t\tcalendars = JSON.parse(response.body)\n\t\telse\n\t\t\tputs \"Client No Calendar boi\"\n\t\tend\n\tend",
"def beginning_of_week; end",
"def beginning_of_week; end",
"def client_options\n {\n client_id: Rails.application.secrets.google_client_id,\n client_secret: Rails.application.secrets.google_client_secret,\n authorization_uri: 'https://accounts.google.com/o/oauth2/auth',\n token_credential_uri: 'https://accounts.google.com/o/oauth2/token',\n scope: Google::Apis::CalendarV3::AUTH_CALENDAR,\n redirect_uri: callback_url\n }\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => unless starts_at.blank? then starts_at.rfc822 else \"\" end,\n :end => unless ends_at.blank? then ends_at.rfc822 else \"\" end,\n :allDay => self.all_day,\n :recurring => false,\n #:url => Rails.application.routes.url_helpers.event_path(id),\n #:color => \"red\"\n }\n end",
"def set_calender_event\n @calender_event = CalenderEvent.find(params[:id])\n end",
"def w_day; end",
"def use_event_type?(noop_required_client)\n # always set type for ES 6\n # for ES 7 only set it if the user defined it\n (maximum_seen_major_version < 7) || (maximum_seen_major_version == 7 && @document_type)\n 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 create_calendar(name, opts={})\n opts[:name] = name\n\n cal = GCalendar::Calendar.new(:opts=>opts)\n\n calendars << cal\n cal.sync\n save\n end",
"def calendar_open\n\t\tcal=Calendar.where(:anio => Date.parse(desde.to_s).year,:department_id => Employee.find(employee_id).department.id).first\n\t\tif cal.nil? || cal.status!=true\n\t\t\t\terrors.add(:desde,\"El calendario para las fechas seleccionadas esta cerrado por su auditor.\")\n\t\tend\n\tend",
"def fullcalendar_events_json\n events.map do |event|\n {\n id: event.id.to_s,\n title: event.name,\n start: event.starts_at.strftime('%Y-%m-%d %H:%M:%S'),\n end: event.ends_at.strftime('%Y-%m-%d %H:%M:%S'),\n allDay: event.all_day,\n url: event_path(event)\n }\n end\n end",
"def start_date?\r\n !event_start_date.blank?\r\n end",
"def get_cal\n return @cal_AC1, @cal_AC2, @cal_AC3, @cal_AC4, @cal_AC5, @cal_AC6, @cal_B1, @cal_B2, @cal_MB, @cal_MC, @cal_MD\n end",
"def today(sg=nil)\n super()\n end"
] | [
"0.66656655",
"0.6306662",
"0.6242163",
"0.6164427",
"0.61604214",
"0.616021",
"0.5997413",
"0.5956652",
"0.5947041",
"0.5947041",
"0.5920075",
"0.5916335",
"0.58496094",
"0.58265",
"0.5808734",
"0.5753126",
"0.5717849",
"0.56975996",
"0.5679915",
"0.56746125",
"0.56701356",
"0.5662243",
"0.5636934",
"0.5613518",
"0.56069857",
"0.5586092",
"0.55797493",
"0.556957",
"0.5550166",
"0.54902875",
"0.5484911",
"0.5469694",
"0.54619",
"0.5407879",
"0.54060066",
"0.53855646",
"0.53795147",
"0.53583086",
"0.5349665",
"0.52995616",
"0.5295789",
"0.5288417",
"0.5283584",
"0.52818286",
"0.5272366",
"0.52654505",
"0.52619654",
"0.52538306",
"0.5245695",
"0.5230506",
"0.5229444",
"0.52253693",
"0.52172834",
"0.52126384",
"0.5205084",
"0.5201091",
"0.51962435",
"0.51941115",
"0.5189254",
"0.5179033",
"0.5168584",
"0.5166971",
"0.516443",
"0.51641893",
"0.51428145",
"0.51415765",
"0.5138087",
"0.5135084",
"0.51325476",
"0.51313126",
"0.5127191",
"0.51244766",
"0.51085234",
"0.51080364",
"0.509985",
"0.5099348",
"0.5094885",
"0.5081676",
"0.50737154",
"0.5070892",
"0.5051388",
"0.5051388",
"0.50507545",
"0.5050634",
"0.5050158",
"0.50474286",
"0.50455505",
"0.50419307",
"0.50419307",
"0.50419307",
"0.50419307",
"0.50419307",
"0.50419307",
"0.50419307",
"0.50419307",
"0.5034543",
"0.5033508",
"0.50321233",
"0.5025905",
"0.5020645",
"0.5019096"
] | 0.0 | -1 |
== Class Methods ==================================================== == Instance Methods ================================================= Server Instance Methods | def receive_line(line)
arguments = line.split(/\s+/)
command = arguments.shift
if (!command or command.empty?)
reply_with_error
else
command_sym = :"#{command.downcase}_command"
if (respond_to?(command_sym))
send(command_sym, *arguments)
else
reply_with_error("Unsupported command #{command.upcase}", :client)
end
end
rescue ArgumentError
reply_with_error("Incorrect arguments to #{command.upcase}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server\n self\n end",
"def server\n super\n end",
"def server\n super\n end",
"def server\n\t\treturn @server ||= self.create_server\n\tend",
"def clientserver\n end",
"def create_server\n\n end",
"def client; end",
"def client; end",
"def server(&blk); end",
"def server(&blk); end",
"def server\n self.next\n end",
"def server\r\n\t\t@usr_server\r\n\tend",
"def initialize server, options\n super server\n @options = options\n end",
"def initialize(server)\n @server = server\n end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def instance; end",
"def instance; end",
"def instance; end",
"def run_server_thread; end",
"def client\n end",
"def create_server\n raise NotImplementedError, \"Implement #{__callee__} in #{self.class.to_s}\"\n end",
"def server\n @@server ||= Server::Cli.new\n #@@server ||= Server::SkypeBot.new\n end",
"def connection_status_server; end",
"def server\n node.server\n end",
"def server\n platform.server\n end",
"def service; end",
"def create_server\n\t\treturn Hglib::Server.new( self.path.to_s )\n\tend",
"def initialize\n\t\t\n\tend",
"def server\n @bot.server\n end",
"def initialize\n log.info \"Main server: #{client[\"/apps/cocina/host\"]} - #{client[\"/apps/cocina/main_port\"]}\"\n super client[\"/apps/cocina/host\"], client[\"/apps/cocina/main_port\"]\n end",
"def internal\n @internal||=ServerClient.new(server,client_options.merge(:internal => true))\n end",
"def method_missing(method, *args)\n @server.send(method, *args)\n end",
"def current_server\n @_current_server\n end",
"def current_server\n @_current_server\n end",
"def remote; end",
"def initialize\r\n\r\n end",
"def socket()\n #This is a stub, used for indexing\n end",
"def server_info()\n #This is a stub, used for indexing\n end",
"def prepare(server); end",
"def initialize\n \n end",
"def initialize\n @status = {}\n @last_update = nil\n @server_status = Overwatch::ServerStatus.new skip_query: true\n @mutex = Mutex.new\n\n populate_servers\n end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def initialize\n\n end",
"def initialize\n\n end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def private; end",
"def initialize()\r\n\r\n end",
"def server_type\n super\n end",
"def initialize\n @allocations = {}\n @http_server = BeEF::Core::Server.instance\n @root_dir = File.expand_path('../../../../', __FILE__)\n end",
"def initialize()\n\t\tend",
"def initialize(server, address)\n @address = address\n super(server)\n end",
"def security_server_client\n end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def start\n\t\tend",
"def init\n\n 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 run\n end",
"def run\n end",
"def public_file_server; end",
"def public_file_server; 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 initialize\n end",
"def initialize\n end",
"def initialize\n end"
] | [
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.7355302",
"0.73002726",
"0.73002726",
"0.7191093",
"0.70575774",
"0.69718635",
"0.6856856",
"0.6856856",
"0.6794205",
"0.6794205",
"0.67753464",
"0.67133224",
"0.6686131",
"0.6622622",
"0.6601338",
"0.6601338",
"0.6601338",
"0.6601338",
"0.6601338",
"0.6601338",
"0.6601338",
"0.6601338",
"0.6529521",
"0.6529521",
"0.6529521",
"0.6525341",
"0.6499431",
"0.64957273",
"0.64791936",
"0.6471513",
"0.64548373",
"0.6395847",
"0.634294",
"0.6333413",
"0.6248021",
"0.6244498",
"0.6240445",
"0.623623",
"0.6223011",
"0.62165356",
"0.62165356",
"0.6199684",
"0.61981416",
"0.6197796",
"0.6196789",
"0.6151029",
"0.61418694",
"0.61403984",
"0.61350787",
"0.61350787",
"0.61324805",
"0.61324805",
"0.61315584",
"0.61315584",
"0.61315584",
"0.61315584",
"0.61292815",
"0.6115885",
"0.6115446",
"0.6107913",
"0.6102882",
"0.60906655",
"0.6074163",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60549504",
"0.60397995",
"0.602256",
"0.6021035",
"0.6021035",
"0.6021035",
"0.6021035",
"0.6021035",
"0.6021035",
"0.6019204",
"0.6019204",
"0.6010599",
"0.6010599",
"0.60048455",
"0.60048455",
"0.60048455",
"0.60048455",
"0.60048455",
"0.60048455",
"0.60048455",
"0.60048455",
"0.60048455"
] | 0.0 | -1 |
This is necessary since Rails 3.0.4 See and | def handle_unverified_request
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def extra; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def view_flow; end",
"def rails_3\n defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::MAJOR >= 3\nend",
"def schubert; end",
"def overrides; end",
"def model_class; end",
"def intensifier; end",
"def name_safe?; end",
"def before_setup; end",
"def private_method\n end",
"def appraisals; end",
"def appraisals; end",
"def formation; end",
"def used?; end",
"def helpers; end",
"def helpers; end",
"def helpers; 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 what_is\n end",
"def before_run; end",
"def ext; end",
"def ext; end",
"def orm_patches_applied; end",
"def isolated; end",
"def isolated; end",
"def verdi; end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def internal; end",
"def who_we_are\r\n end",
"def base_class; end",
"def request_test_helpers_require_keyword_args?\n ActiveRecord::VERSION::STRING.to_f >= 5.0\nend",
"def specialty; end",
"def required_defaults; end",
"def initialize\n super \n end",
"def required_positionals; end",
"def safe_by_default; end",
"def lookup_context; end",
"def lookup_context; end",
"def lookup_context; end",
"def wrapped_causes; end",
"def missing; end",
"def before_bootstrap; end",
"def required_class; end",
"def conscientious_require; end",
"def public; end",
"def public; end",
"def culprit\n @culprit\n end",
"def _view; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def after_view_setup\n end",
"def model_name; end",
"def model_name; end",
"def real_name; end",
"def hints; end",
"def required; end",
"def required; end",
"def required; end",
"def _default_wrap_model; end",
"def support\n raise \"Not implemented\"\n end",
"def internal?; end",
"def cause; end",
"def cause; end"
] | [
"0.7121049",
"0.58587027",
"0.58177334",
"0.5817659",
"0.5698671",
"0.5698671",
"0.5684884",
"0.5684884",
"0.5684884",
"0.5684884",
"0.56329834",
"0.5577374",
"0.55254394",
"0.5512003",
"0.55052704",
"0.5503234",
"0.54796845",
"0.54687154",
"0.54683936",
"0.545734",
"0.545734",
"0.54505116",
"0.54439265",
"0.54334706",
"0.54334706",
"0.54334706",
"0.5431768",
"0.5431768",
"0.5431768",
"0.54311025",
"0.54176265",
"0.54095596",
"0.5396325",
"0.5396325",
"0.5394258",
"0.53903925",
"0.53903925",
"0.5390162",
"0.53893447",
"0.53893447",
"0.53893447",
"0.53893447",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.53662455",
"0.5352024",
"0.5344138",
"0.5342338",
"0.53423065",
"0.5340119",
"0.53342944",
"0.5306965",
"0.5305256",
"0.53014743",
"0.5300048",
"0.5300048",
"0.5300048",
"0.5296206",
"0.5293805",
"0.52863497",
"0.52858406",
"0.5280179",
"0.5279427",
"0.5279427",
"0.5276855",
"0.5273965",
"0.5245756",
"0.5245756",
"0.5245756",
"0.5239005",
"0.522124",
"0.522124",
"0.52134335",
"0.5210967",
"0.52085024",
"0.52085024",
"0.52085024",
"0.5203107",
"0.5198279",
"0.5195588",
"0.51912594",
"0.51912594"
] | 0.0 | -1 |
+each_child+ iterates over each child. | def each_child(&block) # :yields: child_node
children.each(&block)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_child\n @children.each { |child| yield child }\n end",
"def each_child\n @children.each { |child| yield child }\n end",
"def each_child\n @children.each_pair { |_, child| yield child }\n end",
"def each_child(&_block)\n @children.each { |child| yield child }\n end",
"def each_child\n \n end",
"def each\n @children.each {|child| yield child}\n end",
"def each\n @children.each { |child| yield child }\n end",
"def each_child\n self.class.child_references.each do |child_attr|\n children = Array(self.send(child_attr)).clone\n children.each do |child|\n yield(child)\n end\n end\n end",
"def each_child\n childptr = CMark.node_first_child(@pointer)\n while not childptr.null? do\n nextptr = CMark.node_next(childptr)\n yield Node.new(nil, childptr)\n childptr = nextptr\n end\n end",
"def each(&block)\n axis_iterator(:child).each(&block)\n end",
"def each_child\n return nil unless self.child\n node = self.child\n while node\n yield node\n node = node.next_sibling\n end\n return true\n end",
"def each(&block)\n sorted_children.each do |name, child|\n yield(name, child)\n end\n end",
"def each(&block)\n block.call(self)\n @child_array.each do |node|\n node.each(&block)\n end\n end",
"def each_child(&block)\n children.each do | child |\n yield(child)\n child.each_child &block unless child.leaf?\n end\n end",
"def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n end",
"def each\n yield self\n children.each {|c| c.each {|n| yield n}}\n end",
"def iterate root_child_itr\t\t\t#to iterate over the nodes\t\t\n\t \n\t ## Collect root_child_itr.children in a variable since it being used twice\n\t ## Can you try using some other conditional construct other than loop and break?\n\t\twhile true\n\t\t ###### Use an intuitive variable name\n\t\t\tchild = root_child_itr.children\n\t\t\t\n\t\t\t##### if temp.children[0]\n\t\t\tif child.children[0] == nil\t\t\t#checking if the node is innermost as innermost node will not be having any childnode\n\t\t\t\t@@arr.push child\n break\n\t\t\telse\n\t\t\t\tscan root_child_itr\t\t# iterate over the childnodes if it is not the parent of the innermost node\n break\n\t\t\tend\t\t\n\t\tend\n\tend",
"def process_child_nodes(node); end",
"def tsort_each_child(node) # :yields: child\n raise NotImplementedError.new\n end",
"def each_child_page\n return if leaf?\n\n return enum_for(:each_child_page) unless block_given?\n\n each_record do |rec|\n yield rec.child_page_number, rec.key\n end\n\n nil\n end",
"def each_node(&block)\n c = children # save children before yield\n yield(self)\n c.each do |n|\n n.each_node(&block)\n end\n end",
"def iterate_children(ts, block, new_model)\n ts.children.each do |cs|\n # assumes there is only one element - could iterate instead but what case would that be?\n element = block.css(cs.selector).first\n\n handle_element(cs, element, new_model)\n end # end top selector children iteration\n end",
"def each_child_recursive # :yields: child\n each_child do |child|\n yield child\n child.each_child_recursive do |subchild|\n yield subchild\n end\n end\n end",
"def each_child_with_index(&block) # :yields: child_node, index\n children.each_with_index(&block)\n nil\n end",
"def each_child_with_index(&block) # :yields: child_node, index\n children.each_with_index(&block)\n nil\n end",
"def each(*selector, &blk)\n children(*selector, &blk)\n self\n end",
"def map_child\n array = []\n @children.each_pair { |_, child| array << (yield child) }\n array\n end",
"def test_each\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(5, @root.size, \"Should have five nodes\")\n assert(@child3.has_children?, \"Should have children\")\n\n nodes = []\n @root.each { |node| nodes << node }\n\n assert_equal(5, nodes.length, \"Should have FIVE NODES\")\n assert(nodes.include?(@root), \"Should have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(nodes.include?(@child3), \"Should have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def each(key, &block)\n if @value\n yield(key, @value)\n end\n @children.each do |letter, child|\n child.each(key + letter, &block)\n end\n end",
"def walk(&blk)\n yield self\n self.each_child do |child|\n child.walk(&blk)\n end\n end",
"def each(&block)\n tree.each(&block)\n end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def each(&block)\n @child_path_parts.each do |key, value|\n yield value\n end\n end",
"def _children\n @children\n end",
"def each(&block)\n root.each(&block)\n end",
"def all_children\n\n yielded_self = if block_given?\n yield self\n end\n\n return ( yielded_self || self ) if self.children.empty?\n _child = self.children.map do |child|\n _name = (yield child if block_given?) || self\n if child.children.empty?\n _name\n else\n [_name, child.all_children{ |this_child| yield this_child if block_given? }]\n end\n end\n return _child\n end",
"def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end",
"def tdiff_each_child(node,&block)\n if node.kind_of?(Nokogiri::XML::Element)\n node.attribute_nodes.sort_by(&:name).each(&block)\n end\n\n node.children.each(&block)\n end",
"def each\n queue = [@root]\n until queue.empty?\n kids = queue.shift.children\n kids.each do |x| yield x end\n queue.concat kids\n end\n end",
"def each_existing_child &block\n children.each_with_index do |child, idx|\n if child.is_nil_parse? then no(\n \"NilParse found in call do each_existing_child(). \"<<\n \"fix this for #{short}\"\n ) end\n block.call(child, idx)\n end\n nil\n end",
"def _children\n @children\n end",
"def walk &blk\n self.children.each do |child|\n yield child\n end\n self.children.each do |child|\n child.walk &blk\n end\n end",
"def each_sequence_member()\n node = self\n container_type = type()\n \n done = false\n until done\n done = true\n node.component_nodes.each do |child_node|\n if child_node.type == container_type then\n node = child_node\n done = false\n else\n yield( child_node )\n end\n end\n end\n end",
"def each_sequence_member()\n node = self\n container_type = type()\n \n done = false\n until done\n done = true\n node.component_nodes.each do |child_node|\n if child_node.type == container_type then\n node = child_node\n done = false\n else\n yield( child_node )\n end\n end\n end\n end",
"def tsort_each_child(node, &block)\n query(:object => node) do |statement|\n block.call(statement.subject)\n end\n end",
"def tsort_each_child(node, &block)\n query(:object => node) do |statement|\n block.call(statement.subject)\n end\n end",
"def tsort_each_child(node, &block)\n query(:object => node) do |statement|\n block.call(statement.subject)\n end\n end",
"def children\n _children\n end",
"def traverse(&block)\n children.each{|j| j.traverse(&block) }\n block.call(self)\n end",
"def iterate(itr)\n itr.call(@leaf)\n end",
"def each &block\n enumerator = Enumerator.new do |words|\n words << as_word if terminal?\n children.each { |child| child.each { |word| words << word } }\n end\n\n block.nil? ? enumerator : enumerator.each(&block)\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def visit_all(&block)\n visit &block\n children.each {|c| c.visit_all &block}\n end",
"def each_child_with_index\n end",
"def each(&block)\n root.each(&block)\n end",
"def iterate_accessible_children\n # Allocate a pointer to LONG for the out param to give AccessibleChildren\n return_count = 0.chr * 4 \n # Allocate space for an array of VARIANTs. AccessibleChildren wilhttp://search.cpan.org/~pbwolf/Win32-ActAcc-1.1/http://search.cpan.org/~pbwolf/Win32-ActAcc-1.1/l\n # place one VARIANT (16 bytes) into each array element. Note that this\n # is a C array and not a Ruby array, so it will appear to be a single\n # binary string:\n child_variant_carray_buf = 0.chr * (16 * @childcount)\n #puts \"CHILDCOUNT IS '#{@childcount}' - allocated a 16*#{@childcount} byte Ruby string:\"\n #pp child_variant_carray_buf\n hr = AccessibleChildren.call(@iacc_ptr,\n 0,\n @childcount,\n child_variant_carray_buf,\n return_count) \n raise \"AccessibleChildren failed!\" if (hr != 0)\n\n #puts \"carray buffer before split:\"\n #pp child_variant_carray_buf\n\n return_count_unpacked = return_count.unpack('L').first\n #puts \"Return count was '#{return_count_unpacked}'\"\n\n # Split the packed buffer string into its individual VARIANTS, by using\n # map to get a Ruby array of 16-byte strings. If this is successful\n # then each string will be a single VARIANT.\n\n # Old Ruby 1.8.7 way of building the array of child variants: \n# child_variants = child_variant_carray_buf.scan(/.{16}/).map {|s| s}.flatten\n # NOTE: Interesting Ruby 1.9 fact - in 1.9, using scan with a regexp\n # on a string with packed binary data seems to always raise an exception.\n #\n # Instead split the packed string into an array of strings this way:\n child_variants = Array.new\n offset = 0\n return_count_unpacked.times do\n #puts \"at offset '#{offset}'\"\n child_variants << child_variant_carray_buf[offset, 16]\n offset += 16\n end\n\n #pp child_variants\n \n # Iterate over the children\n count = 1\n child_variants.each do |variant| \n #puts \"examining child variant #{count}\"\n count += 1\n # We could unpack the entire variant into an array like this:\n# vtchild = variant.unpack('SSSSLL')\n# vt = vtchild[0]\n # Or, we can just access the members one at a time like this:\n vt = variant[0,2].unpack('S').first\n\n # Skip if the variant's .vt is not VT_DISPATCH. This avoids trying to QI\n # any variants that do not contain an IDispatch/IAccessible object.\n if (vt != VT_DISPATCH)\n #puts(\"No IDispatch/IAccessible in this VARIANT...skipping it.\")\n next\n end\n # Get the IDispatch* value stored in the VARIANT's .pdispVal member.\n # This will be a Ruby Fixnum representing a memory address.\n pdispval_ptr = variant[8,4].unpack('L').first\n\n # We must get the QueryInterface function ptr of the IDispatch object,\n # so we can QI the IAccessible interface of the IDispatch. Perhaps\n # there's some more graceful way to handle this; maybe make it a method?\n #\n # IDispatch contains 7 functions, so we need 7 blocks of 4 bytes for\n # each function's address:\n child_vtbl_ptr = 0.chr * 4\n child_vtbl = 0.chr * (4 * 7)\n memcpy(child_vtbl_ptr, pdispval_ptr, 4)\n memcpy(child_vtbl, child_vtbl_ptr.unpack('L').first, 4 * 7)\n child_vtbl = child_vtbl.unpack('L*')\n queryInterface = Win32::API::Function.new(child_vtbl[0], 'PPP', 'L')\n # Get the IAccessible of the IDispatch\n child_iacc = 0.chr * 4\n hr = queryInterface.call(pdispval_ptr, IID_IAccessible, child_iacc)\n raise \"QueryInterface of child element failed!\" if (hr != S_OK)\n\n child = AccessibleObject.new(:iacc, child_iacc)\n\n #puts \"Child name is: '#{child.name}'\"\n\n if block_given?\n yield child\n end\n\n # FIXME - whether a match is found or not, we need to release/free all\n # unneeded child objects and BSTRs created during the search...\n end\n end",
"def each(&proc)\n @subtrees.each(&proc)\n end",
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def children\n attributes.fetch(:children)\n end",
"def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end",
"def traverse(&block)\n children.each { |j| j.traverse(&block) }\n block.call(self)\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def apply_to_children(&block)\n self.entities.each do |entity|\n block.call(entity)\n entity.apply_to_children(&block)\n end\n end",
"def each\n queue = [@root]\n until queue.empty?\n node = queue.shift\n queue += node.children\n yield node\n end\n end",
"def add_children children\n children.each { |child| add_child child }\n end",
"def tsort_each_child(table_name, &block)\n TableInspector.new(table_name).\n select_parents_from(@table_names).each(&block)\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def traverse_down(&block)\n block.call(self)\n if(!children.nil?)\n children.each{ |child| child.traverse_down(&block) }\n end\n end",
"def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n end",
"def apply_children\n \n end",
"def each(node, &block)\n visit(node, &block)\n end",
"def each &block\n @root.each(&block)\n end",
"def each\n\n this_node = @head\n\n size.times do |i|\n yield this_node.value\n this_node = this_node.child\n end\n\n return self\n end",
"def draw_children\n first = true\n @children.each do |child|\n child.draw(1, first)\n first = false\n end\n puts '└──'\n end",
"def each_child_index\n end",
"def iterate(node)\n return unless node.is_a?(AST::Node)\n\n before = :\"on_#{node.type}\"\n after = :\"after_#{node.type}\"\n skip_node = catch :skip_child_nodes do\n execute_callback(before, node)\n end\n\n if skip_node != node\n node.children.each do |child|\n iterate(child) if child.is_a?(AST::Node)\n end\n end\n\n execute_callback(after, node)\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def each_recursive(&block)\n tree.each_recursive(&block)\n end",
"def each()\n @root.each(\"\") do |k, v|\n yield(k, v)\n end\n end",
"def children\n ary = normal_children.dup\n ary << fallback_child if fallback_child\n ary\n end",
"def children\n Dir[file_path + '/*'].map do |path|\n child ::File.basename(path)\n end\n end",
"def each\n return enum_for :each unless block_given?\n\n yield as_word if terminal?\n\n children_tree.each_value do |child|\n child.each do |word|\n yield word\n end\n end\n\n self\n end",
"def each(&blk)\n @trees.each_value(&blk)\n end",
"def children\n raise NotImplementedError\n end",
"def all_children\n children(all: true)\n end"
] | [
"0.83317053",
"0.83268374",
"0.81140023",
"0.80316937",
"0.7905068",
"0.7903883",
"0.788483",
"0.75929475",
"0.7458274",
"0.74274695",
"0.72852683",
"0.72834605",
"0.7254624",
"0.7145825",
"0.7081104",
"0.7064256",
"0.6837179",
"0.67730933",
"0.6771015",
"0.67336655",
"0.66845936",
"0.66363484",
"0.659675",
"0.6471779",
"0.6471779",
"0.64701235",
"0.6456738",
"0.6453776",
"0.6319642",
"0.6311234",
"0.63041097",
"0.62763375",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.6252294",
"0.62208",
"0.6207248",
"0.6193788",
"0.6179247",
"0.61749285",
"0.6168494",
"0.61588585",
"0.6158417",
"0.6129946",
"0.6125487",
"0.6112464",
"0.6112464",
"0.6086855",
"0.6086855",
"0.6086855",
"0.6066874",
"0.6052937",
"0.6051763",
"0.6040804",
"0.6021531",
"0.6021531",
"0.6021531",
"0.6021531",
"0.60175884",
"0.5989675",
"0.5989161",
"0.598794",
"0.5986857",
"0.5969872",
"0.5968606",
"0.59615165",
"0.5957357",
"0.5948103",
"0.59408396",
"0.5930182",
"0.5929286",
"0.5910015",
"0.5898414",
"0.5894507",
"0.589384",
"0.5880637",
"0.5867448",
"0.58650833",
"0.5861067",
"0.584727",
"0.5846828",
"0.58366615",
"0.58359283",
"0.58355385",
"0.5833348",
"0.5827039",
"0.5825271",
"0.5814608",
"0.58129174",
"0.5811514",
"0.57946324"
] | 0.8106261 | 3 |
+each_child_with_index+ iterates over each child. | def each_child_with_index(&block) # :yields: child_node, index
children.each_with_index(&block)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_child_with_index\n end",
"def each_child_index\n end",
"def each_with_index(&block)\n @tree.each_with_index(&block)\n end",
"def child(index)\n @children[index]\n end",
"def get_child(index)\n @children[index]\n end",
"def get_child(index)\n \t@children[index]\n end",
"def [](index)\n children[index]\n end",
"def [](index)\n @children[index]\n end",
"def [](i)\n\t @children[i]\n\tend",
"def each(&block)\n axis_iterator(:child).each(&block)\n end",
"def get_child_positions\n @children.map { |x| x.idx }\n end",
"def index_of(child)\n children.index(child)\n end",
"def each_child\n @children.each_pair { |_, child| yield child }\n end",
"def each_child\n @children.each { |child| yield child }\n end",
"def each_child\n @children.each { |child| yield child }\n end",
"def print_children(index)\n\t\tfor i in (0..(@binder_file_tree_array[index].length-1))\n\n\t\t\tnode = @binder_file_tree_array[index][i]\n\n\t\t\t\t@retarray << [\tnode.id.to_s,\n\t\t\t\t\t\t\t\tnode.title,\n\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\tnode.format.to_i,\n\t\t\t\t\t\t\t\tnode.versions]\n\n\t\t\tif @binder_parent_id_array.include? @binder_file_tree_array[index][i].id.to_s\n\t\t\t\t@retarray += print_children(index + 1)\n\t\t\tend\n\t\tend\n\t\treturn @retarray.uniq\n\tend",
"def mutate_child(index, mutator = Mutator, &block)\n block ||= ->(_node) { true }\n child = children.at(index)\n mutator.each(child, self) do |mutation|\n next unless block.call(mutation)\n emit_child_update(index, mutation)\n end\n end",
"def child(n)\n if n < 0\n raise Exceptions::ZipperError,\n \"child index cannot be negative\"\n end\n\n cursor = down\n until n.zero?\n cursor = cursor.next\n n -= 1\n end\n cursor\n end",
"def each_child(&_block)\n @children.each { |child| yield child }\n end",
"def each_child(&block) # :yields: child_node\n children.each(&block)\n nil\n end",
"def get_child_index\n return 0\n end",
"def each_child\n \n end",
"def each_with_index\n each_linked_list_item_with_index do |node, index|\n yield node.payload, index\n end\n end",
"def traverse index_array\n\t\treturn self if index_array.size == 0\n\t\tchild = index_array.shift\n\t\treturn nil if child > @children.size\n\t\treturn @children[child - 1].traverse(index_array)\n\tend",
"def each\n @children.each { |child| yield child }\n end",
"def my_each_with_index\n\t\tself.length.times do |index|\n\t\t\tyield(self[index], index)\n\t\tend\n\tend",
"def each_index\n\t\t\[email protected]_index { |x| yield x }\n\t\tend",
"def each\n @children.each {|child| yield child}\n end",
"def getChildrenIdx(idx)\n [2 * idx + 1, 2 * idx + 2]\n end",
"def delete_child_at(index)\n # NOTE: All deleting uses this method so that subclasses can override default behaviour when deleting a child\n @children.delete_at(index)\n end",
"def each(&block)\n sorted_children.each do |name, child|\n yield(name, child)\n end\n end",
"def index(child); end",
"def idx_children(parent_i)\n [parent_i * 2 + 1, parent_i * 2 + 2]\n end",
"def item(index)\n c = @children[index]\n yield c if block_given?\n return c\n end",
"def move_to_child_with_index(node, index)\n index = index.to_i\n\n if index >= 0\n move_to_child_with_position node, index + 1\n elsif node\n movement(node, :strict => true) do |to|\n to.parent = node\n to.position = to.target.children.size + index + 1\n end\n else\n move_to_child_with_position nil, scope.roots.size + index + 1\n end\n end",
"def each(&block)\n block.call(self)\n @child_array.each do |node|\n node.each(&block)\n end\n end",
"def index_children(children)\n children.each do |model|\n Logger.new($stdout).info(\"Generating indexes for #{model}\")\n model.create_indexes\n index_children(model.descendants)\n end\n end",
"def right_child_index(i)\n (i * 2) + 1\n end",
"def left_child_index(i)\n i * 2\n end",
"def each_child_page\n return if leaf?\n\n return enum_for(:each_child_page) unless block_given?\n\n each_record do |rec|\n yield rec.child_page_number, rec.key\n end\n\n nil\n end",
"def apply_child (child_index, workitem)\n\n child_index, child = if child_index.is_a?(Integer)\n [ child_index, raw_children[child_index] ]\n else\n [ raw_children.index(child_index), child_index ]\n end\n\n get_expression_pool.tlaunch_child(\n self, child, child_index, workitem, :register_child => true)\n end",
"def own_child_index\n return nil if parent.nil? # self is root\n own_index = nil\n parent.children.each_with_index { |c,i|\n if self == c\n own_index = i\n break\n end\n }\n own_index\n end",
"def create_index_nodes_for_children(root_element)\n self.child_nodes.keys.each do |association_name|\n association_value = send(association_name)\n\n Array(association_value).each do |child_node|\n child_node.create_index_node(root_element)\n end\n end\n end",
"def tsort_each_child(node) # :yields: child\n raise NotImplementedError.new\n end",
"def sink index\n loop do\n # define all other relevant index values\n last_item_index = size - 1\n l_child = 2 * index + 1\n r_child = 2 * index + 2\n # default to L in case of tie\n smaller_child = l_child\n # set smaller_child to right_child if that is a valid index and it is less than the left\n smaller_child = r_child if (r_child < last_item_index && less_than?(r_child, l_child))\n # if we are outside the bounds of our tree\n # or if we cannot sink item at `index` anymore\n break if (l_child >= last_item_index || less_than?(index, smaller_child))\n # otherwise, swap the values, \"bubbling\" the item down\n swap_values_at(smaller_child, index)\n # set the new index to the positions we've just moved to\n index = smaller_child\n end\n end",
"def child_index=(idx)\n move_to_child_with_index(parent, idx.to_i) unless new_record?\n end",
"def child_index=(idx)\n move_to_child_with_index(parent, idx.to_i) unless new_record?\n end",
"def each_index\n return enum_for(:each_index) unless block_given?\n\n each_index_root_page_number do |page_number|\n yield index(page_number)\n end\n\n nil\n end",
"def child_index=(idx)\n move_to_child_with_index(parent, idx.to_i) unless new_record?\n end",
"def parent_child_index(parent) # @private\n # Could be {\"post[authors_attributes]\"=>0} or { :authors => 0 }\n duck = parent[:builder].instance_variable_get('@nested_child_index')\n \n # Could be symbol for the association, or a model (or an array of either, I think? TODO)\n child = parent[:for]\n # Pull a sybol or model out of Array (TODO: check if there's an Array)\n child = child.first if child.respond_to?(:first)\n # If it's an object, get a symbol from the class name\n child = child.class.name.underscore.to_sym unless child.is_a?(Symbol)\n \n key = \"#{parent[:builder].object_name}[#{child}_attributes]\"\n\n # TODO: One of the tests produces a scenario where duck is \"0\" and the test looks for a \"1\" \n # in the legend, so if we have a number, return it with a +1 until we can verify this scenario.\n return duck + 1 if duck.is_a?(Fixnum)\n \n # First try to extract key from duck Hash, then try child\n (duck[key] || duck[child]).to_i + 1\n end",
"def each_child\n childptr = CMark.node_first_child(@pointer)\n while not childptr.null? do\n nextptr = CMark.node_next(childptr)\n yield Node.new(nil, childptr)\n childptr = nextptr\n end\n end",
"def iterate_children(ts, block, new_model)\n ts.children.each do |cs|\n # assumes there is only one element - could iterate instead but what case would that be?\n element = block.css(cs.selector).first\n\n handle_element(cs, element, new_model)\n end # end top selector children iteration\n end",
"def test_index # Test the [] method\n assert_raise(ArgumentError) {@root[nil]}\n\n @root << @child1\n @root << @child2\n assert_equal(@child1.name, @root['Child1'].name, \"Child 1 should be returned\")\n assert_equal(@child1.name, @root[0].name, \"Child 1 should be returned\")\n assert_equal(@child1.name, @root[-2].name, \"Child 1 should be returned\") # Negative access also works\n assert_equal(@child1.name, @root[-(@root.children.size)].name, \"Child 1 should be returned\") # Negative access also works\n\n assert_equal(@child2.name, @root['Child2'].name, \"Child 2 should be returned\")\n assert_equal(@child2.name, @root[1].name, \"Child 2 should be returned\")\n assert_equal(@child2.name, @root[-1].name, \"Child 2 should be returned\") # Negative access also works\n\n assert_nil(@root['Some Random Name'], \"Should return nil\")\n assert_nil(@root[99], \"Should return nil\")\n assert_nil(@root[-(@root.children.size+1)], \"Should return nil\")\n assert_nil(@root[-3], \"Should return nil\")\n end",
"def each_with_index\n return nil if @head.nil?\n node_index = 1 #I'll consider first node as 1 \n entry = @head\n until entry.nil?\n yield entry, node_index\n entry = entry.next\n node_index +=1\n end\n end",
"def each_child\n self.class.child_references.each do |child_attr|\n children = Array(self.send(child_attr)).clone\n children.each do |child|\n yield(child)\n end\n end\n end",
"def spawn_child(index)\n master_pid = $$ # need to store in order to pass down to child\n child_pid = fork do\n @file_lock.close\n child_class.new(index, master_pid).start\n end\n children[index] = child_pid\n ProcessManager::Log.info \"#{description}: Spawned child #{index + 1}/#{ProcessManager::Config.config[:children]}\"\n end",
"def child number\n unless @node.send(@children).nil?\n @node = ( ( @node.send(@children) ).at(number) )\n end\n end",
"def test_indexed_access\n setup_test_tree\n\n assert_equal(@child1, @root[0], \"Should be the first child\")\n assert_equal(@child4, @root[2][0], \"Should be the grandchild\")\n assert_nil(@root[\"TEST\"], \"Should be nil\")\n assert_nil(@root[99], \"Should be nil\")\n assert_raise(ArgumentError) { @root[nil] }\n end",
"def each_existing_child &block\n children.each_with_index do |child, idx|\n if child.is_nil_parse? then no(\n \"NilParse found in call do each_existing_child(). \"<<\n \"fix this for #{short}\"\n ) end\n block.call(child, idx)\n end\n nil\n end",
"def delete_child(index)\n dup_children = children.dup\n dup_children.delete_at(index)\n emit_type(*dup_children)\n end",
"def each_index\n\t\[email protected]_index do |y|\n\t\t\t@data[y].each_index do |x|\n\t\t\t\tyield x, y\n\t\t\tend\n\t\tend \n\tend",
"def my_each_with_index\n for i in 0...self.length do\n yield(self[i], i)\n end\n return self\n end",
"def iterate root_child_itr\t\t\t#to iterate over the nodes\t\t\n\t \n\t ## Collect root_child_itr.children in a variable since it being used twice\n\t ## Can you try using some other conditional construct other than loop and break?\n\t\twhile true\n\t\t ###### Use an intuitive variable name\n\t\t\tchild = root_child_itr.children\n\t\t\t\n\t\t\t##### if temp.children[0]\n\t\t\tif child.children[0] == nil\t\t\t#checking if the node is innermost as innermost node will not be having any childnode\n\t\t\t\t@@arr.push child\n break\n\t\t\telse\n\t\t\t\tscan root_child_itr\t\t# iterate over the childnodes if it is not the parent of the innermost node\n break\n\t\t\tend\t\t\n\t\tend\n\tend",
"def my_each_with_index\n i = 0\n while i < self.size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each(&block)\n @index.each(&block)\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each\n yield self\n children.each {|c| c.each {|n| yield n}}\n end",
"def each_with_index(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i),i) }\n end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each\n @indexes.each { |_name, index| yield index }\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield self[i], i\n i += 1\n end\n end",
"def next_child_index (returning_fei)\n\n next_id = if returning_fei.is_a?(Integer)\n returning_fei + 1\n elsif returning_fei == self.fei\n 0\n else\n returning_fei.child_id.to_i + 1\n end\n\n loop do\n\n break if next_id > raw_children.length\n\n raw_child = raw_children[next_id]\n\n return next_id \\\n if raw_child.is_a?(Array) or raw_child.is_a?(FlowExpressionId)\n\n next_id += 1\n end\n\n nil\n end",
"def index_of_child child\n found = nil\n node_id = child.node_id\n each_with_index do |child, idx|\n next unless child.respond_to?(:node_id)\n if child.node_id == node_id\n found = idx\n break\n end\n end\n if ! found\n fail(\"no child of mine: (##{child.node_id} is not in #{node_id}\")\n end\n found\n end",
"def child_index(path)\n resource = sitemap.find_resource_by_path(\"#{path}/index.html\")\n return \"\" if resource.children.size == 0\n resource.children.each { |e| \"<li>#{link_to e.data.id, e.url}</li>\" }\n index = resource.children.reduce(\"\") { |a, e| a + \"<li>#{link_to e.data.title, e.url}</li>\" }\n \"<ul>#{index}</ul>\"\n end",
"def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n end",
"def each &block\n each_with_index {|x, i| block.call(x)}\n end",
"def each_index\n @block_args.each_index do |i|\n yield i\n end\n end",
"def iterate(itr)\n itr.call(@leaf)\n end",
"def each_with_index # :yields: e, i, j\n (0...hsize).each { |j|\n (0...vsize).each { |i|\n yield self[i,j], i, j\n }\n }\n self\n end",
"def bubble_up(index)\n parent_index = (index / 2)\n\n # return if we reach the root element\n return if index <= 1\n\n # or if the parent is already less than the child\n return if @elements[parent_index].num_of_MRVs <= @elements[index].num_of_MRVs\n\n # otherwise we exchange the child with the parent\n exchange(index, parent_index)\n\n # and keep bubbling up\n bubble_up(parent_index)\n end",
"def my_each_with_index\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each_index\n (0...hsize).each { |j|\n (0...vsize).each { |i|\n yield i, j\n }\n }\n self\n end",
"def process_child_nodes(node); end",
"def cfei_at(i)\n\n children.find { |cfei| Ruote.extract_child_id(cfei) == i }\n end",
"def move_to_child_with_index(node, index)\n raise ActiveRecord::ActiveRecordError, \"index can't be nil\" unless index\n\n tenacious_transaction do\n new_siblings = (node.try(:children) || ordered_tree_scope.roots).\n reload.\n lock(true).\n reject { |root_node| root_node == self }\n\n if new_siblings.empty?\n node ? move_to_child_of(node) : move_to_root\n elsif new_siblings.count <= index\n move_to_right_of(new_siblings.last)\n elsif\n index >= 0 ? move_to_left_of(new_siblings[index]) : move_to_right_of(new_siblings[index])\n end\n end\n end",
"def find_element_children(index, el_depth, ordering)\n\t\tchildren = Array.new\n\t\ti = index + 1\n\t\tcurr_el = get_element_in_ordering(i, ordering)\n\t\twhile (curr_el == \"PlaceHolder\") #ignore nil elements\n\t\t\ti = i+1\n\t\t\tcurr_el = get_element_in_ordering(i, ordering)\n\t\tend\n\n\t\tif curr_el.is_a?(Node)\n\t\t\tcurr_child_depth = curr_el.depth\n\t\telse #if it's a note, it can't have children, so arbitrary big depth that'll get rest on the first node\n\t\t\tcurr_child_depth = 100000\n\t\tend\n\n\t\twhile (curr_el != nil && el_depth < curr_el.depth) #until you find something of equal or lesser depth\n\t\t\t#basically, include it if it's nested deeper (therefore in this loop,) but don't go into children of what you find)\n\t\t\tif curr_el.depth <= curr_child_depth && curr_el.is_a?(Node)\n\t\t\t\tnode_and_index = { node: curr_el, index: i}\n\t\t\t\tchildren.push(node_and_index)\n\t\t\t\tcurr_child_depth = curr_el.depth\n\t\t\telsif curr_el.depth <= curr_child_depth && (curr_el.is_a?(Note) || curr_el.is_a?(LinkCollection))\n\t\t\t\tnode_and_index = { node: curr_el, index: i}\n\t\t\t\tchildren.push(node_and_index)\n\t\t\t\tcurr_child_depth = 100000 \n\t\t\tend\n\t\t\t#if there's an indented note after some nodes, it will likely get ignored\n\n\t\t\ti = i+1\n\t\t\tcurr_el = get_element_in_ordering(i, ordering)\n\t\t\twhile (curr_el == \"PlaceHolder\") #ignore nil elements\n\t\t\t\ti = i+1\n\t\t\t\tcurr_el = get_element_in_ordering(i, ordering)\n\t\t\tend\n\t\tend\n\t\treturn children\n\tend",
"def right_child_node(index)\n index * 2 + 2\n end",
"def my_each_with_index\n \ti = 0\n \twhile i < self.length\n \t\tif block_given?\n \t\t\tyield(self[i], i)\n \t\telse\n \t\t\treturn self\n \t\tend\n \t\ti +=1\n \tend\n \tself\n end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield self[i], i\n i += 1\n end\n self\n end",
"def each_index(&block)\n return enum_for(:each_index) unless block_given?\n 0.upto(size-1, &block)\n self\n end",
"def getChildNode(xml, index)\n\n #puts \"XML -- \\n\\n#{xml}\"\n\t childCount = 0\n if(xml != nil && xml[\"childCount\"] != nil)\n\n childCount = xml[\"childCount\"].to_i\n \t\tif(index >= 0 && index < childCount)\n \t\t return xml[index]\n \t\tend\n end\n\t return nil\n\tend",
"def child(name, index)\n define_getter(name, index)\n define_update_method(name, index)\n end",
"def each_with_index(&block)\n @delegate.each_with_index(&block)\n end",
"def next_child_in_path(start_node_index, end_node_index)\n next_child = end_node_index\n while parent_index(end_node_index) != start_node_index\n end_node_index = parent_index(end_node_index)\n next_child = end_node_index\n end \n next_child\n end",
"def parent_child_index(parent) #:nodoc:\n duck = parent[:builder].instance_variable_get('@nested_child_index')\n\n if duck.is_a?(Hash)\n child = parent[:for]\n child = child.first if child.respond_to?(:first)\n duck[child].to_i + 1\n else\n duck.to_i + 1\n end\n end",
"def left_child_node(index)\n index * 2 + 1\n end",
"def map_child\n array = []\n @children.each_pair { |_, child| array << (yield child) }\n array\n end",
"def left_child(indx)\n 2*indx + 1\n end"
] | [
"0.82137316",
"0.7930641",
"0.73494834",
"0.706672",
"0.70498025",
"0.70198655",
"0.6961662",
"0.67976767",
"0.6777808",
"0.6738946",
"0.6671282",
"0.6645055",
"0.6573938",
"0.6547132",
"0.65461504",
"0.6528009",
"0.6524863",
"0.65145725",
"0.64962417",
"0.64926803",
"0.6482804",
"0.64723337",
"0.64085066",
"0.63681936",
"0.6364935",
"0.63329244",
"0.63170993",
"0.6311477",
"0.6299973",
"0.6235223",
"0.62061304",
"0.61895573",
"0.6181711",
"0.61491275",
"0.6147019",
"0.6137855",
"0.61288",
"0.6111877",
"0.6091587",
"0.6063407",
"0.6059951",
"0.6037519",
"0.6031767",
"0.6018643",
"0.5977551",
"0.5964326",
"0.5964326",
"0.59572226",
"0.59565425",
"0.5949089",
"0.5946973",
"0.5918423",
"0.58866936",
"0.5886499",
"0.58851326",
"0.5879712",
"0.5878397",
"0.58730096",
"0.5836526",
"0.58304036",
"0.58293676",
"0.5827127",
"0.582329",
"0.5816305",
"0.58091915",
"0.5805656",
"0.5805656",
"0.5802127",
"0.57920486",
"0.5787304",
"0.5779535",
"0.57735217",
"0.57718766",
"0.57363284",
"0.5733789",
"0.5728584",
"0.57280034",
"0.57146645",
"0.57068354",
"0.5694746",
"0.5691337",
"0.5689793",
"0.5677808",
"0.56771564",
"0.56766796",
"0.56538415",
"0.5651745",
"0.5649323",
"0.5639038",
"0.56379724",
"0.5630072",
"0.56094885",
"0.5593484",
"0.559259",
"0.5587093",
"0.55858433",
"0.5577437",
"0.55714405",
"0.5562714"
] | 0.8773223 | 1 |
+find_element+ searches an element which universal name is specified by the arguments. It returns nil if not found. | def find_element(*names)
traverse_element(*names) {|e| return e }
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_name name\n find_element :name, name\n end",
"def find_element(*args)\n sleep 0.1\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => \"element not found\"})\n wait.until {\n bridge.find_element_by by, what.to_s, ref\n }\n rescue Selenium::WebDriver::Error::TimeOutError => e\n return nil\n #raise Selenium::WebDriver::Error::NoSuchElementError\n end",
"def match_element_name(element_name)\n match(element, element_name)\n end",
"def find_element(*args)\n sleep 0.4\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new(timeout: timeout, message: 'element not found')\n wait.until do\n begin\n bridge.find_element_by(by, what.to_s, ref)\n rescue\n false\n end\n end\n rescue Selenium::WebDriver::Error::TimeOutError\n puts \"element not found #{how} #{what}\" if timeout > 3\n nil\n end",
"def find_element(element, strategy=:css)\n @fox_driver.find_element(strategy, element)\n end",
"def element_named(name)\n @elements.find{|e| e.name.to_s == name.to_s}\n end",
"def element(name, *find_args)\n build_element(name, *find_args) do\n define_method(name) do |*runtime_args, &block|\n raise_if_block(self, name, !block.nil?, :element)\n _find(*merge_args(find_args, runtime_args))\n end\n\n create_get_element_params(name, find_args)\n end\n end",
"def find_native_element(native_element)\n find_element(native_element[:locator], native_element[:element])\nend",
"def find_page_element(*args)\n element = page.find(*args)\nend",
"def find_eles tag_name\n @driver.find_elements :tag_name, tag_name\n end",
"def capybara_element(*args, wait: 0, **options)\n context.send(\"#{name}_element\", *args, **options.merge(match: :first, wait: wait))\n rescue Capybara::ElementNotFound\n nil\n end",
"def find_element\n raise \"Not a valid Finder: #{find_by.to_sym}\" unless FINDERS.include? find_by.to_sym\n\n case find_by.to_sym\n when :id\n $driver.find_element(find_by.to_sym, locator)\n when :value\n $driver.find(locator)\n when :xpath\n $driver.find_element(find_by.to_sym, locator)\n end\n end",
"def el(element_name)\n $LOG.info \"fetching the element #{element_name}\"\n element_reader = get_locator(element_name)\n begin\n if element_reader.length > 0\n element_reader.each do |k,v|\n if(k=='class' || k=='css' || k=='id' || k=='xpath' || k=='partial_link_text' || k=='tag_name')\n begin\n $elem = $driver.find_element(k.to_sym,v.to_s)\n $LOG.info \"Element found \\n #{element_name} : #{k} => #{v}\"\n rescue Exception => e\n $LOG.error \"Element not found \"\n $LOG.error \"#{element_name} : #{k} => #{v}\"\n $LOG.error \"Error message :: \" + e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n e.attach_file(\"test_file\", \"log/webscreenshot/webScreenshot.png\", true )\n raise \"Element not found \\n #{element_name} : #{k} => #{v} \\n Error Message :: \" + e.message\n end\n $elem\n end\n end\n else\n $LOG.error \"Element not present in object repository\"\n raise \"Element not present in object repository\"\n end\n $elem\n rescue Exception => e\n $LOG.error \"Error in finding the element :: \" + e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Error in finding the element :: \" + e.message\n end\n end",
"def element(name)\n elements.find { |el| el.name == name.to_s }\n end",
"def find_name(name)\n @driver.find_element(:name, name).click\n end",
"def find(locator)\n @browser.find_element locator\n end",
"def find_by(element, var) \n @selenium.find_element(element, var)\n end",
"def find(selector)\n DOM::Element.from_node `#{@el}.querySelector(#{selector}) || Opal.nil`\n end",
"def find(selector)\n value = `#{@el}.querySelector(#{selector}) || false`\n value ? DOM::Element.fromNode(value) : nil\n end",
"def find_elements(*args)\r\n how, what = extract_args(args)\r\n\r\n if how == :jquery && ref.nil?\r\n bridge.executeScript(\"return jQuery(arguments[0]).get();\", what)\r\n elsif how == :jquery && !ref.nil?\r\n bridge.executeScript(\"return jQuery(arguments[0]).find(arguments[1]).get();\",self, what)\r\n else\r\n unless by = FINDERS[how.to_sym]\r\n raise ArgumentError, \"cannot find elements by #{how.inspect}\"\r\n end\r\n\r\n bridge.find_elements_by by, what.to_s, ref\r\n end\r\n end",
"def getElementByAttribute(elementFindBy,elementIdentity,attributeName,attributeValue)\n puts \"in getElementByAttribute\"\n elements = @driver.find_elements(elementFindBy, elementIdentity)\n elements.each do |element|\n if element.attribute(attributeName) != nil then\n if element.attribute(attributeName).include? attributeValue then\n return element\n break\n end\n end\n end\n end",
"def element_name(str)\n find_element(:name, str)\n end",
"def FindChildOf(parentByStrat, parentIdentifier, childByStrat, childIdentifier)\n parent = find_element(parentByStrat, parentIdentifier)\n return nil if parent==nil\n return parent.find_element(childByStrat, childIdentifier)\nend",
"def find_element_button(browser, element_name, execution=false)\n button = nil\n not_found = \"element not found\"\n\n if browser.button(visible_text: element_name).present?\n button = browser.button(visible_text: element_name)\n puts button.text\n elsif browser.input(type: \"submit\", value: element_name)\n button = browser.input(type: \"submit\", value: element_name)\n puts button.value\n elsif browser.li(visible_text: element_name).present?\n button = browser.li(visible_text: element_name)\n puts button.text\n elsif browser.a(visible_text: element_name).present?\n button = browser.a(visible_text: element_name)\n puts button.text\n elsif browser.div(visible_text: element_name).present?\n button = browser.div(visible_text: element_name)\n puts button.text\n elsif browser.span(visible_text: element_name).present?\n button = browser.span(visible_text: element_name)\n puts button.text\n else\n #print not found if the element was not found\n puts not_found\n return nil\n end\n #click if the element found--function\n unless execution == false\n button.click\n end\n return \"ok\"\nend",
"def find_element(by, locator)\n Log.debug('Finding element...')\n element.find_element(by, locator)\n end",
"def find_elements(element_name, response)\n response.body.xpath(\".//x:#{element_name}\", 'x' => response.body.namespace.href)\n end",
"def name_exact name\n # exact description\n result = mobile :find, [ [ [5, name] ] ]\n\n return result if result.kind_of? Selenium::WebDriver::Element\n\n if result.length > 0\n result.first\n else\n Appium::Common.raise_no_element_error\n end\n end",
"def get_element(locator, base_element = nil)\n (base_element ? base_element : @browser).find_element(locator)\n end",
"def find_element( element_names )\n element_names = [ *element_names ]\n\n while( true )\n e = @pull_parser.peek\n if e.start_element?\n if element_names.include?( e[0] )\n return e[0]\n else\n return NOTHING\n end\n elsif e.end_element?\n return END_CONTEXT\n elsif e.end_document?\n return END_CONTEXT\n elsif e.text? \n # ignore whitespace between elements\n raise \"unexpected text content: #{e.inspect}\" if e[0] !~ /[[:space:]]/\n @pull_parser.pull\n end\n end\n end",
"def name name\n # work around https://github.com/appium/appium/issues/543\n # @driver.find_element :name, name\n mobile :find, [ [ [7, name] ] ]\n end",
"def locate\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n @element_name = locate_tagged_element('A', @how, @what)\r\n end\r\n @o = self\r\n end",
"def find_element(locator)\n return locator if locator.is_a?(Selenium::WebDriver::Element)\n\n element = nil\n how, what = parse_locator(locator)\n\n if how == :css\n new_what, nth = what.scan(/(.*):eq\\((\\d+)\\)/).flatten\n element = find_elements(\"#{how}=#{new_what}\")[nth.to_i] if nth\n end\n\n element ||= driver.find_element(how, what)\n\n raise Selenium::WebDriver::Error::NoSuchElementError, \"Failed to find element: #{locator}\" unless element\n\n wait_for { element.displayed? }\n\n element\n end",
"def get(element, name)\n lookup(key(element.to_s, name.to_s))\n end",
"def get(element, name)\n lookup(key(element.to_s, name.to_s))\n end",
"def find_by_name(name)\n return nil unless name.present?\n names.select {|e| e == name}\n end",
"def tag tag_name\n find_element :tag_name, tag_name\n end",
"def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end",
"def find_element(id, model)\n case model.downcase\n when 'work'\n return Work.find(id)\n when 'basicfile'\n return BasicFile.find(id)\n when 'singlefileinstance'\n return SingleFileInstance.find(id)\n when 'orderedinstance'\n return OrderedInstance.find(id)\n when 'person'\n return AuthorityMetadataUnit.find(id)\n else\n raise 'Unknown element type'\n end\n end",
"def locate\r\n @o = nil\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n @element_name = locate_tagged_element(\"TR\", @how, @what) \r\n end\r\n @o = self\r\n end",
"def locate\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n @element_name = locate_tagged_element(\"input\", @how, @what, @type, @value)\r\n end\r\n @o = self\r\n end",
"def element_location(element_name)\n $LOG.info \"getting element location #{element_name}\"\n begin\n wait_and_find_element(element_name)\n el_loc = el element_name\n el_loc.location\n rescue Exception => e\n $LOG.error \"Error getting element location of element name : #{element_name} \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Error getting element location of element name : #{element_name} \"+e.message\n end\n end",
"def create_existence_checker(element_name, *find_args)\n method_name = \"has_#{element_name}\"\n create_helper_method(method_name, *find_args) do\n define_method(method_name) do |*runtime_args|\n args = merge_args(find_args, runtime_args)\n wait_until('at least one element exists', *args)\n end\n end\n end",
"def locate\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n if(self.class::INPUT_TYPES.include?(\"select-one\"))\r\n @element_name = locate_tagged_element(\"select\", @how, @what, self.class::INPUT_TYPES)\r\n else \r\n @element_name = locate_tagged_element(\"input\", @how, @what, self.class::INPUT_TYPES)\r\n end \r\n end\r\n @o = self\r\n end",
"def find_elements(*args)\n how, what = extract_args(args)\n by = _set_by_from_finders(how)\n begin\n bridge.find_elements_by by, what.to_s, ref\n rescue Selenium::WebDriver::Error::TimeoutError\n []\n end\n end",
"def locate\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n @element_name = locate_tagged_element(\"TD\", @how, @what) \r\n end\r\n @o = self\r\n end",
"def expected_element element_name, timeout=30\n define_method 'expected_element' do\n self.send(element_name).wait_until_present timeout\n end\n end",
"def find_ele_by_text tag, text\n @driver.find_element :xpath, %Q(#{tag}[@text='#{text}'])\n end",
"def get_element_with_attributes name=nil\n get_element(name,nil,true)\n end",
"def get_element_attribute(access_type, access_name, attribute_name)\n $driver.find_element(:\"#{access_type}\" => \"#{access_name}\").attribute(\"#{attribute_name}\")\nend",
"def getElement_xpath(key,d=nil)\n if(d==nil)\n xpath = Keys_CONFIG[key]\n begin\n @driver.find_element(:xpath,xpath)\n rescue\n puts \"Element : \"+xpath+\" not found\"\n end \n elsif(d!=nil)\n @driver.find_element(:xpath,key)\n end\nend",
"def find_element(by, locator)\n Log.debug('[GRIDIUM::Element] Finding element...')\n Element.new(\"Child of #{@name}\", by, locator, parent: @element)\n end",
"def els(element_name)\n element_reader = get_locator(element_name)\n begin\n if element_reader.length > 0\n element_reader.each do |k,v|\n if(k=='class' || k=='css' || k=='id' || k=='xpath' || k=='partial_link_text' || k=='tag_name')\n begin\n $elems = $driver.find_elements(k.to_sym,v.to_s)\n $LOG.info \"Elements found \\n #{element_name} : #{k} => #{v}\"\n rescue Exception => e\n $LOG.error \"Element not found \"\n $LOG.error \"#{element_name} : #{k} => #{v}\"\n $LOG.error \"Error message :: \" + e.message\n raise \"Element not found \\n #{element_name} : #{k} => #{v} \\n Error Message :: \" + e.message\n end\n $elems\n end\n end\n else\n $LOG.error \"Element not present in object repository\"\n raise \"Element not present in object repository\"\n end\n $elems\n rescue Exception => e\n $LOG.error \"Error in finding the element :: \" + e.message\n raise \"Error in finding the element :: \" + e.message\n end\n end",
"def find_names name\n find_elements :name, name\n end",
"def find_elements(by, locator)\n element.find_elements(by, locator)\n end",
"def find_element(input_1, input_2)\n if input_1.find_index(input_2) == nil\n return -1\n end\n input_1.find_index(input_2)\nend",
"def expected_element(element_name, timeout=5)\n define_method(\"has_expected_element?\") do\n self.respond_to? \"#{element_name}_element\" and self.send(\"#{element_name}_element\").when_present timeout\n end\n end",
"def find_by_id(item)\n @driver.find_element(:id, item)\n end",
"def find(name); end",
"def locate\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n @element_name = locate_tagged_element('IMG', @how, @what)\r\n end\r\n @o = self\r\n end",
"def get_element_text(access_type, access_name)\n $driver.find_element(:\"#{access_type}\" => \"#{access_name}\").text\nend",
"def find_argument_by_name(name)\n arguments.find { |a| a.name == name }\n end",
"def find_by_name(name)\n end",
"def find_elements(locator)\n driver.find_elements(locator)\n end",
"def find_id id\n wait { find_element(:id, id) }\nend",
"def find_custom_element(xpath, timeout = WAITING_TIMEOUT)\n wait = Selenium::WebDriver::Wait.new(:timeout => timeout, :message => \"\\n\\nERROR! Element with xpath: '#{xpath}' was not found after #{timeout} seconds of waiting!\\n\\n\")\n custom_element = HomePage::Elements\n wait.until {\n custom_element = find_element(:xpath, xpath)\n custom_element.displayed?\n }\n custom_element\n end",
"def find(typed_name)\n nil\n end",
"def getElementByAttribute(driver, elementFindBy, elementIdentity, attributeName, attributeValue,attributeName2 = nil,attributeValue2=nil)\n puts \"in accountAssignment::getElementByAttribute\"\n driver.execute_script(\"arguments[0].scrollIntoView();\", driver.find_element(elementFindBy, elementIdentity))\n #puts \"in getElementByAttribute #{attributeValue}\"\n elements = driver.find_elements(elementFindBy, elementIdentity)\n elements.each do |element|\n if element.attribute(attributeName) != nil then\n if attributeName2.nil? then\n if element.attribute(attributeName).include? attributeValue then\n #puts \"element found\"\n return element\n end\n elsif !attributeName2.nil? then\n puts \"2nd attribute check\"\n if attributeValue2.nil? then\n puts \"2nd value in nil\"\n puts \"121--1\"\n puts element.attribute(attributeName)\n puts \"121--2\"\n puts element.attribute(attributeName2)\n puts \"121--2\"\n if (element.attribute(attributeName).include? attributeValue) && (element[0].attribute(attributeName2).nil?) then\n puts \"2nd attributeValue -- nil\"\n #puts \"element found\"\n return element\n end\n else\n if (element.attribute(attributeName).include? attributeValue) && (element.attribute(attributeName2).include? attributeValue2) then\n #puts \"element found\"\n puts '2nd attributeValue -- not nil'\n return element\n end\n end\n end\n end\n end\n end",
"def check_element_exists(exist, element)\n element = element.downcase.gsub(' ', '_')\n\n if exist == 'exist'\n unless wait_until{send(\"#{element}?\")}\n raise \"#{element} was not found!\"\n end\n\n elsif exist == 'not exist'\n if send(\"#{element}?\")\n raise \"#{element} was found!\"\n end\n\n else 'Incorrect option selected'\n end\n end",
"def elements(name, *find_args)\n build_elements(name, *find_args) do\n define_method(name) do |*runtime_args, &block|\n raise_if_block(self, name, !block.nil?, :elements)\n _all(*merge_args(find_args, runtime_args))\n end\n\n create_get_element_params(name, find_args)\n end\n end",
"def complex_find_exact(class_name, value)\n find_element :uiautomator, string_visible_exact(class_name, value)\n end",
"def element_displayed(element_name)\n $LOG.info \"verify element displayed in current page #{element_name}\"\n begin\n wait_and_find_element element_name\n el_disp = el element_name\n el_disp.display?\n rescue Exception => e\n $LOG.error \"error in displaying Element of element name : #{element_name} \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"error in displaying Element of element name : #{element_name}\"+e.message\n end\n end",
"def locate\r\n if @how == :jssh_name\r\n @element_name = @what\r\n elsif @how == :xpath\r\n @element_name = element_by_xpath(@container, @what)\r\n else\r\n @element_name = locate_tagged_element('TABLE', @how, @what)\r\n end\r\n @o = self\r\n end",
"def find_ele_by_attr_include tag, attr, value\n @driver.find_element :xpath, %Q(#{tag}[contains(@#{attr}, '#{value}')])\n end",
"def findAttribute(attribName)\n if @xmlElement.attributes[attribName] != nil\n return(@xmlElement.attributes[attribName])\n else\n if @parentElem != nil\n return(@parentElem.findAttribute(attribName))\n end\n end\n\n return nil\n end",
"def create_nonexistence_checker(element_name, *find_args)\n method_name = \"has_no_#{element_name}\"\n create_helper_method(method_name, *find_args) do\n define_method(method_name) do |*runtime_args|\n args = merge_args(find_args, runtime_args)\n wait_until('no element exists', *args)\n end\n end\n end",
"def find_ele_by_attr(class_name, attr, value)\n @driver.find_element :xpath, string_attr_exact(class_name, attr, value)\n end",
"def tag_name(locator)\n find_element(locator).tag_name\n end",
"def _check_has_element(*find_args)\n elements = page.find_elements(*find_args)\n return elements.empty? ? false : true\n end",
"def get_element(by, value)\n @wait.until { @browser.find_element(by, value).displayed? }\n element = @browser.find_element(by, value) # ; @wait.until { element.displayed?}\n return @browser.find_element(by, value) if element\n raise \"Element you have passed: #{value} with selector: #{by}\"\\\n \" was not found on page in #{@wait.inspect} time\"\n end",
"def search(xpath)\n return self.each_element( xpath ){}\n end",
"def wait_and_find_element(element_name)\n $LOG.info \"Waiting for element #{element_name}\"\n begin\n # timeout = INITIALIZATION_COMPONENTS['wait'].to_i\n timeout = Vanilla::ConfigReader.configuration_reader\n timeout = timeout['wait']\n if timeout == 0\n timeout = 10\n end\n wait_ele = el(element_name)\n wait = Selenium::WebDriver::Wait.new(timeout: timeout ) # seconds\n wait.until { wait_ele }\n rescue Exception => e\n $LOG.error \"Element is not displayed in specific time \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Element is not displayed in specific time \"+e.message\n end\n end",
"def method_missing(name, *args, &block)\n query_without_question_mark = /^has_(?<name>.+)_(?<type>#{ ELEMENT_TYPES })$/.match(name)\n element_query = /^has_(?<name>.+)_(?<type>#{ ELEMENT_TYPES })\\??$/.match(name)\n element_find = /^(?<name>.+)_(?<type>#{ ELEMENT_TYPES })$/.match(name)\n element_action = /^(?<action>click|fill_in|select|check)_(?<name>.+)_(?<type>#{ ELEMENT_TYPES })/.match(name)\n\n if element_action\n raise \"Undefined method '#{ element_action[0] }'. Maybe you mean \" +\n \"#{ self.class }##{ element_action['name'] }_#{ element_action['type'] }.#{ element_action['action'] }?\"\n elsif query_without_question_mark\n q = query_without_question_mark\n raise \"#{ self.class} doesn't have a method named has_#{ q['name'] }_#{ q['type'] }. \" +\n \"Try using 'has_#{ q['name'] }_#{ q['type'] }?' (with a trailing question mark) instead.\"\n elsif element_query\n raise_missing_element_declaration_error(element_query['name'], element_query['type'])\n elsif element_find\n raise_missing_element_declaration_error(element_find['name'], element_find['type'])\n else\n super name, args, block\n end\n end",
"def element_from_page(options = {})\n default_options = {\n :page_urlname => \"\",\n :page_id => nil,\n :element_name => \"\"\n }\n options = default_options.merge(options)\n if options[:page_id].blank?\n page = Page.find_by_urlname_and_public(options[:page_urlname], true)\n else\n page = Page.find_by_id_and_public(options[:page_id], true)\n end\n return \"\" if page.blank?\n element = page.elements.find_by_name_and_public(options[:element_name], true)\n return element\n end",
"def click_on_element(element_name)\n $LOG.info \"clicking on element #{element_name} \"\n begin\n wait_and_find_element element_name\n click_ele = el(element_name)\n click_ele.click\n rescue Exception => e\n $LOG.error \"Can't click on element \"+ e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Can't click on element \"+ e.message\n end\n end",
"def find(name, default: T.unsafe(nil), **options); end",
"def element\n if @element.nil? and @locators.nil?\n raise \"Cannot find an element without locators or a webelement defined\"\n end\n if @element.nil? or is_stale?\n wait(\"Element #{self} was not present after #{$element_timeout} seconds\").until {\n exists?\n }\n end\n return @element\n end",
"def locate_input_element(how, what, types, value=nil)\r\n @browser.locate_input_element(how, what, types, value)\r\n end",
"def find(el)\n BinarySearchTree.find!(@root, el)\n end",
"def is_element_present(type,ele)\n ref=$array[\"#{ele}\"]\n \n path=ele.split(\"_\").last\n val=\"\"\n if type == \"button\"\n val=$browser.button(:\"#{path}\", \"#{ref}\").exists?\n \n elsif type == \"link\"\n val=$browser.link(:\"#{path}\", \"#{ref}\").exists?\n \n elsif type == \"checkbox\"\n val=$browser.checkbox(:\"#{path}\", \"#{ref}\").exists? \n \n elsif type == \"textfield\"\n val=$browser.text_field(:\"#{path}\", \"#{ref}\").exists?\n \n elsif type == \"radiobutton\"\n val=$browser.radio(:\"#{path}\", \"#{ref}\").exists?\n \n elsif type == \"list\"\n val=$browser.select_list(:\"#{path}\", \"#{ref}\").exists?\n \n elsif type == \"img\"\n val=$browser.img(:\"#{path}\", \"#{ref}\").exists?\n \n elsif type == \"div\"\n val=$browser.div(:\"#{path}\", \"#{ref}\").exists?\n \n else\n $log.info \"{ele} is not present\"\n raise(\"given type is not found\")\n end\n if val\n $log.info \"given #{ele} present on the page\"\n else\n $log.info \" fail to find the element\"\n raise(\"given #{ele} does not exists\")\n end\nend",
"def first_ele tag_name\n # XPath index starts at 1\n find_element :xpath, \"//#{tag_name}[1]\"\n end",
"def find_innermost_element(locator = self.locator, search_node = xml)\n debug(\"DescriptorInitialization:find_innermost_element using #{locator} in #{search_node.inspect}\")\n until node = extract_first_node(locator, search_node)\n # clip off the left most [*] predicate or /* path\n md = %r{\n \\[[^\\]]+\\]$ |\n /[^/\\[]*$\n }x.match(locator)\n break if md.nil? || md.pre_match == '/'\n locator = md.pre_match\n end\n node ||= search_node \n node = node.element if node.kind_of?(REXML::Attribute)\n node = node.parent if node.kind_of?(REXML::Text)\n return node\n end",
"def find_input(attribute_name, options = T.unsafe(nil), &block); end",
"def element_by_id(elem_id)\r\n @web_browser.element_by_id(elem_id)\r\n end",
"def find_ele_by_predicate(class_name: '*', value:)\n elements = find_eles_by_predicate(class_name: class_name, value: value)\n raise _no_such_element if elements.empty?\n\n elements.first\n end",
"def lookup(name, *tags)\n xpath(tags.map{ |tag| \"./xs:#{tag}[@name='#{name}']\" }.join('|'))[0]\n end",
"def [](name)\n name = name.to_sym\n raise ArgumentError, \"no such element #{name}\" unless @named_elements.key?(name)\n\n @named_elements[name]\n end",
"def find_elements(locator)\n how, what = parse_locator(locator)\n elements = driver.find_elements(how, what)\n\n raise Selenium::WebDriver::Error::NoSuchElementError, \"Failed to find elements: #{locator}\" if elements.empty?\n\n elements\n end",
"def XOlookFor(tag, tvalue, wait)\n\t\tres= OK\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# default is OK\n\t\turl= @wwBrws.url.to_s\n\t\t$pfd.tstart( url)\n\t\t$alog.lwrite(('LookForElement '+tag.to_s+' with value /'+tvalue+'/'), 'DEBG')\n\t\tbegin\n\t\t\t(wait ? self.setPageTimer() : self.clearPageTimer()) \t\t\t\t# set or clear the page timer\n\t\t\tfinished= false\n\t\t\tuntil (self.getPageTimer() || (finished=findElement(tag, tvalue)))\n\t\t\t\tsleep TIMETICK\n\t\t\tend\n\t\t\tif(findElement(tag, tvalue))\n\t\t\t\t$pfd.calcApplRes(true,'OK: '+tag.to_s+' found:/'+tvalue+'/', url)\n\t\t\t\tres= OK\n\t\t\telse\n\t\t\t\tmsg= tag.to_s+' not found. Value: /'+tvalue+'/ '+$!.to_s\n\t\t\t\tres= setResCritical( msg)\n\t\t\tend\n\t\trescue\n\t\t\tmsg= tag.to_s+' not selectable. Value: /'+tvalue+'/ '+$!.to_s\n\t\t\tres= setResCritical( msg)\n\t\tend\n\n\t\treturnRes (res )\n\tend",
"def find_xpath path\n wait { find_element(:xpath, path) }\nend"
] | [
"0.71347195",
"0.7113149",
"0.6979475",
"0.686167",
"0.6686384",
"0.66583276",
"0.6535173",
"0.6529971",
"0.65133566",
"0.6501438",
"0.6477793",
"0.6443796",
"0.6404845",
"0.6374332",
"0.6307289",
"0.62016606",
"0.61916465",
"0.6083959",
"0.6042386",
"0.6016829",
"0.59899044",
"0.5977287",
"0.5918471",
"0.5911419",
"0.5910522",
"0.5833588",
"0.5833489",
"0.58183616",
"0.57868475",
"0.5784377",
"0.5763097",
"0.57483494",
"0.5736579",
"0.5736579",
"0.56268513",
"0.5624857",
"0.56240565",
"0.56174344",
"0.56132835",
"0.5593064",
"0.55859524",
"0.5571422",
"0.5563502",
"0.55427974",
"0.55398285",
"0.5539195",
"0.55186284",
"0.5513603",
"0.5494811",
"0.5492367",
"0.5471648",
"0.5464776",
"0.5462914",
"0.543244",
"0.54296625",
"0.54215705",
"0.5418319",
"0.5406621",
"0.53916144",
"0.5386276",
"0.5382545",
"0.5380859",
"0.5380704",
"0.5371443",
"0.53623325",
"0.5355128",
"0.53292465",
"0.53209126",
"0.52966094",
"0.5285158",
"0.52772665",
"0.5268453",
"0.52612853",
"0.52565265",
"0.5253633",
"0.5252915",
"0.5242964",
"0.52422273",
"0.5230412",
"0.52183664",
"0.52175426",
"0.52040327",
"0.5203897",
"0.52024955",
"0.5200586",
"0.5192481",
"0.51769423",
"0.5168987",
"0.51443493",
"0.5144145",
"0.5139108",
"0.5137984",
"0.5136848",
"0.51367575",
"0.51343083",
"0.512032",
"0.5115748",
"0.5108943",
"0.51014566"
] | 0.7357559 | 1 |
+each_hyperlink_uri+ traverses hyperlinks such as HTML href attribute of A element. It yields Hpricot::Text (or Hpricot::Loc) and URI for each hyperlink. The URI objects are created with a base URI which is given by HTML BASE element or the argument ((|base_uri|)). +each_hyperlink_uri+ doesn't yields href of the BASE element. | def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri
base_uri = URI.parse(base_uri) if String === base_uri
links = []
each_hyperlink_attribute {|elem, attr, hyperlink|
if %r{\{http://www.w3.org/1999/xhtml\}(?:base)\z}i =~ elem.name
base_uri = URI.parse(hyperlink.to_s)
else
links << hyperlink
end
}
if base_uri
links.each {|hyperlink| yield hyperlink, base_uri + hyperlink.to_s }
else
links.each {|hyperlink| yield hyperlink, URI.parse(hyperlink.to_s) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_uri(base_uri=nil) # :yields: URI\n each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }\n end",
"def each_uri(base_uri=nil) # :yields: URI\n each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }\n end",
"def each_hyperlink # :yields: text\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def each_hyperlink # :yields: text\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def process_links(base_uri, links, level = -1)\n links.each do |uri|\n # Good to process\n next unless good_resource?(uri)\n\n # Same domain\n next unless uri.host == base_uri.host\n\n # Already processed\n next if @processed_links.include? uri.to_s\n @processed_links << uri.to_s\n\n # Run\n puts uri\n begin\n page = agent.get(uri)\n puts \"\\tok\"\n if level != 0 && agent.get_cached?(uri)\n file_name = agent.cached_file_name(uri)\n new_links = process_data(uri, file_name)\n #ap new_links\n process_links(uri, new_links, level - 1)\n end\n rescue Mechanize::ResponseCodeError\n puts \"\\terror\"\n rescue => ex\n unless parser_params[:skip_errors]\n raise\n end\n end\n\n end\n end",
"def each_url\n return enum_for(__method__) unless block_given?\n\n each_link do |link|\n begin\n yield URI(link)\n rescue URI::InvalidURIError\n end\n end\n end",
"def each_link(&block)\n return enum_for(__method__) unless block_given?\n\n each_body do |content_type,body|\n mime_type = MIME::Type.new(content_type)\n\n case mime_type.sub_type\n when 'html', 'xhtml'\n Nokogiri::HTML(body).search('//a[@href]').each do |a|\n yield a.attr('href')\n end\n when 'plain'\n URI.extract(body,['http','https'],&block)\n end\n end\n end",
"def links\n @links ||= parsed_links.map{ |l| URL.absolutify(URL.unrelativize(l, scheme), base_url) }.compact.uniq\n end",
"def each\n @links.each { |title, url| yield title, url }\n end",
"def links()\n links = Nokogiri::HTML(RedCloth.new(self.body).to_html).css(\"a\").map do |link|\n if (href = link.attr(\"href\")) && href.match(/^https?:/)\n href\n end\n end.compact\n uris = []\n links.each do |link|\n puts link\n uris.push(URI.parse(link))\n end\n return uris\n end",
"def links\n @doc.css('a[href]').map do |a|\n parse_element_attribute_uri(a, 'href')\n end.compact.uniq\n end",
"def each_link\n return enum_for(:each_link) unless block_given?\n l = Cproton.pn_link_head(@impl, 0);\n while l\n l2 = l # get next before yield, in case yield closes l and unlinks it\n l = Cproton.pn_link_next(l, 0)\n yield Link.wrap(l2)\n end\n self\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 extract_all_links(html, base)\n base_url = URI.parse(base)\n doc = Nokogiri::HTML(html)\n links = []\n doc.css(\"a\").each do |node|\n \n begin\n uri = URI(node['href'])\n if uri.absolute? and uri.scheme != \"javascript\" \n links << uri.to_s\n elsif uri.path.start_with?(\"/\")\n uri = base_url + uri\n end\n rescue\n # don't do anything\n end\n end \n links.uniq\n end",
"def links\n @links ||= parsed_links.map{ |l| absolutify_url(unrelativize_url(l)) }.compact.uniq\n end",
"def linked_hrefs(css_selector, strip_spaces = true)\n lnks = css(css_selector)\n ret = []\n for l in lnks\n if l['href']\n url = l['href']\n if strip_spaces\n url.gsub!(/\\s/,'')\n end\n ret << normalize_url(url)\n end\n end\n return ret\n end",
"def links\n @links ||= begin\n if doc\n # get a list of distinct links on the page, in absolute url form\n links = doc.css('a[href]').inject([]) do |list, link|\n href = link.attributes['href'].content\n href.strip! if href\n \n unless skip_link?(href)\n begin\n url = to_absolute(href)\n rescue URI::InvalidURIError\n $stderr.puts \"ERROR: bad URI #{href.inspect} on page #{self.url.to_s.inspect}\"\n else\n list << url if url.scheme =~ /^https?$/\n end\n end\n list\n end\n \n links.uniq!\n links\n else\n []\n end\n end\n end",
"def all_links(options = {}) \n options[:valid_schemes] = [:http, :https] unless options.has_key? :valid_schemes\n data = link_data\n links = data.keys.map{|key| data[key]}.flatten.uniq\n links = links.map{|link| UriHelper.join_no_fragment(@url, link).to_s }\n links = links.reject{|link| link =~ /\\/([^\\/]+?)\\/\\1\\// }\n links = links.reject{|link| link =~ /([^\\/]+?)\\/([^\\/]+?)\\/.*?\\1\\/\\2/ } \n links = links.select{|link| options[:valid_schemes].include? link.split(':')[0].to_sym}\n links\n end",
"def handle_links(links_object)\n @uri = links_object['file']\n end",
"def process_anchor_tags(html)\n content = Nokogiri::HTML::DocumentFragment.parse(html)\n anchors = content.css(\"a[href]\")\n anchors.each do |item|\n if processable_link?(item)\n add_target_blank_attribute(item)\n add_rel_attributes(item)\n add_css_classes_if_required(item)\n end\n next\n end\n content.to_html\n end",
"def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end",
"def link uri\n self.apply_hyperlink java.net.URI.new(uri)\n end",
"def parse_links\n @body.scan(@@link_re) do |x|\n m = Regexp.last_match\n type = 'link'\n from = self\n text = m['text_or_to']\n to = @twine.passage_from_name(m['to'] ? m['to'] : m['text_or_to'])\n @links << Link.new(from, to, text, type)\n end\n end",
"def link_urls(tweet)\n tweet.gsub(/([A-Z]+:\\/\\/[^\\s]+)/i, '<a href=\"\\1\">\\1</a>')\n end",
"def auto_link_urls(text, html_options = {}, options = {})\n link_attributes = html_options.stringify_keys\n text.gsub(AUTO_LINK_RE) do\n scheme, href = $1, $&\n punctuation = []\n trailing_gt = \"\"\n\n if auto_linked?($`, $')\n # do not change string; URL is already linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n while href.sub!(/[^#{WORD_PATTERN}\\/\\-=;]$/, '')\n punctuation.push $&\n if opening = BRACKETS[punctuation.last] and href.scan(opening).size > href.scan(punctuation.last).size\n href << punctuation.pop\n break\n end\n end\n\n # don't include trailing > entities as part of the URL\n trailing_gt = $& if href.sub!(/>$/, '')\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless scheme\n\n unless options[:sanitize] == false\n link_text = sanitize(link_text)\n href = sanitize(href)\n end\n content_tag(:a, link_text, link_attributes.merge('href' => href), !!options[:sanitize]) + punctuation.reverse.join('') + trailing_gt.html_safe\n end\n end\n end",
"def fetch_page_links(uri)\n Nokogiri::HTML(open(uri).read).css(\"a\").map do |link|\n if (href = link.attr(\"href\"))\n href\n end\n end.compact\n rescue Exception => ex\n log \"Unhandled exception while fetching links of #{uri}\"\n log \"Error fetching links of #{uri}\"\n log ex.class\n log ex.message\n return []\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 auto_link_urls(text)\n text.gsub(AUTO_LINK_RE) do\n href = $&\n punctuation = ''\n left, right = $`, $'\n # detect already linked URLs and URLs in the middle of a tag\n if left =~ /<[^>]+$/ && right =~ /^[^>]*>/\n # do not change string; URL is alreay linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n if href.sub!(/[^\\w\\/-]$/, '') and punctuation = $& and opening = BRACKETS[punctuation]\n if href.scan(opening).size > href.scan(punctuation).size\n href << punctuation\n punctuation = ''\n end\n end\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless href.index('http') == 0\n\n %Q(<a href=\"#{href}\">#{link_text}</a>)\n end\n end\n end",
"def each(&block)\n @lock.synchronize do\n @links.each(&block)\n end\n end",
"def each\n @links.each { |_, actor| yield(actor) }\n end",
"def urls_to_links(options = {})\n wrap_with = options[:wrap_with] || ['','']\n html_options = options[:html_options] || ''\n\n # ascii_only option - show URLs with warning about contain non-latin characters\n if options[:ascii_only]\n validate_url_contains_ascii(@modified_string, html_options, wrap_with)\n else\n @modified_string.gsub!(\n /(\\s|^|\\A|\\n|\\t|\\r)((http|https):\\/\\/.*?)([,.])?(\\s|$|\\n|\\Z|\\t|\\r|<)/,\n '\\1<a href=\"\\2\" ' + html_options + '>\\2</a>\\4\\5'\n )\n end\n self\n end",
"def href_parse\n href_elems = @parsed_page.css('a[href]')\n href_elems.map do |elem|\n elem.attributes['href'].value\n end\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 each_sitemap_url\n return enum_for(__method__) unless block_given?\n\n each_sitemap_link do |link|\n if (url = to_absolute(link))\n yield url\n end\n end\n end",
"def auto_link_urls(text, html_options = {}, options = {})\n link_attributes = html_options.stringify_keys\n text.gsub(AUTO_LINK_RE) do\n scheme, href = $1, $&\n punctuation = []\n\n if auto_linked?($`, $')\n # do not change string; URL is already linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n while href.sub!(/[^#{WORD_PATTERN}\\/-]$/, '')\n punctuation.push $&\n if opening = BRACKETS[punctuation.last] and href.scan(opening).size > href.scan(punctuation.last).size\n href << punctuation.pop\n break\n end\n end\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless scheme\n\n unless options[:sanitize] == false\n #link_text = sanitize(link_text)\n #href = sanitize(href)\n end\n #content_tag(:a, link_text, link_attributes.merge('href' => href), !!options[:sanitize]) + punctuation.reverse.join('')\n \"<a href=#{href} target='_blank'>#{link_text}</a>\"\n end\n end\n end",
"def auto_link_urls(text, html_options = {}, options = {})\n link_attributes = html_options.stringify_keys\n text.gsub(AUTO_LINK_RE) do\n scheme, href = $1, $&\n punctuation = []\n\n if auto_linked?($`, $')\n # do not change string; URL is already linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n while href.sub!(/[^\\w\\/-]$/, '')\n punctuation.push $&\n if opening = BRACKETS[punctuation.last] and href.scan(opening).size > href.scan(punctuation.last).size\n href << punctuation.pop\n break\n end\n end\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless scheme\n\n unless options[:sanitize] == false\n link_text = sanitize(link_text)\n href = sanitize(href)\n end\n content_tag(:a, link_text, link_attributes.merge('href' => href,'target' => \"_blank\"), !!options[:sanitize]) + punctuation.reverse.join('')\n end\n end\n end",
"def to_url(host)\n uri = URI.parse(href)\n if uri.absolute?\n if uri.host != URI.parse(host).host\n Grell.logger.debug \"GRELL does not follow links to external hosts: #{href}\"\n nil\n else\n href # Absolute link to our own host\n end\n else\n if uri.path.nil?\n Grell.logger.debug \"GRELL does not follow links without a path: #{uri}\"\n nil\n end\n if uri.path.start_with?('/')\n host + href # convert to full URL\n else # links like href=\"google.com\" the browser would go to http://google.com like \"http://#{link}\"\n Grell.logger.debug \"GRELL Bad formatted link: #{href}, assuming external\"\n nil\n end\n end\n rescue URI::InvalidURIError # Invalid links propagating till we navigate to them\n href\n end",
"def convert_urls_to_links(text)\n # url = /(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp):\\/\\/)|(www\\.))+(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(\\/[a-zA-Z0-9\\&%_\\.\\/-~-]*)?/\n # url = /( |^)http:\\/\\/([^\\s]*\\.[^\\s]*)( |$)/\n\n # while text =~ url\n # name = $2\n # text.sub! /( |^)http:\\/\\/#{name}( |$)/, \" <a href='http://#{name}' >#{name}</a> \"\n # end\n\n Rinku.auto_link(text)\n end",
"def links\n return @links unless @links.nil?\n @links = []\n return @links if !doc\n\n doc.search(\"//a[@href]\").each do |a|\n next if a['data-method'] && a['data-method'] != 'get'\n u = a['href']\n next if u.nil? or u.empty?\n abs = to_absolute(u) rescue next\n @links << abs if in_domain?(abs)\n end\n @links.uniq!\n @links\n end",
"def convert_relative_links(url)\n base_url = doc.css('base').present? ? doc.css('base')[0]['href'] : url.split('?').first \n return if base_url.blank?\n doc.css('a').each do |link|\n link['href'] = converted_link(base_url, link['href'])\n end\n end",
"def links\n return @links if @links\n return false unless @source\n @links = @source.scan(HREF_CONTENTS_RE).map do |match|\n # filter some malformed URLS that come in\n # meant to be a loose filter to catch all reasonable HREF attributes.\n link = match[0]\n Link.new(@t.scheme, @t.host, link).path\n end.uniq\n end",
"def post_urls\n arr_hrefs = []\n collect_post_elements.each do |element|\n # there should only be one headline link per post\n if link = element.search( headline_element ).first \n uri = URI.parse link['href']\n uri.fragment = nil\n arr_hrefs << uri.to_s \n end\n end\n\n return arr_hrefs\n end",
"def uri\n @uri ||= begin\n uri = Addressable::URI.parse(sanitize_link(@link_string))\n uri.normalize\n uri.query_values = nil\n uri\n end\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def internal_links\n return [] if @links.empty?\n\n links = @links\n .select { |link| link.is_relative?(host: @url.to_base) }\n .map(&:without_base)\n .map do |link| # We map @url.to_host into / because it's a duplicate.\n link.to_host == @url.to_host ? Wgit::Url.new('/') : link\n end\n\n Wgit::Utils.process_arr(links)\n end",
"def get_hrefs\n # this will grab all the html from the url that\n # the user created the scraper with\n url_to_scrape = HTTParty.get(self.url)\n # nokogiri turns everything from HTTParty into nodes.\n nodes = Nokogiri::HTML(url_to_scrape)\n nodes.css('a').each do |a|\n self.hrefs << a['href']\n end\n self.hrefs\n end",
"def process_links(host_url)\n file = open(url)\n links = Nokogiri::HTML(file).search('a')\n protocol = url.split('://').first\n links = links.map { |link| [link.text.strip, link['href']] }.to_h\n create_report(links, protocol, host_url)\n rescue StandardError => error\n puts \"Error Encountered : #{error}\"\n end",
"def auto_link_urls(text, html_options = {})\n extra_options = Mash.new(html_options).to_html_attributes\n extra_options = \" #{extra_options}\" unless extra_options.blank?\n\n text.gsub(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $4\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n text = b + c\n text = yield(text) if block_given?\n %(#{a}<a href=\"#{b==\"www.\"?\"http://www.\":b}#{c}\"#{extra_options}>#{text}</a>#{d})\n end\n end\n end",
"def links\n return @links if (defined?(@links) && [email protected]?)\n @links = Nokogiri::HTML.parse(@html).css('a')\n @links = @links.map {|link| link.attribute('href').to_s}\n @links = @links.delete_if{ |link| (link.nil? || link.to_s == '') }\n\n # remove non-HTTP links\n @links = @links.delete_if{|x| x if !x.match(\"http\")}\n\n # handle HTTP redirect links\n # i.e. 'http://www.google.com/?=http://www.cats.com'\n @links = @links.map{|x| \"http\" + x.split(\"http\").last}.compact\n\n # Remove URL params from links\n @links = @links.map{|x| x.split(/\\?|\\&/).first}.compact\n\n # Sanitize links\n @links = @links.map{|x| URI.decode(x).downcase.strip}.compact\n\n # Remove link proxies(i.e. from Google) & decode URI again\n if url.match(/google\\.com/i)\n @links = @links.map{|x| x.split(\"%2b\").first}.compact\n @links = @links.map{|x| URI.decode(x).downcase.strip}.compact\n end\n\n return @links.uniq\n end",
"def get_hyperlink(row)\n URI.join(native_host, row.dig('uri')).to_s\n end",
"def each_sitemap_link\n return enum_for(__method__) unless block_given?\n\n each_extracted_sitemap_links('url') { |url| yield(url) }\n end",
"def auto_link_urls_custom(text, href_options = {})\n options = href_options.dup\n options[:rel] = \"nofollow\" unless options.delete(:suppress_no_follow)\n options[:class] = options.delete(:url_class)\n\n url_entities = {}\n if options[:url_entities]\n options[:url_entities].each do |entity|\n entity = entity.with_indifferent_access\n url_entities[entity[:url]] = entity\n end\n options.delete(:url_entities)\n end\n\n html_attrs = html_attrs_for_options(options)\n\n Twitter::Rewriter.rewrite_urls(text) do |url|\n href = if options[:link_url_block]\n options.delete(:link_url_block).call(url)\n else\n html_escape(url)\n end\n\n display_url = url\n if url_entities[url] && url_entities[url][:display_url]\n display_url = url_entities[url][:display_url]\n end\n\n %(<a href=\"#{href}\"#{html_attrs}>#{html_escape(display_url)}</a>)\n end\n end",
"def auto_link_hashtags(text, options = {}) # :yields: hashtag_text\n options = options.dup\n options[:url_class] ||= DEFAULT_URL_CLASS\n options[:hashtag_class] ||= DEFAULT_HASHTAG_CLASS\n options[:hashtag_url_base] ||= \"http://twitter.com/search?q=%23\"\n options[:target] ||= DEFAULT_TARGET\n extra_html = HTML_ATTR_NO_FOLLOW unless options[:suppress_no_follow]\n\n Twitter::Rewriter.rewrite_hashtags(text) do |hash, hashtag|\n hashtag = yield(hashtag) if block_given?\n href = if options[:hashtag_url_block]\n options[:hashtag_url_block].call(hashtag)\n else\n \"#{options[:hashtag_url_base]}#{html_escape(hashtag)}\"\n end\n %(<a href=\"#{href}\" title=\"##{html_escape(hashtag)}\" #{target_tag(options)}class=\"#{options[:url_class]} #{options[:hashtag_class]}\"#{extra_html}>#{html_escape(hash)}#{html_escape(hashtag)}</a>)\n end\n end",
"def each_sitemap_index_url\n return enum_for(__method__) unless block_given?\n\n each_sitemap_index_link do |link|\n if (url = to_absolute(link))\n yield url\n end\n end\n end",
"def get_raw_links\n @doc.xpath(LINKS_XPATH).map { |link| link['href'] }\n end",
"def handle_regexp_HYPERLINK(target)\n url = target.text\n\n gen_url url, url\n end",
"def collect_links(html)\n Hash[Nokogiri::HTML(html).css('a').collect {|node| [node.text.strip, node.attributes['href'].to_s]}]\n end",
"def href\n if @href_overridden != true || @href.nil?\n original_href = @href\n \n override_href = lambda do |current_href|\n begin\n if current_href.nil? && self.feed_data != nil\n # The current url is nil and we have feed data to go on\n true\n elsif current_href != nil && !([\"http\", \"https\"].include?(\n URI.parse(current_href.to_s).scheme))\n if self.feed_data != nil\n # The current url is set, but isn't a http/https url and\n # we have feed data to use to replace the current url with\n true\n else\n # The current url is set, but isn't a http/https url but\n # we don't have feed data to use to replace the current url\n # with so we'll have to wait until we do\n false\n end\n else\n # The current url is set to an http/https url and there's\n # no compelling reason to override it\n false\n end\n rescue\n # Something went wrong, so we should err on the side of caution\n # and attempt to override the url\n true\n end\n end\n if override_href.call(@href) && self.feed_data != nil\n begin\n links = FeedTools::GenericHelper.recursion_trap(:feed_href) do\n self.links\n end\n link = FeedTools::GenericHelper.recursion_trap(:feed_href) do\n self.link\n end\n if links != nil\n for link_object in links\n if link_object.rel == 'self'\n if link_object.href != link ||\n (link_object.href =~ /xml/ ||\n link_object.href =~ /atom/ ||\n link_object.href =~ /feed/)\n @href = link_object.href\n @href_overridden = true\n @links = nil\n @link = nil\n return @href\n end\n end\n end\n end\n rescue Exception\n end\n @links = nil\n @link = nil\n \n # rdf:about is ordered last because a lot of people put the url to\n # the feed inside it instead of a link to their blog.\n # Ordering it last gives them as many chances as humanly possible\n # for them to redeem themselves. If the link turns out to be the\n # same as the blog link, it will be reset to the original value.\n @href = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"admin:feed/@rdf:resource\",\n \"admin:feed/@resource\",\n \"feed/@rdf:resource\",\n \"feed/@resource\",\n \"@rdf:about\",\n \"@about\",\n \"newLocation/text()\",\n \"atom10:link[@rel='self']/@href\"\n ], :select_result_value => true) do |result|\n override_href.call(FeedTools::UriHelper.normalize_url(result))\n end\n begin\n if !(@href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@href)\n @href = FeedTools::UriHelper.resolve_relative_uri(\n @href, [self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n @href = FeedTools::UriHelper.normalize_url(@href)\n end \n @href.strip! unless @href.nil?\n @href = nil if @href.blank?\n @href_overridden = true\n if @href == nil\n @href = original_href\n @href_overridden = false\n end\n if @href == self.link\n @href = original_href\n @href_overridden = false\n end\n if @href_overridden == true\n @links = nil\n @link = nil\n end\n end\n end\n return @href\n end",
"def find_links_to(url, &block)\n url, selector = if url.kind_of? Array\n [url[1], url[0]]\n else\n [url, 'a']\n end\n \n links = (@data/selector).find_all do |link|\n link[:href].match(strip_url_params(url)) if link and link[:href]\n end\n \n links = links.compact.collect { |link| [link[:href], link.inner_text] }.uniq[0..@_hits - 1]\n \n links.collect do |link|\n yield link[0]\n end\n end",
"def internal_full_links\n links = internal_links\n return [] if links.empty?\n\n links.map { |link| base_url(link: link).concat(link) }\n end",
"def hyperlinks\n links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) }\n links.map { |a| a.hyperlink }\n end",
"def auto_link_urls(text)\n text.gsub(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $4\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n text = b + c\n text = yield(text) if block_given?\n %(#{a}<a href=\"#{b==\"www.\"?\"http://www.\":b}#{c}\">#{text}</a>#{d})\n end\n end\n end",
"def links\n url = @controller.request.url\n url = url.split('.')[0..-2].join('.') if url =~ /\\.\\w+$/\n\n parent_url = url.split('/')[0..-2].join('/')\n parent_name = parent_url.split('/')[0..-2].last.singularize\n\n _links = {\n self: { href: url },\n parent_name => { href: parent_url }\n }\n\n { _links: _links }\n end",
"def handle_uri(uri, reference, redirect_count)\n uri = uri.normalize\n\n new_report = nil\n\n @mtx.synchronize do\n unless report = @link_reports[uri.to_s]\n report = @link_reports[uri.to_s] =\n LinkReport.new(uri, skip_uri?(uri, reference))\n new_report = report\n end\n\n report.references << reference\n end\n\n if new_report\n if new_report.skip?\n @control.log_skip(new_report)\n elsif redirect_count > 2 # TODO hard-coded\n new_report.error_message = \"redirect limit exceeded\"\n else\n @pool_queue.push_job do\n crawl_uri(uri, new_report, redirect_count)\n end\n end\n end\n end",
"def resolve_all_links()\n @links.each_value { |lnk|\n set_link_target(lnk) if lnk.target.nil?\n }\n end",
"def rebase_hrefs(input, base_uri)\n Utils.rebase_hrefs(input, base_uri) rescue input\n end",
"def update_hrefs(css_selector)\n @doc.css(css_selector + ' a').each do |a|\n\n href = Flatfish::Url.absolutify(a['href'], @cd)\n\n # Create tokens for internal links and images/files\n if href =~ /#{@accepted_domain}/\n # NB: the brackets will be URL encoded, so we are flagging them here and gsubbing them before saving\n if @file_whitelist.include?(File.extname(href))\n media = get_media(href)\n href = \"[FLATFISHmedia:#{media.id}FLATFISH]\"\n elsif href !~ /mailto:/\n link = Flatfish::Link.find_or_create_by(url: href)\n href = \"[FLATFISHlink:#{link.id}FLATFISH]\"\n end\n end\n a['href'] = href\n end\n end",
"def process_uris(element, value, evaluation_context, base, **options)\n return [] if value.to_s.empty?\n add_debug(element) {\"process_uris: #{value}\"}\n value.to_s.split(/\\s+/).map {|v| process_uri(element, v, evaluation_context, base, **options)}.compact\n end",
"def links\n each_link.to_set\n end",
"def auto_link_urls(text, options = {}, &block)\n auto_link_entities(text, Extractor.extract_urls_with_indices(text, :extract_url_without_protocol => false), options, &block)\n end",
"def find_links(page)\n links = []\n for link in page.links\n canonical = \"\"\n if /\\Ahttps?/.match(link.href.to_s)\n canonical = canonical + link.href.to_s\n else\n base = page.uri.scheme + \"://\" + page.uri.host\n base.chomp!\n begin\n if !link.uri\n next\n end\n canonical = URI.join(base, link.uri.path.to_s).to_s\n rescue URI::InvalidURIError, URI::InvalidComponentError\n next\n end\n end\n canonical.gsub!(/\\/\\z/, \"\")\n links.push(canonical)\n end\n return links\nend",
"def urls_to_links(s)\n urls = /((https?:\\/\\/|www\\.)([-\\w\\.]+)+(:\\d+)?(\\/([\\w\\/_\\.\\-\\%]*(\\?\\S+)?)?)?)/\n s.gsub(urls) {\n if $1[-1..-1] == '.'\n url = $1.chop\n '<a href=\"'+url+'\">'+url+'</a>.'\n else\n '<a href=\"'+$1+'\">'+$1+'</a>'\n end\n }\n end",
"def links\n _links = { self: polymorphic_url(record_with_ancestor_chain(@record)) }\n\n resources.each do |name, resource|\n _links.update(name => polymorphic_url(record_with_ancestor_chain(resource)))\n end\n\n sub_resources.each do |sub_resource|\n _links.update(sub_resource => polymorphic_url(record_with_ancestor_chain(@record) << sub_resource))\n end\n\n { _links: _links }\n end",
"def link_to_url(link)\n uri = URI.parse(link)\n if uri.absolute?\n if uri.host != URI.parse(host).host\n Grell.logger.debug \"GRELL does not follow links to external hosts: #{link}\"\n nil\n else\n link # Absolute link to our own host\n end\n else\n if uri.path.nil?\n Grell.logger.debug \"GRELL does not follow links without a path: #{uri}\"\n nil\n end\n if uri.path.start_with?('/')\n host + link #convert to full URL\n else #links like href=\"google.com\" the browser would go to http://google.com like \"http://#{link}\"\n Grell.logger.debug \"GRELL Bad formatted link: #{link}, assuming external\"\n nil\n end\n end\n\n rescue URI::InvalidURIError #We will have invalid links propagating till we navigate to them\n link\n end",
"def doublelink_each_link(html)\n Nokogiri::HTML(html).css('.double-link').each do |doublelink|\n title_link = doublelink.css('.media__bd__header').text.strip\n subtitle_link = doublelink.css('.media__bd__subheader').text.strip\n\n yield(title_link, subtitle_link)\n end\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 absolutify_url(uri)\n if uri =~ /^\\w*\\:/i\n normalize_url(uri)\n else\n Addressable::URI.join(@url, uri).normalize.to_s\n end\n rescue URI::InvalidURIError, Addressable::URI::InvalidURIError => e\n add_fatal_error \"Link parsing exception: #{e.message}\" and nil\n end",
"def uri\n @uri ||= if @href then\n begin\n URI.parse @href\n rescue URI::InvalidURIError\n begin\n URI.parse(Addressable::URI.escape(@href))\n rescue Addressable::URI::InvalidURIError\n raise URI::InvalidURIError\n end\n end\n end\n end",
"def links\n _links = parent_link.update({\n self: { href: @controller.polymorphic_url(collection_hierarchy) }\n })\n\n { _links: _links }\n end",
"def each_url(&block)\n urls.each do |url|\n yield url, handlers[url].first, handlers[url].last\n end\n end",
"def select_eo_links(irs_doc)\n irs_doc.xpath('//a/@href').select { |link| link.to_s =~ LINK_REGEX }.map(&:to_s)\n end",
"def parse_links(comment)\n auto_link(comment, html: {target: '_blank'}) do |text|\n URI.parse(text).host\n end\n end",
"def links\n nodes = @node.xpath(\"atom:link\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomLink.new(node) }\n end",
"def absolute_links\n @data.absolute_links ||= links.map { |l| absolutify_url(unrelativize_url(l)) }\n end",
"def urls_linking_to(urls)\n unless urls.is_a?(Array)\n urls = [urls] unless urls.is_a?(Array)\n single = true\n end\n\n links = pages_linking_to(urls)\n links.each { |url, pages| links[url] = pages.map{|p| p.url} }\n\n if single and !links.empty?\n return links[urls.first]\n else\n return links\n end\n end",
"def extract_links(doc)\n (doc/'a').map { |link|\n href = link['href']\n CGI.unescapeHTML(href) if href && href !~ /^#/\n }.compact\n end",
"def parse_links(html, ttl)\n doc = Nokogiri::HTML(html)\n doc.css('a').each do |a|\n if a.attribute('name')\n next\n end\n my_ttl = ttl\n href = a.attribute('href').to_s\n # Use URI.join to dispose of nasty relative hrefs\n href = URI.join(@base_url, href).to_s\n\n match = href.match(/(\\w+):/)\n proto = match.captures[0]\n\n if my_ttl > 0\n # Are we http(s)?\n if proto.downcase.start_with?('http')\n # http(s) found so decrement TTL\n my_ttl -= 1\n else\n # not http(s) so add with a ttl of 0\n my_ttl = 0\n end\n end\n # Link parsed so add it to the list\n @links.push({'href' => href, 'ttl' => my_ttl})\n end\n end",
"def find_links(url)\n # This should return an array of all links at the given URL\n # Can be done using Nokogiri's css OR xpath methods\n #links = page.xpath('//a[@href]').map\n #links = page.xpath('//@href').map(&:value)\n links = []\n doc = Nokogiri::HTML(open(url))\n doc.css('a').each do |a_tag| #doc.css('a') is Nokogiri::XML::NodeSet\n href_str = String(a_tag['href']) # converting to String in case if it is NilClass type\n if href_str.include? \"http\"\n links.push(a_tag['href'])\n end \n end\n links\nend",
"def links\n nodes = @doc.xpath(\"atom:feed/atom:link\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomLink.new(node) }\n end",
"def create_links(tweet)\n # NOTE: URLs before Users, otherwise we'll double escape the URLs\n link_users(link_hashtags(link_urls(html_escape(tweet))))\n #link_users(link_urls(html_escape(tweet)))\n end",
"def links\n @links ||= if @breadcrumb_key.present?\n # Reload breadcrumbs configuration if needed\n Gretel::Crumbs.reload_if_needed\n\n # Get breadcrumb set by the `breadcrumb` method\n crumb = Gretel::Crumb.new(context, breadcrumb_key, *breadcrumb_args)\n\n # Links of first crumb\n links = crumb.links.dup\n \n # Get parent links\n links.unshift *parent_links_for(crumb)\n\n links\n else\n []\n end\n end",
"def url\n if links.alternate\n links.alternate.href\n elsif links.self\n links.self.href\n else\n links.map.each do |l|\n l.href\n end.compact.first\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 change_hrefs(html)\n DOM.walk(html) do |node|\n for attr_name in %w{href src}\n attr_obj = node.attributes[attr_name]\n\n # Ignore if its blank\n next if !attr_obj\n\n # URL encode any spaces\n orig_href = attr_obj.to_s.gsub(\" \", \"%20\")\n\n begin\n src = URI(orig_href)\n rescue\n log \"#{orig_href} not a valid URI\"\n next\n end\n\n if internal_link?(src.to_s)\n linked_item = nil\n\n if src.path == \"\"\n # If its just an anchor like '#this' just set to the current file\n linked_item = self\n else\n # Match on the unescaped href\n unescaped_path = URI::unescape(src.path)\n linked_item = get_item(unescaped_path)\n end\n\n # Change link\n if linked_item\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\n new_path = URI(new_path)\n\n if src.fragment\n new_path.fragment = src.fragment\n end\n\n log \"Changing #{src.to_s} to #{new_path.to_s}\"\n attr_obj.content = new_path.to_s\n else\n log \"No item in manifest for #{src}\"\n end\n end\n end\n end\n end",
"def internal_links\n @internal_links ||= links.select {|link| host_from_url(link) == host }\n end",
"def rss_links \n\t\tdoc.xpath(\"//link[@type=\\\"application/rss+xml\\\"]\").map do |link|\n\t\t\tif link['href'] =~ /^http:\\/\\//\n\t\t\t\tlink['href']\n\t\t\telse\n\t\t\t\t\"#{@url}#{link['href']}\"\n\t\t\tend\n\t\tend\n\tend",
"def link(*urls)\n opts = urls.last.respond_to?(:to_hash) ? urls.pop : {}\n opts[:rel] = urls.shift unless urls.first.respond_to? :to_str\n options = opts.map { |k, v| \" #{k}=#{v.to_s.inspect}\" }\n html_pattern = \"<link href=\\\"%s\\\"#{options.join} />\"\n http_pattern = ['<%s>', *options].join ';'\n link = (response['Link'] ||= '')\n\n urls.map do |url|\n link << \",\\n\" unless link.empty?\n link << (http_pattern % url)\n html_pattern % url\n end.join \"\\n\"\n end"
] | [
"0.80388737",
"0.80388737",
"0.68152297",
"0.6563176",
"0.61115044",
"0.59787226",
"0.5922701",
"0.56546956",
"0.55441445",
"0.54774034",
"0.54203355",
"0.5384993",
"0.5340982",
"0.53149194",
"0.5239278",
"0.52178496",
"0.51959705",
"0.51754093",
"0.51732105",
"0.5149983",
"0.5133463",
"0.5092635",
"0.5052601",
"0.50313175",
"0.50120974",
"0.49962085",
"0.4987649",
"0.49854872",
"0.49795774",
"0.49635458",
"0.4949534",
"0.4940512",
"0.49385694",
"0.4894833",
"0.48946247",
"0.48814636",
"0.48746058",
"0.4865015",
"0.48645908",
"0.4863994",
"0.48399618",
"0.4833387",
"0.4831735",
"0.48245907",
"0.48245907",
"0.47823018",
"0.4752665",
"0.47504386",
"0.47454342",
"0.47447363",
"0.47208452",
"0.4720229",
"0.46788117",
"0.46621996",
"0.46612728",
"0.4656496",
"0.46496984",
"0.46138996",
"0.4596081",
"0.45890173",
"0.45849797",
"0.45849112",
"0.45834827",
"0.4573235",
"0.45665905",
"0.45614955",
"0.45524213",
"0.45487726",
"0.4544495",
"0.4520086",
"0.45182344",
"0.45156166",
"0.45121607",
"0.44972596",
"0.4490288",
"0.44848207",
"0.44794282",
"0.447238",
"0.44668582",
"0.44631255",
"0.44451913",
"0.44382548",
"0.4427206",
"0.44256616",
"0.44216925",
"0.44168526",
"0.44095257",
"0.4408546",
"0.43928334",
"0.43847755",
"0.43825302",
"0.43804386",
"0.43796036",
"0.43775883",
"0.43775883",
"0.4369782",
"0.43608573",
"0.43607026",
"0.43537936"
] | 0.83022004 | 1 |
+each_hyperlink+ traverses hyperlinks such as HTML href attribute of A element. It yields Hpricot::Text or Hpricot::Loc. Note that +each_hyperlink+ yields HTML href attribute of BASE element. | def each_hyperlink # :yields: text
links = []
each_hyperlink_attribute {|elem, attr, hyperlink|
yield hyperlink
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_hyperlink # :yields: text\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri\n base_uri = URI.parse(base_uri) if String === base_uri\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n if %r{\\{http://www.w3.org/1999/xhtml\\}(?:base)\\z}i =~ elem.name\n base_uri = URI.parse(hyperlink.to_s)\n else\n links << hyperlink\n end\n }\n if base_uri\n links.each {|hyperlink| yield hyperlink, base_uri + hyperlink.to_s }\n else\n links.each {|hyperlink| yield hyperlink, URI.parse(hyperlink.to_s) }\n end\n end",
"def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri\n base_uri = URI.parse(base_uri) if String === base_uri\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n if %r{\\{http://www.w3.org/1999/xhtml\\}(?:base)\\z}i =~ elem.name\n base_uri = URI.parse(hyperlink.to_s)\n else\n links << hyperlink\n end\n }\n if base_uri\n links.each {|hyperlink| yield hyperlink, base_uri + hyperlink.to_s }\n else\n links.each {|hyperlink| yield hyperlink, URI.parse(hyperlink.to_s) }\n end\n end",
"def each_link\n return enum_for(:each_link) unless block_given?\n l = Cproton.pn_link_head(@impl, 0);\n while l\n l2 = l # get next before yield, in case yield closes l and unlinks it\n l = Cproton.pn_link_next(l, 0)\n yield Link.wrap(l2)\n end\n self\n end",
"def each_uri(base_uri=nil) # :yields: URI\n each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }\n end",
"def each_uri(base_uri=nil) # :yields: URI\n each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }\n end",
"def each_link(&block)\n return enum_for(__method__) unless block_given?\n\n each_body do |content_type,body|\n mime_type = MIME::Type.new(content_type)\n\n case mime_type.sub_type\n when 'html', 'xhtml'\n Nokogiri::HTML(body).search('//a[@href]').each do |a|\n yield a.attr('href')\n end\n when 'plain'\n URI.extract(body,['http','https'],&block)\n end\n end\n end",
"def process_anchor_tags(html)\n content = Nokogiri::HTML::DocumentFragment.parse(html)\n anchors = content.css(\"a[href]\")\n anchors.each do |item|\n if processable_link?(item)\n add_target_blank_attribute(item)\n add_rel_attributes(item)\n add_css_classes_if_required(item)\n end\n next\n end\n content.to_html\n end",
"def each\n @links.each { |title, url| yield title, url }\n end",
"def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end",
"def doublelink_each_link(html)\n Nokogiri::HTML(html).css('.double-link').each do |doublelink|\n title_link = doublelink.css('.media__bd__header').text.strip\n subtitle_link = doublelink.css('.media__bd__subheader').text.strip\n\n yield(title_link, subtitle_link)\n end\n end",
"def process_links(base_uri, links, level = -1)\n links.each do |uri|\n # Good to process\n next unless good_resource?(uri)\n\n # Same domain\n next unless uri.host == base_uri.host\n\n # Already processed\n next if @processed_links.include? uri.to_s\n @processed_links << uri.to_s\n\n # Run\n puts uri\n begin\n page = agent.get(uri)\n puts \"\\tok\"\n if level != 0 && agent.get_cached?(uri)\n file_name = agent.cached_file_name(uri)\n new_links = process_data(uri, file_name)\n #ap new_links\n process_links(uri, new_links, level - 1)\n end\n rescue Mechanize::ResponseCodeError\n puts \"\\terror\"\n rescue => ex\n unless parser_params[:skip_errors]\n raise\n end\n end\n\n end\n end",
"def each_url\n return enum_for(__method__) unless block_given?\n\n each_link do |link|\n begin\n yield URI(link)\n rescue URI::InvalidURIError\n end\n end\n end",
"def links\n if @links.blank?\n @links = []\n link_nodes =\n FeedTools::XmlHelper.combine_xpaths_all(self.channel_node, [\n \"atom10:link\",\n \"atom03:link\",\n \"atom:link\",\n \"link\",\n \"channelLink\",\n \"a\",\n \"url\",\n \"href\"\n ])\n for link_node in link_nodes\n link_object = FeedTools::Link.new\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:href\",\n \"@atom03:href\",\n \"@atom:href\",\n \"@href\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.href == \"atom10:\" ||\n link_object.href == \"atom03:\" ||\n link_object.href == \"atom:\"\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@href\"\n ], :select_result_value => true)\n end\n if link_object.href.nil? && link_node.base_uri != nil\n link_object.href = \"\"\n end\n begin\n if !(link_object.href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(link_object.href)\n link_object.href = FeedTools::UriHelper.resolve_relative_uri(\n link_object.href,\n [link_node.base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n link_object.href =\n FeedTools::UriHelper.normalize_url(link_object.href)\n end\n link_object.href.strip! unless link_object.href.nil?\n next if link_object.href.blank?\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:hreflang\",\n \"@atom03:hreflang\",\n \"@atom:hreflang\",\n \"@hreflang\"\n ], :select_result_value => true)\n if link_object.hreflang == \"atom10:\" ||\n link_object.hreflang == \"atom03:\" ||\n link_object.hreflang == \"atom:\"\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@hreflang\"\n ], :select_result_value => true)\n end\n unless link_object.hreflang.nil?\n link_object.hreflang = link_object.hreflang.downcase\n end\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:rel\",\n \"@atom03:rel\",\n \"@atom:rel\",\n \"@rel\"\n ], :select_result_value => true)\n if link_object.rel == \"atom10:\" ||\n link_object.rel == \"atom03:\" ||\n link_object.rel == \"atom:\"\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@rel\"\n ], :select_result_value => true)\n end\n unless link_object.rel.nil?\n link_object.rel = link_object.rel.downcase\n end\n if link_object.rel.nil? && self.feed_type == \"atom\"\n link_object.rel = \"alternate\"\n end\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:type\",\n \"@atom03:type\",\n \"@atom:type\",\n \"@type\"\n ], :select_result_value => true)\n if link_object.type == \"atom10:\" ||\n link_object.type == \"atom03:\" ||\n link_object.type == \"atom:\"\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@type\"\n ], :select_result_value => true)\n end\n unless link_object.type.nil?\n link_object.type = link_object.type.downcase\n end\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:title\",\n \"@atom03:title\",\n \"@atom:title\",\n \"@title\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.title == \"atom10:\" ||\n link_object.title == \"atom03:\" ||\n link_object.title == \"atom:\"\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@title\"\n ], :select_result_value => true)\n end\n # This catches the ambiguities between atom, rss, and cdf\n if link_object.title == link_object.href\n link_object.title = nil\n end\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:length\",\n \"@atom03:length\",\n \"@atom:length\",\n \"@length\"\n ], :select_result_value => true)\n if link_object.length == \"atom10:\" ||\n link_object.length == \"atom03:\" ||\n link_object.length == \"atom:\"\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@length\"\n ], :select_result_value => true)\n end\n if !link_object.length.nil?\n link_object.length = link_object.length.to_i\n else\n if !link_object.type.nil? && link_object.type[0..4] != \"text\" &&\n link_object.type[-3..-1] != \"xml\" &&\n link_object.href =~ /^http:\\/\\//\n # Retrieve the length with an http HEAD request\n else\n link_object.length = nil\n end\n end\n @links = [] if @links.nil?\n @links << link_object\n end\n end\n return @links\n end",
"def links\n @links ||= begin\n if doc\n # get a list of distinct links on the page, in absolute url form\n links = doc.css('a[href]').inject([]) do |list, link|\n href = link.attributes['href'].content\n href.strip! if href\n \n unless skip_link?(href)\n begin\n url = to_absolute(href)\n rescue URI::InvalidURIError\n $stderr.puts \"ERROR: bad URI #{href.inspect} on page #{self.url.to_s.inspect}\"\n else\n list << url if url.scheme =~ /^https?$/\n end\n end\n list\n end\n \n links.uniq!\n links\n else\n []\n end\n end\n end",
"def each(&block)\n @lock.synchronize do\n @links.each(&block)\n end\n end",
"def parse_links\n @body.scan(@@link_re) do |x|\n m = Regexp.last_match\n type = 'link'\n from = self\n text = m['text_or_to']\n to = @twine.passage_from_name(m['to'] ? m['to'] : m['text_or_to'])\n @links << Link.new(from, to, text, type)\n end\n end",
"def auto_link_urls(text, html_options = {})\n extra_options = Mash.new(html_options).to_html_attributes\n extra_options = \" #{extra_options}\" unless extra_options.blank?\n\n text.gsub(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $4\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n text = b + c\n text = yield(text) if block_given?\n %(#{a}<a href=\"#{b==\"www.\"?\"http://www.\":b}#{c}\"#{extra_options}>#{text}</a>#{d})\n end\n end\n end",
"def links\n each_link.to_set\n end",
"def hyperlinks\n links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) }\n links.map { |a| a.hyperlink }\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\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 infobox_each_link(html)\n Nokogiri::HTML(html).css('.infobox').each do |infobox|\n infobox_body = infobox.css('.infobox-body')\n\n title_link = infobox_body.css('h3 a').text.strip\n subtitle_link = infobox_body.css('p a').first\n subtitle_link = subtitle_link.text.strip if subtitle_link\n\n yield(title_link, subtitle_link)\n end\n end",
"def collect_links(html)\n Hash[Nokogiri::HTML(html).css('a').collect {|node| [node.text.strip, node.attributes['href'].to_s]}]\n end",
"def each_sitemap_link\n return enum_for(__method__) unless block_given?\n\n each_extracted_sitemap_links('url') { |url| yield(url) }\n end",
"def links\n @doc.css('a[href]').map do |a|\n parse_element_attribute_uri(a, 'href')\n end.compact.uniq\n end",
"def hyperlink\n @hyperlink_rel ? @hyperlink_rel.target : ''\n end",
"def process_links(host_url)\n file = open(url)\n links = Nokogiri::HTML(file).search('a')\n protocol = url.split('://').first\n links = links.map { |link| [link.text.strip, link['href']] }.to_h\n create_report(links, protocol, host_url)\n rescue StandardError => error\n puts \"Error Encountered : #{error}\"\n end",
"def auto_link_urls(text)\n text.gsub(AUTO_LINK_RE) do\n href = $&\n punctuation = ''\n left, right = $`, $'\n # detect already linked URLs and URLs in the middle of a tag\n if left =~ /<[^>]+$/ && right =~ /^[^>]*>/\n # do not change string; URL is alreay linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n if href.sub!(/[^\\w\\/-]$/, '') and punctuation = $& and opening = BRACKETS[punctuation]\n if href.scan(opening).size > href.scan(punctuation).size\n href << punctuation\n punctuation = ''\n end\n end\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless href.index('http') == 0\n\n %Q(<a href=\"#{href}\">#{link_text}</a>)\n end\n end\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 auto_link_urls(text, html_options = {}, options = {})\n link_attributes = html_options.stringify_keys\n text.gsub(AUTO_LINK_RE) do\n scheme, href = $1, $&\n punctuation = []\n trailing_gt = \"\"\n\n if auto_linked?($`, $')\n # do not change string; URL is already linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n while href.sub!(/[^#{WORD_PATTERN}\\/\\-=;]$/, '')\n punctuation.push $&\n if opening = BRACKETS[punctuation.last] and href.scan(opening).size > href.scan(punctuation.last).size\n href << punctuation.pop\n break\n end\n end\n\n # don't include trailing > entities as part of the URL\n trailing_gt = $& if href.sub!(/>$/, '')\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless scheme\n\n unless options[:sanitize] == false\n link_text = sanitize(link_text)\n href = sanitize(href)\n end\n content_tag(:a, link_text, link_attributes.merge('href' => href), !!options[:sanitize]) + punctuation.reverse.join('') + trailing_gt.html_safe\n end\n end\n end",
"def each\n @links.each { |_, actor| yield(actor) }\n end",
"def link_scrap(page)\n webpage = Nokogiri::HTML(open(page_params))\n webpage.css('a').each do |link| \n @link_obj = Link.new(text: link.text.strip, href: link['href'])\n page.links << @link_obj\n end\n end",
"def auto_link_urls(text, html_options = {}, options = {})\n link_attributes = html_options.stringify_keys\n text.gsub(AUTO_LINK_RE) do\n scheme, href = $1, $&\n punctuation = []\n\n if auto_linked?($`, $')\n # do not change string; URL is already linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n while href.sub!(/[^#{WORD_PATTERN}\\/-]$/, '')\n punctuation.push $&\n if opening = BRACKETS[punctuation.last] and href.scan(opening).size > href.scan(punctuation.last).size\n href << punctuation.pop\n break\n end\n end\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless scheme\n\n unless options[:sanitize] == false\n #link_text = sanitize(link_text)\n #href = sanitize(href)\n end\n #content_tag(:a, link_text, link_attributes.merge('href' => href), !!options[:sanitize]) + punctuation.reverse.join('')\n \"<a href=#{href} target='_blank'>#{link_text}</a>\"\n end\n end\n end",
"def auto_link_urls(text)\n text.gsub(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $4\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n text = b + c\n text = yield(text) if block_given?\n %(#{a}<a href=\"#{b==\"www.\"?\"http://www.\":b}#{c}\">#{text}</a>#{d})\n end\n end\n end",
"def links\n @links ||= parsed_links.map{ |l| URL.absolutify(URL.unrelativize(l, scheme), base_url) }.compact.uniq\n end",
"def links\n return @links unless @links.nil?\n @links = []\n return @links if !doc\n\n doc.search(\"//a[@href]\").each do |a|\n next if a['data-method'] && a['data-method'] != 'get'\n u = a['href']\n next if u.nil? or u.empty?\n abs = to_absolute(u) rescue next\n @links << abs if in_domain?(abs)\n end\n @links.uniq!\n @links\n end",
"def linked_hrefs(css_selector, strip_spaces = true)\n lnks = css(css_selector)\n ret = []\n for l in lnks\n if l['href']\n url = l['href']\n if strip_spaces\n url.gsub!(/\\s/,'')\n end\n ret << normalize_url(url)\n end\n end\n return ret\n end",
"def auto_link_urls(text, html_options = {}, options = {})\n link_attributes = html_options.stringify_keys\n text.gsub(AUTO_LINK_RE) do\n scheme, href = $1, $&\n punctuation = []\n\n if auto_linked?($`, $')\n # do not change string; URL is already linked\n href\n else\n # don't include trailing punctuation character as part of the URL\n while href.sub!(/[^\\w\\/-]$/, '')\n punctuation.push $&\n if opening = BRACKETS[punctuation.last] and href.scan(opening).size > href.scan(punctuation.last).size\n href << punctuation.pop\n break\n end\n end\n\n link_text = block_given?? yield(href) : href\n href = 'http://' + href unless scheme\n\n unless options[:sanitize] == false\n link_text = sanitize(link_text)\n href = sanitize(href)\n end\n content_tag(:a, link_text, link_attributes.merge('href' => href,'target' => \"_blank\"), !!options[:sanitize]) + punctuation.reverse.join('')\n end\n end\n end",
"def links\n @links ||= parsed_links.map{ |l| absolutify_url(unrelativize_url(l)) }.compact.uniq\n end",
"def links\n return @links if (defined?(@links) && [email protected]?)\n @links = Nokogiri::HTML.parse(@html).css('a')\n @links = @links.map {|link| link.attribute('href').to_s}\n @links = @links.delete_if{ |link| (link.nil? || link.to_s == '') }\n\n # remove non-HTTP links\n @links = @links.delete_if{|x| x if !x.match(\"http\")}\n\n # handle HTTP redirect links\n # i.e. 'http://www.google.com/?=http://www.cats.com'\n @links = @links.map{|x| \"http\" + x.split(\"http\").last}.compact\n\n # Remove URL params from links\n @links = @links.map{|x| x.split(/\\?|\\&/).first}.compact\n\n # Sanitize links\n @links = @links.map{|x| URI.decode(x).downcase.strip}.compact\n\n # Remove link proxies(i.e. from Google) & decode URI again\n if url.match(/google\\.com/i)\n @links = @links.map{|x| x.split(\"%2b\").first}.compact\n @links = @links.map{|x| URI.decode(x).downcase.strip}.compact\n end\n\n return @links.uniq\n end",
"def handle_regexp_HYPERLINK(target)\n url = target.text\n\n gen_url url, url\n end",
"def convert_urls_to_links(text)\n # url = /(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp):\\/\\/)|(www\\.))+(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(\\/[a-zA-Z0-9\\&%_\\.\\/-~-]*)?/\n # url = /( |^)http:\\/\\/([^\\s]*\\.[^\\s]*)( |$)/\n\n # while text =~ url\n # name = $2\n # text.sub! /( |^)http:\\/\\/#{name}( |$)/, \" <a href='http://#{name}' >#{name}</a> \"\n # end\n\n Rinku.auto_link(text)\n end",
"def each_sitemap_url\n return enum_for(__method__) unless block_given?\n\n each_sitemap_link do |link|\n if (url = to_absolute(link))\n yield url\n end\n end\n end",
"def has_hyperlink?\n HYPERLINK_HOOKS.each { |string|\n return true if self.include?(string)\n }\n false\n end",
"def link_headers\n yield if block_given?\n return '' unless response.include? 'Link'\n\n response['Link'].split(\",\\n\").map do |line|\n url, *opts = line.split(';').map(&:strip)\n \"<link href=\\\"#{url[1..-2]}\\\" #{opts.join ' '} />\"\n end.join \"\\n\"\n end",
"def extract_all_links(html, base)\n base_url = URI.parse(base)\n doc = Nokogiri::HTML(html)\n links = []\n doc.css(\"a\").each do |node|\n \n begin\n uri = URI(node['href'])\n if uri.absolute? and uri.scheme != \"javascript\" \n links << uri.to_s\n elsif uri.path.start_with?(\"/\")\n uri = base_url + uri\n end\n rescue\n # don't do anything\n end\n end \n links.uniq\n end",
"def extract_links(doc)\n (doc/'a').map { |link|\n href = link['href']\n CGI.unescapeHTML(href) if href && href !~ /^#/\n }.compact\n end",
"def auto_link_hashtags(text, options = {}) # :yields: hashtag_text\n options = options.dup\n options[:url_class] ||= DEFAULT_URL_CLASS\n options[:hashtag_class] ||= DEFAULT_HASHTAG_CLASS\n options[:hashtag_url_base] ||= \"http://twitter.com/search?q=%23\"\n options[:target] ||= DEFAULT_TARGET\n extra_html = HTML_ATTR_NO_FOLLOW unless options[:suppress_no_follow]\n\n Twitter::Rewriter.rewrite_hashtags(text) do |hash, hashtag|\n hashtag = yield(hashtag) if block_given?\n href = if options[:hashtag_url_block]\n options[:hashtag_url_block].call(hashtag)\n else\n \"#{options[:hashtag_url_base]}#{html_escape(hashtag)}\"\n end\n %(<a href=\"#{href}\" title=\"##{html_escape(hashtag)}\" #{target_tag(options)}class=\"#{options[:url_class]} #{options[:hashtag_class]}\"#{extra_html}>#{html_escape(hash)}#{html_escape(hashtag)}</a>)\n end\n end",
"def get_raw_links\n @doc.xpath(LINKS_XPATH).map { |link| link['href'] }\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 link_urls(tweet)\n tweet.gsub(/([A-Z]+:\\/\\/[^\\s]+)/i, '<a href=\"\\1\">\\1</a>')\n end",
"def get_hrefs\n # this will grab all the html from the url that\n # the user created the scraper with\n url_to_scrape = HTTParty.get(self.url)\n # nokogiri turns everything from HTTParty into nodes.\n nodes = Nokogiri::HTML(url_to_scrape)\n nodes.css('a').each do |a|\n self.hrefs << a['href']\n end\n self.hrefs\n end",
"def links()\n links = Nokogiri::HTML(RedCloth.new(self.body).to_html).css(\"a\").map do |link|\n if (href = link.attr(\"href\")) && href.match(/^https?:/)\n href\n end\n end.compact\n uris = []\n links.each do |link|\n puts link\n uris.push(URI.parse(link))\n end\n return uris\n end",
"def find_links_to(url, &block)\n url, selector = if url.kind_of? Array\n [url[1], url[0]]\n else\n [url, 'a']\n end\n \n links = (@data/selector).find_all do |link|\n link[:href].match(strip_url_params(url)) if link and link[:href]\n end\n \n links = links.compact.collect { |link| [link[:href], link.inner_text] }.uniq[0..@_hits - 1]\n \n links.collect do |link|\n yield link[0]\n end\n end",
"def find_links(page)\n links = []\n for link in page.links\n canonical = \"\"\n if /\\Ahttps?/.match(link.href.to_s)\n canonical = canonical + link.href.to_s\n else\n base = page.uri.scheme + \"://\" + page.uri.host\n base.chomp!\n begin\n if !link.uri\n next\n end\n canonical = URI.join(base, link.uri.path.to_s).to_s\n rescue URI::InvalidURIError, URI::InvalidComponentError\n next\n end\n end\n canonical.gsub!(/\\/\\z/, \"\")\n links.push(canonical)\n end\n return links\nend",
"def href_parse\n href_elems = @parsed_page.css('a[href]')\n href_elems.map do |elem|\n elem.attributes['href'].value\n end\n end",
"def run\n @html.css('a').each do |node|\n @link = create_element(node)\n\n line = node.line\n\n if target_blank? && not_rel_noopener?\n return add_issue(\"Links with target='_blank' must have rel='noopener'.\", line: line)\n end\n end\n end",
"def linkPages\n @all_pages.each_value do |one_page|\n one_page.addPageLinks\n end\n @all_pages.each_value do |one_page|\n one_page.addMissingLinkNames\n end\n end",
"def my_auto_link(text, href_options = {})\n extra_options = tag_options(href_options.stringify_keys) || \"\"\n text.gsub(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $5\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n text = b + c\n text = yield(text) if block_given?\n %(#{a}<a href=\"#{b==\"www.\"?\"http://www.\":b}#{c}\"#{extra_options}>#{text}</a>#{d})\n end\n end\n end",
"def parse_link\n start_line_number = @src.current_line_number\n result = @src.scan(LINK_START)\n cur_pos = @src.pos\n saved_pos = @src.save_pos\n\n link_type = (result =~ /^!/ ? :img : :a)\n\n # no nested links allowed\n if link_type == :a && (@tree.type == :img || @tree.type == :a ||\n @stack.any? {|t, _| t && (t.type == :img || t.type == :a) })\n add_text(result)\n return\n end\n el = Element.new(link_type, nil, nil, location: start_line_number)\n\n count = 1\n found = parse_spans(el, LINK_BRACKET_STOP_RE) do\n count += (@src[1] ? -1 : 1)\n count - el.children.select {|c| c.type == :img }.size == 0\n end\n unless found\n @src.revert_pos(saved_pos)\n add_text(result)\n return\n end\n alt_text = extract_string([email protected], @src).gsub(ESCAPED_CHARS, '\\1')\n @src.scan(LINK_BRACKET_STOP_RE)\n\n # reference style link or no link url\n if @src.scan(LINK_INLINE_ID_RE) || [email protected](/\\(/)\n emit_warning = !@src[1]\n link_id = normalize_link_id(@src[1] || alt_text)\n if @link_defs.key?(link_id)\n link_def = @link_defs[link_id]\n add_link(el, link_def[0], link_def[1], alt_text,\n link_def[2] && link_def[2].options[:ial])\n else\n if emit_warning\n warning(\"No link definition for link ID '#{link_id}' found on line #{start_line_number}\")\n end\n @src.revert_pos(saved_pos)\n add_text(result)\n end\n return\n end\n\n # link url in parentheses\n if @src.scan(/\\(<(.*?)>/)\n link_url = @src[1]\n if @src.scan(/\\)/)\n add_link(el, link_url, nil, alt_text)\n return\n end\n else\n link_url = +''\n nr_of_brackets = 0\n while (temp = @src.scan_until(LINK_PAREN_STOP_RE))\n link_url << temp\n if @src[2]\n nr_of_brackets -= 1\n break if nr_of_brackets == 0\n elsif @src[1]\n nr_of_brackets += 1\n else\n break\n end\n end\n link_url = link_url[1..-2]\n link_url.strip!\n\n if nr_of_brackets == 0\n add_link(el, link_url, nil, alt_text)\n return\n end\n end\n\n if @src.scan(LINK_INLINE_TITLE_RE)\n add_link(el, link_url, @src[2], alt_text)\n else\n @src.revert_pos(saved_pos)\n add_text(result)\n end\n end",
"def links\n return @links if @links\n return false unless @source\n @links = @source.scan(HREF_CONTENTS_RE).map do |match|\n # filter some malformed URLS that come in\n # meant to be a loose filter to catch all reasonable HREF attributes.\n link = match[0]\n Link.new(@t.scheme, @t.host, link).path\n end.uniq\n end",
"def hyperlink=(v, options = {})\n options[:href] = v\n if hyperlink.is_a?(Hyperlink)\n options.each do |o|\n hyperlink.send(\"#{o[0]}=\", o[1]) if hyperlink.respond_to? \"#{o[0]}=\"\n end\n else\n @hyperlink = Hyperlink.new(self, options)\n end\n hyperlink\n end",
"def highlight_links(text)\n text = '' if text.nil?\n begin\n new_text = text.dup\n while new_text =~ /([\\s\\r\\n]+|^)[^\"]*(http[s]{0,1}:\\/\\/[^\\s\\r\\n<]*)/u\n link = $2\n new_text.gsub!(link, \"<a href=\\\"#{link}\\\" rel=\\\"nofollow\\\" target=\\\"_blank\\\">#{link}</a>\")\n end\n new_text\n rescue\n text\n end\n end",
"def auto_link_urls(text, options = {}, &block)\n auto_link_entities(text, Extractor.extract_urls_with_indices(text, :extract_url_without_protocol => false), options, &block)\n end",
"def get_all_links_as_hash(page)\n parsed_page = Nokogiri::HTML(page)\n links = parsed_page.css('a')\n\n all_links = Hash[links.xpath('//a[@href]').map {|link| [link.text.strip, link['href']]}]\n\n return all_links\nend",
"def internal_links\n return [] if @links.empty?\n\n links = @links\n .select { |link| link.is_relative?(host: @url.to_base) }\n .map(&:without_base)\n .map do |link| # We map @url.to_host into / because it's a duplicate.\n link.to_host == @url.to_host ? Wgit::Url.new('/') : link\n end\n\n Wgit::Utils.process_arr(links)\n end",
"def links\n @links ||= if @breadcrumb_key.present?\n # Reload breadcrumbs configuration if needed\n Gretel::Crumbs.reload_if_needed\n\n # Get breadcrumb set by the `breadcrumb` method\n crumb = Gretel::Crumb.new(context, breadcrumb_key, *breadcrumb_args)\n\n # Links of first crumb\n links = crumb.links.dup\n \n # Get parent links\n links.unshift *parent_links_for(crumb)\n\n links\n else\n []\n end\n end",
"def resolve_all_links()\n @links.each_value { |lnk|\n set_link_target(lnk) if lnk.target.nil?\n }\n end",
"def links\n _links = parent_link.update({\n self: { href: @controller.polymorphic_url(collection_hierarchy) }\n })\n\n { _links: _links }\n end",
"def link uri\n self.apply_hyperlink java.net.URI.new(uri)\n end",
"def normalize_links\n @links.map! do |link|\n relationship = case link\n when Symbol, String then @relationships[link]\n when Associations::Relationship then link\n end\n\n if relationship.respond_to?(:links)\n relationship.links\n else\n relationship\n end\n end\n\n @links.flatten!\n @links.uniq!\n end",
"def inline_docbook_autolink_urls(text)\n text.gsub!(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $5\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n %(#{a}<ulink url=\"#{b==\"www.\"?\"http://www.\":b}#{c}\">#{b}#{c}</ulink>#{d})\n end\n end\n end",
"def internal_links\n @internal_links ||= links.select {|link| host_from_url(link) == host }\n end",
"def handle_special_HYPERLINK(special); end",
"def get_links(url)\n @driver.get(url)\n data = @driver.execute_script(\"return document.getElementsByTagName('html')[0].innerHTML\")\n\n Nokogiri::HTML(data).css(\"a\").map do |link|\n if (href = link.attr(\"href\"))\n res = Link.new\n\n begin\n res.href = self.build_careers_page_url(url, href.strip).to_s\n rescue\n res.href = nil\n end\n res.text = link.text\n res\n end\n end.compact.reject do |link|\n link.href.nil?\n end.uniq\n end",
"def links\n url = @controller.request.url\n url = url.split('.')[0..-2].join('.') if url =~ /\\.\\w+$/\n\n parent_url = url.split('/')[0..-2].join('/')\n parent_name = parent_url.split('/')[0..-2].last.singularize\n\n _links = {\n self: { href: url },\n parent_name => { href: parent_url }\n }\n\n { _links: _links }\n end",
"def select_eo_links(irs_doc)\n irs_doc.xpath('//a/@href').select { |link| link.to_s =~ LINK_REGEX }.map(&:to_s)\n end",
"def links\n construct_html(self.items)\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 parse_content\n doc = Nokogiri::HTML(open(url.source))\n doc.css('a', 'h1', 'h2', 'h3').map do |link|\n UrlContent.new do |urlc|\n content = link.content.strip.force_encoding(\"utf-8\")\n if link.node_name == 'a'\n content = link.get_attribute(\"href\")\n if not (content.present? and (content.starts_with?(\"http\") or content.starts_with?(\"www\")))\n content = url.source+content.to_s\n end\n end\n urlc.content = content\n urlc.content_type = link.node_name\n urlc.url = self.url\n end\n end\n end",
"def handle_special_HYPERLINK(special) # rubocop:disable Style/MethodName\n @hyperlink ? special.text : super\n end",
"def all_links(options = {}) \n options[:valid_schemes] = [:http, :https] unless options.has_key? :valid_schemes\n data = link_data\n links = data.keys.map{|key| data[key]}.flatten.uniq\n links = links.map{|link| UriHelper.join_no_fragment(@url, link).to_s }\n links = links.reject{|link| link =~ /\\/([^\\/]+?)\\/\\1\\// }\n links = links.reject{|link| link =~ /([^\\/]+?)\\/([^\\/]+?)\\/.*?\\1\\/\\2/ } \n links = links.select{|link| options[:valid_schemes].include? link.split(':')[0].to_sym}\n links\n end",
"def html_link(item)\n tag :a, yield, :href => item.url\n end",
"def convert_relative_links(url)\n base_url = doc.css('base').present? ? doc.css('base')[0]['href'] : url.split('?').first \n return if base_url.blank?\n doc.css('a').each do |link|\n link['href'] = converted_link(base_url, link['href'])\n end\n end",
"def find_links(url)\n # This should return an array of all links at the given URL\n # Can be done using Nokogiri's css OR xpath methods\n #links = page.xpath('//a[@href]').map\n #links = page.xpath('//@href').map(&:value)\n links = []\n doc = Nokogiri::HTML(open(url))\n doc.css('a').each do |a_tag| #doc.css('a') is Nokogiri::XML::NodeSet\n href_str = String(a_tag['href']) # converting to String in case if it is NilClass type\n if href_str.include? \"http\"\n links.push(a_tag['href'])\n end \n end\n links\nend",
"def auto_link_urls_custom(text, href_options = {})\n options = href_options.dup\n options[:rel] = \"nofollow\" unless options.delete(:suppress_no_follow)\n options[:class] = options.delete(:url_class)\n\n url_entities = {}\n if options[:url_entities]\n options[:url_entities].each do |entity|\n entity = entity.with_indifferent_access\n url_entities[entity[:url]] = entity\n end\n options.delete(:url_entities)\n end\n\n html_attrs = html_attrs_for_options(options)\n\n Twitter::Rewriter.rewrite_urls(text) do |url|\n href = if options[:link_url_block]\n options.delete(:link_url_block).call(url)\n else\n html_escape(url)\n end\n\n display_url = url\n if url_entities[url] && url_entities[url][:display_url]\n display_url = url_entities[url][:display_url]\n end\n\n %(<a href=\"#{href}\"#{html_attrs}>#{html_escape(display_url)}</a>)\n end\n end",
"def h text\n # Link links\n out = text.gsub( %r{http(s)?://[^\\s<]+} ) { |url| \"<a href='#{url}'>#{url}</a>\" }\n\n # Link Twitter Handles\n out = out.gsub(/@(\\w+)/) {|a| \"<a href=\\\"http://twitter.com/#{a[1..-1]}\\\"/>#{a}</a>\" }\n\n # Link Hash tags\n out = out.gsub(/#(\\w+)/) {|hash| link_to hash, url(:hash, hash[1..-1]) }\n\n return out\n end",
"def internal_links\n @internal_links ||= links.select {|link| URL.new(link).host == host }\n end",
"def handle_links(links_object)\n @uri = links_object['file']\n end",
"def inline_textile_autolink_urls(text)\n text.gsub!(AUTO_LINK_RE) do\n all, a, b, c, d = $&, $1, $2, $3, $5\n if a =~ /<a\\s/i # don't replace URL's that are already linked\n all\n else\n %(#{a}<a href=\"#{b==\"www.\"?\"http://www.\":b}#{c}\">#{b}#{c}</a>#{d})\n end\n end\n end",
"def parse_links(html, ttl)\n doc = Nokogiri::HTML(html)\n doc.css('a').each do |a|\n if a.attribute('name')\n next\n end\n my_ttl = ttl\n href = a.attribute('href').to_s\n # Use URI.join to dispose of nasty relative hrefs\n href = URI.join(@base_url, href).to_s\n\n match = href.match(/(\\w+):/)\n proto = match.captures[0]\n\n if my_ttl > 0\n # Are we http(s)?\n if proto.downcase.start_with?('http')\n # http(s) found so decrement TTL\n my_ttl -= 1\n else\n # not http(s) so add with a ttl of 0\n my_ttl = 0\n end\n end\n # Link parsed so add it to the list\n @links.push({'href' => href, 'ttl' => my_ttl})\n end\n end",
"def process_page_link_tag(tag)\n parts = tag.split(' ')\n\n url, *descp = parts\n title = descp.join(\" \")\n\n alternatives = Repos.alternatives(*url.split(\"/\"))\n\n base_link, add_links = [], []\n\n extern_url = url =~ /^https?:/\n\n url = \"/#{url}\" if not url[0..0] == \"/\" and not extern_url\n title = url if title.empty?\n\n if extern_url\n return %Q{<a href=\"#{url}\">#{title}</a>}\n elsif tag =~ /^mailto:/\n return %Q{<a href=\"#{tag}\">#{tag.split(\":\")[1..-1]}</a>}\n end\n\n if not alternatives.empty?\n alternatives.each_pair do |ext, file|\n if ext == defext # find page with default extension\n\n base_url =\n if alternatives.size > 1\n # add extension for base_url unless given\n url !~ /\\.#{ext}$/ ? \"#{url}.#{ext}\" : url\n else url end\n\n base_link << [base_url, file]\n else\n add_links << [\"#{url}.#{ext}\", file]\n end\n end\n else\n # not existing page\n base_link << [url, nil]\n end\n\n # sort links by extension\n add_links = add_links.sort_by{|link, file| File.extname(file) }\n\n if base_link.empty?\n base_link << add_links.shift\n end\n\n title = title[1..-1] if title[0..0] == \"/\"\n base_link.map!{|url, _| mk_link(url, (alternatives.empty? ? \"o\" : \"x\"), title) }\n add_links.map!{|url, _| mk_link(url, 'alt', nil) }\n\n ret = base_link.join\n unless add_links.empty?\n ret << \" <span class='alts'><sup>(%s)</sup></span>\" % add_links.join(\", \")\n end\n ret\n end",
"def all_links\n self.fulltext_links + self.non_fulltext_links\n end",
"def handle_special_HYPERLINK(special)\n url = special.text\n gen_url url, url\n end",
"def process_links!(source)\r\n links.each{ |l| source.gsub!(\"[[#{l}]]\", link(l)) }\r\n end",
"def alink(*args)\n\n args << {} unless args.last.is_a?(Hash)\n args.last[:title] = true\n\n opts = args.last\n\n hl = hlink(*args)\n\n attributes = %w[ href rel title ].inject([]) { |a, att|\n if val = hl[att]\n a << \"#{att}=\\\"#{val}\\\"\"\n end\n a\n }.join(' ')\n\n \"<a #{attributes}>#{opts[:text] || hl['href']}</a>\"\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"
] | [
"0.77974546",
"0.6900931",
"0.6900931",
"0.6458919",
"0.645232",
"0.645232",
"0.6238984",
"0.6070783",
"0.5955524",
"0.5760612",
"0.57457316",
"0.5647629",
"0.5582062",
"0.55414397",
"0.553746",
"0.55043495",
"0.55015755",
"0.5463523",
"0.5451055",
"0.5444632",
"0.54409724",
"0.54409724",
"0.5423491",
"0.5420706",
"0.5401324",
"0.53676087",
"0.53633183",
"0.53517467",
"0.53501755",
"0.5339841",
"0.53362715",
"0.5323741",
"0.5317131",
"0.531687",
"0.52779585",
"0.5251495",
"0.5240835",
"0.5237656",
"0.52351135",
"0.52343434",
"0.52291435",
"0.5211783",
"0.5169813",
"0.5158583",
"0.5151735",
"0.5136694",
"0.5132205",
"0.5123016",
"0.50914407",
"0.50809884",
"0.5078629",
"0.50701076",
"0.50701076",
"0.5064375",
"0.50577873",
"0.5047197",
"0.50415075",
"0.503024",
"0.50288975",
"0.5018001",
"0.50028896",
"0.5000927",
"0.49844742",
"0.49824318",
"0.4977309",
"0.49720734",
"0.49719432",
"0.49611726",
"0.49308842",
"0.49252248",
"0.49218094",
"0.4916936",
"0.4912502",
"0.49061343",
"0.4894325",
"0.48916057",
"0.48780978",
"0.48758942",
"0.48663387",
"0.48658615",
"0.48635575",
"0.48616564",
"0.48476923",
"0.4844853",
"0.4843621",
"0.48430082",
"0.48418283",
"0.48357084",
"0.4834822",
"0.48333517",
"0.48269704",
"0.4818911",
"0.47956473",
"0.47913405",
"0.47889578",
"0.47837028",
"0.47835964",
"0.47826824",
"0.47707817",
"0.47695473"
] | 0.7916504 | 0 |
+each_uri+ traverses hyperlinks such as HTML href attribute of A element. It yields URI for each hyperlink. The URI objects are created with a base URI which is given by HTML BASE element or the argument ((|base_uri|)). | def each_uri(base_uri=nil) # :yields: URI
each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri\n base_uri = URI.parse(base_uri) if String === base_uri\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n if %r{\\{http://www.w3.org/1999/xhtml\\}(?:base)\\z}i =~ elem.name\n base_uri = URI.parse(hyperlink.to_s)\n else\n links << hyperlink\n end\n }\n if base_uri\n links.each {|hyperlink| yield hyperlink, base_uri + hyperlink.to_s }\n else\n links.each {|hyperlink| yield hyperlink, URI.parse(hyperlink.to_s) }\n end\n end",
"def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri\n base_uri = URI.parse(base_uri) if String === base_uri\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n if %r{\\{http://www.w3.org/1999/xhtml\\}(?:base)\\z}i =~ elem.name\n base_uri = URI.parse(hyperlink.to_s)\n else\n links << hyperlink\n end\n }\n if base_uri\n links.each {|hyperlink| yield hyperlink, base_uri + hyperlink.to_s }\n else\n links.each {|hyperlink| yield hyperlink, URI.parse(hyperlink.to_s) }\n end\n end",
"def each_url\n return enum_for(__method__) unless block_given?\n\n each_link do |link|\n begin\n yield URI(link)\n rescue URI::InvalidURIError\n end\n end\n end",
"def process_links(base_uri, links, level = -1)\n links.each do |uri|\n # Good to process\n next unless good_resource?(uri)\n\n # Same domain\n next unless uri.host == base_uri.host\n\n # Already processed\n next if @processed_links.include? uri.to_s\n @processed_links << uri.to_s\n\n # Run\n puts uri\n begin\n page = agent.get(uri)\n puts \"\\tok\"\n if level != 0 && agent.get_cached?(uri)\n file_name = agent.cached_file_name(uri)\n new_links = process_data(uri, file_name)\n #ap new_links\n process_links(uri, new_links, level - 1)\n end\n rescue Mechanize::ResponseCodeError\n puts \"\\terror\"\n rescue => ex\n unless parser_params[:skip_errors]\n raise\n end\n end\n\n end\n end",
"def each_link(&block)\n return enum_for(__method__) unless block_given?\n\n each_body do |content_type,body|\n mime_type = MIME::Type.new(content_type)\n\n case mime_type.sub_type\n when 'html', 'xhtml'\n Nokogiri::HTML(body).search('//a[@href]').each do |a|\n yield a.attr('href')\n end\n when 'plain'\n URI.extract(body,['http','https'],&block)\n end\n end\n end",
"def each\n @links.each { |title, url| yield title, url }\n end",
"def for_uri(uri)\n current_uri = self.class.base_uri\n self.class.base_uri uri\n yield\n self.class.base_uri current_uri\n end",
"def each_hyperlink # :yields: text\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def each_hyperlink # :yields: text\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def extract_all_links(html, base)\n base_url = URI.parse(base)\n doc = Nokogiri::HTML(html)\n links = []\n doc.css(\"a\").each do |node|\n \n begin\n uri = URI(node['href'])\n if uri.absolute? and uri.scheme != \"javascript\" \n links << uri.to_s\n elsif uri.path.start_with?(\"/\")\n uri = base_url + uri\n end\n rescue\n # don't do anything\n end\n end \n links.uniq\n end",
"def process_uris(element, value, evaluation_context, base, **options)\n return [] if value.to_s.empty?\n add_debug(element) {\"process_uris: #{value}\"}\n value.to_s.split(/\\s+/).map {|v| process_uri(element, v, evaluation_context, base, **options)}.compact\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 links\n @links ||= parsed_links.map{ |l| URL.absolutify(URL.unrelativize(l, scheme), base_url) }.compact.uniq\n end",
"def each\n @links.each { |_, actor| yield(actor) }\n end",
"def links()\n links = Nokogiri::HTML(RedCloth.new(self.body).to_html).css(\"a\").map do |link|\n if (href = link.attr(\"href\")) && href.match(/^https?:/)\n href\n end\n end.compact\n uris = []\n links.each do |link|\n puts link\n uris.push(URI.parse(link))\n end\n return uris\n end",
"def each_url(&block)\n urls.each do |url|\n yield url, handlers[url].first, handlers[url].last\n end\n end",
"def rebase_hrefs(input, base_uri)\n Utils.rebase_hrefs(input, base_uri) rescue input\n end",
"def each(&block)\n @lock.synchronize do\n @links.each(&block)\n end\n end",
"def fetch_page_links(uri)\n Nokogiri::HTML(open(uri).read).css(\"a\").map do |link|\n if (href = link.attr(\"href\"))\n href\n end\n end.compact\n rescue Exception => ex\n log \"Unhandled exception while fetching links of #{uri}\"\n log \"Error fetching links of #{uri}\"\n log ex.class\n log ex.message\n return []\n end",
"def process_uri(uri)\n require 'open-uri'\n require 'open_uri_redirections'\n open(uri, :allow_redirections => :safe) do |r|\n r.base_uri.to_s\n end\n end",
"def process_data(base_uri, file_name)\n puts \"\\tprocess_data(#{file_name})\"\n\n links = []\n\n ext = parser.get_extension(base_uri)\n if ext == '.css'\n # CSS\n links = parser.get_links_from_css file_name\n elsif ext == '.js'\n # JS\n links = parser.get_links_from_js file_name\n elsif %w{ .gif .png .jpg .jpeg .ico }.include? ext\n # skip\n else\n # HTML\n links = parser.get_links_from_html file_name\n end\n\n links.inject([]) do |memo, link|\n uri = build_uri(base_uri, link)\n memo << uri if uri\n memo\n end\n end",
"def handle_links(links_object)\n @uri = links_object['file']\n end",
"def each_sitemap_url\n return enum_for(__method__) unless block_given?\n\n each_sitemap_link do |link|\n if (url = to_absolute(link))\n yield url\n end\n end\n end",
"def initialize(uri)\r\n\t\t@uri = clean(uri)\r\n\t\t@uri_xml_encoded_only = REXML::Text.normalize(@uri)\r\n\t\t\r\n\t\t\r\n\t\t@follow_link = true\r\n\tend",
"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 each_sitemap_index_url\n return enum_for(__method__) unless block_given?\n\n each_sitemap_index_link do |link|\n if (url = to_absolute(link))\n yield url\n end\n end\n end",
"def generate_links rss_file, basedir='/'\n\tbasedir = \"/#{basedir}\" unless basedir.start_with? '/'\n\tbasedir = \"#{basedir}/\" unless basedir.end_with? '/'\n\n\tdir = File.dirname(File.expand_path(rss_file))\n\trss = File.read(rss_file)\n\n\tfeed = RSS::Parser.parse(rss, false)\n\n\titem_map = Hash[*feed.items.map{|item|\n\t\tlink = item.link.split('/').last\n\t\t[link, {:item => item, :filename => item.pubDate.strftime(\"source/#{link}/index.html\")}]\n\t}.flatten]\n\n\tfeed.items.each do |item|\n\t\tpost_uri = URI.parse(item.link)\n\n\t\tpermalink = item.link.split('/').last\n\t\tfilename = item_map[permalink][:filename]\n\t\tdirname = File.dirname(filename)\n\t\thref = item.pubDate.strftime(\"#{basedir}%Y/%m/%d/#{permalink}/\")\n\t\ttitle = item.title\n\n\t\tFileUtils.mkdir_p(dirname)\n\t\toutfile = File.new(filename, \"w\")\n\t\toutfile.write <<-HTML\n\t\t<!DOCTYPE html>\n\t\t<html>\n\t\t\t<head>\n\t\t\t\t<title>#{title}</title>\n\t\t\t\t<meta http-equiv=\"Refresh\" content=\"0; url=#{href}\">\n\t\t\t\t<link href=\"#{basedir}stylesheets/screen.css\" rel=\"stylesheet\" type=\"text/css\">\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t<a style=\"color: inherit; text-decoration: none\" href=\"#{href}\">#{title}</a>\n\t\t\t</body>\n\t\t</html>\n\t\tHTML\n\t\toutfile.close\n\tend\n\n\tnil\nend",
"def each_link\n return enum_for(:each_link) unless block_given?\n l = Cproton.pn_link_head(@impl, 0);\n while l\n l2 = l # get next before yield, in case yield closes l and unlinks it\n l = Cproton.pn_link_next(l, 0)\n yield Link.wrap(l2)\n end\n self\n end",
"def links\n @doc.css('a[href]').map do |a|\n parse_element_attribute_uri(a, 'href')\n end.compact.uniq\n end",
"def all\n @all ||= raw.map { |link| URL.absolutify(link, base_url) }.compact.uniq\n end",
"def get_hrefs\n # this will grab all the html from the url that\n # the user created the scraper with\n url_to_scrape = HTTParty.get(self.url)\n # nokogiri turns everything from HTTParty into nodes.\n nodes = Nokogiri::HTML(url_to_scrape)\n nodes.css('a').each do |a|\n self.hrefs << a['href']\n end\n self.hrefs\n end",
"def crawlOne(uri)\r\n @crawled[uri]=true\r\n req = retrievePage(uri)\r\n newURIs = yield(uri,req)\r\n newURIs.each{|link|\r\n if @crawled[link] == nil\r\n @toCrawl << link\r\n end\r\n }\r\n end",
"def process_anchor_tags(html)\n content = Nokogiri::HTML::DocumentFragment.parse(html)\n anchors = content.css(\"a[href]\")\n anchors.each do |item|\n if processable_link?(item)\n add_target_blank_attribute(item)\n add_rel_attributes(item)\n add_css_classes_if_required(item)\n end\n next\n end\n content.to_html\n end",
"def uri\n @uri ||= begin\n uri = Addressable::URI.parse(sanitize_link(@link_string))\n uri.normalize\n uri.query_values = nil\n uri\n end\n end",
"def all_links(options = {}) \n options[:valid_schemes] = [:http, :https] unless options.has_key? :valid_schemes\n data = link_data\n links = data.keys.map{|key| data[key]}.flatten.uniq\n links = links.map{|link| UriHelper.join_no_fragment(@url, link).to_s }\n links = links.reject{|link| link =~ /\\/([^\\/]+?)\\/\\1\\// }\n links = links.reject{|link| link =~ /([^\\/]+?)\\/([^\\/]+?)\\/.*?\\1\\/\\2/ } \n links = links.select{|link| options[:valid_schemes].include? link.split(':')[0].to_sym}\n links\n end",
"def post_urls\n arr_hrefs = []\n collect_post_elements.each do |element|\n # there should only be one headline link per post\n if link = element.search( headline_element ).first \n uri = URI.parse link['href']\n uri.fragment = nil\n arr_hrefs << uri.to_s \n end\n end\n\n return arr_hrefs\n end",
"def change_hrefs(html)\n DOM.walk(html) do |node|\n for attr_name in %w{href src}\n attr_obj = node.attributes[attr_name]\n\n # Ignore if its blank\n next if !attr_obj\n\n # URL encode any spaces\n orig_href = attr_obj.to_s.gsub(\" \", \"%20\")\n\n begin\n src = URI(orig_href)\n rescue\n log \"#{orig_href} not a valid URI\"\n next\n end\n\n if internal_link?(src.to_s)\n linked_item = nil\n\n if src.path == \"\"\n # If its just an anchor like '#this' just set to the current file\n linked_item = self\n else\n # Match on the unescaped href\n unescaped_path = URI::unescape(src.path)\n linked_item = get_item(unescaped_path)\n end\n\n # Change link\n if linked_item\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\n new_path = URI(new_path)\n\n if src.fragment\n new_path.fragment = src.fragment\n end\n\n log \"Changing #{src.to_s} to #{new_path.to_s}\"\n attr_obj.content = new_path.to_s\n else\n log \"No item in manifest for #{src}\"\n end\n end\n end\n end\n end",
"def uri\n @uri ||= if @href then\n begin\n URI.parse @href\n rescue URI::InvalidURIError\n begin\n URI.parse(Addressable::URI.escape(@href))\n rescue Addressable::URI::InvalidURIError\n raise URI::InvalidURIError\n end\n end\n end\n end",
"def href\n if @href_overridden != true || @href.nil?\n original_href = @href\n \n override_href = lambda do |current_href|\n begin\n if current_href.nil? && self.feed_data != nil\n # The current url is nil and we have feed data to go on\n true\n elsif current_href != nil && !([\"http\", \"https\"].include?(\n URI.parse(current_href.to_s).scheme))\n if self.feed_data != nil\n # The current url is set, but isn't a http/https url and\n # we have feed data to use to replace the current url with\n true\n else\n # The current url is set, but isn't a http/https url but\n # we don't have feed data to use to replace the current url\n # with so we'll have to wait until we do\n false\n end\n else\n # The current url is set to an http/https url and there's\n # no compelling reason to override it\n false\n end\n rescue\n # Something went wrong, so we should err on the side of caution\n # and attempt to override the url\n true\n end\n end\n if override_href.call(@href) && self.feed_data != nil\n begin\n links = FeedTools::GenericHelper.recursion_trap(:feed_href) do\n self.links\n end\n link = FeedTools::GenericHelper.recursion_trap(:feed_href) do\n self.link\n end\n if links != nil\n for link_object in links\n if link_object.rel == 'self'\n if link_object.href != link ||\n (link_object.href =~ /xml/ ||\n link_object.href =~ /atom/ ||\n link_object.href =~ /feed/)\n @href = link_object.href\n @href_overridden = true\n @links = nil\n @link = nil\n return @href\n end\n end\n end\n end\n rescue Exception\n end\n @links = nil\n @link = nil\n \n # rdf:about is ordered last because a lot of people put the url to\n # the feed inside it instead of a link to their blog.\n # Ordering it last gives them as many chances as humanly possible\n # for them to redeem themselves. If the link turns out to be the\n # same as the blog link, it will be reset to the original value.\n @href = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"admin:feed/@rdf:resource\",\n \"admin:feed/@resource\",\n \"feed/@rdf:resource\",\n \"feed/@resource\",\n \"@rdf:about\",\n \"@about\",\n \"newLocation/text()\",\n \"atom10:link[@rel='self']/@href\"\n ], :select_result_value => true) do |result|\n override_href.call(FeedTools::UriHelper.normalize_url(result))\n end\n begin\n if !(@href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@href)\n @href = FeedTools::UriHelper.resolve_relative_uri(\n @href, [self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n @href = FeedTools::UriHelper.normalize_url(@href)\n end \n @href.strip! unless @href.nil?\n @href = nil if @href.blank?\n @href_overridden = true\n if @href == nil\n @href = original_href\n @href_overridden = false\n end\n if @href == self.link\n @href = original_href\n @href_overridden = false\n end\n if @href_overridden == true\n @links = nil\n @link = nil\n end\n end\n end\n return @href\n end",
"def each_sitemap_link\n return enum_for(__method__) unless block_given?\n\n each_extracted_sitemap_links('url') { |url| yield(url) }\n end",
"def each_address(&blk) # :yields: url\n addresses.each(&blk)\n end",
"def crawl(start_uri)\n start_uri = start_uri.normalize\n @queue << start_uri\n \n timeout(@options[:timeout]) {\n while(uri = @queue.shift)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n \n headers = {\n 'User-Agent' => @options[:useragent]\n }\n \n head = http.head(uri.path, headers)\n next if head.content_type != \"text/html\" # If the page retrieved is not an HTML document, we'll choke on it anyway. Skip it\n \n resp = http.get(uri.path, headers)\n\n changed\n notify_observers(resp, uri)\n \n html = Nokogiri.parse(resp.body)\n a_tags = html.search(\"a\")\n @queue = @queue + a_tags.collect do |t|\n begin\n next_uri = uri + t.attribute(\"href\").to_s.strip\n rescue\n nil\n end\n end\n @queue = @queue.compact.uniq\n @queue = @queue.reject {|u| \n @crawled.include?(u) or\n u == uri or\n !(u.kind_of?(URI::HTTP)) or\n (u.host != uri.host and !@options[:external]) or\n (@options[:exclude].any? { |excl| u.path.include?(excl)})\n }\n end\n @crawled << uri\n end\n }\n \n end",
"def convert_relative_links(url)\n base_url = doc.css('base').present? ? doc.css('base')[0]['href'] : url.split('?').first \n return if base_url.blank?\n doc.css('a').each do |link|\n link['href'] = converted_link(base_url, link['href'])\n end\n end",
"def process_uri(uri)\n ret = uri\n\n require 'open-uri'\n require 'open_uri_redirections'\n begin\n open(uri, :allow_redirections => :safe) do |r|\n ret = r.base_uri.to_s\n end\n end\n\n ret\n end",
"def link uri\n self.apply_hyperlink java.net.URI.new(uri)\n end",
"def uri\n \"http://example.com#{base_path}#{anchor}\"\n end",
"def links\n @links ||= parsed_links.map{ |l| absolutify_url(unrelativize_url(l)) }.compact.uniq\n end",
"def parse_uri(input)\n lines = parse_input input\n extract_uri lines\n end",
"def uri\n @uri ||= select { |type,value| type == :uri }.map do |(type,value)|\n URI.parse(value)\n end\n end",
"def _uri_template\n @uri_template ||= Addressable::Template.new(@link['href'])\n end",
"def join(*uris)\n uris[0] = convert_to_uri(uris[0])\n uris.inject :merge\n end",
"def join(*uris)\n uris[0] = convert_to_uri(uris[0])\n uris.inject :merge\n end",
"def href_parse\n href_elems = @parsed_page.css('a[href]')\n href_elems.map do |elem|\n elem.attributes['href'].value\n end\n end",
"def fetch (uri, post={}, &block)\n start_time = Time.now\n u = absolute_uri(uri)\n @base_uris.push(u)\n yield(@crawler.fetch(u, post))\n report_time(Time.now - start_time)\n @base_uris.pop\n end",
"def links\n @links ||= begin\n if doc\n # get a list of distinct links on the page, in absolute url form\n links = doc.css('a[href]').inject([]) do |list, link|\n href = link.attributes['href'].content\n href.strip! if href\n \n unless skip_link?(href)\n begin\n url = to_absolute(href)\n rescue URI::InvalidURIError\n $stderr.puts \"ERROR: bad URI #{href.inspect} on page #{self.url.to_s.inspect}\"\n else\n list << url if url.scheme =~ /^https?$/\n end\n end\n list\n end\n \n links.uniq!\n links\n else\n []\n end\n end\n end",
"def base(href = \"\") # :yield:\n attributes = if href.kind_of?(String)\n { \"HREF\" => href }\n else\n href\n end\n super(attributes)\n end",
"def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end",
"def handle_uri(uri, reference, redirect_count)\n uri = uri.normalize\n\n new_report = nil\n\n @mtx.synchronize do\n unless report = @link_reports[uri.to_s]\n report = @link_reports[uri.to_s] =\n LinkReport.new(uri, skip_uri?(uri, reference))\n new_report = report\n end\n\n report.references << reference\n end\n\n if new_report\n if new_report.skip?\n @control.log_skip(new_report)\n elsif redirect_count > 2 # TODO hard-coded\n new_report.error_message = \"redirect limit exceeded\"\n else\n @pool_queue.push_job do\n crawl_uri(uri, new_report, redirect_count)\n end\n end\n end\n end",
"def with_base_uri(new_base_uri, &blk)\n if block_given?\n begin\n old_uri = self.base_uri\n\n set_base_uri(new_base_uri)\n\n blk.call\n ensure\n set_base_uri(old_uri)\n end\n end\n end",
"def process_links(host_url)\n file = open(url)\n links = Nokogiri::HTML(file).search('a')\n protocol = url.split('://').first\n links = links.map { |link| [link.text.strip, link['href']] }.to_h\n create_report(links, protocol, host_url)\n rescue StandardError => error\n puts \"Error Encountered : #{error}\"\n end",
"def uri=(value)\n @uris << value\n end",
"def each(uri = nil, &block) # :yield: cookie\n # if uri\n # ...\n # else\n # synchronize {\n # ...\n # }\n # end\n # self\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 to_uri(uri, base_uri = nil)\n case base_uri\n when nil, ''\n Utils.normalize_uri(uri.to_s)\n else\n Utils.normalize_uri(base_uri) + Utils.normalize_uri(uri.to_s)\n end\n rescue URI::Error\n nil\n end",
"def internal_full_links\n links = internal_links\n return [] if links.empty?\n\n links.map { |link| base_url(link: link).concat(link) }\n end",
"def links\n return @links if @links\n return false unless @source\n @links = @source.scan(HREF_CONTENTS_RE).map do |match|\n # filter some malformed URLS that come in\n # meant to be a loose filter to catch all reasonable HREF attributes.\n link = match[0]\n Link.new(@t.scheme, @t.host, link).path\n end.uniq\n end",
"def extract_uris(uri, uri_content)\n # file must be a directory\n if !File.directory?(uri) then\n return Array.new()\n end\n\n # creating the new uris container\n new_uris = Array.new()\n\n # getting the children of the 'uri' folder\n Dir.foreach(uri) do |f|\n # building the new uri path\n path = \"#{uri}/#{f}\"\n\n # appending the new uris values if they aren't the '.' and '..' directories\n if f != '.' and f != '..' then\n new_uris << path\n end\n end\n\n # returning the new uris\n return new_uris\n end",
"def resolve_all_links()\n @links.each_value { |lnk|\n set_link_target(lnk) if lnk.target.nil?\n }\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def initialize(base_url = nil, **opts)\n @scheme = nil\n @host = nil\n @prefix = []\n self.attributes = URI.parse_uri base_url\n self.attributes = opts\n yield self if block_given?\n end",
"def set_uri(base, path)\n @uri = \"#{base}/#{path}/#{self.identifier}\"\n end",
"def links\n return @links unless @links.nil?\n @links = []\n return @links if !doc\n\n doc.search(\"//a[@href]\").each do |a|\n next if a['data-method'] && a['data-method'] != 'get'\n u = a['href']\n next if u.nil? or u.empty?\n abs = to_absolute(u) rescue next\n @links << abs if in_domain?(abs)\n end\n @links.uniq!\n @links\n end",
"def internal_links\n return [] if @links.empty?\n\n links = @links\n .select { |link| link.is_relative?(host: @url.to_base) }\n .map(&:without_base)\n .map do |link| # We map @url.to_host into / because it's a duplicate.\n link.to_host == @url.to_host ? Wgit::Url.new('/') : link\n end\n\n Wgit::Utils.process_arr(links)\n end",
"def parse(uri)\n URI.for(*self.split(uri), self)\n end",
"def normalize_uri\r\n self.link = Addressable::URI.heuristic_parse(self.link).normalize!.to_s if self.link\r\n end",
"def extract_uris(uri, uri_content)\n # in our case, no new uri can be extracted from a web resource\n return Array.new()\n end",
"def open_url_generator(bib)\n open_url_link = open_url_resolve_link(bib)\n links = UmdOpenUrl::Resolver.resolve(open_url_link)\n links\n end",
"def update_hrefs(css_selector)\n @doc.css(css_selector + ' a').each do |a|\n\n href = Flatfish::Url.absolutify(a['href'], @cd)\n\n # Create tokens for internal links and images/files\n if href =~ /#{@accepted_domain}/\n # NB: the brackets will be URL encoded, so we are flagging them here and gsubbing them before saving\n if @file_whitelist.include?(File.extname(href))\n media = get_media(href)\n href = \"[FLATFISHmedia:#{media.id}FLATFISH]\"\n elsif href !~ /mailto:/\n link = Flatfish::Link.find_or_create_by(url: href)\n href = \"[FLATFISHlink:#{link.id}FLATFISH]\"\n end\n end\n a['href'] = href\n end\n end",
"def link_urls(tweet)\n tweet.gsub(/([A-Z]+:\\/\\/[^\\s]+)/i, '<a href=\"\\1\">\\1</a>')\n end",
"def absolutify_url(uri)\n if uri =~ /^\\w*\\:/i\n normalize_url(uri)\n else\n Addressable::URI.join(@url, uri).normalize.to_s\n end\n rescue URI::InvalidURIError, Addressable::URI::InvalidURIError => e\n add_fatal_error \"Link parsing exception: #{e.message}\" and nil\n end",
"def emit_base_uri(collector, base_uri)\n if collector and collector.respond_to? :base_uri=\n collector.base_uri = namespace\n end\n end",
"def each\n page = Page.new @uri, @filters, @headers\n until page.nil?\n yield page\n page = page.next\n end\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 base_uri=(uri)\n # If the baseUri does not end with a slash, we must add it\n uri += '/' unless uri[-1] == '/'\n @base_uri = uri\n end",
"def uri(custom_uri = nil)\n if custom_uri\n @uri = custom_uri\n @http = create_http # yike, oh well. less intrusive this way\n else # if no custom passed, we use existing, which, if unset, is set to site uri\n @uri ||= URI.parse(site)\n end\n end",
"def linked_hrefs(css_selector, strip_spaces = true)\n lnks = css(css_selector)\n ret = []\n for l in lnks\n if l['href']\n url = l['href']\n if strip_spaces\n url.gsub!(/\\s/,'')\n end\n ret << normalize_url(url)\n end\n end\n return ret\n end",
"def extract_uris(uri, uri_content)\n # empty --> this is like an abstract class method\n end",
"def goto(uri)\n reset\n\n # Fetch content\n open(uri) do |f|\n @meta[:uri] = uri.dup\n if f.respond_to?(:meta)\n @meta[:headers] = f.meta.dup\n @meta[:status] = f.status.dup\n @meta[:base_uri] = f.base_uri.dup\n end\n\n if f.respond_to?(:metas)\n @meta[:split_headers] = f.metas.dup\n end\n\n @content = f.read\n end\n\n # Pass content to Nokigiri\n @parsed = ::Nokogiri.send(@parse_method, @content) do |config|\n config.options = @options\n end\n end",
"def test_uri_weird\n doc = Nokogiri::HTML::Document.new\n\n node = Nokogiri::XML::Node.new('foo', doc)\n node['href'] = 'http://foo.bar/ baz'\n\n link = Mechanize::Page::Link.new(node, nil, nil)\n\n assert_equal 'http://foo.bar/%20baz', link.uri.to_s\n end",
"def links\n each_link.to_set\n end",
"def each(&block)\n if block_given?\n current = self\n while current\n coll = current.respond_to?(@key) ? current.send(@key) : _resource\n coll.each(&block)\n break unless current._links[:next]\n\n current = current._links.next\n end\n else\n to_enum(:each)\n end\n end",
"def parse_links\n @body.scan(@@link_re) do |x|\n m = Regexp.last_match\n type = 'link'\n from = self\n text = m['text_or_to']\n to = @twine.passage_from_name(m['to'] ? m['to'] : m['text_or_to'])\n @links << Link.new(from, to, text, type)\n end\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 links\n url = @controller.request.url\n url = url.split('.')[0..-2].join('.') if url =~ /\\.\\w+$/\n\n parent_url = url.split('/')[0..-2].join('/')\n parent_name = parent_url.split('/')[0..-2].last.singularize\n\n _links = {\n self: { href: url },\n parent_name => { href: parent_url }\n }\n\n { _links: _links }\n end",
"def relativize(base_uri)\n if self.to_s.start_with?(base_uri.to_s) && %w(# ?).include?(self.to_s[base_uri.to_s.length, 1]) ||\n base_uri.to_s.end_with?(\"/\", \"#\") &&\n self.to_s.start_with?(base_uri.to_s)\n return RDF::URI(self.to_s[base_uri.to_s.length..-1])\n else\n # Create a list of parents, for which this IRI may be relative.\n u = RDF::URI(base_uri)\n iri_set = u.to_s.end_with?('/') ? [u.to_s] : []\n iri_set << u.to_s while (u = u.parent)\n iri_set.each_with_index do |bb, index|\n next unless self.to_s.start_with?(bb)\n rel = \"../\" * index + self.to_s[bb.length..-1]\n return rel.empty? ? \"./\" : rel\n end\n end\n self\n end",
"def absolute_uri (uri)\n return uri if @base_uris.empty?\n base = URI.parse(@base_uris.last)\n base.merge(uri).to_s\n end",
"def url(uri=nil)\n @uri = Addressable::Template.new(uri.gsub(/:(?![0-9])(\\w+)/) { \"{#{$1}}\" }) unless uri.nil?\n @uri\n end",
"def find_links\n @links = {}\n @contents.xpath('//a[@href]').each do |tag|\n if tag[:href].include? \"http://wiki.dublincore.org/index.php\"\n tag[:href] = tag[:href].sub(\"http://wiki.dublincore.org/index.php\", \"\")\n tag[:href] = @base_url + tag[:href] unless tag[:href].include? \"File:\"\n elsif tag[:href].include? \"/index.php\"\n tag[:href] = tag[:href].sub(\"/index.php\", \"\")\n tag[:href] = @base_url + tag[:href] unless tag[:href].include? \"File:\" \n end\n if tag[:href].include? \"File:\"\n if tag.children[0][:src].nil?\n file_name = tag[:href].sub(\"/File:\", \"\")\n source = html_get(URI.parse(URI.escape(File.join('http://wiki.dublincore.org/index.php', tag[:href]))))\n contents = Nokogiri::HTML(source)\n file_path = contents.xpath(\"//a[@class='internal']/@href\")\n # download_resource(File.join('http://wiki.dublincore.org/index.php', file_path.to_s), File.join(@file_dir, file_name))\n tag[:href] = File.join(@base_url, \"files/#{file_name}\")\n else\n tag[:href] = File.join(@base_url, \"images/#{File.basename(tag.children[0][:src])}\")\n tag.children[0][:src] = File.join(@base_url, \"images/#{File.basename(tag.children[0][:src])}\")\n end\n end\n @links[tag[:href]] = (tag[:title] || '') if (! @links.include? tag[:href])\n end\n end"
] | [
"0.8447926",
"0.8447926",
"0.6748913",
"0.67058986",
"0.6264313",
"0.6128267",
"0.60414875",
"0.5970319",
"0.5841095",
"0.5840394",
"0.5712688",
"0.56757635",
"0.56583065",
"0.5569994",
"0.556946",
"0.5550127",
"0.55427045",
"0.55214435",
"0.54943734",
"0.5464179",
"0.54433346",
"0.5397079",
"0.5382705",
"0.53584194",
"0.5328963",
"0.53224564",
"0.5279566",
"0.52670413",
"0.5256991",
"0.5201749",
"0.5193194",
"0.51879394",
"0.5183544",
"0.5181349",
"0.518083",
"0.5171895",
"0.5170128",
"0.5169082",
"0.51424795",
"0.5127731",
"0.5123638",
"0.51204747",
"0.51142067",
"0.51027906",
"0.5101271",
"0.509581",
"0.5092034",
"0.5086504",
"0.50799954",
"0.5077656",
"0.5054735",
"0.5054735",
"0.50546134",
"0.5049824",
"0.5048554",
"0.5046905",
"0.50324357",
"0.50143075",
"0.5006343",
"0.49776074",
"0.49585932",
"0.4955656",
"0.49554944",
"0.4953627",
"0.4946079",
"0.49325585",
"0.49184468",
"0.4905099",
"0.48966008",
"0.48966008",
"0.48941338",
"0.4885182",
"0.4883003",
"0.4873263",
"0.48719013",
"0.48690495",
"0.48680618",
"0.48435414",
"0.48356423",
"0.48295859",
"0.48280048",
"0.48129958",
"0.47958797",
"0.47951403",
"0.47921848",
"0.4780708",
"0.4775147",
"0.47745493",
"0.47631127",
"0.47463256",
"0.47279492",
"0.47228193",
"0.4719597",
"0.47082537",
"0.47006574",
"0.4697233",
"0.46892422",
"0.46870062",
"0.46819994"
] | 0.88244975 | 1 |
+author+ searches author and return it as a text. It returns nil if not found. +author+ searchs following information. in HTML in HTML authorname in RSS authorname in RSS | def author
traverse_element('meta',
'{http://www.w3.org/1999/xhtml}meta') {|e|
begin
next unless e.fetch_attr('name').downcase == 'author'
author = e.fetch_attribute('content').strip
return author if !author.empty?
rescue IndexError
end
}
traverse_element('link',
'{http://www.w3.org/1999/xhtml}link') {|e|
begin
next unless e.fetch_attr('rev').downcase == 'made'
author = e.fetch_attribute('title').strip
return author if !author.empty?
rescue IndexError
end
}
if channel = find_element('{http://purl.org/rss/1.0/}channel')
channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|
begin
author = e.extract_text.strip
return author if !author.empty?
rescue IndexError
end
}
channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|
begin
author = e.extract_text.strip
return author if !author.empty?
rescue IndexError
end
}
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author\n traverse_element('meta',\n '{http://www.w3.org/1999/xhtml}meta') {|e|\n begin\n next unless e.fetch_attr('name').downcase == 'author'\n author = e.fetch_attribute('content').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n traverse_element('link',\n '{http://www.w3.org/1999/xhtml}link') {|e|\n begin\n next unless e.fetch_attr('rev').downcase == 'made'\n author = e.fetch_attribute('title').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n if channel = find_element('{http://purl.org/rss/1.0/}channel')\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n\n ['http://www.w3.org/2005/Atom', 'http://purl.org/atom/ns#'].each {|xmlns|\n each_child {|top|\n next unless top.elem?\n if top.name == \"{#{xmlns}}feed\"\n if feed_author = find_element(\"{#{xmlns}}author\")\n feed_author.traverse_element(\"{#{xmlns}}name\") {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n end\n }\n }\n\n nil\n end",
"def author\n @node.at_xpath(\"author\").try(:content)\n end",
"def author\n if @author.nil?\n @author = FeedTools::Author.new\n author_node = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"atom10:author\",\n \"atom03:author\",\n \"atom:author\",\n \"author\",\n \"managingEditor\",\n \"dc:author\",\n \"dc:creator\"\n ])\n unless author_node.nil?\n @author.raw = FeedTools::XmlHelper.try_xpaths(\n author_node, [\"text()\"], :select_result_value => true)\n @author.raw = FeedTools::HtmlHelper.unescape_entities(@author.raw)\n unless @author.raw.nil?\n raw_scan = @author.raw.scan(\n /(.*)\\((\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\)/i)\n if raw_scan.nil? || raw_scan.size == 0\n raw_scan = @author.raw.scan(\n /(\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\s*\\((.*)\\)/i)\n unless raw_scan.size == 0\n author_raw_pair = raw_scan.first.reverse\n end\n else\n author_raw_pair = raw_scan.first\n end\n if raw_scan.nil? || raw_scan.size == 0\n email_scan = @author.raw.scan(\n /\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b/i)\n if email_scan != nil && email_scan.size > 0\n @author.email = email_scan.first.strip\n end\n end\n unless author_raw_pair.nil? || author_raw_pair.size == 0\n @author.name = author_raw_pair.first.strip\n @author.email = author_raw_pair.last.strip\n else\n unless @author.raw.include?(\"@\")\n # We can be reasonably sure we are looking at something\n # that the creator didn't intend to contain an email address\n # if it got through the preceeding regexes and it doesn't\n # contain the tell-tale '@' symbol.\n @author.name = @author.raw\n end\n end\n end\n if @author.name.blank?\n @author.name = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:name/text()\",\n \"atom03:name/text()\",\n \"atom:name/text()\",\n \"name/text()\",\n \"@name\"\n ], :select_result_value => true)\n )\n end\n if @author.email.blank?\n @author.email = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:email/text()\",\n \"atom03:email/text()\",\n \"atom:email/text()\",\n \"email/text()\",\n \"@email\"\n ], :select_result_value => true)\n )\n end\n if @author.url.blank?\n @author.url = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:url/text()\",\n \"atom03:url/text()\",\n \"atom:url/text()\",\n \"url/text()\",\n \"atom10:uri/text()\",\n \"atom03:uri/text()\",\n \"atom:uri/text()\",\n \"uri/text()\",\n \"@href\",\n \"@uri\",\n \"@href\"\n ], :select_result_value => true)\n )\n end\n if @author.name.blank? && [email protected]? &&\n [email protected]?\n name_scan = @author.raw.scan(\n /\"?([^\"]*)\"? ?[\\(<].*#{@author.email}.*[\\)>].*/)\n if name_scan.flatten.size == 1\n @author.name = name_scan.flatten[0].strip\n end\n if @author.name.blank?\n name_scan = @author.raw.scan(\n /.*#{@author.email} ?[\\(<]\"?([^\"]*)\"?[\\)>].*/)\n if name_scan.flatten.size == 1\n @author.name = name_scan.flatten[0].strip\n end\n end\n end\n @author.name = nil if @author.name.blank?\n @author.raw = nil if @author.raw.blank?\n @author.email = nil if @author.email.blank?\n @author.url = nil if @author.url.blank?\n if @author.url != nil\n begin\n if !(@author.url =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@author.url)\n @author.url = FeedTools::UriHelper.resolve_relative_uri(\n @author.url, [author_node.base_uri, self.base_uri])\n end\n rescue\n end\n end\n if FeedTools::XmlHelper.try_xpaths(author_node,\n [\"@gr:unknown-author\"], :select_result_value => true) == \"true\"\n if @author.name == \"(author unknown)\"\n @author.name = nil\n end\n end\n end\n # Fallback on the itunes module if we didn't find an author name\n begin\n @author.name = self.itunes_author if @author.name.nil?\n rescue\n @author.name = nil\n end\n end\n return @author\n end",
"def author\n @title_pages.each { |tp| tp.author and return tp.author }\n nil\n end",
"def author\n author = self[:author] || ''\n\n if author.present?\n @author ||= Infopark::Crm::Contact.search(params: { login: author }).first\n @author ||= Infopark::Crm::Contact.search(params: { email: author }).first\n end\n end",
"def author_name\n if author\n author.full_name\n else\n 'No Author Found'\n end\n end",
"def get_author()\n if not self.check_metatags('author')\n return false\n end\n author = @@metadata['author'].gsub(/\\./,'_').gsub(/\\&/,'').gsub(/\\-/,'_').gsub(/\\s/,'_').gsub(/\\,/,'_').gsub(/\\_\\_/,'_')\n I18n.enforce_available_locales = false\n I18n.transliterate(author).downcase # Normalising\n end",
"def get_author\n puts \"Search Author. Enter 4 letters\".red\n puts \">\".magenta.bold\n r = gets[0..3].chomp\n puts \"Searching... #{r}\".red\n i = 0\n @@book_class.each do | book |\n book.author.chomp\n x = book.author.chomp\n answer = /#{r}/i =~ x\n # puts answer\n if answer != nil\n # puts x\n puts \"Author: #{x}\"\n # pp \"id: #{book.book_id}, title #{book.title}\".chomp #, date due: #{book.due_date}\n end\n end\n i +1\n end",
"def author_tag(text); end",
"def find_article_titles_by_author(author)\n @titles = []\n search_techcrunch[\"articles\"].each do |article|\n if article[\"author\"].include?(author)\n @titles << article[\"title\"]\n end\n end\n @titles.each_with_index do |title, index| puts \"#{index+1}. #{title}\"\n end\n return nil\n end",
"def author\n @author ||= Readability::Document.new(@html).author\n end",
"def author_string\n if !self.verbatim_author.nil?\n self.verbatim_author\n elsif !self.source_id.nil?\n self.source.authority_name\n else\n nil\n end\n end",
"def author\n val = authors and val.first\n end",
"def the_author(content=nil)\n if node = content || @content || Content.get(params[:id]) \n author = node.author\n end\n end",
"def get_author()\n @author\n end",
"def author\n @author ||=\n convert_content(item_attributes!.author) ||\n convert_content(item_attributes!.creator) ||\n \"\"\n end",
"def author\n @author ||= begin\n UnfuddleAPI::People.find(self[:author_id]).username\n rescue\n ''\n end\n end",
"def\n get_author()\n @author\n end",
"def citation_author\n surname = authors.first.last_name\n initials = authors.first.initials\n\n if authors.size > 1\n return \"#{surname} et al.\"\n else\n return \"#{surname}, #{initials}\"\n end\n end",
"def searchauthor\n end",
"def find_by_author(author)\n raise \"Must be overridden\"\n end",
"def get_author()\n return @author\n end",
"def author_name\n author.full_name if author\n end",
"def author\n @info[:Author]\n end",
"def author\n @author ||= get_author\n end",
"def author_name\n if self.author\n self.author.name\n else\n nil\n end\n end",
"def authors\n document.search(\"[@id='bookAuthors']/[@itemprop='author']/a/span\").map { |elem| elem.innerHTML.strip } rescue []\n end",
"def author; @author; end",
"def author; @author; end",
"def author\n @author\n end",
"def authors()\n authors_or_editors(@text[:author].to_names) if @text[:author]\n end",
"def itunes_author\n if @itunes_author.nil?\n @itunes_author = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"itunes:author/text()\"\n ], :select_result_value => true)\n )\n @itunes_author = nil if @itunes_author.blank?\n end\n return @itunes_author\n end",
"def author\n name.split(/[\\/-]/).first\n end",
"def authorstring\n @authorstring ||= self.authors.collect { |a| a.last }.sort.to_sentence(:last_word_connector => ' и ')\n @authorstring\n end",
"def resolved_author\n return @resolved_author if defined? @resolved_author\n\n sources = [page[\"author\"]]\n sources << page[\"authors\"].first if page[\"authors\"].is_a?(Array)\n sources << site[\"author\"]\n @resolved_author = sources.find { |s| !s.to_s.empty? }\n end",
"def resolved_author\n return @resolved_author if defined? @resolved_author\n\n sources = [page[\"author\"]]\n sources << page[\"authors\"].first if page[\"authors\"].is_a?(Array)\n sources << site[\"author\"]\n @resolved_author = sources.find { |s| !s.to_s.empty? }\n end",
"def author(solr_doc)\n solr_doc[Solrizer.solr_name(\"author\", :searchable)]\n end",
"def resolved_author; end",
"def author\n authors.first\n end",
"def author\n authors.first\n end",
"def get_linked_author_name_or_blank\n ret = get_author_name_or_blank\n ret = \"<a href=\\\"#{self.link}\\\" target=\\\"quote_extern\\\">#{ret}</a>\" unless ret.blank? or self.link.blank?\n ret\n end",
"def author\n\t\t@author\n\tend",
"def parse_author(author:)\n return nil if author.nil?\n\n parts = author.split('|')\n { author: parts.first, organization: parts.last }\n end",
"def author value = nil\n return @author if value.nil?\n @author = value\n end",
"def page_author(author)\n content_for_layout :meta_author, author\n end",
"def authors\n author\n end",
"def author_name\n if read_attribute('comment_body') =~ COMMENT_BODY_PARSER\n $1\n elsif created_by and created_by.sfcontact\n created_by.sfcontact.name\n end\n end",
"def author_name\n self.author ? self.author.name : nil\n end",
"def is_author?( author = '' )\n return false unless @is_author\n\n return true if author.blank?\n\n author_obj = get_queried_object\n\n author = [author].map {|a| a.to_s}\n\n if author.include?(author_obj.id.to_s)\n return true\n elsif author.include?(author_obj.nickname)\n return true\n elsif author.include?(author_obj.user_nicename)\n return true\n end\n false\n end",
"def extract_author(an_array)\n author_string_index = an_array.index{|s| s.start_with?(\"Author:\")}\n author_string = an_array[author_string_index]\n return author_string.gsub('Author:','').strip\nend",
"def verbatim_author(author_year)\n return nil if author_year.blank?\n author_year.gsub(/\\,+\\s*\\d\\d\\d\\d/, '')\n end",
"def author_name\n self.author.name if author \n end",
"def author_display(author)\n if (author.first.present? && author.last.present?)\n \"#{author.last}, #{author.first.slice(0,1)}\"\n elsif author.display.present?\n author.display\n elsif author.last.present?\n author.last\n else\n nil\n end\n end",
"def author_name\n self.author ? self.author.name : nil \n end",
"def author_exuid\n author && author.to_param\n end",
"def author(version = Origen.app.version.prefixed)\n version = VersionString.new(version)\n version = version.prefixed if version.semantic?\n capture = false\n File.readlines(\"#{Origen.root}/doc/history\").each do |line|\n line = line.strip\n if capture\n if capture && line =~ /^#+ by (.*) on (.*(AM|PM))/\n user = Origen.fsl.find_by_name(Regexp.last_match(1))\n return user if user\n\n return Regexp.last_match(1)\n end\n else\n if line =~ /Tag:/\n line = line.gsub('\\\\', '')\n if line =~ /^#+ Tag: #{version}$/ ||\n line =~ />Tag: #{version}</\n capture = true\n end\n end\n end\n end\n nil\n end",
"def author=(author)\n @author = author.to_s.strip\n end",
"def atom_entry_author(atom_entry, content)\n atom_entry.author do |author|\n entry_author = content.author_for(current_agent)\n\n author.name(sanitize(entry_author.name))\n if entry_author.respond_to?(:openid_uris) && entry_author.openid_uris.any?\n author.uri(entry_author.openid_uris.first)\n end\n end\n\n end",
"def author() headers['author'] end",
"def author\n response = read(\"/user/#{@author}/about.json\", :handler => \"User\") if @author\n @author_data ||= response[0] if response\n end",
"def by_author\n user = find_obj_or_goto_index(\n model: User, obj_id: params[:by_author].to_s,\n index_path: name_descriptions_path\n )\n return unless user\n\n query = create_query(:NameDescription, :by_author, user: user)\n show_selected_name_descriptions(query)\n end",
"def author_uri\n meta['author']\n end",
"def get_author\n\t\t# TODO\n\t\tauthor_id\n\tend",
"def get_author_name(author)\n author_object = Author.find_by_var(\"authors\", \"id\", author) \n # => one Author Obj\n @author_name = author_object.name\n \n end",
"def getAuthorBibTeX(name)\n url = \"http://portal.acm.org/authorBibTex.cfm?query=(Author:#{name})\"\n fetchURL(url).scan(PRE).each do |match|\n bib = convertToTeX match[0].strip\n print bib, \"\\n\\n\"\n end\nend",
"def author\n return '' if self.authors.empty?\n self.authors.join(', ')\n end",
"def author\n commenter.try(:name)\n end",
"def author_name\n self.author ? \"#{self.author}\" : 'Anonymous'\n end",
"def author\n @author_data ||= read(\"/user/#{@author}/about.json\", :handler => \"User\")\n end",
"def nice_author(author)\n return nice_author(\"#{$2} #{$1}\") if author =~ /^(.+),\\s+(.+)$/\n return nice_author(\"#{$1} #{$2}\") if author =~ /^(.+)\\.(.+)$/\n return author.titleize\nend",
"def author\n I18n.locale = params[:lang]\n\n @quotes = Quote.where(:author => CGI::unescape(params[:author]))\n @quote = Quote.new\n\n @quote.author = params[:author] if !(params[:author].nil?)\n\n respond_to do |format|\n format.html # author.html.erb\n format.xml { render :xml => @quotes }\n end\n end",
"def author_string\n auth = nil\n if authors.size > 0 # Build based on People \n case authors.size\n when 1\n auth = authors.first.last_name # self.author\n when 2 \n auth = authors.map(&:last_name).join(\" & \")\n when 3...100\n auth = authors[0..-1].map(&:last_name).join(\", \") + \" & \" + authors.last.last_name\n end\n else # Build based on string\n auth = self.author\n end\n auth\n end",
"def author; end",
"def author\n props[ AUTHOR_PROP_NAME ] if props\n end",
"def show_authors(result)\n author_array = []\n if result['Items'].present?\n flag = 0\n authorString = []\n result['Items'].each do |item|\n if item['Group'].present?\n if item['Group'] == \"Au\"\n # let Don and Michelle know what this cleaner function does\n newAuthor = processAPItags(item['Data'].to_s)\n # i'm duplicating the semicolor - fix\n newAuthor.gsub!(\"<br />\", \"; \")\n authorString.push(newAuthor)\n flag = 1\n end\n end\n end\n if flag == 1\n return truncate_article authorString.join(\"; \").html_safe\n end\n end\n contributors = result.fetch('RecordInfo', {}).fetch('BibRecord', {}).fetch('BibRelationships', {}).fetch('HasContributorRelationships', [])\n if not contributors.empty?\n contributors.each do |contributor|\n namefull = contributor.fetch('PersonEntity', {}).fetch('Name', {}).fetch('NameFull', nil)\n if namefull\n url_vars = {\"q\" => '\"' + namefull.gsub(\",\", \"\").gsub(\"%2C\", \"\").to_s + '\"', \"search_field\" => \"author\"}\n link2 = generate_next_url_newvar_from_hash(url_vars)\n author_link = '<a href=\"' + request.fullpath.split(\"?\")[0] + \"?\" + link2 + '\">' + namefull.to_s + '</a>'\n author_array.push(author_link)\n end\n\n end\n return author_array.join(\"; \").html_safe\n end\n return ''\n end",
"def get_author\n a = cached_author_year.to_s.gsub(/,\\s\\(?\\d+\\)?\\s\\[\\d+\\]|,\\s\\(?\\d+\\)?/, '')\n a = a.gsub('(', '') if a.starts_with?('(') && !a.include?(')')\n return a\n end",
"def comment_author_html(comment)\n if comment.url && !comment.url.blank?\n link_to comment.name, comment.url, :rel => \"nofollow\"\n else\n comment.name\n end\n end",
"def author?\n !author.nil? && !author.empty?\n end",
"def pretty_author(user, options = {})\n content_tag :span, :class => \"author vcard\" do\n content_tag :span, :class => \"fn\" do\n user.name rescue \"Admin\"\n end\n end\n end",
"def author\n (self.authors.empty?) ? '' : self.authors.join(', ')\n end",
"def author_with_parens\n au = author_string\n return nil if au.nil?\n (self.parens == true) ? \"(#{au})\" : au\n end",
"def author\n # TODO: Return object instead\n @json['project']['meta']['author']\n end",
"def authors\n nodes = @doc.xpath(\"atom:feed/atom:author\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomPerson.new(node) }\n end",
"def get_books author\n books = @books[author]\n if books == nil\n puts \"No such author\"\n else\n puts books.join ', '\n end\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 author\n page.version.author.name\n end",
"def name\n author_hash[\"name\"]\n end",
"def name\n author_hash[\"name\"]\n end",
"def publisher\n if @publisher.nil?\n @publisher = FeedTools::Author.new\n @publisher.raw = FeedTools::HtmlHelper.unescape_entities( \n FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"webMaster/text()\",\n \"dc:publisher/text()\"\n ], :select_result_value => true))\n\n unless @publisher.raw.blank?\n raw_scan = @publisher.raw.scan(\n /(.*)\\((\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\)/i)\n if raw_scan.nil? || raw_scan.size == 0\n raw_scan = @publisher.raw.scan(\n /(\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\s*\\((.*)\\)/i)\n unless raw_scan.size == 0\n publisher_raw_pair = raw_scan.first.reverse\n end\n else\n publisher_raw_pair = raw_scan.first\n end\n if raw_scan.nil? || raw_scan.size == 0\n email_scan = @publisher.raw.scan(\n /\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b/i)\n if email_scan != nil && email_scan.size > 0\n @publisher.email = email_scan.first.strip\n end\n end\n unless publisher_raw_pair.nil? || publisher_raw_pair.size == 0\n @publisher.name = publisher_raw_pair.first.strip\n @publisher.email = publisher_raw_pair.last.strip\n else\n unless @publisher.raw.include?(\"@\")\n # We can be reasonably sure we are looking at something\n # that the creator didn't intend to contain an email address if\n # it got through the preceeding regexes and it doesn't\n # contain the tell-tale '@' symbol.\n @publisher.name = @publisher.raw\n end\n end\n end\n\n @publisher.name = nil if @publisher.name.blank?\n @publisher.raw = nil if @publisher.raw.blank?\n @publisher.email = nil if @publisher.email.blank?\n @publisher.url = nil if @publisher.url.blank?\n if @publisher.url != nil\n begin\n if !(@publisher.url =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@publisher.url)\n channel_base_uri = nil\n unless self.channel_node.nil?\n channel_base_uri = self.channel_node.base_uri\n end\n @publisher.url = FeedTools::UriHelper.resolve_relative_uri(\n @publisher.url, [channel_base_uri, self.base_uri])\n end\n rescue\n end\n end \n end\n return @publisher\n end",
"def book_by_author(author)\n\t\t\tresponse = request('/book/author', :author => author)\n\t\t\tHashie::Mash.new(response['book'])\n\t\tend",
"def set_author\n @author = Author.friendly.find(params[:author_name])\n end",
"def author\n \"#{user.name} (#{user.login})\"\n end",
"def authors\n nodes = @node.xpath(\"atom:author\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomPerson.new(node) }\n end",
"def authors\n if self.channel.generator == 'Twitter'\n return [@item.title.split(':')[0]]\n end\n [@item.author, ((@item.dc_creators.empty?) ? nil : @item.dc_creators.collect{|c| c.content})].flatten.uniq.compact.reject{|au| au == '' || au.match(/^\\s+$/)}\n end",
"def notification_author_name_for(content)\n return unless content.respond_to? :author\n if !content.author.is_a?(Group) && current_user == content.author.user\n _('You')\n elsif content.anonymous?\n _('Anonymous')\n else\n # link_to(content.author.name, commoner_path(content.author))\n content.author.name\n end\n end",
"def author_info\n self.authors.map(&:full_name).join(', ')\n end",
"def show\n (@response, @document_list) = search_results(set_author_query(params))\n\n # Remove the header search form, to prefer the search within author form\n @no_header_search = true\n end",
"def has_author?(author)\n ret = false\n @authors.each{ |auth| ret = true if auth == author }\n ret\n end",
"def to_s\n author_name\n end",
"def author_name(book)\n \"#{book.author.first_name} #{book.author.last_name}\"\n end"
] | [
"0.7628827",
"0.7618069",
"0.737916",
"0.7331381",
"0.7310339",
"0.73037755",
"0.72365296",
"0.71748424",
"0.7109011",
"0.7036566",
"0.7010603",
"0.6967935",
"0.6964151",
"0.69358504",
"0.6879695",
"0.6864359",
"0.6818832",
"0.68099236",
"0.6806723",
"0.6770926",
"0.67676795",
"0.6764762",
"0.67634255",
"0.6761242",
"0.674617",
"0.674074",
"0.67365366",
"0.6732876",
"0.6732876",
"0.67315143",
"0.670398",
"0.66873145",
"0.6674864",
"0.6664952",
"0.66508996",
"0.66508996",
"0.6650715",
"0.66400105",
"0.6637911",
"0.6637911",
"0.66295093",
"0.6619519",
"0.6607186",
"0.66053945",
"0.6595737",
"0.6577431",
"0.6560043",
"0.6549306",
"0.651847",
"0.65136695",
"0.6494423",
"0.6484982",
"0.6472446",
"0.64497274",
"0.6425498",
"0.6424756",
"0.64128965",
"0.63805693",
"0.6376706",
"0.63579005",
"0.63563544",
"0.6355384",
"0.6354539",
"0.63249105",
"0.6319311",
"0.63120645",
"0.63072836",
"0.63068825",
"0.63040006",
"0.62880343",
"0.62778366",
"0.6274306",
"0.6253432",
"0.62444955",
"0.6232824",
"0.622058",
"0.6216582",
"0.62139785",
"0.6203025",
"0.6177309",
"0.614837",
"0.6136498",
"0.6134859",
"0.61235446",
"0.6120134",
"0.61132777",
"0.6105144",
"0.6105144",
"0.61024594",
"0.60806346",
"0.60804236",
"0.6071265",
"0.60588723",
"0.60578823",
"0.6050484",
"0.6037468",
"0.6035011",
"0.60253984",
"0.60140026",
"0.6005234"
] | 0.78793484 | 0 |
If the steps list is changed, this method will probably no longer be valid. | def send_to_correct_step
if Member::States.include? step
original_state = @member.state
set_state previous_step
if [email protected]?
member_step = wizard_steps.index(original_state) || 0
jump_to wizard_steps[member_step.next]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_steps\n @valid_steps ||= self.steps\n end",
"def steps=(new_value)\n @steps = new_value\n end",
"def valid_steps= valid_steps\n unless valid_steps.nil?\n valid_steps = valid_steps.collect {|s| s.to_sym}\n valid_steps = steps.select {|s| valid_steps.include? s}\n @valid_steps = valid_steps\n end\n end",
"def before_steps(steps)\n @current_feature_element[:steps] = []\n end",
"def set_invalid_steps(steps)\n self.invalid_steps = steps\n end",
"def steps\n @steps ||= []\n end",
"def step_taken\n\t\t@step = !@step\n\tend",
"def to_dos_feed\n self.reload\n self.p_steps\n end",
"def set_steps\n invalid_steps = []\n unless @page && @page.content_type\n steps = {pages: %w[position title type],\n names: %w[Position Title Type]}\n self.steps = steps[:pages]\n self.steps_names = steps[:names]\n else\n invalid_steps << 'type' if params[:id] != 'type'\n steps = @page.form_steps\n self.steps = steps[:pages]\n self.steps_names = steps[:names]\n end\n\n invalid_steps << session[:invalid_steps][@page_id] if session[:invalid_steps][@page_id]\n invalid_steps.flatten!\n invalid_steps.uniq!\n set_invalid_steps invalid_steps\n end",
"def p_steps_user\n self.reload\n self.p_steps\n end",
"def steps\n @steps ||= 0\n end",
"def step_ids=(new_step_ids)\n super\n new_step_ids = new_step_ids.reject(&:blank?).map(&:to_i)\n\n new_step_ids.each_with_index do |step_id, index|\n steps.where(id: step_id).update_all(position: index + 1)\n end\n end",
"def step_ids=(new_step_ids)\n super\n new_step_ids = new_step_ids.reject(&:blank?).map(&:to_i)\n\n new_step_ids.each_with_index do |step_id, index|\n steps.where(id: step_id).update_all(position: index + 1)\n end\n end",
"def advance\n\tlcs = (last_completed_step.is_a? Array) ? last_completed_step.first : last_completed_step\n\n\tif (lcs.blank? or not HYDRANT_STEPS.exists?(lcs))\n\t Rails.logger.warn \"<< Step #{lcs} invalid, defaulting to first step >>\"\n\t self.last_completed_step = HYDRANT_STEPS.first.step\n\telsif (not HYDRANT_STEPS.last?(lcs))\n\t next_step = HYDRANT_STEPS.next(lcs).step\n\t Rails.logger.debug \"<< Advancing to the next step - #{next_step} >>\"\n self.last_completed_step = next_step \n end\n end",
"def update_order_steps\n order = current_order\n\n if !signed_in? # 'personal'\n update_order_personal_info\n end\n\n if !order.has_checkout_step?(\"address\") || order.bill_address.blank? || order.shipping_address.blank?\n update_order_addresses\n end\n\n order.state = 'payment'\n order.save\n end",
"def evaluate_next_step_on_change?\n false\n end",
"def move_up\n #get current order of step\n i = self.step_order\n saved = false\n experiment = self.experiment\n\n unless i == 1 \n # increment the order of the previous step\n other_step = experiment.steps.find_by_step_order(i - 1) \n other_step.step_order = i\n self.step_order = i - 1\n \n saved = self.save && other_step.save\n end\n saved\n end",
"def move_down\n #get current order of step\n i = self.step_order\n saved = false\n experiment = self.experiment\n\n unless i == experiment.steps.length \n # increment the order of the previous step\n other_step = experiment.steps.find_by_step_order(i + 1) \n other_step.step_order = i\n self.step_order = i + 1\n \n saved = self.save && other_step.save\n end\n return saved\n end",
"def contains\n @steps\n end",
"def step(steps, force = false)\n #This is a stub, used for indexing\n end",
"def step_errors\n @step_errors ||= []\n end",
"def assign_required_steps\n self.steps = resource.required_steps\n end",
"def get_dead_steps\n CukeSniffer::DeadStepsHelper::build_dead_steps_hash(@step_definitions)\n end",
"def sheets_steps= value ; @sheets_steps = value end",
"def update step\n\t\t\ttbd = []\n\t\t\[email protected]_with_index do |element, index|\n\t\t\t\telement.expires -= step\n\t\t\t\ttbd << index if element.dead?\n\t\t\tend\n\t\t\tunless tbd.empty?\n\t\t\t\ttbd.reverse.each do |i|\n\t\t\t\t\[email protected]_at i\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def steps\n Rails.cache.fetch([self, \"pill_sequence_steps\"]) { pill_sequence_steps }\n end",
"def permitted_attributes_for_step(step)\n []\n end",
"def revisit_next_step?\n false\n end",
"def set_steps_to_done!(ready_steps)\n ready_steps.each do |step|\n puts \"step #{step} finished!\"\n @successors[step].each do |successor|\n # remove the ready step from the predecessor list\n @predecessors[successor].delete(step)\n end\n # no successors any more\n @successors[step].clear\n @steps.delete(step)\n end\n end",
"def steps\n unless @steps_loaded\n step_file = File.expand_path(\"./steps/#{self.class.name.underscore}.rb\", @@current_dir)\n if File.exists?(step_file)\n self.instance_eval File.read(step_file), __FILE__, __LINE__ + 1\n else\n raise StepsFileNotFoundError.new(\"File #{step_file} not found\")\n end\n @steps_loaded = true\n end\n end",
"def form_steps\n self.steps\n end",
"def prevent_changes_if_plan_performed # Editing/updating/destroying a step - Step.find(params[:id])\n step = action_name == \"create\" ? Plan.find(params[:plan_id]).steps.build : Step.find(params[:id])\n redirect_to plan_path(step.plan), alert: \"The steps that comprise an ERP plan cannot be changed once that plan is finished.\" if step.plan.finished?\n end",
"def remaining_steps\n ([ current_step ] + future_steps.map {|ea| ea}).compact\n end",
"def before_step(step)\n @current_step = step\n end",
"def steps_editable(user)\n # TODO: Improve efficiency! Way too many DB calls!\n self.workflow.step_flows.where(current_step_role: user.roles.first.name).collect(&:current_step)\n end",
"def update_steps_history # rubocop:disable Metrics/AbcSize\n if history.nil?\n log_action('Creating first step into the back link history')\n session[:back_link_history] = { '1' => page }\n elsif last_step_page != page\n return clear_unused_steps if back_button && history\n\n log_action('Adding step to the back link history')\n session[:back_link_history][next_step] = page\n end\n end",
"def all_steps\n\t#make calls to step here...\nend",
"def increase_steps\r\n @steps = [@steps + 1, 9999999].min\r\n end",
"def initialize\n @steps = {}\n @notes = {}\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 test_steps; end",
"def test_steps; end",
"def state_changed\n\t\t\[email protected] == 0 ? state_no_items : state_has_items\n\t\tend",
"def update_if_next_lesson\n if self.lesson_id.changed? || self.part_id.changed?\n avaliable_lessons.each_with_index do |lesson, index|\n next_lesson = lesson[i+1]\n if next_lesson_in_list\n self.save\n else\n #Error ActiveRecord::RecordNotSaved: Failed to save the record\n end\n end\n end\n end",
"def steps\n step_flows.collect(&:current_step)\n end",
"def steps\n find_solution\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 complete_order_step(order, order_step)\n original_state = order.state\n order.state = order_step\n\n if !order.next\n order.state = original_state\n order.save(validate: false) # store data from paypal. user will be redirect to 'personal' tab\n end\n end",
"def steps_todo\n @todo.map do |item|\n case item\n when SequenceCursor\n item.steps_todo\n else\n item\n end\n end.flatten\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 incrementStep\n @current_step_index += 1\n @workflow[:current_step] = @current_step_index\n\n if @current_step_index < @workflow[:steps].size\n return true\n end\n\n return false\n end",
"def currentStepIndex\n @current_step_index\n end",
"def checkSteps(numSteps, direction)\n\t\tgoodToGo = true\n\t\tif (@indexOfExecution + numSteps) > doCommandList.length && direction\n\t\t\tputs \"-There was an error stepping forward\"\n\t\t\tgoodToGo = false\n\t\telsif (@indexOfExecution - numSteps) < 0 && !direction\n\t\t\tputs \"-There was an error stepping backward\"\n\t\t\tgoodToGo = false\n\t\tend\n\t\t\n\t\treturn goodToGo\n\tend",
"def index\n @taken_steps = TakenStep.all\n end",
"def steps\n steps_keywords = %w(Given When Then And But)\n nsteps = 0\n @steps = []\n while true\n print \"Add step [Y/n]: \"\n choice = gets\n if choice.downcase.strip != \"n\"\n puts \"Step #{nsteps +1}:\"\n step = gets.capitalize\n init_step_word = step.split(' ').first\n if steps_keywords.include?(init_step_word)\n @steps << step\n nsteps = nsteps ++ 1\n else\n puts \"Error: #{init_step_word} unsupported initial value\"\n puts \"Use only #{steps_keywords} keywords\"\n end\n elsif choice.downcase.strip == \"n\"\n break\n else\n \"please enter a valid choice.\"\n end\n end\n write_feature\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 upa_steps=(_arg0); end",
"def step_result; 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 update_last_completed_onboarding_step(new_step)\n if last_completed_onboarding_step_for_active_recipient.blank?\n self.last_completed_onboarding_step_for_active_recipient = new_step\n save!\n else\n onboarding = UserOnboarding.new(self)\n next_step = onboarding.next_step_after last_completed_onboarding_step_for_active_recipient\n if new_step == next_step\n self.last_completed_onboarding_step_for_active_recipient = new_step\n save!\n end\n end\n end",
"def upa_steps; end",
"def step\n move_if_needed; return self\n end",
"def update\n @step = @project.steps.find_by_position(params[:id])\n authorize! :update, @step \n\n # update corresponding collections\n @step.project.collections.each do |collection|\n collection.touch\n end\n \n @step.images.each do |image|\n image.update_attributes(:saved => true)\n end\n\n # remove question if question description is empty\n if params[:step][:question_attributes] && params[:step][:question_attributes][:description].length == 0 && @step.question\n @step.question.destroy\n end\n\n if params[:step][:published_on_date]\n date = params[:step][:published_on_date]\n logger.debug \"date: #{date}\"\n time = params[:step][:published_on_time]\n # retain the same seconds as the original published_on date\n time.insert 5, \":\" + @step.published_on.strftime(\"%S\")\n # logger.debug \"time: #{time}\"\n timeZone = params[:step][:timeZone]\n # logger.debug \"timeZone: #{timeZone}\"\n dateTime = date + \" \" + time + \" \" + timeZone\n # logger.debug \"dateTime: #{dateTime}\"\n dateTime = DateTime.strptime(dateTime, '%m/%d/%Y %I:%M:%S %p %Z')\n # logger.debug \"datetime: #{dateTime}\"\n \n params[:step][:published_on] = dateTime\n params[:step].delete :'published_on_date'\n params[:step].delete :\"published_on_time\"\n params[:step].delete :timeZone\n end\n\n # update the project \n @project.touch\n\n # update the user last updated date\n current_user.touch\n\n # remove any design attributes if they contain an ID that doesn't exist (the file had been removed)\n if params[:step][:design_files_attributes]\n params[:step][:design_files_attributes].values.each do |design_file|\n if DesignFile.exists?(design_file['id']) == false\n design_file.delete :id\n end\n end\n end\n \n respond_to do |format|\n\n if @step.update_attributes(params[:step])\n \n # clear label color if user didn't select color\n if @step.label == false\n @step.update_column(\"label_color\", nil)\n end\n\n # clear edit\n edit = Edit.where(\"user_id = ? AND step_id = ?\", current_user.id, @step.id).first\n edit.update_attributes(:started_editing_at => nil)\n if edit.project_id.blank?\n edit.update_attributes(:project_id => @project.id)\n end\n \n # check whether project is published\n if @project.public? || @project.privacy.blank?\n @project.set_published(current_user.id, @project.id, @step.id)\n end\n\n # check and set built attribute of project\n @project.set_built\n\n # create a public activity for any questions associated with the step if it doesn't already exist\n if @step.question && !PublicActivity::Activity.where(:trackable_type => \"Question\").where(:trackable_id => @step.question.id).exists?\n @step.question.create_activity :create, owner: current_user, primary: true\n end\n\n # create project on the village if the current user is a village user and the project doesn't already exist\n if @project.village_id.blank? && current_user.from_village? && !access_token.blank? && @project.public?\n create_village_project\n elsif [email protected]_id.blank? && !access_token.blank?\n update_village_project\n end\n\n format.html { \n redirect_to project_steps_path(@project), :notice => 'Step was successfully updated.', :flash => {:createdStep => @step.id} \n }\n format.json { head :no_content }\n else\n Rails.logger.info(@step.errors.inspect)\n format.html { render :action => \"edit\" }\n format.json { render :json => @step.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @step = @task.steps.build\n end",
"def move_next\n \n # before validation, clear validation residues\n self.clear_associated_errors\n \n Logger.new(STDOUT).info(\"Step: \" + self.step.to_s)\n Logger.new(STDOUT).info(\"Sortie object before validation: \" + self.sortie.inspect)\n if self.valid?\n \n # init some new defaults in here\n case self.step\n when 0, 1\n \n case self.step\n when 0\n \n case self.operation\n when 'join'\n # create sortie result object on selected geo\n\n # respond ajax/json for map refresh\n\n #@sorties = Sortie.find_sorties_for_user(current_user)\n @sorties ||= []\n \n when 'create'\n\n # not much to do\n #@user = session[:user]\n self.sortie ||= Sortie.new( :time => self.timerange.start )\n Logger.new(STDOUT).info(self.sortie.inspect)\n\n end\n \n when 1\n \n # switch to full validation for user, TODO: revert, refactor for existing usser...\n self.host.completeness = 'complete' if self.host.completeness == 'discovery'\n \n # profile/review step\n # profile: # set up dob year based on age\n\n # actually need to be refactored: it's a submit...\n case self.operation\n when 'join'\n #session[:selected_dates] = params[:dates]\n\n\n when 'create'\n\n end\n \n end\n \n # common for step 0 and 1\n self.step += 1\n 'next'\n when 2\n # finish...\n self.save_associated\n # do save etc. call separate action?\n self.complete = {'create' => 'created', 'join' => 'joined'}[self.operation]\n 'complete'\n end\n else\n Logger.new(STDOUT).info(\"Stepflow Validation Errors: \" + self.errors.full_messages.inspect)\n 'error'\n end\n end",
"def skip_step\n session[:skipped_steps] ||= []\n session[:skipped_steps].push current_step\n\n return redirect_to workflow_url\n end",
"def can_increment_step\n !step_flow.next_step.nil?\n end",
"def steps_done_array\n @steps_done_array = self.singleton_class.get_bits_set_for_steps_done(steps_done)\n end",
"def steps\n if template_steps_bound?\n @unbound_steps = nil\n @bound_steps ||= build_steps\n else\n @unbound_steps ||= build_steps\n end\n end",
"def set_taken_step\n @taken_step = TakenStep.find(params[:id])\n end",
"def future_steps\n if active\n Step.filter(:system => system).where{ |o| o.number >= next_step_number}.order(:number.asc)\n else\n []\n end\n end",
"def decrement_step\n self.step_flow = self.step_flow.prev if can_decrement_step\n self.step_status.mirror_step_flow(self.step_flow)\n self.step_status.save\n self.save\n end",
"def update\n @post = Post.find(params[:id])\n\n params[:post][:steps] = \"\"\n if params[:post][:step] \n params[:post][:step].each do |k, v|\n if params[:post][:step].length == k.to_i\n params[:post][:steps] << v\n else\n params[:post][:steps] << v + '|'\n end\n end\n end\n params[:post].delete(\"step\")\n\n if @post.update_attributes(params[:post])\n flash[:success] = 'Post was successfully created.'\n redirect_to @post \n else\n render action: \"edit\"\n end\n end",
"def finished?\n @step == @total_steps + 1\n end",
"def steps\n %w[first last]\n end",
"def current_step \n @current_step || steps.first\n end",
"def step1\n \n end",
"def intentions_for_next_step(*args)\n raise \"StateItem must be subclassed to be used!\"\n end",
"def execute(step)\n end",
"def steps_remaining\n @total_steps - @step\n end",
"def completed?\n @step == @total_steps\n end",
"def call\n update_steps_history\n clear_more_then_10_steps\n determinate_back_link_url\n end",
"def reset\n session[:chosen_options] = []\n session[:skipped_steps] = []\n\n redirect_to workflow_url\n end",
"def create\n\n # ensure that the submitted parent_id actually exists\n if !Step.exists?(params[:step][:parent_id].to_i)\n logger.debug \"Step doesn't exist!\"\n if @project.steps.last\n params[:step][:parent_id] = @project.steps.last.id\n else\n params[:step][:parent_id] = nil\n end\n end\n\n if params[:step][:pin] && params[:step][:pin].empty?\n params[:step][:pin] = nil\n end\n\n @step = @project.steps.build(params[:step])\n authorize! :create, @step \n\n if params[:step][:position]\n @step.position = params[:step][:position]\n else\n @step.position = @numSteps\n end\n \n respond_to do |format|\n if @step.save\n\n # update corresponding collections\n @step.project.collections.each do |collection|\n collection.touch\n end\n \n # create an edit entry\n Edit.create(:user_id => current_user.id, :step_id => @step.id, :project_id => @project.id)\n\n # check whether project is published\n if @project.public? || @project.privacy.blank?\n @project.set_published(current_user.id, @project.id, @step.id)\n end\n\n @project.set_built\n\n # update the project updated_at date\n @project.touch\n\n # update the user last_updated_at date\n current_user.touch\n\n @step.update_attributes(:published_on => @step.created_at)\n\n # create a public activity for any added question\n if @step.question\n Rails.logger.debug(\"created new question\")\n @step.question.create_activity :create, owner: current_user, primary: true\n end\n\n # log the creation of a new step\n @project.delay.log\n\n format.html { \n\n # update all images with new step id\n new_step_images = @project.images.where(\"step_id = -1\")\n new_step_images.each do |image|\n image.update_attributes(:saved => true)\n image.update_attributes(:step_id => @step.id)\n end\n\n # update all videos with new step id\n new_step_videos = @project.videos.where(\"step_id = -1\")\n new_step_videos.each do |video|\n video.update_attributes(:saved=>true)\n video.update_attributes(:step_id=> @step.id)\n end\n\n # push project to village if it doesn't already exist\n if @project.village_id.blank? && current_user.from_village? && @project.public? && !access_token.blank?\n create_village_project\n elsif [email protected]_id.blank? && !access_token.blank?\n update_village_project\n end\n \n redirect_to project_steps_path(@project), :flash=>{:createdStep => @step.id}\n \n }\n \n format.json { render :json => @step }\n else\n Rails.logger.debug(@step.errors.inspect)\n format.html { render :action => \"new\" }\n format.json { render :json => @step.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def increment_step\n if self.step_status.current_step == self.step_flow.current_step\n # We are incrementing withing the context of the normal workflow.\n self.step_flow = self.step_flow.next if can_increment_step\n self.step_status.mirror_step_flow(step_flow)\n else\n # We are in the middle of a workflow jump; instead of incrementing\n # to the next StepFlow, we need to reset the state of the StepStatus\n # to where the DeathRecord was before the workflow jump. We also need\n # to restore ownership to the User who requested the change.\n self.step_status.mirror_step_flow(step_flow)\n unless self.step_status.requestor.nil?\n self.owner = self.step_status.requestor # Set owner back to requestor\n self.step_status.requestor = nil # Blank out requestor\n end\n end\n self.step_status.save\n self.save\n end",
"def task_steps_simple\n # this is a read-only display of workflow steps needed or completed\n # D - C - P - B - S\n # maybe it'll contain a id of the related item\n steps = Task.find_all_by_job_id(self).sort { |a, b| (a.order || 1) <=> (b.order || 1) } \n \n #puts steps.class\n end",
"def enforce_can_visit_step\n return if step == 'wicked_finish'\n return if resource.can_visit_step?(step)\n\n next_step = wizard_steps.reverse.find { |step| resource.can_visit_step?(step) }\n raise('There is no wizard step to visit. Make sure can_visit_step?(step) returns true for at least one step') unless next_step\n\n if Rails.env.development?\n Rails.logger.info \" \\e[31m\\e[1mFAILED\\e[0m\\e[22m\" # bold red\n Rails.logger.info \" Unable to visit step :#{step}. Last can_visit_step? is :#{next_step}. Change the acts_as_wizard model's can_visit_step?(step) function to change this.\"\n end\n\n flash[:success] = \"You have been redirected to the #{resource_wizard_step_title(resource, next_step)} step.\"\n redirect_to wizard_path(next_step)\n end",
"def current_step\n\t\t@current_step || steps.first\t\n\tend",
"def after_step(_step_result, _scenario)\n raise NotImplementedError.new \\\n \"#{self.class.name}#after_step must be implemented in subclass.\"\n end",
"def clear_unused_steps\n log_action('Clearing future steps from the back link history')\n current_step_keys = history.select { |k, _v| k <= previous_step }.keys\n session[:back_link_history] = history.slice(*current_step_keys)\n end",
"def create\n @step = StepsTaken.new(step_params)\n\n if @step.save\n redirect_to @step, notice: 'Step was successfully created.'\n else\n render :new\n end\n end",
"def steps\n %i[upload setup order]\n end",
"def edit\n redirect_to wizard_path(steps[0])\n end",
"def toggle_step_by_step\n @step_by_step = !@step_by_step\n end",
"def steps(n)\nend",
"def forward_steps(new_row) # ahhh all the logic to see if this should be added or not should be in here awesome, yeah helper methods *are* supposed to be like this right to better help modularize things nice\n f_steps = Array.new\n one_step = [new_row, @pos[1]] \n two_step_row = new_row + forward_dir # if it can jump you've gotta increment this by another step lol can't believe you forgot this about pawns wow\n if (two_step_row >= 0) && (two_step_row <= 7) # ah lmfao didn't fucking check if it's a NullPiece there or not LOL amazing bug catching god debugger is god mode\n (f_steps << [two_step_row, @pos[1]]) if (at_start_row? && @board.grid[two_step_row][@pos[1]].is_a?(NullPiece) && @board.grid[new_row][@pos[1]].is_a?(NullPiece)) # if the pawn is at the start step then add this new step if it's valid otherwise don't note can't do self.at_start_row? because this is invalid. # also added another check here wow so many things to watch out for you can't double step past a square that's occupied by another piece so have to check that the one step piece is also a NullPiece amazing catch man so much to catch lol\n end\n f_steps << one_step if @board.grid[new_row][@pos[1]].is_a?(NullPiece) # only allow this move if the new row is in bounds and there is no piece in that position\n f_steps\n end",
"def can_decrement_step\n !step_flow.previous_step.nil?\n end",
"def before_test_case(*args)\n @test_steps =[]\n @scenario_tags = []\n @failed_step = {}\n end"
] | [
"0.70787966",
"0.69534796",
"0.6756621",
"0.6710165",
"0.6421414",
"0.6409363",
"0.6273505",
"0.60578233",
"0.60547745",
"0.6027131",
"0.60084236",
"0.59220606",
"0.59220606",
"0.58423513",
"0.5835021",
"0.58194196",
"0.574197",
"0.57391196",
"0.5729767",
"0.57267",
"0.57184863",
"0.5718213",
"0.5703962",
"0.56636184",
"0.5659146",
"0.5650163",
"0.5650028",
"0.5611174",
"0.5609403",
"0.56071347",
"0.5599761",
"0.5553816",
"0.5531582",
"0.55279624",
"0.552329",
"0.550562",
"0.54808515",
"0.54774505",
"0.5456716",
"0.5434547",
"0.5434547",
"0.5421908",
"0.5421908",
"0.5420353",
"0.5417968",
"0.54092735",
"0.53984684",
"0.53847694",
"0.5360548",
"0.534659",
"0.5336697",
"0.53355044",
"0.5328856",
"0.5319784",
"0.53042495",
"0.5303769",
"0.530207",
"0.5301578",
"0.52987105",
"0.5298251",
"0.5283292",
"0.5258014",
"0.5257627",
"0.52470934",
"0.5245394",
"0.5243787",
"0.52411383",
"0.52391946",
"0.52281415",
"0.5226764",
"0.52093947",
"0.5186026",
"0.51845694",
"0.51835954",
"0.5176722",
"0.5167697",
"0.5161848",
"0.5159506",
"0.5151819",
"0.5151687",
"0.51460016",
"0.51438147",
"0.5137814",
"0.51352084",
"0.51341105",
"0.51316196",
"0.5125295",
"0.51214945",
"0.5119452",
"0.5117409",
"0.51138747",
"0.5110313",
"0.50927126",
"0.5084408",
"0.50810254",
"0.5076725",
"0.5070427",
"0.5069661",
"0.50692064",
"0.5057123"
] | 0.56465715 | 27 |
Depending on record type, the address can be nil or an array containing different address parts. | def decompose_address(parts)
addresses = parts || []
address, city, zip, country_code = nil, nil, nil, nil
if !addresses.empty?
address = addresses[0] if addresses[0]
zip, city = addresses[1].split(" ", 2) if addresses[1]
country_code = addresses[2] if addresses[2]
end
[address, city, zip, country_code]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def address_as_string(type)\n ad = address(type)\n begin\n ad.nil? ? nil : \"#{ad.country.name}, #{ad.city.name}, #{ad.street1}, #{ad.street2}\"\n rescue\n \"sorry, bad address\"\n end\n end",
"def address\n unless addresses.empty?\n addresses.first\n else\n nil\n end\n end",
"def address_type; @address_impl.getType; end",
"def street_address(include_secondary: T.unsafe(nil)); end",
"def set_address_type\n\n end",
"def address_as_ids(type)\n ad = address(type)\n begin\n ad.nil? ? nil : \"#{ad.country.id}$#{ad.city.id}$#{ad.street1}$#{ad.street2}$#{ad.address_type}\"\n rescue\n \"0$0$0$0$0\"\n end\n end",
"def full_address_array\n [name, address1, address2, city_state_zip].compact\n end",
"def full_address_array\n [name, address1, address2, city_state_zip].compact\n end",
"def full_address\n [self.address, \"Madrid\", \"Spain\"].compact.join(\", \") if self.address\n end",
"def build_address(address)\n {\n id: address&.id,\n address_line1: address&.address_line1,\n address_line2: address&.address_line2,\n city: address&.city,\n state: address&.state,\n country: address&.country,\n }\n end",
"def default_address\n type_category = contact_type_category('address')\n MasterType.find_by_type_category(type_category)\n end",
"def address\n address = []\n address << [address1] if !address1.blank?\n address << [address2] if !address2.blank?\n address << [city] if !city.blank?\n address << [province] if !province.blank?\n address << [region] if !region.blank?\n address << [zip_code] if !zip_code.blank?\n address.join(\", \")\n end",
"def build_address_details(xml, addressType, address)\n if not address.nil? then\n xml.tag!(addressType){\n xml.Location{\n xml.Address{\n xml.Firstname(address[:name]) \n xml.Street1(address[:address1]) unless address[:address1].nil?\n xml.Street2(address[:address2]) unless address[:address2].nil?\n xml.Street3(address[:address3]) unless address[:address3].nil?\n xml.City(address[:city]) unless address[:city].nil?\n xml.StateProv(address[:state]) unless address[:state].nil?\n xml.PostalCode(address[:zip]) unless address[:zip].nil?\n }\n }\n }\n end\n end",
"def define_address_type\n if @address_type.nil?\n data_file = if !@address_type_data_file.nil?\n @address_type_data_file\n else\n \"#{::File.expand_path(::File.join(\"..\", \"data_files\"), __FILE__)}/address_type.yml\"\n end\n address_types = Psych.load_file(data_file)\n @address_type = address_types.sample unless address_types.nil?\n end\n @address_type = '' unless @set_blank == false\n end",
"def full_address\n addr = []\n addr << country.try(:name) if show_country\n addr << (state.try(:name).presence || state_name) if show_state\n addr << address1\n addr.compact.join(', ')\n end",
"def default_address\n type_category = contactable.contact_type_category('address')\n\n MasterType.find_by_type_category_and_type_value(type_category, id)\n end",
"def address\n return poi.address unless poi.nil?\n return place.address unless place.nil?\n addr = get_address\n return addr.blank? ? raw_address : addr\n end",
"def order_billing_address_lines\n order.bill_address.try(:full_address_array)\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 full_address\n address.presence || [street_number, routes, locality, administrative_area_level_1, country].compact.reject(&:blank?).join(', ')\n end",
"def address_list_fetch(field_name)\n if values = fetch_all(field_name, nil)\n list = nil\n values.each { |value|\n if list\n list.concat(Address.parse(value))\n else\n list = Address.parse(value)\n end\n }\n if list and !list.empty?\n list\n end\n end or RMail::Address::List.new\n end",
"def address\n\t\t\taddress = [self.address_1, self.try(:address_2), \"#{self.city} #{self.try(:state)}\", \"#{self.try(:zip)}\"].compact\n\t\t\taddress.delete(\"\")\n\t\t\taddress.join(\"<br/>\")\n\t\tend",
"def build_addresses(v)\n # only create on address\n if v.kind_of? Hash\n return [Address.new(v)]\n # create multiple addresses\n elsif v.kind_of? Array\n # todo: multiple addresses\n end\n end",
"def address_model\n a = CIVICRM::Address.new(\n contact_id: self.contact_id,\n location_type_id: self.location_type_id,\n is_primary: self.primary,\n is_billing: false,\n street_address: self.address1,\n street_number: self.street_number,\n supplemental_address_1: self.address2,\n supplemental_address_2: self.address3\n\n )\n # Add county, state, country, and zipcode stuff now\n self.set_location(a)\n end",
"def address_record_params\n params.fetch(:address_record, {})\n end",
"def address\n [address_line_1, address_line_2, town_city, county, postcode].join(\", \")\n end",
"def full_address; 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 address_model\n a = CIVICRM::Address.new(\n contact_id: self.contact_id,\n location_type_id: self.location_type_id,\n is_primary: self.primary,\n is_billing: false,\n street_address: self.address1,\n street_number: self.street_number,\n supplemental_address_1: self.address2,\n supplemental_address_2: self.address3,\n city: self.city\n\n )\n # Add county, state, country, and zipcode stuff now\n self.set_location(a)\n end",
"def extract_addresses(address_list)\n addresses = []\n address_list.each do |address|\n addresses << address[:address] if ['ipv4', 'hostname'].include?(address[:type])\n end\n addresses\nend",
"def order_ship_address_lines\n order.ship_address.try(:full_address_array)\n end",
"def buildAddress(addrRaw)\n # Check if first address row contains P O Box substring\n isPoB = addrRaw['s'].include? \"P O Box\"\n location = Array.new\n\n fullLoc = (addrRaw['s'] == \"-\" || isPoB) ? \"\" : \"#{addrRaw['s']}, \"\n partialLoc = (addrRaw['s2'] == \"-\") ? \"\" : \"#{addrRaw['s2']},\" \n partialLoc += (addrRaw['l'] == \"-\") ? \"\" : \"#{addrRaw['l']}, \" \n partialLoc += (addrRaw['r'] == \"-\") ? \"\" : \"#{addrRaw['r']}, \" \n partialLoc += (addrRaw['z'] == \"-\") ? \"\" : \"#{addrRaw['z']}, \" \n partialLoc += (addrRaw['c'] == \"-\") ? \"\" : \"#{addrRaw['c']}\"\n\n fullLoc += partialLoc\n\n # If address does not contain an 'AU', it is added to the end of the address\n if fullLoc != \"\"\n if fullLoc.exclude? \"AU\"\n # Set fullLoc as well as partialLoc in case all address was contained in the first line\n fullLoc += \", AU\"\n partialLoc += \", AU\"\n end\n end\n \n location[0] = fullLoc\n location[1] = partialLoc\n \n return location\n end",
"def full_street_address\n postcode_only_address\n end",
"def address\n get_value :address\n end",
"def full(address)\n \"#{address[:type]} #{address[:description]}, #{address[:neighborhood]}, #{address[:city]}-#{address[:state]}, Brasil.\"\n end",
"def get_address\n @address\n end",
"def full_address\n part_1 = address\n part_2 = [zip_code, city].reject(&:blank?).join(' ')\n part_3 = \"France\"\n [part_1, part_2, part_3].reject(&:blank?).join(', ')\n end",
"def address_for_geocode\n add = []\n add << self.address_1\n add << self.address_2 if self.address_2.present?\n add << self.address_3 if self.address_3.present?\n add << self.city if self.city.present?\n add << self.region if self.region.present?\n add << self.postcode if self.postcode.present?\n add << (self.country.present? ? self.country : 'United Kingdom')\n add.join(', ')\n end",
"def address_present\n if address.blank?\n errors.add(:address, \"Can't be empty\")\n end\n end",
"def add_address # rubocop:disable Metrics/AbcSize\n return unless @bib.place.any?\n\n reg = @bib.place[0].region[0].name if @bib.place[0].region.any?\n addr = [@bib.place[0].name, @bib.place[0].city, reg]\n @item.address = addr.compact.join(\", \")\n end",
"def address_check(obj)\n if obj.address.vague_address == nil\n \"No address provided.\"\n else\n obj.address.vague_address\n end\n end",
"def build_address(address)\n {\n route: address.address1,\n neighborhood: address.address2,\n locality: address.address3,\n postalCode: address.postal_code,\n subLocality: address.city,\n state: address.city,\n country: address.country.name\n }.\n # INFO: equivalent of .compact\n select { |_, value| !value.nil? }\n end",
"def display_address(type)\n [self.send(\"#{type}_city\"), self.send(\"#{type}_state\")].compact.uniq.join(\", \")\n #address_list << send.(\"#{type}_city\") unless send.(\"#{type}_city\").blank?\n #address_list << send.(\"#{type}_state\") unless send.(\"#{type}_state\").blank?\n #address_list << send.(\"#{type}_country\") unless send.(\"#{type}_country\").blank?\n #address_list.join(\", \")\n end",
"def red_address_data(kind, address)\n data = {\n 'Name' => f.cut(29) { address.firstname.to_s.squish },\n 'Surname' => f.cut(29) { address.lastname.to_s.squish },\n 'Email' => f.cut(44) { email.to_s.squish },\n 'Address' => f.cut(29) { address.address1.to_s.squish },\n 'Address2' => f.cut(29) { address.address2.to_s.squish },\n 'City' => f.cut(19) { address.city.to_s.squish },\n # 'StateCode' => address.state_name.to_s.squish.cut(30),\n 'Country' => address.country.correct_iso3,\n 'PostalCode' => f.cut(8) { address.zipcode.to_s.squish },\n 'HomePhone' => f.cut(18) { f.digits { address.phone } },\n # 'MobilePhone' => nil,\n # 'FaxPhone' => nil,\n # 'TimeToDeparture => nil\n }\n\n data.map { |k, v| { [kind, k].join('_') => v } }.reduce(&:merge)\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 edgarj_address?(col)\n @record.class.edgarj_address?(col)\n end",
"def address_params\n end",
"def address\n [address1, city, state, country, zip].compact.join(', ')\n end",
"def address\n return \"\" unless [city, state, state_code].all?(&:present?)\n \"#{city}, #{state}(#{state_code})\"\n end",
"def street_address\n [\n house_number, \n street_predirection, \n street_name, \n street_type, \n street_postdirection, \n unit_type, \n unit_number\n ].compact.delete_if(&:empty?).join(' ')\n end",
"def secondary_address; end",
"def full_address\n\t\t[address1, address2, city, state, zipcode].join(', ')\n\tend",
"def full_street_address #Take all location fields, remove nil elements with .compact, then return a string for Geocoder\n [address_1, address_2, city, country, z_post_code].compact.join(', ')\n end",
"def record()\n street = @street_name_source.record() \n house_number = @house_number_source.record()\n postal_code_and_town = @postal_town_source.record()\n # Very fragile / relies on proper input data file:\n postal_code, town = postal_code_and_town.match(/(\\w+)\\s+(.+)/)[1,2]\n Address.new( house_number, street, postal_code, town )\n end",
"def address\n @address\n end",
"def address\n [address1, address2, city, state, zip].compact.join(', ')\n end",
"def handle_address_id(id)\n case id\n when AuthorizeNet::Address\n set_fields(:customer_address_id => id.customer_address_id.to_s)\n when nil\n nil\n else\n set_fields(:customer_address_id => id.to_s)\n end\n end",
"def address\n \"%s %s %s %s\"%([self.prefecture_code,self.address_city,self.address_street,self.address_building])\n end",
"def build_params_for_address()\n\n end",
"def address\n [address1, address2, city, state, zip].compact.join(', ')\n end",
"def full_address\n [address, town, state, zipcode].compact.join(', ')\n end",
"def address(format = :full)\n fail\n end",
"def nil_address\n self.address_line1 = nil\n self.address_line2 = nil\n self.locality = nil\n self.county = nil\n self.country = nil\n self.postcode = nil\n end",
"def addresses; end",
"def main_address\n addresses.first\n end",
"def get_full_address\n [\n (address.empty? ? nil : address),\n (self.le_city.nil? ? nil : self.le_city.get_full_name)\n ].compact.join(\", \")\n end",
"def get_full_address\n [\n (address.empty? ? nil : address),\n (self.le_city.nil? ? nil : self.le_city.get_full_name)\n ].compact.join(\", \")\n end",
"def address?\n if self.address\n return false\n else\n return true\n end\n end",
"def address() @address; end",
"def address_component_for(type)\n return nil if response.nil? || response['results'].empty?\n\n response['results'].first['address_components'].find do |c|\n c['types'].include?(type)\n end\n end",
"def full_address\n city.present? ? city_delim = city + \",\" : city_delim = city\n [address_1, address_2, city_delim, state, zip].reject(&:nil? || empty?).join(' ')\n end",
"def full_address\n \"#{address1}, #{address2}, #{city}, #{state}, #{zipcode}\"\nend",
"def full_address\n [ address, city, state, zipcode, country ].compact.join(', ')\n end",
"def full_address\n [address, city, state, zipcode, country].compact.join(\", \")\n end",
"def address_list_assign(field_name, addresses)\n if addresses.kind_of?(Array)\n value = addresses.collect { |e|\n if e.kind_of?(RMail::Address)\n e.format\n else\n RMail::Address.parse(e.to_str).collect { |a|\n a.format\n }\n end\n }.flatten.join(\", \")\n set(field_name, value)\n elsif addresses.kind_of?(RMail::Address)\n set(field_name, addresses.format)\n else\n address_list_assign(field_name,\n RMail::Address.parse(addresses.to_str))\n end\n end",
"def address\n load_step # Need to load the account to make the decision\n if AccountType.other_organisation?(@account.account_type)\n # Uses overrides as the address is at address.company not at company\n wizard_address_step(STEPS, address_attribute: :org_address,\n next_step: :address_next_step)\n elsif AccountType.registered_organisation?(@account.account_type)\n wizard_address_step(STEPS, address_not_required: :reg_company_contact_address_yes_no,\n next_step: :address_next_step)\n else # must be individual\n wizard_address_step(STEPS, next_step: :address_next_step)\n end\n end",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def data_from_zonefile_record type, zf_record\n case type.to_s.upcase\n when \"A\"\n String zf_record[:host]\n when \"AAAA\"\n String zf_record[:host]\n when \"CNAME\"\n String zf_record[:host]\n when \"MX\"\n \"#{zf_record[:pri]} #{zf_record[:host]}\"\n when \"NAPTR\"\n \"#{zf_record[:order]} #{zf_record[:preference]} \" \\\n \"#{zf_record[:flags]} #{zf_record[:service]} \" \\\n \"#{zf_record[:regexp]} #{zf_record[:replacement]}\"\n when \"NS\"\n String zf_record[:host]\n when \"PTR\"\n String zf_record[:host]\n when \"SOA\"\n \"#{zf_record[:primary]} #{zf_record[:email]} \" \\\n \"#{zf_record[:serial]} #{zf_record[:refresh]} \" \\\n \"#{zf_record[:retry]} #{zf_record[:expire]} \" \\\n \"#{zf_record[:minimumTTL]}\"\n when \"SPF\"\n String zf_record[:data]\n when \"SRV\"\n \"#{zf_record[:pri]} #{zf_record[:weight]} \" \\\n \"#{zf_record[:port]} #{zf_record[:host]}\"\n when \"TXT\"\n String zf_record[:text]\n else\n raise ArgumentError, \"record type '#{type}' is not supported\"\n end\n end",
"def payment_address!\n return unless currency.coin?\n record = payment_address\n\n # The address generation process is in progress.\n if record.address.blank?\n record\n else\n # allows user to have multiple addresses.\n payment_addresses.create!(currency: currency)\n end\n end",
"def full_address\n \"#{address}, #{city}, #{state}, #{zip}\"\n end",
"def build_address(address)\n {\n receiver: address.full_name,\n email: order.email,\n phoneNumber: address.phone,\n route: address.address1,\n street_number: address.address1.scan(/\\d+/).first,\n internalNumber: address.address2.scan(/\\d+/).first,\n neighborhood: address.address2,\n locality: address.address3,\n postal_code: address.zipcode,\n subLocality: address.city,\n state: address.state.name,\n country: address.country.name,\n }\n end",
"def add_address(type, street_1, street_2, city, state, zipcode)\n #Initialize a new instance of the Address class (why)\n address = Address.new\n #then set all of the ATTRIBUTES to the ARGUEMENTS of this METHOD\n address.type = type\n address.street_1 = street_1\n address.street_2 = street_2\n address.city = city\n address.state = state\n address.zipcode =zipcode\n #then append this to the internal array of addresses-since addresses is a attr_reader we do not have to use the @ sign\n addresses.push(address)\n end",
"def get_verbose_address\n [\n (address.empty? ? nil : address),\n (self.le_city.nil? ? nil : self.le_city.get_verbose_name)\n ].compact.join(\", \")\n end",
"def get_verbose_address\n [\n (address.empty? ? nil : address),\n (self.le_city.nil? ? nil : self.le_city.get_verbose_name)\n ].compact.join(\", \")\n end",
"def discard_blank_addresses\n return unless self.state == 'address' || self.state == 'cart'\n\n if bill_address && bill_address.invalid? && bill_address.blank?\n self.bill_address = nil\n end\n if ship_address && ship_address.invalid? && ship_address.blank?\n self.ship_address = nil\n end\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 full_address\r\n [street, city, state, zip_code].delete_if{ |content| content.blank? }.join(\", \")\r\n end",
"def address\n @address\n end",
"def address_detail\n \"#{province.try :name}#{city.try :name}#{district.try :name}#{address}\"\n end",
"def _address_fields \n if(@addr_fields) \n return @addr_fields\n end\n \n _format_map( __dir__ + \"/manual_info/p_addr.fmt\" )\n end",
"def address_components_of_type(type)\n address_components.select{ |k, v| k == type.to_s }\n end",
"def address=(value)\n @address = value\n end",
"def address=(value)\n @address = value\n end",
"def address_street\n address.street\n end",
"def address_one_line\n \"%s, %s, %s %s\" % [self.address_line_1, self.city, self.state_abbr, self.zipcode]\n end",
"def address_prop\n # See https://schema.org/PostalAddress for details and examples\n # {\n # \"streetAddress\": \"1600 Pennsylvania Avenue\",\n # \"addressLocality\": \"Washington\",\n # \"addressRegion\": \"District of Columbia\",\n # \"postalCode\": \"20500\",\n # \"addressCountry\": \"US\"\n # }\n end",
"def full_address\n [address, city].compact.join(', ')\n end",
"def try_to_fix address\n parts = address.split(\",\")\n if parts.shift\n parts.join(',')\n else\n address\n end\n end",
"def address\n [street, city, state, country].compact.join(', ')\n end",
"def ip_address_record(env)\n data_type = env[:machine].provider_config.private_only ? \"primaryBackendNetworkComponent\" : \"primaryNetworkComponent\"\n data_type = \"primaryBackendNetworkComponent\" if env[:machine].provider_config.force_private_ip\n mask = \"#{data_type}.primaryIpAddressRecord.id,#{data_type}.primaryIpAddressRecord.ipAddress\"\n record = sl_warden { env[:sl_machine].object_mask(\"mask[#{mask}]\").getObject }\n return {\n :address => record[data_type][\"primaryIpAddressRecord\"][\"ipAddress\"],\n :id => record[data_type][\"primaryIpAddressRecord\"][\"id\"]\n }\n end"
] | [
"0.65583926",
"0.65539306",
"0.647403",
"0.63811654",
"0.6258254",
"0.62276167",
"0.6187602",
"0.6187602",
"0.6161641",
"0.6125532",
"0.6121623",
"0.60956407",
"0.6089826",
"0.60646635",
"0.6062472",
"0.6053029",
"0.6043283",
"0.60272133",
"0.60201013",
"0.601169",
"0.5916684",
"0.59017044",
"0.5889874",
"0.58731127",
"0.58708197",
"0.5859698",
"0.58337986",
"0.5827543",
"0.5816382",
"0.58105904",
"0.5789861",
"0.5787534",
"0.57772225",
"0.57575417",
"0.5756284",
"0.57504946",
"0.57499456",
"0.57448775",
"0.5735116",
"0.57310456",
"0.57245356",
"0.57224995",
"0.5704335",
"0.5704102",
"0.5702094",
"0.5696726",
"0.5692024",
"0.56809855",
"0.5677365",
"0.567636",
"0.56643474",
"0.56641686",
"0.565513",
"0.56491554",
"0.5647961",
"0.563844",
"0.5636303",
"0.5632825",
"0.56297153",
"0.5622209",
"0.56208575",
"0.5620282",
"0.5613996",
"0.5613606",
"0.56123644",
"0.56107557",
"0.56100136",
"0.5604865",
"0.5595641",
"0.5590543",
"0.5584026",
"0.5583637",
"0.55823123",
"0.5578117",
"0.55756694",
"0.55717236",
"0.5562811",
"0.5562811",
"0.5555701",
"0.5554766",
"0.55502194",
"0.55457354",
"0.55440265",
"0.5542957",
"0.5542957",
"0.55402094",
"0.55396676",
"0.55378705",
"0.552968",
"0.5527166",
"0.55267817",
"0.5526529",
"0.55261236",
"0.55261236",
"0.55185175",
"0.55157775",
"0.551574",
"0.55140626",
"0.551264",
"0.55097663",
"0.55044854"
] | 0.0 | -1 |
FIXME: Requires UTF8 Encoding (see 11) | def parse_moreinfo
if @input.match?(/Tov.* ld\.:\n/)
p("whois.nic.hu: parse_moreinfo") if 1 == 2 || $DEBUG
@ast["moreinfo"] = @input.scan_until(/^\n/)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodings; 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 encoding_line; end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def encoding_found; end",
"def encoding_found; end",
"def decode; end",
"def decode; end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def charset; end",
"def charset; end",
"def charset; end",
"def encode_string_ex; end",
"def encoding(encoding); end",
"def found_encoding; end",
"def found_encoding; 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 isutf8;\tKconv.isutf8(self) end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def encoding()\n #This is a stub, used for indexing\n end",
"def convert_encoding(content); end",
"def iconv() end",
"def force_utf32; end",
"def force_utf32; end",
"def force_utf32; end",
"def test_encoded_in_change_out\n doc = Document.new( @encoded )\n doc.xml_decl.encoding = \"UTF-8\"\n assert_equal(\"UTF-8\", doc.encoding)\n REXML::Formatters::Default.new.write( doc.root, out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n char = XPath.first( doc, \"/a/b/text()\" ).to_s\n char.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"ĉ\".b, char )\n end",
"def unicode_names; end",
"def encoding_line=(_arg0); end",
"def encode_string; end",
"def utf8read(x)\n File.open(x,\"rb\"){|f|\n if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf\n f.pos=0 # skip UTF-8 byte order mark\n end\n data=f.read\n ec1=Encoding::Converter.new(\"utf-8\",\"utf-16\",{\n :undef=>:replace,\n :invalid=>:replace\n })\n ec2=Encoding::Converter.new(\"utf-16\",\"utf-8\",{\n :undef=>:replace,\n :invalid=>:replace,\n :replace=>\"\\uFFFD\"\n })\n data=ec1.convert(data)\n data=ec2.convert(data)\n return data\n }\nend",
"def find_encoding(encoding); end",
"def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end",
"def ignore_encoding_error; end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def get\n self.data.force_encoding(Encoding::UTF_16BE).encode(Encoding::UTF_8)\n end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def charset\n 'UTF8'\n end",
"def toutf8; Kconv.toutf8(self) end",
"def writeencoding; end",
"def contents_convert_utf8\n @publication.title = @publication.title ? @publication.title.force_encoding('UTF-8') : \"\"\n @publication.abstract = @publication.abstract ? @publication.abstract.force_encoding('UTF-8') : \"\"\n @publication.contents = @publication.contents ? @publication.contents.force_encoding('UTF-8') : \"\"\n end",
"def charset=(_); end",
"def encoding\n\t'ISO-8859-1'\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def he_decode(text); self.class.he_decode text; end",
"def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend",
"def default_encoding\n Encoding::UTF_8\n end",
"def encode!; end",
"def test_sdbm\n key = 'あいうえおかきくけこ'\n val = 'たちつてとなにぬねの'\n @tag.tag_db[key] = val\n assert_equal val, @tag.tag_db[key].force_encoding(Encoding::UTF_8)\n end",
"def force_entry_names_encoding; end",
"def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end",
"def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end",
"def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end",
"def decode(text); end",
"def to_utf8!; replace(to_utf8); end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def default_encoding; end",
"def default_encoding; end",
"def charset=(_arg0); end",
"def encoder; end",
"def encoder; end",
"def meta_encoding=(encoding); end",
"def meta_encoding=(encoding); end",
"def read_string; end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def test_in_different_access\n doc = Document.new <<-EOL\n <?xml version='1.0' encoding='ISO-8859-1'?>\n <a a=\"\\xFF\">\\xFF</a>\n EOL\n expect = \"\\303\\277\"\n expect.force_encoding(::Encoding::UTF_8)\n assert_equal( expect, doc.elements['a'].attributes['a'] )\n assert_equal( expect, doc.elements['a'].text )\n end",
"def encoding=(enc); end",
"def prepare_data data\n Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(data)\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def test_encoded_in_different_out\n doc = Document.new( @encoded )\n REXML::Formatters::Default.new.write( doc.root, Output.new( out=\"\", \"UTF-8\" ) )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n end",
"def decode_string(str)\n\nend",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end",
"def binary_string; end",
"def chars; self[:data].to_a ; end"
] | [
"0.70922756",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.6784962",
"0.6755033",
"0.6662436",
"0.6662436",
"0.66331244",
"0.66331244",
"0.6631727",
"0.6631727",
"0.65608567",
"0.6549858",
"0.6549858",
"0.6549858",
"0.6511965",
"0.64771503",
"0.6476976",
"0.6476976",
"0.64286816",
"0.64286816",
"0.6427182",
"0.6427182",
"0.6427182",
"0.6427182",
"0.6427182",
"0.6360227",
"0.63163596",
"0.6309128",
"0.6228218",
"0.6199559",
"0.6182109",
"0.6182109",
"0.6182109",
"0.6159193",
"0.6150002",
"0.6140324",
"0.6069896",
"0.60533047",
"0.60517794",
"0.6028567",
"0.6020668",
"0.6016366",
"0.6016366",
"0.6002824",
"0.59928584",
"0.59924567",
"0.5970364",
"0.59702647",
"0.5962699",
"0.59614486",
"0.5945646",
"0.591113",
"0.58971065",
"0.5883222",
"0.5882506",
"0.5865655",
"0.5861802",
"0.58269507",
"0.5811711",
"0.57950616",
"0.578608",
"0.57840574",
"0.5777011",
"0.5770867",
"0.5769422",
"0.5766703",
"0.5761561",
"0.5761561",
"0.57598186",
"0.57524383",
"0.57524383",
"0.57450634",
"0.57450634",
"0.57173544",
"0.5691939",
"0.5689199",
"0.5679051",
"0.56690645",
"0.5660523",
"0.5658033",
"0.5654214",
"0.5649448",
"0.5645461",
"0.5645461",
"0.5645461",
"0.56396824",
"0.5612611"
] | 0.0 | -1 |
FIXME: Requires UTF8 Encoding (see 11) | def parse_not_found
if @input.match?(/Nincs (.*?) \/ No match\n/)
p("whois.nic.hu: parse_not_found") if 1 == 2 || $DEBUG
@input.scan(/Nincs (.*?) \/ No match\n/)
return @ast['NotFound'] = true
end
@ast['NotFound'] = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodings; 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 encoding_line; end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def decode; end",
"def decode; end",
"def encoding_found; end",
"def encoding_found; end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def charset; end",
"def charset; end",
"def charset; end",
"def encode_string_ex; end",
"def encoding(encoding); end",
"def found_encoding; end",
"def found_encoding; 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 isutf8;\tKconv.isutf8(self) end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def encoding()\n #This is a stub, used for indexing\n end",
"def convert_encoding(content); end",
"def iconv() end",
"def force_utf32; end",
"def force_utf32; end",
"def force_utf32; end",
"def test_encoded_in_change_out\n doc = Document.new( @encoded )\n doc.xml_decl.encoding = \"UTF-8\"\n assert_equal(\"UTF-8\", doc.encoding)\n REXML::Formatters::Default.new.write( doc.root, out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n char = XPath.first( doc, \"/a/b/text()\" ).to_s\n char.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"ĉ\".b, char )\n end",
"def unicode_names; end",
"def encoding_line=(_arg0); end",
"def encode_string; end",
"def utf8read(x)\n File.open(x,\"rb\"){|f|\n if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf\n f.pos=0 # skip UTF-8 byte order mark\n end\n data=f.read\n ec1=Encoding::Converter.new(\"utf-8\",\"utf-16\",{\n :undef=>:replace,\n :invalid=>:replace\n })\n ec2=Encoding::Converter.new(\"utf-16\",\"utf-8\",{\n :undef=>:replace,\n :invalid=>:replace,\n :replace=>\"\\uFFFD\"\n })\n data=ec1.convert(data)\n data=ec2.convert(data)\n return data\n }\nend",
"def find_encoding(encoding); end",
"def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end",
"def ignore_encoding_error; end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def get\n self.data.force_encoding(Encoding::UTF_16BE).encode(Encoding::UTF_8)\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def charset\n 'UTF8'\n end",
"def toutf8; Kconv.toutf8(self) end",
"def writeencoding; end",
"def contents_convert_utf8\n @publication.title = @publication.title ? @publication.title.force_encoding('UTF-8') : \"\"\n @publication.abstract = @publication.abstract ? @publication.abstract.force_encoding('UTF-8') : \"\"\n @publication.contents = @publication.contents ? @publication.contents.force_encoding('UTF-8') : \"\"\n end",
"def charset=(_); end",
"def encoding\n\t'ISO-8859-1'\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def he_decode(text); self.class.he_decode text; end",
"def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend",
"def default_encoding\n Encoding::UTF_8\n end",
"def encode!; end",
"def test_sdbm\n key = 'あいうえおかきくけこ'\n val = 'たちつてとなにぬねの'\n @tag.tag_db[key] = val\n assert_equal val, @tag.tag_db[key].force_encoding(Encoding::UTF_8)\n end",
"def force_entry_names_encoding; end",
"def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end",
"def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end",
"def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end",
"def decode(text); end",
"def to_utf8!; replace(to_utf8); end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def default_encoding; end",
"def default_encoding; end",
"def charset=(_arg0); end",
"def encoder; end",
"def encoder; end",
"def meta_encoding=(encoding); end",
"def meta_encoding=(encoding); end",
"def read_string; end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def test_in_different_access\n doc = Document.new <<-EOL\n <?xml version='1.0' encoding='ISO-8859-1'?>\n <a a=\"\\xFF\">\\xFF</a>\n EOL\n expect = \"\\303\\277\"\n expect.force_encoding(::Encoding::UTF_8)\n assert_equal( expect, doc.elements['a'].attributes['a'] )\n assert_equal( expect, doc.elements['a'].text )\n end",
"def encoding=(enc); end",
"def prepare_data data\n Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(data)\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def test_encoded_in_different_out\n doc = Document.new( @encoded )\n REXML::Formatters::Default.new.write( doc.root, Output.new( out=\"\", \"UTF-8\" ) )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n end",
"def decode_string(str)\n\nend",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end",
"def binary_string; end",
"def chars; self[:data].to_a ; end"
] | [
"0.7091389",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.6783546",
"0.6753659",
"0.66605264",
"0.66605264",
"0.66308355",
"0.66308355",
"0.66303533",
"0.66303533",
"0.655941",
"0.6548453",
"0.6548453",
"0.6548453",
"0.65111",
"0.6475819",
"0.6474921",
"0.6474921",
"0.6427884",
"0.6427884",
"0.642638",
"0.642638",
"0.642638",
"0.642638",
"0.642638",
"0.6358",
"0.63148266",
"0.63095343",
"0.6228149",
"0.61993945",
"0.61805",
"0.61805",
"0.61805",
"0.6158228",
"0.61484945",
"0.613974",
"0.60698986",
"0.6050292",
"0.6050102",
"0.60277826",
"0.6017625",
"0.60150427",
"0.60150427",
"0.6001047",
"0.5994008",
"0.599105",
"0.5968866",
"0.5968481",
"0.59633356",
"0.5961519",
"0.59453285",
"0.59102726",
"0.5895447",
"0.5883021",
"0.58820516",
"0.5864184",
"0.5859574",
"0.5826559",
"0.5811879",
"0.5795282",
"0.57853913",
"0.5781304",
"0.5774219",
"0.57708585",
"0.5769099",
"0.5766308",
"0.5759782",
"0.5759782",
"0.57593614",
"0.5752301",
"0.5752301",
"0.574407",
"0.574407",
"0.57159215",
"0.56916016",
"0.5687095",
"0.56788695",
"0.5669436",
"0.5660262",
"0.5655614",
"0.5653383",
"0.564846",
"0.5644614",
"0.5644614",
"0.5644614",
"0.56389266",
"0.56135124"
] | 0.0 | -1 |
FIXME: Requires UTF8 Encoding (see 11) | def parse_in_progress
if @input.match?(/(.*?) folyamatban \/ Registration in progress\n/)
p("whois.nic.hu: parse_in_progress") if 1 == 2 || $DEBUG
@input.scan(/(.*?) folyamatban \/ Registration in progress\n/)
return @ast['InProgress'] = true
end
@ast['InProgress'] = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodings; 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 encoding_line; end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def decode; end",
"def decode; end",
"def encoding_found; end",
"def encoding_found; end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def charset; end",
"def charset; end",
"def charset; end",
"def encode_string_ex; end",
"def encoding(encoding); end",
"def found_encoding; end",
"def found_encoding; 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 isutf8;\tKconv.isutf8(self) end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def encoding()\n #This is a stub, used for indexing\n end",
"def convert_encoding(content); end",
"def iconv() end",
"def force_utf32; end",
"def force_utf32; end",
"def force_utf32; end",
"def test_encoded_in_change_out\n doc = Document.new( @encoded )\n doc.xml_decl.encoding = \"UTF-8\"\n assert_equal(\"UTF-8\", doc.encoding)\n REXML::Formatters::Default.new.write( doc.root, out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n char = XPath.first( doc, \"/a/b/text()\" ).to_s\n char.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"ĉ\".b, char )\n end",
"def unicode_names; end",
"def encoding_line=(_arg0); end",
"def encode_string; end",
"def utf8read(x)\n File.open(x,\"rb\"){|f|\n if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf\n f.pos=0 # skip UTF-8 byte order mark\n end\n data=f.read\n ec1=Encoding::Converter.new(\"utf-8\",\"utf-16\",{\n :undef=>:replace,\n :invalid=>:replace\n })\n ec2=Encoding::Converter.new(\"utf-16\",\"utf-8\",{\n :undef=>:replace,\n :invalid=>:replace,\n :replace=>\"\\uFFFD\"\n })\n data=ec1.convert(data)\n data=ec2.convert(data)\n return data\n }\nend",
"def find_encoding(encoding); end",
"def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end",
"def ignore_encoding_error; end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def get\n self.data.force_encoding(Encoding::UTF_16BE).encode(Encoding::UTF_8)\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def charset\n 'UTF8'\n end",
"def toutf8; Kconv.toutf8(self) end",
"def writeencoding; end",
"def contents_convert_utf8\n @publication.title = @publication.title ? @publication.title.force_encoding('UTF-8') : \"\"\n @publication.abstract = @publication.abstract ? @publication.abstract.force_encoding('UTF-8') : \"\"\n @publication.contents = @publication.contents ? @publication.contents.force_encoding('UTF-8') : \"\"\n end",
"def charset=(_); end",
"def encoding\n\t'ISO-8859-1'\nend",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def he_decode(text); self.class.he_decode text; end",
"def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend",
"def default_encoding\n Encoding::UTF_8\n end",
"def encode!; end",
"def test_sdbm\n key = 'あいうえおかきくけこ'\n val = 'たちつてとなにぬねの'\n @tag.tag_db[key] = val\n assert_equal val, @tag.tag_db[key].force_encoding(Encoding::UTF_8)\n end",
"def force_entry_names_encoding; end",
"def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end",
"def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end",
"def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end",
"def decode(text); end",
"def to_utf8!; replace(to_utf8); end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def default_encoding; end",
"def default_encoding; end",
"def charset=(_arg0); end",
"def encoder; end",
"def encoder; end",
"def meta_encoding=(encoding); end",
"def meta_encoding=(encoding); end",
"def read_string; end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def test_in_different_access\n doc = Document.new <<-EOL\n <?xml version='1.0' encoding='ISO-8859-1'?>\n <a a=\"\\xFF\">\\xFF</a>\n EOL\n expect = \"\\303\\277\"\n expect.force_encoding(::Encoding::UTF_8)\n assert_equal( expect, doc.elements['a'].attributes['a'] )\n assert_equal( expect, doc.elements['a'].text )\n end",
"def encoding=(enc); end",
"def prepare_data data\n Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(data)\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def test_encoded_in_different_out\n doc = Document.new( @encoded )\n REXML::Formatters::Default.new.write( doc.root, Output.new( out=\"\", \"UTF-8\" ) )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n end",
"def decode_string(str)\n\nend",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end",
"def force_utf32=(_arg0); end",
"def binary_string; end",
"def chars; self[:data].to_a ; end"
] | [
"0.7091389",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.6783546",
"0.6753659",
"0.66605264",
"0.66605264",
"0.66308355",
"0.66308355",
"0.66303533",
"0.66303533",
"0.655941",
"0.6548453",
"0.6548453",
"0.6548453",
"0.65111",
"0.6475819",
"0.6474921",
"0.6474921",
"0.6427884",
"0.6427884",
"0.642638",
"0.642638",
"0.642638",
"0.642638",
"0.642638",
"0.6358",
"0.63148266",
"0.63095343",
"0.6228149",
"0.61993945",
"0.61805",
"0.61805",
"0.61805",
"0.6158228",
"0.61484945",
"0.613974",
"0.60698986",
"0.6050292",
"0.6050102",
"0.60277826",
"0.6017625",
"0.60150427",
"0.60150427",
"0.6001047",
"0.5994008",
"0.599105",
"0.5968866",
"0.5968481",
"0.59633356",
"0.5961519",
"0.59453285",
"0.59102726",
"0.5895447",
"0.5883021",
"0.58820516",
"0.5864184",
"0.5859574",
"0.5826559",
"0.5811879",
"0.5795282",
"0.57853913",
"0.5781304",
"0.5774219",
"0.57708585",
"0.5769099",
"0.5766308",
"0.5759782",
"0.5759782",
"0.57593614",
"0.5752301",
"0.5752301",
"0.574407",
"0.574407",
"0.57159215",
"0.56916016",
"0.5687095",
"0.56788695",
"0.5669436",
"0.5660262",
"0.5655614",
"0.5653383",
"0.564846",
"0.5644614",
"0.5644614",
"0.5644614",
"0.56389266",
"0.56135124"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(session[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:username, :email, :myprofileurl)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def 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 filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\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 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 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 permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586",
"0.629103",
"0.6282451",
"0.6243152",
"0.62413",
"0.6219024",
"0.6213724",
"0.62103724",
"0.61945",
"0.61786324",
"0.61755824",
"0.6173267",
"0.6163613",
"0.6153058",
"0.61521065",
"0.6147508",
"0.61234015",
"0.61168665",
"0.6107466",
"0.6106177",
"0.6091159",
"0.60817343",
"0.6071238",
"0.6062299",
"0.6021663",
"0.60182893",
"0.6014239",
"0.6011563",
"0.60080767",
"0.60080767",
"0.60028875",
"0.60005623",
"0.59964156",
"0.5993086",
"0.5992319",
"0.5992299",
"0.59801805",
"0.59676576",
"0.59606016",
"0.595966",
"0.59591126",
"0.59589803",
"0.5954058",
"0.5953234",
"0.5944434",
"0.5940526",
"0.59376484",
"0.59376484",
"0.5935253",
"0.5930846",
"0.5926387",
"0.59256274",
"0.5917907",
"0.5910841",
"0.590886",
"0.59086543",
"0.59060425",
"0.58981544",
"0.5898102",
"0.5896809",
"0.5895416",
"0.58947027",
"0.58923644",
"0.5887903",
"0.58830196",
"0.5880581",
"0.5873854",
"0.58697754",
"0.5869004",
"0.58669055",
"0.5866886",
"0.58664906",
"0.5864619",
"0.58630043",
"0.5862495",
"0.5861368",
"0.5859712",
"0.5855544",
"0.58551925",
"0.5851284",
"0.5850602"
] | 0.0 | -1 |
before_action :set_child, only: [:show, :edit, :update, :destroy] | def update_attributes(hash)
hash.keys.each do |key|
m = "#{key}="
Child.send(m, hash[key]) if Child.respond_to?(m)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_parent_child\n\t \t@parent_child = ParentChild.find(params[:id])\n\tend",
"def show\n @child = Child.find(params[:id])\n #used to determine layout used\n @child_crud = true\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @child }\n end\n end",
"def set_child_record\n @child_record = ChildRecord.find(params[:id])\n end",
"def new_child\n nil\n end",
"def add_child\n category_id = params[:id].gsub('category_', '')\n @category = Category.find(category_id)\n parent_id = params[:parent_id]\n if parent_id\n @parent = Category.find(parent_id)\n @category.parent = @parent \n else\n @category.parent = nil\n end\n @category.save!\n render :update do |page|\n page.remove(\"category_#{@category.id}_row\")\n if @parent\n if @parent.name == ASSOCIATION.short_name\n page.replace_html(\"category_root\", :partial => \"category\", :collection => @parent.children.sort)\n else\n page.call(:expandDisclosure, parent_id)\n end\n end\n if @parent.nil?\n page.replace_html(\"unknown_category_root\", :partial => \"category\", :collection => Category.find_all_unknowns.sort)\n end\n end\n end",
"def set_child_actor\n @child_actor = ChildActor.find(params[:id])\n end",
"def children\n child_check\n super\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to :back, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to children_path, notice: \"Child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @child = Child.new\n @child_crud = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.html {render}\n format.json { render json: @child }\n end\n end",
"def index\n @child = Child.all\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def child_params\n params.require(:child).permit(:id, :age, :name)\n end",
"def update\n @child = Child.find(params[:id])\n\n respond_to do |format|\n if @child.update_attributes(params[:child])\n format.html { redirect_to children_url, notice: 'Child was successfully updated.' }\n format.js { @current_child = @child}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: \"Child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_traumatized_child\n @traumatized_child = TraumatizedChild.find(params[:id])\n end",
"def create\n @child = Child.new(params[:child])\n @child_crud = true\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_url, notice: 'Child was successfully created.' }\n format.js { @current_child = @child}\n format.json { render json: @child, status: :created, location: @child }\n else\n format.html { render :layout => false, action: \"new\"}\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_parent\n @parent = Mutant.find params[:mutant_id] if params[:mutant_id]\n @parent = Term.find params[:term_id] if params[:term_id]\n set_enrollment if params[:action].in? ['show', 'destroy']\n end",
"def create\n @child = Child.new(child_params)\n \n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render action: 'show', status: :created, location: @child }\n else\n format.html { render action: 'new' }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t \t\tif @parent_child.update(parent_child_params)\n\t\t\t\tformat.html { redirect_to @parent_child, notice: 'Parent child was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @parent_child }\n\t \t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @parent_child.errors, status: :unprocessable_entity }\n\t \t\tend\n\t\tend\n \tend",
"def index(child); end",
"def set_child_note\n @note = ChildNote.find(params[:id])\n end",
"def show\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @childmaster }\n end\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def show\n @parent_path = set_parent_path\n end",
"def add_child(child)\n child.parent = self\n end",
"def add_child\n @portfolio = @site.portfolios.build\n @parent_id = params[:id]\n render :action => 'new'\n end",
"def destroy\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n @child_resource.destroy\n\n respond_to do |format|\n format.html { redirect_to child_resources_url }\n format.json { head :no_content }\n end\n end",
"def add_child\n category_id = params[:id].gsub('category_', '')\n @category = Category.find(category_id)\n parent_id = params[:parent_id]\n if parent_id\n @parent = Category.find(parent_id)\n @category.parent = @parent \n else\n @category.parent = nil\n end\n begin\n @category.save!\n render :update do |page|\n page.redirect_to(:action => :index)\n end\n rescue Exception => error\n stack_trace = error.backtrace.join(\"\\n\")\n RACING_ON_RAILS_DEFAULT_LOGGER.error(\"#{error}\\n#{stack_trace}\")\n message = \"Could not insert category\"\n render :update do |page|\n page.replace_html(\"message_category_name_#{parent_id}\", render(:partial => '/admin/error', :locals => {:message => message, :error => error }))\n end\n end\n end",
"def update\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n\n respond_to do |format|\n if @child_resource.update_attributes(params[:child_resource])\n format.html { redirect_to @child_resource, notice: 'Child resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @child_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def children= (c)\n end",
"def set_parent_info\n @parent_info = ParentInfo.find(params[:id])\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_path, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def as_nested_actions; end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def child\n @folder = Folder.new\n @folder.parent = Folder.find(params[:id])\n @folder.user = @current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @folder }\n end\n end",
"def set_content\n @content = Content.find(params[:id])\n @parent = @content\n end",
"def show\n @child_resource = ChildResource.find(params[:id])\n # require view permissions on this object\n require_privilege(Alberich::Privilege::VIEW, @child_resource)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @child_resource }\n end\n end",
"def set_parent_category\n @parent_category = ParentCategory.find(params[:id])\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_initialize_child(child)\n # No Op by default\n end",
"def create\n @provider = Provider.find(params[:provider_id])\n @child = @provider.children.create(child_params)\n # @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to :back, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def before_action \n end",
"def new\n @page_name = \"New child record\"\n @child = Child.new\n @form_sections = get_form_sections_for_child @child\n respond_to do |format|\n format.html\n format.xml { render :xml => @child }\n end\n end",
"def child_params\n params.require(:child).permit(:name, :surname, :birthday, :lang, :hand, :school, :school_type, :school_lvl, :imagepath, :note, :archived, :version, :id_child, :id)\n end",
"def show\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parent }\n end\n end",
"def show\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parent }\n end\n end",
"def shallow_args(parent, child)\n child.try(:new_record?) ? [parent, child] : child\n # params[:action] == 'new' ? [parent, child] : child\n end",
"def set_parent_of\n @parent_of = ParentOf.find(params[:id])\n end",
"def edit\n #SET_CHEF method will be called form BEFORE_ACTION\n end",
"def update\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n if @childmaster.update_attributes(params[:childmaster])\n format.html { redirect_to(@childmaster, :notice => 'Childmaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @childmaster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @childmaster }\n end\n end",
"def setup_child\n log(:at => \"setup_child\")\n end",
"def paste_child\n @obj = Node.find(params[:id])\n node = Basket.basket.first_child\n\n if node\n @obj.insert_child(node)\n end\n\n render 'show'\n end",
"def set_child_development\n @child_development = ChildDevelopment.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @child_record.update(child_record_params)\n format.html { redirect_to @child_record, notice: 'Child record was successfully updated.' }\n format.json { render :show, status: :ok, location: @child_record }\n else\n format.html { render :edit }\n format.json { render json: @child_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n if @childmaster.update_attributes(params[:childmaster])\n format.html { redirect_to @childmaster, notice: 'Childmaster was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @childmaster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @thema.try(:new_parent_id)\n @thema.parent = Thema.find(@thema.new_parent_id)\n end\n\n respond_to do |format|\n if @thema.update(thema_params)\n format.html { redirect_to @thema, notice: 'Thema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def set_view ch\n @child = ch\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :no_content }\n end\n end",
"def update_menu\n parent = self._parent\n while parent.class != DcManual do \n parent = parent._parent \n end\n parent.do_before_save\n parent.save\nend",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :ok }\n end\n end",
"def show\n #These are nested resources that are only displayed in the context of their parent patient\n redirect_to(root_url)\n end",
"def _tree_navigate_through_child\n @ontology_class = OntologyClass.find_by_id(params[:id])\n \n @object_relationship = ObjectRelationship.find(params[:parent_relationship]) if !params[:parent_relationship].blank?\n @object_relationship == 'root' if !@object_relationship \n \n # close 1 1; open 0 1; open false (close); true (open) \n render :update do |page|\n page.replace \"level_#{@ontology_class.id}\", :partial => 'ontology/tree/tree_recurser', :locals => {\n :level => (params[:close] ? 1 : 0),\n :max_depth => 1,\n :parent_node => @ontology_class,\n :open => (params[:close] ? false : true),\n :relationship => @object_relationship,\n :relationship_type => params[:relationship_type] }\n end and return \n end",
"def create_or_update_then_render_child(parent, child_name)\n child_obj = parent.send(child_name)\n attribute_name_params_template = \"#{child_name}_params\"\n attribute_name_params = send(attribute_name_params_template)\n\n child_obj = build_has_one_child_if_nil parent, child_name\n child_obj.assign_attributes(attribute_name_params)\n\n render_wizard child_obj\n end"
] | [
"0.7531524",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.7189979",
"0.6919538",
"0.6531595",
"0.6493758",
"0.64724576",
"0.6402979",
"0.63683087",
"0.62908024",
"0.62908024",
"0.62908024",
"0.62908024",
"0.62908024",
"0.62908024",
"0.628363",
"0.628201",
"0.628201",
"0.6276857",
"0.6265042",
"0.62555516",
"0.62404054",
"0.6213031",
"0.6199778",
"0.61690474",
"0.61638445",
"0.6129139",
"0.609789",
"0.60958374",
"0.60947764",
"0.6082887",
"0.60795826",
"0.6061293",
"0.6014582",
"0.60013884",
"0.60013884",
"0.60013884",
"0.59955716",
"0.5995141",
"0.5978996",
"0.5974856",
"0.59705293",
"0.59586245",
"0.5955758",
"0.5948421",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5946373",
"0.5943621",
"0.59380555",
"0.59367746",
"0.59367746",
"0.5934007",
"0.59319884",
"0.59222084",
"0.5921592",
"0.5918283",
"0.5911195",
"0.5910014",
"0.58983165",
"0.5883136",
"0.58819485",
"0.5879549",
"0.5879549",
"0.58734024",
"0.5871132",
"0.5864877",
"0.5859697",
"0.5851171",
"0.5848048",
"0.58477193",
"0.584745",
"0.58459395",
"0.5834957",
"0.5833843",
"0.5833102",
"0.5821547",
"0.5816421",
"0.5815526",
"0.5811131",
"0.5809472",
"0.5803478",
"0.57971126"
] | 0.0 | -1 |
GET /children GET /children.json | def index
children = []
base_uri = 'https://postjson-d117c.firebaseio.com/'
@firebase = Firebase::Client.new(base_uri)
childrenjs = @firebase.get("Child")
parsed = JSON.parse(childrenjs.raw_body)
kids = parsed.deep_symbolize_keys
kids.uniq.each do |key, value|
value.each do |key2, value2|
children << value
end
end
@children = children.flatten.uniq
# render :json => @children
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def children\n @resource.children\n end",
"def get_children\n @children\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def get_children\n \t@children\n end",
"def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end",
"def children_get()\n @children\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def children\n return @children if [email protected]?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end",
"def children\n parent_id = params['parent_id']\n\n children = Child.includes(:bursts).where(parent_id: parent_id).map{ |child|\n last_burst = child.bursts.last\n burst_rate = last_burst.present? ? calc_burst_rate(last_burst) : 0\n\n {\n id: child.id,\n name: child.name,\n burst_rate: burst_rate\n }\n }\n\n render json: children\n end",
"def get_children\n return @children\n end",
"def _children\n @children\n end",
"def children\n _children\n end",
"def children\n attributes.fetch(:children)\n end",
"def get_children\n return children\n end",
"def children(*args)\n return call_ancestry_method(:children) if use_ancestry?\n\n Relationship.resources(child_rels(*args))\n end",
"def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end",
"def children\n @children ||= []\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end",
"def children\n @children ||= {}.with_indifferent_access\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def list_children id\n\t\traw_output = @fred.category( 'children', category_id: id.to_s )\n\n\t\traw_output.categories.category\n\tend",
"def children\n []\n end",
"def children\n []\n end",
"def show\n if(params.has_key?(:children))\n if(params[:children] == \"true\")\n @node = Node.find(params[:id]).children\n end\n else\n @node = Node.find(params[:id])\n end\n render json: @node\n end",
"def get_children()\n {}\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children(options={})\n @global_page.children.all options\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def get_paged_org_unit_children(org_unit_id, bookmark = '')\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/children/paged/\"\n path += \"?bookmark=#{bookmark}\" if bookmark != ''\n _get(path)\n # return json of org_unit children\nend",
"def children\n entries\n end",
"def children\n return [] if child_count <= 0\n with_cache(:children) do\n @od.request(\"#{api_path}/children?$top=1000\")['value'].map do |child|\n OneDriveItem.smart_new(@od, child)\n end\n end\n end",
"def show\n @children = Children.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def children\n self.class.children(self) \n end",
"def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def children\n children_tree.values\n end",
"def children\n children_tree.values\n end",
"def get_children(name, options)\n children = hash[name]\n children = children.is_a?(Hash) ? children : {}\n\n create_hash_children(children, options)\n end",
"def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end",
"def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end",
"def children\n ie = index_entry\n ie.children.collect{ |child| child.resource } if ie\n end",
"def all_children\n children(all: true)\n end",
"def all_children\n find_all_children_with_dotted_ids\n end",
"def children(path)\n # r = nil\n # zk_call do\n # r = @zk.get_children(path: path)\n # end\n # debug \"ZK: Children '#{path}' => '#{r}'\"\n # raise NonExistingPathException.new(path) unless r[:stat].exists?\n # r[:children]\n end",
"def getAllChildren\n children = Tree.where(\"tree_type_id = ? AND version_id = ? AND subject_id = ? AND grade_band_id = ? AND code like ?\", tree_type_id, version_id, subject_id, grade_band_id, code+'.%')\n Rails.logger.debug(\"*** tree children: #{children.inspect}\")\n return children\n end",
"def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end",
"def index\n @dec_form_children = DecFormChild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dec_form_children }\n end\n end",
"def children\n node.children\n end",
"def children\n Array.new\n end",
"def index\n @parents = Parent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parents }\n end\n end",
"def list_children(path)\n path = \"#{Paths::VFS}/#{path}\" unless path.start_with?(Paths::VFS)\n path = sanitize_path(path)\n\n @api.get(path)\n end",
"def children\n properties \n end",
"def get_children_folders(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n folders_json = ''\n\n if response.code == 200.to_s\n folders_json = JSON.parse(response.read_body)['data']\n else\n puts \"Problem with getting folders. Status: #{response.code}\"\n puts response.body\n end\n folders_json\nend",
"def children\n @ref.children.to_ruby\n end",
"def index\n @traumatized_children = TraumatizedChild.all\n end",
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end",
"def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend",
"def roots\n @objects = Node.roots\n respond_to do |format|\n format.html\n format.json {render json: @objects}\n end\n end",
"def show\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n \n children << key\n end\n end\n parsed.each do |key, value|\n children << key\n value.each do |key3, value3|\n children << value3\n end\n end\n \n response = @firebase.get(\"Child/\").raw_body\n #@child = eval(response)\n \n render :json => response\n end",
"def children\n # return students\n return offerings\n end",
"def index\n @child = Child.all\n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def children\n raise NotImplementedError\n end",
"def get_children(pi)\n response = Net::HTTP.get_response URI.parse(URI.escape(SERVICE_DCMDB + \"work/\" + pi + \"/children\"))\n children = Array.new\n case response\n when Net::HTTPSuccess\n doc = Document.new(response.body)\n XPath.each(doc, \"//workpid\") { |el|\n children.push(el.text)\n } \n end\n\n return children\n\n end",
"def all_children\n return @all_children if !@all_children.nil?\n @all_children = PhotoCollection.all_urls.find_all{|url| url[self.url] && url != self.url}.collect{|url| PhotoCollection.find_by_url(url)}\n end",
"def getObjectChildren _obj, _args\n \"_obj getObjectChildren _args;\" \n end",
"def children(entity)\n self.all(:parent_id => entity.id)\n end",
"def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end",
"def current_children\n\t p @children\n\tend",
"def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end",
"def get_children()\n return @space.get_children()\n end",
"def children\n child_objects(Dependency)\n end",
"def all_activities_children\n @activity_children = ActivityChild.includes(:child)\n end"
] | [
"0.80130404",
"0.7882042",
"0.7781168",
"0.7538884",
"0.7376999",
"0.73671556",
"0.7354207",
"0.73513156",
"0.7289584",
"0.72810805",
"0.72810805",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7161739",
"0.71592",
"0.7154487",
"0.7149481",
"0.7119744",
"0.7077208",
"0.70744425",
"0.7068363",
"0.7006868",
"0.69452524",
"0.69406825",
"0.6889751",
"0.68373454",
"0.68228793",
"0.68163884",
"0.68163884",
"0.6803557",
"0.6790239",
"0.6766579",
"0.6755903",
"0.67295414",
"0.6718265",
"0.6718265",
"0.6718265",
"0.6691721",
"0.6691721",
"0.66737634",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.66289145",
"0.6623755",
"0.6600997",
"0.65841967",
"0.6583331",
"0.65787333",
"0.6553719",
"0.6547198",
"0.6526974",
"0.6526974",
"0.650869",
"0.6508471",
"0.64918905",
"0.6484928",
"0.64784974",
"0.6475587",
"0.64754194",
"0.64605445",
"0.64591956",
"0.64560896",
"0.6446656",
"0.6431386",
"0.64251655",
"0.6422385",
"0.640457",
"0.63998264",
"0.639431",
"0.6370573",
"0.63604105",
"0.6343819",
"0.6332041",
"0.63188386",
"0.6318659",
"0.6307421",
"0.6272279",
"0.6260352",
"0.62424135",
"0.62353426",
"0.62263495",
"0.62246186",
"0.62223494",
"0.6210727",
"0.62099445",
"0.6199819",
"0.61997926",
"0.6198872",
"0.61537963"
] | 0.6708626 | 39 |
GET /children/1 GET /children/1.json | def show
children = []
base_uri = 'https://postjson-d117c.firebaseio.com/'
@firebase = Firebase::Client.new(base_uri)
childrenjs = @firebase.get("Child")
parsed = JSON.parse(childrenjs.raw_body)
kids = parsed.deep_symbolize_keys
kids.uniq.each do |key, value|
value.each do |key2, value2|
children << key
end
end
parsed.each do |key, value|
children << key
value.each do |key3, value3|
children << value3
end
end
response = @firebase.get("Child/").raw_body
#@child = eval(response)
render :json => response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def get_children\n @children\n end",
"def children\n @resource.children\n end",
"def show\n if(params.has_key?(:children))\n if(params[:children] == \"true\")\n @node = Node.find(params[:id]).children\n end\n else\n @node = Node.find(params[:id])\n end\n render json: @node\n end",
"def children_get()\n @children\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def get_children\n \t@children\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def show\n @children = Children.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def children\n parent_id = params['parent_id']\n\n children = Child.includes(:bursts).where(parent_id: parent_id).map{ |child|\n last_burst = child.bursts.last\n burst_rate = last_burst.present? ? calc_burst_rate(last_burst) : 0\n\n {\n id: child.id,\n name: child.name,\n burst_rate: burst_rate\n }\n }\n\n render json: children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def children\n return @children if [email protected]?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end",
"def children\n attributes.fetch(:children)\n end",
"def _children\n @children\n end",
"def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end",
"def list_children id\n\t\traw_output = @fred.category( 'children', category_id: id.to_s )\n\n\t\traw_output.categories.category\n\tend",
"def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end",
"def _children\n @children\n end",
"def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def get_children\n return @children\n end",
"def index\n @child = Child.all\n end",
"def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end",
"def index\n @parents = Parent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parents }\n end\n end",
"def children(*args)\n return call_ancestry_method(:children) if use_ancestry?\n\n Relationship.resources(child_rels(*args))\n end",
"def children\n []\n end",
"def index\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n children << value\n end\n end \n \n@children = children.flatten.uniq\n # render :json => @children\n\n end",
"def children\n _children\n end",
"def show\n @child = Child.find(params[:id])\n #used to determine layout used\n @child_crud = true\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @child }\n end\n end",
"def children\n @children ||= []\n end",
"def get_children\n return children\n end",
"def children\n []\n end",
"def get_paged_org_unit_children(org_unit_id, bookmark = '')\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/children/paged/\"\n path += \"?bookmark=#{bookmark}\" if bookmark != ''\n _get(path)\n # return json of org_unit children\nend",
"def get_children()\n {}\n end",
"def index\n @dec_form_children = DecFormChild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dec_form_children }\n end\n end",
"def children\n return [] if child_count <= 0\n with_cache(:children) do\n @od.request(\"#{api_path}/children?$top=1000\")['value'].map do |child|\n OneDriveItem.smart_new(@od, child)\n end\n end\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def current_children\n\t p @children\n\tend",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def index(child); end",
"def show\n respond_to do |format|\n format.html # show.html.haml\n format.xml { render :xml => @children }\n end\n end",
"def index\n @traumatized_children = TraumatizedChild.all\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n @children ||= {}.with_indifferent_access\n end",
"def find_child!(children, child_id)\n child = find_child(children, child_id)\n error 404, convert(body_for(:not_found)) unless child\n child\n end",
"def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end",
"def new\n @children = Children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n self.class.children(self) \n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def get_child(index)\n @children[index]\n end",
"def index\n authorize! :index, nil\n @parents = Parent.by_name\n end",
"def get_children_folders(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n folders_json = ''\n\n if response.code == 200.to_s\n folders_json = JSON.parse(response.read_body)['data']\n else\n puts \"Problem with getting folders. Status: #{response.code}\"\n puts response.body\n end\n folders_json\nend",
"def show\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parent }\n end\n end",
"def show\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parent }\n end\n end",
"def children\n entries\n end",
"def get_child!(children)\n children[1] || children\n end",
"def tree_children\n\n tree[2]\n end",
"def get_children(name, options)\n children = hash[name]\n children = children.is_a?(Hash) ? children : {}\n\n create_hash_children(children, options)\n end",
"def get_child(index)\n \t@children[index]\n end",
"def child\n @folder = Folder.new\n @folder.parent = Folder.find(params[:id])\n @folder.user = @current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @folder }\n end\n end",
"def show\n @animal = Animal.find(params[:id])\n \n @zoo = Zoo.find(params[:zoo_id])\n @father = @animal.father\n @mother = @animal.mother\n @children = @animal.children\n @siblings = @animal.siblings\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @animal }\n end\n end",
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def children\n ie = index_entry\n ie.children.collect{ |child| child.resource } if ie\n end",
"def show\n @category = Category.by_alias params[:alias]\n raise ActionController::RoutingError, 'Not found' if @category.nil?\n\n @children = @category.children\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def children\n properties \n end",
"def children\n # return students\n return offerings\n end",
"def index\n @stories = Story.all#.each{|story| story.parentId = \"1\"}\n stories_with_parent_id = @stories.map {|story| story.add_parent_id_info}\n puts stories_with_parent_id\n render json: stories_with_parent_id\n end",
"def children(path)\n # r = nil\n # zk_call do\n # r = @zk.get_children(path: path)\n # end\n # debug \"ZK: Children '#{path}' => '#{r}'\"\n # raise NonExistingPathException.new(path) unless r[:stat].exists?\n # r[:children]\n end",
"def index\n @ministry_children = MinistryChild.all\n end",
"def children\n Array.new\n end",
"def children\n @ref.children.to_ruby\n end",
"def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end",
"def index\n # @cloud_resources = CloudResource.all\n root = CloudResource.find_root\n root = params[:id] || root.id\n @cloud_resource = CloudResource.find root.to_i\n @cloud_resources = @cloud_resource.children(params[:page] || 1).order(\"name DESC\")\n end",
"def show\n #Find the employee with id supplied from the front-end and return direct subtree of that node including the parent node\n begin @employees = Employee.find(params[:id]).subtree.arrange_serializable(:order => :id)\n render json: @employees\n rescue => err \n render json: {error: err}\n end\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml { render :xml => @children, :status => :created, :location => @children }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.7499588",
"0.7324712",
"0.72646785",
"0.71289086",
"0.70389336",
"0.7035334",
"0.69792575",
"0.6978602",
"0.6978602",
"0.6977394",
"0.6936022",
"0.6908084",
"0.68532836",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6759537",
"0.66919076",
"0.66919076",
"0.6675221",
"0.66204584",
"0.6561765",
"0.65326124",
"0.65014976",
"0.6498514",
"0.64820653",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.64660233",
"0.6457498",
"0.64434445",
"0.64413947",
"0.64401454",
"0.642735",
"0.6419071",
"0.64089596",
"0.63958883",
"0.63737947",
"0.63490814",
"0.6338526",
"0.6303782",
"0.6292829",
"0.62910485",
"0.62758267",
"0.6272027",
"0.6250028",
"0.62233096",
"0.6219041",
"0.6213546",
"0.62109345",
"0.6203497",
"0.61905587",
"0.61751354",
"0.61751354",
"0.61751354",
"0.61745447",
"0.61664397",
"0.6156154",
"0.61514115",
"0.6135286",
"0.61290455",
"0.61290455",
"0.612592",
"0.6111869",
"0.61114144",
"0.61113137",
"0.6109511",
"0.6100155",
"0.6100155",
"0.6071668",
"0.60700035",
"0.6064136",
"0.6053379",
"0.60519755",
"0.60513294",
"0.60422444",
"0.6034892",
"0.60308266",
"0.60244244",
"0.6017053",
"0.6006388",
"0.5987268",
"0.5968957",
"0.59682417",
"0.596643",
"0.59562147",
"0.59456116",
"0.5938397",
"0.59356517",
"0.59344524"
] | 0.6175378 | 62 |
POST /children POST /children.json | def create
@child = Child.new(child_params)
base_uri = 'https://postjson-d117c.firebaseio.com/'
@firebase = Firebase::Client.new(base_uri)
kid = []
child_params.each do |k,v|
kid << k
kid<< v
end
# render :json => kid
response = @firebase.push("Child", :name => kid[1.to_i].to_s, :age => kid[3.to_i].to_s)
respond_to do |format|
if response.success?
format.html { redirect_to @child, notice: 'Child was successfully created.' }
format.json { render :show, status: :created, location: @child }
else
format.html { render :new }
format.json { render json: @child.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_post!(params)\n @children.create! params\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml { render :xml => @children, :status => :created, :location => @children }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_path, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def children_for page, title\n page.children.create({\n :title => title,\n :deletable => true,\n :status => 'live',\n :show_in_menu => true,\n :parent_id => page.id\n })\nend",
"def add_children\n parent = Event.find(params[:parent_id])\n parent.missing_children.each do |child|\n child.parent = parent\n child.save!\n end\n redirect_to(edit_admin_event_path(parent))\n end",
"def create\n @provider = Provider.find(params[:provider_id])\n @child = @provider.children.create(child_params)\n # @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to :back, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_children children\n children.each { |child| add_child child }\n end",
"def children\n\t@child = Child.find(params[:id])\n\t@parents = @child.parents.all\n\trespond_to do |format|\n\t\tformat.js { }\n\tend\n end",
"def children\n parent_id = params['parent_id']\n\n children = Child.includes(:bursts).where(parent_id: parent_id).map{ |child|\n last_burst = child.bursts.last\n burst_rate = last_burst.present? ? calc_burst_rate(last_burst) : 0\n\n {\n id: child.id,\n name: child.name,\n burst_rate: burst_rate\n }\n }\n\n render json: children\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_children(&block)\n if respond_to?(:response)\n self.response &block\n else\n block.call if block_given?\n end\n end",
"def create\n @kid = Kid.create(kid_params)\n @parent = Parent.find(params[:parent_id])\n @parent.kids << @kid\n redirect_to parent_kids_path\n # render json: @kid, status: 201\n end",
"def create\n @child = Child.new(child_params)\n \n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render action: 'show', status: :created, location: @child }\n else\n format.html { render action: 'new' }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def index\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n children << value\n end\n end \n \n@children = children.flatten.uniq\n # render :json => @children\n\n end",
"def add_children(child_ids)\n\t\tchild_ids.each do |child_id|\n\t\t\tself.passoc.create(:child_id => child_id)\n\t\tend\n\tend",
"def new\n @children = Children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def add_children(kids)\n i = 0\n while i < kids.size\n t = kids.get(i)\n add_child(t)\n i += 1\n end\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def create\n @child = Child.new(params[:child])\n @child_crud = true\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_url, notice: 'Child was successfully created.' }\n format.js { @current_child = @child}\n format.json { render json: @child, status: :created, location: @child }\n else\n format.html { render :layout => false, action: \"new\"}\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n format.js {}\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end",
"def update_children\n self.children.each do |child|\n child.update_children\n unless child.new_record?\n child.save\n child.move_to_child_of(self) if child.parent_id != self.id\n end\n end if self.changed?\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def get_children\n @children\n end",
"def get_children\n \t@children\n end",
"def children\n @resource.children\n end",
"def add_new_child(name)\n\tnew_child = Child.new(name)\n\tnew_hash = {}\n\tnew_child.instance_variables.each {|item| new_hash[item.to_s.delete('@')] = new_child.instance_variable_get(item)}\n\tChildren[\"children\"].push(new_hash)\n\tupdate_file('children.yaml', Children)\nend",
"def create\n @traumatized_child = TraumatizedChild.new(traumatized_child_params)\n\n respond_to do |format|\n if @traumatized_child.save\n format.html { redirect_to @traumatized_child, notice: \"Traumatized child was successfully created.\" }\n format.json { render :show, status: :created, location: @traumatized_child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @traumatized_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def children\n attributes.fetch(:children)\n end",
"def create_from_children\n single_day_event = Event.find(params[:id])\n new_parent = MultiDayEvent.create_from_children(single_day_event.multi_day_event_children_with_no_parent)\n expire_cache\n redirect_to(action: :edit, id: new_parent.to_param)\n end",
"def children\n @children ||= []\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def addChildren(child)\n\t\tfm = Family.new\n\t\tfm.person_id = child.id\n\t\tfm.parent_id = id\n\t\tif fm.save\n\t\t\tputs 'children was added successfully!'\n\t\telse \n\t\t\tputs 'children was added unsuccessfully!'\n\t\tend\n\tend",
"def index\n @dec_form_children = DecFormChild.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dec_form_children }\n end\n end",
"def new\n @child = Child.new\n @child_crud = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.html {render}\n format.json { render json: @child }\n end\n end",
"def add_child name\n @children << name\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def children\n @children ||= {}.with_indifferent_access\n end",
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def children\n []\n end",
"def add_children(more_children)\n @children.push(*more_children)\n end",
"def show\n if(params.has_key?(:children))\n if(params[:children] == \"true\")\n @node = Node.find(params[:id]).children\n end\n else\n @node = Node.find(params[:id])\n end\n render json: @node\n end",
"def child\n @folder = Folder.new\n @folder.parent = Folder.find(params[:id])\n @folder.user = @current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @folder }\n end\n end",
"def add_child\n category_id = params[:id].gsub('category_', '')\n @category = Category.find(category_id)\n parent_id = params[:parent_id]\n if parent_id\n @parent = Category.find(parent_id)\n @category.parent = @parent \n else\n @category.parent = nil\n end\n @category.save!\n render :update do |page|\n page.remove(\"category_#{@category.id}_row\")\n if @parent\n if @parent.name == ASSOCIATION.short_name\n page.replace_html(\"category_root\", :partial => \"category\", :collection => @parent.children.sort)\n else\n page.call(:expandDisclosure, parent_id)\n end\n end\n if @parent.nil?\n page.replace_html(\"unknown_category_root\", :partial => \"category\", :collection => Category.find_all_unknowns.sort)\n end\n end\n end",
"def create_child_items\n category.path.each do |category|\n create_child_item_for_category category\n end\n end",
"def children(max_distance=@default_distance)\n @children[0] = [@entity] if @children[0].empty?\n add_relatives(@children,1,max_distance,:children)\n @children\n end",
"def children; []; end",
"def visit_children(parent)\n parent.children.each do |child|\n child.node_parent = parent\n visit(child)\n end\n end",
"def visit_children(parent)\n parent.children.each do |child|\n child.node_parent = parent\n visit(child)\n end\n end",
"def children_get()\n @children\n end",
"def create\n @user = current_user.children.create(params[:user].merge :email => \"design+parent_id#{current_user.id}_child_count#{current_user.children.count + 1}@newint.com.au\")\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_path(current_user), notice: 'User was successfully created.' }\n format.json { render json: [:institution, @user], status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def child_params\n params.require(:child).permit(:id, :age, :name)\n end",
"def children\n []\n end",
"def create_instance_children(instance)\n # Add children to component\n if children\n children.each do |child|\n instance.add_child(child.create())\n end\n end\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def create\n if params[:tag][:parent]==nil then params[:tag][:parent]=0 end\n if params[:tag][:parent].to_i>0\n parent=Tag.find(params[:tag][:parent])\n parent.children+=1\n parent.save\n end\n @tag = Tag.create(params[:tag])\n @tag.type_id=params[:tag][:type_id]\n @tag.save\n respond_to do |format|\n if @tag.valid?\n format.html { redirect_to(:action=>'new') }\n else\n format.html { redirect_to(:action=>'new') }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n child = Assembly.find(params[:child_id])\n @relationship = @assembly.relationships.build(child: child)\n child = @relationship.child\n child.used = true\n child.save\n\n respond_to do |format|\n if @relationship.save\n format.html { redirect_to [@plan, @assembly], notice: 'Relationship was successfully created.' }\n format.json { render json: @relationship, status: :created, location: @relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_relationship_within\n authorize! :read, form_params[:child_id]\n\n if form.save\n notice = I18n.t('create_within', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)\n redirect_to redirect_path(item: form.child), notice: notice\n else\n redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }\n end\n end",
"def new_child\n @parent = Comment.find(params[:id])\n @comment = @parent.children.new(user_id: current_user.id, task_id: @task.id)\n\n end",
"def add_child(child)\n \t\t@children << child\n \tend",
"def add_child\n @portfolio = @site.portfolios.build\n @parent_id = params[:id]\n render :action => 'new'\n end",
"def create\n parent = Location.find(params[:location][:parent_id])\n @location = parent.children_class.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Admin::Location was successfully created.'\n format.html { redirect_to(admin_location_path(@location)) }\n format.xml { render :xml => @location, :status => :created, :location => [:admin,@location] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_child(name, file_contents)\n # Parse the contents to ensure they are valid JSON\n begin\n object = Chef::JSONCompat.parse(file_contents)\n rescue Chef::Exceptions::JSON::ParseError => e\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Parse error reading JSON creating child '#{name}': #{e}\")\n end\n\n # Create the child entry that will be returned\n result = make_child_entry(name, true)\n\n # Normalize the file_contents before post (add defaults, etc.)\n if data_handler\n object = data_handler.normalize_for_post(object, result)\n data_handler.verify_integrity(object, result) do |error|\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, nil, \"Error creating '#{name}': #{error}\")\n end\n end\n\n # POST /api_path with the normalized file_contents\n begin\n rest.post(api_path, object)\n rescue Timeout::Error => e\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Timeout creating '#{name}': #{e}\")\n rescue Net::HTTPClientException => e\n # 404 = NotFoundError\n if e.response.code == \"404\"\n raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)\n # 409 = AlreadyExistsError\n elsif $!.response.code == \"409\"\n raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, self, e, \"Failure creating '#{name}': #{path}/#{name} already exists\")\n # Anything else is unexpected (OperationFailedError)\n else\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Failure creating '#{name}': #{e.message}\")\n end\n end\n\n # Clear the cache of children so that if someone asks for children\n # again, we will get it again\n @children = nil\n\n result\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def index\n @traumatized_children = TraumatizedChild.all\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :no_content }\n end\n end",
"def create\n parent_id = params[:parent_id]\n if parent_id\n @category = Category.new(category_params.except(:edge))\n @edge = Edge.new(:weight => category_params[:edge][:weight])\n @parent_category = Category.find(parent_id)\n if @parent_category.children.create category_params.except(:edge)\n @category.id = @parent_category.children.where(:name => category_params[:name].upcase).first.id\n @edge.update_attributes(:start_node_id => parent_id.to_i, :end_node_id => @category.id)\n render :json => {:message => 'Category was successfully created.', :parent_id => parent_id, :id => @category.id, :name => @category.name}, :status => 200, :layout => false\n else\n render :json => {:message => 'Category failed to create.'}, :status => 400, :layout => false\n end\n end\n end",
"def set_children\n all_mentees = self.mentees\n new_mentees = all_mentees\n\n while new_mentees.length > 0\n to_add = []\n new_mentees.each do |new_mentee|\n to_add << new_mentee.mentees.to_a\n end\n new_mentees = to_add.flatten!\n all_mentees << to_add\n end\n\n all_mentees.each do |mentee|\n mentee.lineage_id = self.lineage_id\n mentee.save\n end\n end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def descendant_params\n params.require(:descendant).permit(:name, :child_id)\n end",
"def create\n \t\tif current_user.donor?\n\t\t\t@parent_child = current_user.parent_parent_children.new(parent_child_params)\n\t\telse\n\t\t\t@parent_child=current_user.build_child_parent_child(parent_child_params)\n\t\tend\n\n\t\trespond_to do |format|\n\t \t\tif @parent_child.save\n\t \t\t\tuser=User.find(@parent_child[:child_id])\n\t \t\t\tif current_user.student?\n\t \t\t\t\tuser.add_role :parent\n\t \t\t\t\tcurrent_user.add_role :child\n\t \t\t\t\tuser.add_role :parent,@parent_child\n\t \t\t\t\tcurrent_user.add_role :child,@parent_child\n\t \t\t\telse\n\t \t\t\t\tuser.add_role :child\n\t \t\t\t\tcurrent_user.add_role :parent\n\t \t\t\t\tuser.add_role :child,@parent_child\n\t \t\t\t\tcurrent_user.add_role :parent,@parent_child\n\t \t\t\tend\n\t\t\t\tformat.html { redirect_to @parent_child, notice: 'Parent child was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @parent_child }\n\t \t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @parent_child.errors, status: :unprocessable_entity }\n\t \t\tend\n\t\tend\n \tend",
"def child_params\n params.require(:child).permit(:name, :surname, :birthday, :lang, :hand, :school, :school_type, :school_lvl, :imagepath, :note, :archived, :version, :id_child, :id)\n end",
"def apply_children\n \n end",
"def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end",
"def download_children(children, path)\n children.each do |child|\n new_path = \"#{path}/#{child.title}\"\n backup_folder_rec child.id, new_path if child.mimeType == FOLDER\n download_if_allowed_child child, new_path\n end\n end",
"def create\n @child = Child.new_with_user_name(current_user_name, params[:child])\n respond_to do |format|\n if @child.save\n flash[:notice] = 'Child record successfully created.'\n format.html { redirect_to(@child) }\n format.xml { render :xml => @child, :status => :created, :location => @child }\n else\n format.html {\n @form_sections = get_form_sections_for_child @child\n render :action => \"new\"\n }\n format.xml { render :xml => @child.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.7426617",
"0.73090565",
"0.685491",
"0.6664779",
"0.6652258",
"0.65630364",
"0.6543847",
"0.651399",
"0.6508057",
"0.6461266",
"0.6390719",
"0.6346286",
"0.62191105",
"0.61931896",
"0.6185605",
"0.61737835",
"0.6164681",
"0.6148178",
"0.613725",
"0.61069894",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.6087279",
"0.60814947",
"0.6076403",
"0.6076403",
"0.6076403",
"0.6076403",
"0.6040731",
"0.6014053",
"0.5991178",
"0.59824413",
"0.59824413",
"0.5971857",
"0.5971483",
"0.59694374",
"0.5960736",
"0.5959877",
"0.59529954",
"0.594085",
"0.5938283",
"0.593668",
"0.5914673",
"0.591248",
"0.58921343",
"0.5862787",
"0.5814473",
"0.57930255",
"0.5791151",
"0.57897633",
"0.57891524",
"0.57747304",
"0.57584965",
"0.57573414",
"0.57303524",
"0.572139",
"0.5713403",
"0.5701113",
"0.5692246",
"0.5692246",
"0.5663912",
"0.56474745",
"0.56399584",
"0.5629163",
"0.56284034",
"0.5620404",
"0.5612894",
"0.56090605",
"0.55961263",
"0.5594224",
"0.55928385",
"0.55854726",
"0.5584218",
"0.5583741",
"0.5579625",
"0.55790514",
"0.55790514",
"0.55790514",
"0.5572978",
"0.5572228",
"0.5568224",
"0.5562058",
"0.55620134",
"0.55620134",
"0.5561944",
"0.55617225",
"0.5558516",
"0.5551233",
"0.55494475",
"0.55446285",
"0.5541977"
] | 0.5761691 | 61 |
POST /children/android POST /children/android.json | def android
#skip_before_action :verify_authenticity_token
print "\n----------------------\n"
data_json = JSON.parse(request.raw_post)
print data_json
print "\n----------------------\n"
data_json = JSON.parse(request.raw_post)
@child = Child.new(data_json)
if @child.glucose < 4
message = "Your Glucose levels are too LOW please drink some juice "
end
if 4 <= @child.glucose && @child.glucose < 9
message = "Your Glucose levels are just great well done "
end
if 9 <= @child.glucose && @child.glucose < 12
message = "Your Glucose levels are a little high if you ate in the last hour please check again in 30 minutes "
end
if 12 <= @child.glucose && @child.glucose <=25
message = "Your Glucose levels are too HIGH please use your insulin NOW "
end
if @child.glucose > 25
message = "Call emergency services "
end
app = RailsPushNotifications::GCMApp.new
gcm_api_key = 'AAAA6eNVwfI:APA91bEdWYsiOgJY5--USHyFt6EfzO52t-vDfQU3SwFLUqg1-6A972l0o6sat45h3FORAGvQwPEN2RCU83sVv-Vd7h3ACPo7sgiEWhCOI0JRu_2thOkgF87O-i4imZffoAUH94eIxMVn'
app.gcm_key = gcm_api_key
app.save
if app.save
notif = app.notifications.build(
destinations: [@child.token],
data: { text: message + @child.name}
)
if notif.save
app.push_notifications
notif.reload
print "Notification successfully pushed through!. Results #{notif.results.success} succeded, #{notif.results.failed} failed"
# redirect_to :android_index
else
print app.errors.full_messages
render :json
end
else
print notif.errors.full_messages
render :json
end
#if response.success do
#render :json => {"ok":true}
#redirect_to 'android#create'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_post!(params)\n @children.create! params\n end",
"def create\n @child = Child.new(child_params)\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n kid = []\n child_params.each do |k,v|\n kid << k\n kid<< v\n \n end\n \n # render :json => kid\n\n response = @firebase.push(\"Child\", :name => kid[1.to_i].to_s, :age => kid[3.to_i].to_s)\n \n respond_to do |format|\n if response.success?\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end \n end\n \n \n end",
"def create\n @provider = Provider.find(params[:provider_id])\n @child = @provider.children.create(child_params)\n # @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to :back, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_path, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml { render :xml => @children, :status => :created, :location => @children }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @child = Child.new(child_params)\n \n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render action: 'show', status: :created, location: @child }\n else\n format.html { render action: 'new' }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: 'Child was successfully created.' }\n format.json { render :show, status: :created, location: @child }\n else\n format.html { render :new }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def create\n @child = Child.new(child_params)\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to @child, notice: \"Child was successfully created.\" }\n format.json { render :show, status: :created, location: @child }\n format.js {}\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end",
"def create\n @kid = Kid.create(kid_params)\n @parent = Parent.find(params[:parent_id])\n @parent.kids << @kid\n redirect_to parent_kids_path\n # render json: @kid, status: 201\n end",
"def index\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n children << value\n end\n end \n \n@children = children.flatten.uniq\n # render :json => @children\n\n end",
"def create\n @traumatized_child = TraumatizedChild.new(traumatized_child_params)\n\n respond_to do |format|\n if @traumatized_child.save\n format.html { redirect_to @traumatized_child, notice: \"Traumatized child was successfully created.\" }\n format.json { render :show, status: :created, location: @traumatized_child }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @traumatized_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @child = Child.new(params[:child])\n @child_crud = true\n\n respond_to do |format|\n if @child.save\n format.html { redirect_to children_url, notice: 'Child was successfully created.' }\n format.js { @current_child = @child}\n format.json { render json: @child, status: :created, location: @child }\n else\n format.html { render :layout => false, action: \"new\"}\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @condominium_child = CondominiumChild.new(condominium_child_params)\n respond_to do |format|\n if @condominium_child.save\n format.json { render :show, status: :created, object: @condominium_child }\n else\n format.json { render json: @condominium_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n children = []\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n childrenjs = @firebase.get(\"Child\")\n parsed = JSON.parse(childrenjs.raw_body)\n kids = parsed.deep_symbolize_keys\n\n kids.uniq.each do |key, value|\n value.each do |key2, value2|\n \n children << key\n end\n end\n parsed.each do |key, value|\n children << key\n value.each do |key3, value3|\n children << value3\n end\n end\n \n response = @firebase.get(\"Child/\").raw_body\n #@child = eval(response)\n \n render :json => response\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @childmaster = Childmaster.new(params[:childmaster])\n\n respond_to do |format|\n if @childmaster.save\n format.html { redirect_to @childmaster, notice: 'Childmaster was successfully created.' }\n format.json { render json: @childmaster, status: :created, location: @childmaster }\n else\n format.html { render action: \"new\" }\n format.json { render json: @childmaster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n child = Assembly.find(params[:child_id])\n @relationship = @assembly.relationships.build(child: child)\n child = @relationship.child\n child.used = true\n child.save\n\n respond_to do |format|\n if @relationship.save\n format.html { redirect_to [@plan, @assembly], notice: 'Relationship was successfully created.' }\n format.json { render json: @relationship, status: :created, location: @relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @toyota_epc_part_number_application_to_models_child = ToyotaEpc::PartNumberApplicationToModelsChild.new(params[:toyota_epc_part_number_application_to_models_child])\n\n respond_to do |format|\n if @toyota_epc_part_number_application_to_models_child.save\n format.html { redirect_to @toyota_epc_part_number_application_to_models_child, :notice => 'Part number application to models child was successfully created.' }\n format.json { render :json => @toyota_epc_part_number_application_to_models_child, :status => :created, :location => @toyota_epc_part_number_application_to_models_child }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @toyota_epc_part_number_application_to_models_child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @child_record = ChildRecord.new(child_record_params)\n\n respond_to do |format|\n if @child_record.save\n format.html { redirect_to @child_record, notice: 'Child record was successfully created.' }\n format.json { render :show, status: :created, location: @child_record }\n else\n format.html { render :new }\n format.json { render json: @child_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n next if k[:xml_name] == 'ConsAssm'\n\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create\n if params[:product_tree][:pId] == \"0\"\n @product_tree = ProductTree.new product_tree_params\n @product_tree.save\n else\n parent_product_tree = ProductTree.find(params[:product_tree][:pId])\n product_tree_params = params[:product_tree]\n @product_tree = parent_product_tree.children.create product_tree_params\n end\n\n respond_to do |format|\n if !@product_tree.nil?\n \n speaker_teachers = params[:product_teachers_json]\n eval(speaker_teachers.gsub(\":\",\"=>\")).each do |speaker_teacher|\n @product_tree.speaker_teachers.create!(:teacher_id => speaker_teacher[\"id\"], :teacher_name => speaker_teacher[\"text\"])\n end\n \n jy_global_assets = params[:jy_global_assets_json]\n eval(jy_global_assets.gsub(\":\",\"=>\")).each do |global_asset|\n ga = GlobalAsset.find(global_asset[\"id\"])\n if !ga.nil? && ga.assetable_id.nil?\n ga.update_attributes({:assetable_id => @product_tree.id, :assetable_type => \"ProductTree\"})\n end\n end\n \n format.html { redirect_to admin_product_tree_path(@product_tree), notice: '课程树创建成功.' }\n format.json { render json: @product_tree, status: :created, location: admin_product_tree_path(@product_tree) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n end",
"def create\n @android_profile = @user.build_android_profile(params[:android_profile])\n\n respond_to do |format|\n if @android_profile.save\n format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully saved.' } }\n format.json { render json: @android_profile, status: :created, location: @android_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @android_profile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_children(child_ids)\n\t\tchild_ids.each do |child_id|\n\t\t\tself.passoc.create(:child_id => child_id)\n\t\tend\n\tend",
"def create\n @toyota_epc_part_number_list_child = ToyotaEpc::PartNumberListChild.new(params[:toyota_epc_part_number_list_child])\n\n respond_to do |format|\n if @toyota_epc_part_number_list_child.save\n format.html { redirect_to @toyota_epc_part_number_list_child, :notice => 'Part number list child was successfully created.' }\n format.json { render :json => @toyota_epc_part_number_list_child, :status => :created, :location => @toyota_epc_part_number_list_child }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @toyota_epc_part_number_list_child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def parent_params\n params.require(:parent).permit(:name, :mobile)\n end",
"def new\n @child = Child.new\n @child_crud = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.html {render}\n format.json { render json: @child }\n end\n end",
"def create_card\n card = @device.cards.where(:card_type => params[:card_type], :native_url => params[:native_url]).first_or_initialize\n parent_card = @device.cards.where(:native_url => params[:parent_native_url]).first\n begin\n params_card = {\n :path => params[:path],\n :name => params[:name],\n :desc => params[:desc]\n }\n params_card = params_card.merge(:parent_id => parent_card.id) if parent_card.present?\n card.update_attributes!(params_card)\n render :json => card\n rescue Exception => e\n puts \"Error in Uploading Contact Photo: \" + e.message.split('for')[0]\n render :json => e.message.split('for')[0], :status => :unprocessable_entity\n end\n end",
"def create_children_from_sdd_json(meta, h)\n # Materials should not be import\n return true\n\n # legacy code --\n # Go through the children\n self_model = meta[:model_name].camelcase(:upper).constantize\n kids = self_model.children_models\n unless kids.nil? || kids.empty?\n kids.each do |k|\n # check if the kids have a json object at this level\n if h[k[:xml_name]]\n logger.debug \"XML child is #{k[:xml_name]}\"\n logger.debug \"Model name is #{k[:model_name]}\"\n if h[k[:xml_name]].is_a? Array\n logger.debug \"#{k[:xml_name]} is an array, will add all the objects\"\n h[k[:xml_name]].each do |h_instance|\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h_instance)\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n elsif h[k[:xml_name]].is_a? Hash\n logger.debug \"#{k[:xml_name]} is a single object, will add only one\"\n klass = k[:model_name].camelcase(:upper).constantize\n if klass.respond_to? :from_sdd_json\n model = klass.from_sdd_json(k, h[k[:xml_name]])\n\n # Assign the foreign key on the object\n model[\"#{meta[:model_name]}_id\"] = id\n model.save!\n else\n logger.warn \"Class #{klass} does not have instance method 'from_sdd_json'\"\n end\n end\n end\n end\n end\n # end legacy code\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end",
"def update_child_devices\n if self.parent_id.blank? && !['assigned', 'instock'].include?(self.status)\n params_attr = {status: 'instock', parent_id: nil} \n else\n params_attr = {status: self.status, parent_id: self.id}\n end\n self.child_devices.update_all(params_attr)\n end",
"def child_params\n params.require(:child).permit(:name, :surname, :birthday, :lang, :hand, :school, :school_type, :school_lvl, :imagepath, :note, :archived, :version, :id_child, :id)\n end",
"def new\n @childmaster = Childmaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @childmaster }\n end\n end",
"def new\n @child_guardian_relationship = ChildGuardianRelationship.new\n @children = User.where(:type => \"Child\").order(:name)\n\n if(params.has_key?(:watcher_id))\n @this_watcher_id = params[:watcher_id]\n else\n @this_watcher_id = 0\n end\n\n @child_guardian_relationship.watcher_id = @this_watcher_id\n\n @watchers = User.where(:type => \"Watcher\").order(:name)\n # @selected_child = params[child][id]\n # @selected_watcher = params[watcher][id]\n # @child_guardian_relationship.set_child(@selected_child)\n # @child_guardian_relationship.set_watcher(@selected_watcher)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @child_guardian_relationship }\n end\n end",
"def create\n @child = Child.new_with_user_name(current_user_name, params[:child])\n respond_to do |format|\n if @child.save\n flash[:notice] = 'Child record successfully created.'\n format.html { redirect_to(@child) }\n format.xml { render :xml => @child, :status => :created, :location => @child }\n else\n format.html {\n @form_sections = get_form_sections_for_child @child\n render :action => \"new\"\n }\n format.xml { render :xml => @child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_child(name, file_contents)\n # Parse the contents to ensure they are valid JSON\n begin\n object = Chef::JSONCompat.parse(file_contents)\n rescue Chef::Exceptions::JSON::ParseError => e\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Parse error reading JSON creating child '#{name}': #{e}\")\n end\n\n # Create the child entry that will be returned\n result = make_child_entry(name, true)\n\n # Normalize the file_contents before post (add defaults, etc.)\n if data_handler\n object = data_handler.normalize_for_post(object, result)\n data_handler.verify_integrity(object, result) do |error|\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, nil, \"Error creating '#{name}': #{error}\")\n end\n end\n\n # POST /api_path with the normalized file_contents\n begin\n rest.post(api_path, object)\n rescue Timeout::Error => e\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Timeout creating '#{name}': #{e}\")\n rescue Net::HTTPClientException => e\n # 404 = NotFoundError\n if e.response.code == \"404\"\n raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)\n # 409 = AlreadyExistsError\n elsif $!.response.code == \"409\"\n raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, self, e, \"Failure creating '#{name}': #{path}/#{name} already exists\")\n # Anything else is unexpected (OperationFailedError)\n else\n raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e, \"Failure creating '#{name}': #{e.message}\")\n end\n end\n\n # Clear the cache of children so that if someone asks for children\n # again, we will get it again\n @children = nil\n\n result\n end",
"def create\n @child_actor = ChildActor.new(child_actor_params)\n\n respond_to do |format|\n if @child_actor.save\n format.html { redirect_to @child_actor, notice: \"Child actor was successfully created.\" }\n format.json { render :show, status: :created, location: @child_actor }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @child_actor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @child_fatality = ChildFatality.new(child_fatality_params)\n\n respond_to do |format|\n if @child_fatality.save\n format.html { redirect_to @child_fatality, notice: 'Child fatality was successfully created.' }\n format.json { render :show, status: :created, location: @child_fatality }\n else\n format.html { render :new }\n format.json { render json: @child_fatality.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_child_org_unit(org_unit_id, child_org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/children/\"\n _post(path, child_org_unit_id)\nend",
"def create\n @monitor_child_relationship = MonitorChildRelationship.new(params[:monitor_child_relationship])\n\n respond_to do |format|\n if @monitor_child_relationship.save\n format.html { redirect_to @monitor_child_relationship, notice: 'Monitor child relationship was successfully created.' }\n format.json { render json: @monitor_child_relationship, status: :created, location: @monitor_child_relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monitor_child_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def child_params\n params.require(:child).permit(:code, :family_id, :notes, :given_name1, :given_name2, :family_name1, :family_name2, :preferred_name, :dob, :status, :gender)\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def create\n @key_donor_child = KeyDonorChild.new(key_donor_child_params)\n\n respond_to do |format|\n if @key_donor_child.save\n format.html { redirect_to @key_donor_child, notice: 'Key donor child was successfully created.' }\n format.json { render :show, status: :created, location: @key_donor_child }\n else\n format.html { render :new }\n format.json { render json: @key_donor_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postEntityPhone( entity_id, number, trackable)\n params = Hash.new\n params['entity_id'] = entity_id\n params['number'] = number\n params['trackable'] = trackable\n return doCurl(\"post\",\"/entity/phone\",params)\n end",
"def create_device\n phone = Phone.where('uuid=?', params[:device_uuid]).first\n if phone\n phone.token = params[:regId]\n phone.save\n else\n if params[:is_android] == \"true\"\n p = Phone.create(:is_android => true, :uuid => params[:device_uuid] , :token => params[:regId])\n else\n p = Phone.create(:is_android => false, :uuid => params[:device_uuid] , :token => params[:regId])\n end\n end\n render :status=>200, :json=>{:success=>\"1\", :message=>\"Success\"}\n end",
"def child\n @folder = Folder.new\n @folder.parent = Folder.find(params[:id])\n @folder.user = @current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @folder }\n end\n end",
"def create\n @folder = current_folder.children.create folder_params\n respond_to do |format|\n format.js {\n if @folder.save\n set_children_folders\n set_children_shortcuts\n FoldersCreateBroadcastJob.perform_later @folder.id, current_folder.id\n else\n @remote_error = true\n end\n }\n end\n\n end",
"def child_params\n c_params = params.require(:child).permit(:manager_id, account_attributes:[:name,:nickname,:email,:birthday,:phone,:address,:password,:password_confirmation])\n c_params[:account_attributes][:uid] = c_params[:account_attributes][:email]\n c_params[:account_attributes][:provider] = \"email\"\n c_params\n end",
"def child_params\n c_params = params.require(:child).permit(:manager_id, account_attributes:[:name,:nickname,:email,:birthday,:phone,:address,:password,:password_confirmation])\n c_params[:account_attributes][:uid] = c_params[:account_attributes][:email]\n c_params[:account_attributes][:provider] = \"email\"\n c_params\n end",
"def create\n @child_guardian_relationship = ChildGuardianRelationship.new(params[:child_guardian_relationship])\n\n respond_to do |format|\n if @child_guardian_relationship.save\n format.html { redirect_to @child_guardian_relationship, notice: 'Child guardian relationship was successfully created.' }\n format.json { render json: @child_guardian_relationship, status: :created, location: @child_guardian_relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @child_guardian_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @child_development = ChildDevelopment.new(child_development_params)\n\n respond_to do |format|\n if @child_development.save\n format.html { redirect_to @child_development, notice: 'Child development was successfully created.' }\n format.json { render :show, status: :created, location: @child_development }\n else\n format.html { render :new }\n format.json { render json: @child_development.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n model = params[:model]\n #NOTE: Pay attention how the data is passed as a hash. This is how locomotive expects it. Not obvious.\n # req.set_form_data('content_entry[name]' => data['name'], 'content_entry[summary]' => data['summary'], 'model' => model)\n form_data = {}\n params[:content_entry].each do |key,val|\n form_data[\"content_entry[#{key}]\"] = val\n end\n #data = params[:content_entry]\n\n uri = URI(\"#{@cms_url}/locomotive/api/content_types/#{model}/entries.json?auth_token=#{APP_CONFIG['locomotive']['auth_token']}\")\n\n req = Net::HTTP::Post.new(uri)\n req.set_form_data(form_data)\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n render :json => res.body\n else\n # examine response code and generate appropriate error message\n render :json => res.value\n end\n\n end",
"def child_params\n params.require(:child).permit(:created_at, :updated_at, :last_name, :first_name, :gender, :dob, :age_years, :age_months, :age_total_months, :location, :no_parent_present, :parental_permission_given, :allergies, :allergies_information, :immunization_utd, :dtap, :hib, :pneumovax, :hepa, :hepb, :influenza, :mmr, :immunization_needed, :revelant_information, :absences, :height_feet, :height_inches, :height_total_inches, :height_total_cm, :weight_lbs, :weight_oz, :weight_kg, :bmi_result, :bmi_percentile, :systolic_1, :diastolic_1, :systolic_2, :diastolic_2, :systolic_3, :diastolic_3, :hemoglobin, :blood_glucose, :hearing_hz_left_1, :hearing_db_left_1, :ear_left_pass_1, :hearing_hz_right_1, :hearing_db_right_1, :ear_right_pass_1, :hearing_hz_left_2, :hearing_db_left_2, :ear_left_pass_2, :hearing_hz_right_2, :hearing_db_right_2, :ear_right_pass_2, :hearing_hz_left_3, :hearing_db_left_3, :ear_left_pass_3, :hearing_hz_right_3, :hearing_db_right_3, :ear_right_pass_3, :hearing_comments, :vision_acuity_left_1, :vision_acuity_right_1, :vision_acuity_both_1, :vision_acuity_right_2, :vision_acuity_left_2, :vision_acuity_both_2, :vision_acuity_right_3, :vision_acuity_left_3, :vision_acuity_both_3, :vision_color_blindness, :cover_test_left, :cover_test_right, :cover_test_both, :wears_corrective_lenses, :vision_comments, :general_appearance, :general_appearance_c, :head, :head_c, :skin, :skin_c, :eyes, :eyes_c, :ears, :ears_c, :nose, :nose_c, :mouth, :mouth_c, :throat, :throat_c, :thyroid, :thyroid_c, :lymph_all_normal, :lymph_pre_auricular, :lymph_post_auricular, :lymph_anterior_cervical, :lymph_posterior_cervical, :lymph_occipital, :lymph_axillary, :lymph_c, :vascular, :vascular_c, :heart, :heart_c, :lungs, :lungs_c, :abdomen, :abdomen_c, :musculoskeletal, :musculoskeletal_c, :scoliosis, :scoliosis_c, :neuro, :neuro_c, :well_child_check, :children_01, :children_02, :children_03, :children_04, :children_05, :children_06, :children_07, :children_08, :children_09, :children_10, :follow_up_01, :follow_up_02, :follow_up_03, :follow_up_04, :follow_up_05, :follow_up_06, :follow_up_07, :follow_up_08, :follow_up_09, :follow_up_10, :text, :guidance, :chart_complete, :np_signature, :faculty_signature, :other_np_signature, :form_id_number)\n end",
"def post(attrs = nil)\n attrs ||= attributes\n\n execute_request('POST') do |uri, headers|\n HTTP.http_client.post(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end",
"def child_params\n params.require(:child).permit(:first_name, :last_name, :birthday, :sex, :dni_number)\n end",
"def post(*args)\n super(*wrap_for_json_api(*args))\n end",
"def create\n @pharmacy_payment_child = PharmacyPaymentChild.new(params[:pharmacy_payment_child])\n\n respond_to do |format|\n if @pharmacy_payment_child.save\n format.html { redirect_to(@pharmacy_payment_child, :notice => 'PharmacyPaymentChild was successfully created.') }\n format.xml { render :xml => @pharmacy_payment_child, :status => :created, :location => @pharmacy_payment_child }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pharmacy_payment_child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_from_children\n single_day_event = Event.find(params[:id])\n new_parent = MultiDayEvent.create_from_children(single_day_event.multi_day_event_children_with_no_parent)\n expire_cache\n redirect_to(action: :edit, id: new_parent.to_param)\n end",
"def child_params\n params.require(:child).permit(:id, :age, :name)\n end",
"def add_children(kids)\n i = 0\n while i < kids.size\n t = kids.get(i)\n add_child(t)\n i += 1\n end\n end",
"def create\n @childmaster = Childmaster.new(params[:childmaster])\n\n respond_to do |format|\n if @childmaster.save\n format.html { redirect_to(@childmaster, :notice => 'Childmaster was successfully created.') }\n format.xml { render :xml => @childmaster, :status => :created, :location => @childmaster }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @childmaster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_mobile\n begin\n @post = Post.new(post_params)\n if @post.save\n unless params[:post][:category].nil? || params[:post][:category].empty?\n params[:post][:category].each do |category_param|\n category = Category.where(name: category_param).first\n unless category.nil?\n type = PostType.new(post_id: @post.id, category_id: category.id)\n type.save!\n end\n end\n end\n render json: @post\n else\n render json: @post.errors, status: :unprocessable_entity \n end\n rescue\n render json: @post.errors, status: :unprocessable_entity \n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @parent_list = TodoList.find(params[:todo_list_id])\n \n @item = TodoItem.new(params[:todo_item])\n @item.todo_list_id = @parent_list.id\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'TodoItem was successfully created.' }\n format.json { render json: {\n success: true,\n data: [@item],\n message: \"TodoItem was successfully created.\"\n }, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: {\n success: false,\n data: [],\n message: @item.errors\n }}\n end\n end\n end",
"def create\n @father = Father.new(params[:father])\n\n respond_to do |format|\n if @father.save\n format.html { redirect_to @father, notice: 'Father was successfully created.' }\n format.json { render json: @father, status: :created, location: @father }\n else\n format.html { render action: \"new\" }\n format.json { render json: @father.errors, status: :unprocessable_entity }\n end\n end\n end",
"def child_params\n params.require(:child).permit(:nickname, :forename, :surname, :UPN, :Class, :childimg, :classroom, :class_year)\n end",
"def create\n @child_model = ChildModel.new(params[:child_model])\n\n respond_to do |format|\n if @child_model.save\n flash[:notice] = 'ChildModel was successfully created.'\n format.html { redirect_to(@child_model) }\n format.xml { render :xml => @child_model, :status => :created, :location => @child_model }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @child_model.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @android_profile = @user.build_android_profile\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @android_profile }\n end\n end",
"def create\n \t\tif current_user.donor?\n\t\t\t@parent_child = current_user.parent_parent_children.new(parent_child_params)\n\t\telse\n\t\t\t@parent_child=current_user.build_child_parent_child(parent_child_params)\n\t\tend\n\n\t\trespond_to do |format|\n\t \t\tif @parent_child.save\n\t \t\t\tuser=User.find(@parent_child[:child_id])\n\t \t\t\tif current_user.student?\n\t \t\t\t\tuser.add_role :parent\n\t \t\t\t\tcurrent_user.add_role :child\n\t \t\t\t\tuser.add_role :parent,@parent_child\n\t \t\t\t\tcurrent_user.add_role :child,@parent_child\n\t \t\t\telse\n\t \t\t\t\tuser.add_role :child\n\t \t\t\t\tcurrent_user.add_role :parent\n\t \t\t\t\tuser.add_role :child,@parent_child\n\t \t\t\t\tcurrent_user.add_role :parent,@parent_child\n\t \t\t\tend\n\t\t\t\tformat.html { redirect_to @parent_child, notice: 'Parent child was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @parent_child }\n\t \t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @parent_child.errors, status: :unprocessable_entity }\n\t \t\tend\n\t\tend\n \tend",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def activity_params\n params.require(:activity).permit(:name, :color, :parent_id)\n end",
"def create\n cp = child_params\n cp[:code] = cp[:code].strip\n @child = Child.new(cp)\n\n respond_to do |format|\n begin\n saved = @child.save\n rescue ActiveRecord::RecordNotUnique => e\n @child.errors[:base] << e.message\n saved = false\n rescue => e\n @child.errors[:base] << e.message\n saved = false\n end\n if saved\n format.html { redirect_to @child, notice: tr('child_created') }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @quest_tree = QuestTree.new(params[:quest_tree])\n\n respond_to do |format|\n if @quest_tree.save\n format.html { redirect_to @quest_tree, notice: 'Quest tree was successfully created.' }\n format.json { render json: @quest_tree, status: :created, location: @quest_tree }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quest_tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def child_record_params\n params.require(:child_record).permit(:record_type, :contents, :created_by, :last_updated_by, :created_on, :last_updated_on, :child_id)\n end",
"def create\n @user = current_user.children.create(params[:user].merge :email => \"design+parent_id#{current_user.id}_child_count#{current_user.children.count + 1}@newint.com.au\")\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_path(current_user), notice: 'User was successfully created.' }\n format.json { render json: [:institution, @user], status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @miscellaneous_child = MiscellaneousChild.new(params[:miscellaneous_child])\n\n respond_to do |format|\n if @miscellaneous_child.save\n format.html { redirect_to(@miscellaneous_child, :notice => 'MiscellaneousChild was successfully created.') }\n format.xml { render :xml => @miscellaneous_child, :status => :created, :location => @miscellaneous_child }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @miscellaneous_child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @parent = Parent.new(params[:parent])\n\n respond_to do |format|\n if @parent.save\n format.html { redirect_to parents_url, notice: 'Parent was successfully created.' }\n format.json { render json: @parent, status: :created, location: @parent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def child_params\n params.require(:child).permit(:username, :password, :name, :age,\n :language, :description, :points, :search)\n end",
"def add_new_child(name)\n\tnew_child = Child.new(name)\n\tnew_hash = {}\n\tnew_child.instance_variables.each {|item| new_hash[item.to_s.delete('@')] = new_child.instance_variable_get(item)}\n\tChildren[\"children\"].push(new_hash)\n\tupdate_file('children.yaml', Children)\nend",
"def create(attributes = {})\n resource = build(attributes)\n @parent.attributes[@name] = resource if resource.save\n resource\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def postBusinessJsonProcess( entity_id, json)\n params = Hash.new\n params['entity_id'] = entity_id\n params['json'] = json\n return doCurl(\"post\",\"/business/json/process\",params)\n end",
"def create\n respond_to do |format|\n if @parent.save\n format.html { redirect_to @parent, notice: 'Parent was successfully created.' }\n format.json { render :show, status: :created, location: @parent }\n else\n format.html { render :new }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ministry_child = MinistryChild.new(ministry_child_params)\n\n respond_to do |format|\n if @ministry_child.save\n format.html { redirect_to @ministry_child, notice: 'Ministry child was successfully created.' }\n format.json { render :show, status: :created, location: @ministry_child }\n else\n format.html { render :new }\n format.json { render json: @ministry_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def child_note_params\n params.require(:child_note).permit(\n :title,\n :body,\n :favorite,\n :parent_id,\n { assets_attributes: [:id, :_destroy, :file] }\n )\n end",
"def create\n parent = Location.find(params[:location][:parent_id])\n @location = parent.children_class.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Admin::Location was successfully created.'\n format.html { redirect_to(admin_location_path(@location)) }\n format.xml { render :xml => @location, :status => :created, :location => [:admin,@location] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_children\n parent = Event.find(params[:parent_id])\n parent.missing_children.each do |child|\n child.parent = parent\n child.save!\n end\n redirect_to(edit_admin_event_path(parent))\n end",
"def create_android\n `android create project -t 5 -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`\n end",
"def create\n @parent_info = ParentInfo.new(parent_info_params)\n\n respond_to do |format|\n if @parent_info.save\n format.html { redirect_to @parent_info, notice: 'Parent info was successfully created.' }\n format.json { render :show, status: :created, location: @parent_info }\n else\n format.html { render :new }\n format.json { render json: @parent_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend",
"def create_android\n puts \"Creating Android project\"\n `android create project -t #{ @target } -k #{ @pkg } -a #{ @name } -n #{ @name.gsub(' ','') } -p #{ @output_dir }`\n end",
"def post(attrs = nil)\n attrs ||= attributes\n execute_request do\n faraday_connection.post { |req| req.body = adapter.serialize(attrs) }\n end\n end",
"def create\n @device_sub_content = DeviceSubContent.new(device_sub_content_params)\n\n respond_to do |format|\n if @device_sub_content.save\n format.html { redirect_to @device_sub_content, notice: 'Device sub content was successfully created.' }\n format.json { render :show, status: :created, location: @device_sub_content }\n else\n format.html { render :new }\n format.json { render json: @device_sub_content.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.61876756",
"0.61232656",
"0.59076315",
"0.5800263",
"0.57623804",
"0.56646115",
"0.56434715",
"0.55546004",
"0.55292016",
"0.5500024",
"0.5483911",
"0.54587495",
"0.5443823",
"0.5340869",
"0.53280234",
"0.53124446",
"0.5302902",
"0.52970505",
"0.52618855",
"0.5249299",
"0.51905584",
"0.51800776",
"0.5172161",
"0.5172161",
"0.5172161",
"0.5172161",
"0.5172161",
"0.5172161",
"0.516073",
"0.5156952",
"0.51126087",
"0.5072053",
"0.5047931",
"0.50475633",
"0.50445914",
"0.5041958",
"0.5038156",
"0.50279784",
"0.50261986",
"0.5025596",
"0.50194895",
"0.5013593",
"0.50108737",
"0.5007525",
"0.49939996",
"0.49930772",
"0.4989761",
"0.4988188",
"0.49808478",
"0.4979682",
"0.4967091",
"0.49616036",
"0.49492565",
"0.4926149",
"0.4926149",
"0.49236667",
"0.4921893",
"0.4917544",
"0.49077147",
"0.49063095",
"0.48937052",
"0.48915333",
"0.48894793",
"0.4887103",
"0.488248",
"0.48790798",
"0.48790604",
"0.48750234",
"0.48689523",
"0.48637977",
"0.48619053",
"0.48605406",
"0.48577732",
"0.4851717",
"0.4847889",
"0.48383638",
"0.48378175",
"0.48332733",
"0.48290122",
"0.48240498",
"0.48219824",
"0.48187238",
"0.48098424",
"0.4806531",
"0.48061475",
"0.48003176",
"0.47987193",
"0.47951257",
"0.47948706",
"0.47894028",
"0.4789381",
"0.47882634",
"0.47822618",
"0.47769055",
"0.4774175",
"0.47699198",
"0.47625574",
"0.4759916",
"0.47542623",
"0.4753333"
] | 0.5638051 | 7 |
PATCH/PUT /children/1 PATCH/PUT /children/1.json | def update
respond_to do |format|
if @child.update(child_params)
format.html { redirect_to @child, notice: 'Child was successfully updated.' }
format.json { render :show, status: :ok, location: @child }
else
format.html { render :edit }
format.json { render json: @child.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to children_path, notice: \"Child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: 'Child was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to @child, notice: \"Child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n end",
"def update\n respond_to do |format|\n if @child.update(child_params)\n format.html { redirect_to :back, notice: 'Child was successfully updated.' }\n format.json { render :show, status: :ok, location: @child }\n else\n format.html { render :edit }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n\n respond_to do |format|\n if @child_resource.update_attributes(params[:child_resource])\n format.html { redirect_to @child_resource, notice: 'Child resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @child_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_children\n self.children.each do |child|\n child.update_children\n unless child.new_record?\n child.save\n child.move_to_child_of(self) if child.parent_id != self.id\n end\n end if self.changed?\n end",
"def repair_children\n @obj = Node.find(params[:id])\n @obj.repair_children\n respond_to do |format|\n format.html {redirect_to nodes_url}\n format.json {render json: @obj}\n end\n end",
"def update\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n if @parent.update_attributes(params[:parent])\n format.html { redirect_to parents_url, notice: 'Parent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @child = Child.find(params[:id])\n\n respond_to do |format|\n if @child.update_attributes(params[:child])\n format.html { redirect_to children_url, notice: 'Child was successfully updated.' }\n format.js { @current_child = @child}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_children\n return if children_attribs.nil?\n\n reload # Ancestry doesn't seem to work properly without this.\n\n # Symbolize keys if regular Hash. (not needed for HashWithIndifferentAccess)\n children_attribs.each{ |a| a.symbolize_keys! if a.respond_to?(:symbolize_keys!) }\n\n self.ranks_changed = false # Assume false to begin.\n self.options_added = false\n self.options_removed = false\n\n # Index all children by ID for better performance\n children_by_id = children.index_by(&:id)\n\n # Loop over all children attributes.\n # We use the ! variant of update and create below so that validation\n # errors on children and options will cascade up.\n (children_attribs || []).each_with_index do |attribs, i|\n\n # If there is a matching (by id) existing child.\n attribs[:id] = attribs[:id].to_i if attribs.key?(:id)\n if attribs[:id] && matching = children_by_id[attribs[:id]]\n self.ranks_changed = true if matching.rank != i + 1\n matching.update_attributes!(attribs.merge(rank: i + 1))\n copy_flags_from_subnode(matching)\n\n # Remove from hash so that we'll know later which ones weren't updated.\n children_by_id.delete(attribs[:id])\n else\n attribs = copy_denormalized_attribs_to_attrib_hash(attribs)\n self.options_added = true\n\n # We need to strip ID in case it's present due to a node changing parents.\n children.create!(attribs.except(:id).merge(rank: i + 1))\n end\n end\n\n # Destroy existing children that were not mentioned in the update.\n self.options_removed = true unless children_by_id.empty?\n children_by_id.values.each{ |c| c.destroy_with_copies }\n\n # Don't need this anymore. Nullify to prevent duplication on future saves.\n self.children_attribs = nil\n end",
"def update\n if @thema.try(:new_parent_id)\n @thema.parent = Thema.find(@thema.new_parent_id)\n end\n\n respond_to do |format|\n if @thema.update(thema_params)\n format.html { redirect_to @thema, notice: 'Thema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t @tree = current_user.trees.find(params[:tree_id])\n\n\t if @tree.nil?\n\t \trender json: { errors: [\"No such tree found\"], success: false }, status: :bad_request\n\t end\n\n\t @person = @tree.people.find(params[:id])\n\n \tif @person.nil?\n \t\trender json: { errors: [\"No such person found\"], success: false }, status: :bad_request\n \tend\n\n \tparams.delete :_id\n\n\t relations = {}\n\t\t \tmodified_people = []\n\n\t\t \tif params[:person][:spouses]\n\t\t \t\trelations[:spouses] = params[:person][:spouses]\n\t\t \t\tparams[:person].delete :spouses\n\t\t \tend\n\n\t\t \tif params[:person][:children]\n\t\t \t\trelations[:children] = params[:person][:children]\n\t\t \t\tparams[:person].delete :children\n\t\t \tend\n\n\t\t \tif params[:person][:parents]\n\t\t \t\trelations[:parents] = params[:person][:parents]\n\t\t \t\tparams[:person].delete :parents\n\t\t \tend\n\n \tif @person.update_attributes(params[:person])\n \t\tmodified_people << @person\n\n \t\trelations.each do |k,v|\n\t\t \t\tv.each do |p|\n\t\t \t\t\tputs \"RELATIONS\", relations\n\t\t \t\t\tputs \"HERE\", k, v, p\n\t\t \t\t\trelative = @tree.people.find(p)\n\t\t \t\t\tputs \"THERE\", relative[k], relative.to_json\n\t\t \t\t\trelative.send(k) << @person\n\t\t \t\t\trelative.save\n\t\t \t\t\tmodified_people << relative\n\t\t \t\tend\n\t\t \tend\n\n \trender json: { person: @person, people: modified_people }, status: :accepted\n \telse\n \trender json: { errors: @person.errors, success: false }, status: :unprocessable_entity\n \tend\n\t\t end",
"def update\n\t\trespond_to do |format|\n\t \t\tif @parent_child.update(parent_child_params)\n\t\t\t\tformat.html { redirect_to @parent_child, notice: 'Parent child was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @parent_child }\n\t \t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @parent_child.errors, status: :unprocessable_entity }\n\t \t\tend\n\t\tend\n \tend",
"def update_memberships\n update_children\n update_parents\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child_link = args[:child_link] if args.key?(:child_link)\n @created = args[:created] if args.key?(:created)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @permissions = args[:permissions] if args.key?(:permissions)\n @self_link = args[:self_link] if args.key?(:self_link)\n @starred = args[:starred] if args.key?(:starred)\n @updated = args[:updated] if args.key?(:updated)\n end",
"def update!(**args)\n @child_type = args[:child_type] if args.key?(:child_type)\n end",
"def update\n respond_to do |format|\n if @traumatized_child.update(traumatized_child_params)\n format.html { redirect_to @traumatized_child, notice: \"Traumatized child was successfully updated.\" }\n format.json { render :show, status: :ok, location: @traumatized_child }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @traumatized_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n format.html { redirect_to leaf_path(@leaf), notice: EDIT_SUCCESS }\n format.json { render :show, status: :ok, location: @leaf }\n else\n format.html { render :edit }\n format.json { render json: @leaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@parent = Parent.find(params[:id])\n respond_to do |format|\n if @parent.update(parent_params)\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_bobchildren(bobchildren_ids)\n bobchildren_ids.reject! {|x| x.empty? }\n \n remove_bobchild_relationships(bobchildren_ids)\n # add the newly checked children\n add_bobchild_reationships(bobchildren_ids)\n end",
"def update\n respond_to do |format|\n if @parent_of.update(parent_of_params)\n format.html { redirect_to @parent_of, notice: 'Parent of was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent_of }\n else\n format.html { render :edit }\n format.json { render json: @parent_of.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tree.update(tree_params)\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tree.update(tree_params)\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tree = Tree.find(params[:id])\n\n respond_to do |format|\n if @tree.update_attributes(params[:tree])\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n if params[:tag][:parent].to_i>0\n parent=Tag.find(params[:tag][:parent])\n parent.children+=1\n parent.save\n end\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_children_moderation_flag\n if self.changed.include?('moderation_flag') and self.content.has_children?\n self.content.children.each do |child|\n similiar_submissions = Submission.where(:content_id => child.id, :feed_id => self.feed_id, :moderation_flag => self.moderation_flag_was)\n similiar_submissions.each do |child_submission|\n child_submission.update_attributes({:moderation_flag => self.moderation_flag, :moderator_id => self.moderator_id})\n end\n end\n end\n end",
"def update \n pastry = Pastry.find(params[:id])\n pastry.update(pastry_params)\n render json: pastry\n end",
"def update!(**args)\n @children_locations = args[:children_locations] if args.key?(:children_locations)\n @parent_chain = args[:parent_chain] if args.key?(:parent_chain)\n @parent_location = args[:parent_location] if args.key?(:parent_location)\n end",
"def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n format.html { redirect_to @leaf, notice: 'Leaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_children_with_new_parent\n if path_changed? and not new_record? then\n old_path = (path_was.blank? ? id.to_s : \"#{path_was}.#{id}\")\n self.class.where(\"path <@ ?\", old_path).update_all([ \"path = TEXT2LTREE(REPLACE(LTREE2TEXT(path), ?, ?))\", old_path, my_path ])\n end\n end",
"def update\n respond_to do |format|\n if @leaf.update(leaf_params)\n format.html { redirect_to @leaf, notice: t('common.message.updated_success')}\n format.json { render :show, status: :ok, location: @leaf }\n else\n format.html { render :edit }\n format.json { render json: @leaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child_record.update(child_record_params)\n format.html { redirect_to @child_record, notice: 'Child record was successfully updated.' }\n format.json { render :show, status: :ok, location: @child_record }\n else\n format.html { render :edit }\n format.json { render json: @child_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_child_moderation\n if self.changed.include?('moderation_flag') and self.content.has_children?\n self.content.children.each do |child|\n similiar_submissions = Submission.where(content_id: child.id, feed_id: self.feed_id, moderation_flag: self.moderation_flag_was)\n similiar_submissions.each do |child_submission|\n child_submission.update_attributes({moderation_flag: self.moderation_flag, moderator_id: self.moderator_id})\n end\n end\n end\n end",
"def update!(**args)\n @parent = args[:parent] if args.key?(:parent)\n @permission = args[:permission] if args.key?(:permission)\n end",
"def update\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n if @childmaster.update_attributes(params[:childmaster])\n format.html { redirect_to @childmaster, notice: 'Childmaster was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @childmaster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parent_info.update(parent_info_params)\n format.html { redirect_to @parent_info, notice: 'Parent info was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent_info }\n else\n format.html { render :edit }\n format.json { render json: @parent_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child_asset_id = args[:child_asset_id] if args.key?(:child_asset_id)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @parent_asset_id = args[:parent_asset_id] if args.key?(:parent_asset_id)\n end",
"def update\n @athletes_parent = AthletesParent.find(params[:id])\n\n respond_to do |format|\n if @athletes_parent.update_attributes(params[:athletes_parent])\n format.html { redirect_to(@athletes_parent, :notice => 'Athletes parent was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @athletes_parent.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @child = Child.get(params[:id])\n new_photo = params[:child].delete(:photo)\n @child.update_properties_with_user_name current_user_name, new_photo, params[:child]\n \n respond_to do |format|\n if @child.save\n flash[:notice] = 'Child was successfully updated.'\n format.html { redirect_to(@child) }\n format.xml { head :ok }\n else\n format.html {\n @form_sections = get_form_sections_for_child @child\n render :action => \"edit\"\n }\n format.xml { render :xml => @child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n @root_post = root_post_of(@post)\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n @root_post.touch(:updated_at)\r\n update_child_posts(@post)\r\n\r\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n begin\n cp = child_params\n cp[:code] = cp[:code].strip\n updated = @child.update(cp)\n rescue ActiveRecord::RecordNotUnique => e\n @child.errors[:base] << e.message\n updated = false\n rescue => e\n @child.errors[:base] << e.message\n updated = false\n end\n if updated\n format.html { redirect_to @child, notice: tr(\"child_updated\")}\n else\n format.html { render :edit }\n end\n end\n end",
"def test_nested_collection_replace\n # Parent.children\n old_children = @parent.children\n\n data = [{ '_type' => 'Child', 'name' => 'newc1' },\n { '_type' => 'Child', 'name' => 'newc2' },]\n\n childcontroller = ChildController.new(params: {\n owner_viewmodel: 'parent',\n association_name: 'children',\n parent_id: @parent.id,\n data: data,\n })\n childcontroller.invoke(:replace)\n\n assert_equal(200, childcontroller.status, childcontroller.hash_response)\n\n @parent.reload\n\n assert_equal(%w[newc1 newc2], @parent.children.order(:position).pluck(:name))\n assert_predicate(Child.where(id: old_children.map(&:id)), :empty?)\n\n assert_all_hooks_nested_inside_parent_hook(childcontroller.hook_trace)\n end",
"def update\n @father = Father.find(params[:id])\n\n respond_to do |format|\n if @father.update_attributes(params[:father])\n format.html { redirect_to @father, notice: 'Father was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @father.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ministry_child.update(ministry_child_params)\n format.html { redirect_to @ministry_child, notice: 'Ministry child was successfully updated.' }\n format.json { render :show, status: :ok, location: @ministry_child }\n else\n format.html { render :edit }\n format.json { render json: @ministry_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @parent = Parent.find(params[:parent][:id])\n\n \t# check that the issuer of the request has both the username and ID, prevent attack\n if params[:parent][:login].gsub(/ /,'') != @parent.login.gsub(/ /,'')\n \tlog_attack \"Error parent update \" + params[:parent][:id] + \" : \" + params[:parent][:login] + \" - @parent.login = \" + @parent.login \t\n respond_to do |format|\n format.xml { render :xml => errorRsp( \"Security error\" ) }\n end\n \treturn\n end\n \n respond_to do |format|\n if @parent.update_attributes(params[:parent])\n format.xml { head :ok }\n else\n log_DB_errors( \"parent\", @parent.errors ) \n format.xml { render :xml => errorRsp( \"Failed to update\" ) }\n end\n end\n end",
"def update_inherited_members\n if parent\n if inherit_members? && !inherit_members_before_last_save\n remove_inherited_member_roles\n remove_inherited_member_functions # PATCH\n add_inherited_member_roles\n add_inherited_member_functions # PATCH\n elsif !inherit_members? && inherit_members_before_last_save\n remove_inherited_member_roles\n remove_inherited_member_functions # PATCH\n end\n end\n end",
"def update\n @miscellaneous_child = MiscellaneousChild.find(params[:id])\n\n respond_to do |format|\n if @miscellaneous_child.update_attributes(params[:miscellaneous_child])\n format.html { redirect_to(@miscellaneous_child, :notice => 'MiscellaneousChild was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @miscellaneous_child.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @parent_types = ParentType.all\n @parent_type = ParentType.find(params[:id])\n\n @parent_type.update_attributes(parent_type_params)\n\n=begin\n respond_to do |format|\n if @parent_type.update(parent_type_params)\n format.html { redirect_to @parent_type, notice: 'Parent type was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent_type }\n else\n format.html { render :edit }\n format.json { render json: @parent_type.errors, status: :unprocessable_entity }\n end\n end\n=end\n end",
"def update\n respond_to do |format|\n if @tree.update(tree_params)\n format.html { redirect_to @tree, notice: 'Tree was successfully updated.' }\n format.json { render :show, status: :ok, location: @tree }\n else\n format.html { render :edit }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \trespond_to do |format|\n \t\tif @tree.update(tree_params)\n \t\t\tformat.html { redirect_to @tree, notice: 'Nome da arvore atualizado com sucesso.' }\n \t\t\tformat.json { render :show, status: :ok, location: @tree }\n \t\telse\n \t\t\tformat.html { render :edit }\n \t\t\tformat.json { render json: @tree.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n end",
"def update\n respond_to do |format|\n if @child_actor.update(child_actor_params)\n format.html { redirect_to @child_actor, notice: \"Child actor was successfully updated.\" }\n format.json { render :show, status: :ok, location: @child_actor }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @child_actor.errors, status: :unprocessable_entity }\n end\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 update\n respond_to do |format|\n if @parent.update(parent_params)\n @user = User.where(email: @parent.students.first.father_email)\n @user.update(student_id: @parent.id) if @user\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foster_parent.update(foster_parent_params)\n format.html { redirect_to @foster_parent, notice: 'Foster parent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foster_parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @children = args[:children] if args.key?(:children)\n @date = args[:date] if args.key?(:date)\n @docid = args[:docid] if args.key?(:docid)\n @parent = args[:parent] if args.key?(:parent)\n end",
"def update\n @shape_type = ShapeType.find(params[:id])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t\telse\n\t\t\t\t# see if the parent shape changed\n\t\t\t\tanc_ary = @shape_type.ancestry.split(\"/\")\n\t\t\t\tif (anc_ary.length == 1 && parent.id.to_s == anc_ary[0]) || parent.id.to_s == anc_ary[anc_ary.length-1]\n\t\t\t\t\t# parent shape did not change, do nothing\n\t\t\t\telse\n\t\t\t\t\t# parent shape did change. update the ancestry value\n\t\t\t\t\tnew_anc = parent.ancestor_ids.join(\"/\")\n\t\t\t\t\tnew_anc += \"/\" + parent.id.to_s\n\t\t\t\t\tparams[:shape_type][:ancestry] = new_anc\n\t\t\t\tend\n\n\t\t if @shape_type.update_attributes(params[:shape_type])\n\t\t\t\t\tmsg = I18n.t('app.msgs.success_updated', :obj => I18n.t('app.common.shape_type'))\n\t\t\t\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n\t\t format.html { redirect_to admin_shape_type_path(@shape_type), notice: msg }\n\t\t format.json { head :ok }\n\t\t else\n\t\t format.html { render action: \"edit\" }\n\t\t format.json { render json: @shape_type.errors, status: :unprocessable_entity }\n\t\t end\n\t end\n end\n end",
"def update_parents(person_id, attributes)\n\t\tif attributes.include?(:father_id) then\n\t \tnew_father_id = attributes[:father_id]\n\t \tif new_father_id and [email protected]?(new_father_id)\n\t \t\tputs \"warning: update person #{person_id} - ignored invalid father_id #{new_father_id}.\"\n\t \telse\n\t \t\t# delete the person from the previous father\n\t \t\told_father_id = @people[person_id].father_id\n\t \t\t@people[old_father_id].children_ids.delete(person_id) if old_father_id\n\t \t\t# add the person to the new father\n\t \t\t@people[new_father_id].children_ids << person_id if new_father_id\n\t \t\t# set the new father id to the child\n\t \t\t@people[person_id].father_id = new_father_id\n\t \tend\n\t end \n\t if attributes.include?(:mother_id) then\n\t \tnew_mother_id = attributes[:mother_id]\n\t \tif new_mother_id and [email protected]?(new_mother_id)\n\t \t\tputs \"warning: update person #{person_id} - ignored invalid mother_id #{new_mother_id}.\"\n\t \telse\n\t \t\t# delete the person from the previous mother\n\t\t\t old_mother_id = @people[person_id].mother_id\n\t \t\t@people[old_mother_id].children_ids.delete(person_id) if old_mother_id\n\t \t\t# add the person to the new mother\n\t \t\t@people[new_mother_id].children_ids << person_id if new_mother_id\n\t \t\t# set the new mother id to the person\n\t\t\t @people[person_id].mother_id = new_mother_id\n\t \tend\n\t end \n\t if attributes.include?(:children_ids) then\n\t \tnew_children_ids = attributes[:children_ids]\n\t \told_children_ids = @people[person_id].children_ids\n\t \tadd_list = new_children_ids - old_children_ids # children to add to this person\n\t \tremove_list = old_children_ids - new_children_ids # children to delete from this person\n\t \tcase @people[person_id].sex # determine if this person is a father or mother\n\t \twhen \"M\", \"F\"\n\t \t\t@people[person_id].sex == \"M\" ? parent_type = :father_id : parent_type = :mother_id\n\t \t\tadd_list.each { | child | update_parents( child, { parent_type => person_id } ) }\n\t \t\tremove_list.each { | child | update_parents( child, { parent_type => nil } ) }\n\t \telse\n\t \t\tputs \"warning: update person #{person_id} - ignored children due to invalid sex #{@people[person_id].sex}\"\n\t \tend\n\t end\n\tend",
"def update\n @ministry_child = MinistryChild.find(params[:id])\n\n respond_to do |format|\n if @ministry_child.update_attributes(params[:ministry_child])\n format.html { redirect_to ministry_path(@ministry_child.ministry.id), notice: 'Ministry child was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ministry_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @childmaster = Childmaster.find(params[:id])\n\n respond_to do |format|\n if @childmaster.update_attributes(params[:childmaster])\n format.html { redirect_to(@childmaster, :notice => 'Childmaster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @childmaster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_for_parent_insert( parent_array, requested_parent_index, parent_index, object )\n\n local_index = @cascade_controller.parent_insert( parent_array, parent_index, 1 )\n undecorated_insert( local_index, nil )\n @children.each { |this_array| this_array.update_for_parent_insert( self, local_index, local_index, object ) }\n\n return self\n \n end",
"def update\n respond_to do |format|\n if @descendant.update(descendant_params)\n format.html { redirect_to @descendant, notice: 'Descendant was successfully updated.' }\n format.json { render :show, status: :ok, location: @descendant }\n else\n format.html { render :edit }\n format.json { render json: @descendant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quest_tree = QuestTree.find(params[:id])\n\n respond_to do |format|\n if @quest_tree.update_attributes(params[:quest_tree])\n format.html { redirect_to @quest_tree, notice: 'Quest tree was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quest_tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @monitor_child_relationship = MonitorChildRelationship.find(params[:id])\n\n respond_to do |format|\n if @monitor_child_relationship.update_attributes(params[:monitor_child_relationship])\n format.html { redirect_to @monitor_child_relationship, notice: 'Monitor child relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @monitor_child_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @child_model = ChildModel.find(params[:id])\n\n respond_to do |format|\n if @child_model.update_attributes(params[:child_model])\n flash[:notice] = 'ChildModel was successfully updated.'\n format.html { redirect_to(@child_model) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @child_model.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_for_parent_set( parent_array, parent_index, object )\n \n parent_local_map = @cascade_controller.parent_local_map( parent_array )\n \n if @cascade_controller.parent_controls_parent_index?( parent_array, parent_index, parent_local_map ) or\n parent_index >= parent_local_map.size\n local_index = @cascade_controller.parent_set( parent_array, parent_index )\n undecorated_set( local_index, nil )\n @children.each { |this_array| this_array.update_for_parent_set( local_index, object ) }\n end\n \n return self\n\n end",
"def update\n authorize! :manage, @node\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to @node, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update_and_save\n self.last_update = Time.now\n self.save!\n\n self.parents.each do |parent|\n parent.update_and_save\n end\n end",
"def update\n @obj = Node.find(params[:id])\n\n respond_to do |format|\n if @obj.update_attributes(params[:node])\n format.html { redirect_to @obj, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @obj.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_subtree\n children.find_all {|child| child.kind_of?(NonLeafNode)}.each do |child|\n child.update_subtree\n end\n update_shash(false)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n if @post.parent_id?\n parent_post = Post.find(@post.parent_id)\n parent_post.updated_at = @post.updated_at\n parent_post.save\n format.html { redirect_to parent_post, notice: 'Post was successfully created.' }\n format.json { head :no_content }\n else\n #flash[:notice] = \"Successfully created post.\"\n #redirect_to \"/posts\"\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fieldset_child = DynamicFieldsets::FieldsetChild.find(params[:id])\n respond_to do |format|\n if @fieldset_child.update_attributes(params[:dynamic_fieldsets_fieldset_child])\n format.html { redirect_to(dynamic_fieldsets_children_dynamic_fieldsets_fieldset_path(@fieldset_child.root_fieldset), :notice => \"Successfully updated a child\")}\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update_child_devices\n if self.parent_id.blank? && !['assigned', 'instock'].include?(self.status)\n params_attr = {status: 'instock', parent_id: nil} \n else\n params_attr = {status: self.status, parent_id: self.id}\n end\n self.child_devices.update_all(params_attr)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @derived_struct_data = args[:derived_struct_data] if args.key?(:derived_struct_data)\n @id = args[:id] if args.key?(:id)\n @json_data = args[:json_data] if args.key?(:json_data)\n @name = args[:name] if args.key?(:name)\n @parent_document_id = args[:parent_document_id] if args.key?(:parent_document_id)\n @schema_id = args[:schema_id] if args.key?(:schema_id)\n @struct_data = args[:struct_data] if args.key?(:struct_data)\n end",
"def update\n respond_to do |format|\n if @adult_children_trait.update(adult_children_trait_params)\n format.html { redirect_to @adult_children_trait, notice: 'Adult children trait was successfully updated.' }\n format.json { render :show, status: :ok, location: @adult_children_trait }\n else\n format.html { render :edit }\n format.json { render json: @adult_children_trait.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @child_fatality.update(child_fatality_params)\n format.html { redirect_to @child_fatality, notice: 'Child fatality was successfully updated.' }\n format.json { render :show, status: :ok, location: @child_fatality }\n else\n format.html { render :edit }\n format.json { render json: @child_fatality.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def update\n respond_to do |format|\n if @condominium_child.update(condominium_child_params)\n format.json { render :show, status: :ok, object: @condominium_child }\n else\n format.json { render json: @condominium_child.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @added_parents = args[:added_parents] if args.key?(:added_parents)\n @removed_parents = args[:removed_parents] if args.key?(:removed_parents)\n end",
"def update\n\n @bookid = params[:id]\n @childid = params[:hire][:childid]\n\n respond_to do |format|\n if @hire.update(hire_params)\n format.html { redirect_to @hire, notice: \"Updated! Nice work.\" }\n format.js.coffee { }\n format.json { render :show, status: :ok, location: @hire }\n else\n format.html { render :edit }\n format.json { render json: @hire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @index_of_sub_tree_with_splitting_feature = args[:index_of_sub_tree_with_splitting_feature] if args.key?(:index_of_sub_tree_with_splitting_feature)\n @index_of_sub_tree_without_splitting_feature = args[:index_of_sub_tree_without_splitting_feature] if args.key?(:index_of_sub_tree_without_splitting_feature)\n @parent = args[:parent] if args.key?(:parent)\n @path_from_root = args[:path_from_root] if args.key?(:path_from_root)\n @pattern_id = args[:pattern_id] if args.key?(:pattern_id)\n @payload = args[:payload] if args.key?(:payload)\n @splitting_feature = args[:splitting_feature] if args.key?(:splitting_feature)\n @splitting_feature_score = args[:splitting_feature_score] if args.key?(:splitting_feature_score)\n end",
"def update\n # Draft or Publish buttons support\n params[:resource][:status] = 'PUBLISHED' if params[:publish_button]\n params[:resource][:status] = 'DRAFT' if params[:draft_button]\n params[:resource][:status] = 'ARCHIVED' if params[:archive_button]\n\n @resource = Resource.find(params[:id])\n @resource_type = @resource.resource_type\n Website.associate_website(@resource, session[:website])\n tree_node = params[:resource][:tree_nodes_attributes]['0']\n if tree_node\n @tree_node = TreeNode.find_by_id_and_resource_id(tree_node[:id],params[:id])\n end\n\n # # ******************\n # # Check permissions!\n # if not (@tree_node && @tree_node.can_edit?)\n # flash[:notice] = \"Access denied. User can't edit this node\"\n # redirect_to session[:referer]\n # end\n # # ******************\n\n parent_id = tree_node[:parent_id]\n unless parent_id == '0' && AuthenticationModel.current_user_is_admin?\n # parent_tree_node = TreeNode.find(parent_id)\n if not (@tree_node && @tree_node.can_edit?)\n flash[:notice] = \"Access denied. User can't create tree node\"\n redirect_to session[:referer]\n end\n end\n \n params[:resource].merge!(:updated_at => Time.now)\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to session[:referer] || :back}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" } #:text => params.inspect } # }\n format.xml { render :xml => @resource.errors.to_xml }\n end\n end\n end",
"def update\n if parent_params[:password].blank?\n parent_params.delete(:password)\n parent_params.delete(:password_confirmation)\n end\n\n successfully_updated = if needs_password?(@parent, parent_params)\n @parent.update(parent_params)\n else\n @parent.update_without_password(parent_params)\n end\n\n respond_to do |format|\n if successfully_updated\n format.html { redirect_to @parent, notice: 'Parent was successfully updated.' }\n format.json { render :show, status: :ok, location: @parent }\n else\n format.html { render :edit }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @child = args[:child] if args.key?(:child)\n @label = args[:label] if args.key?(:label)\n @phrase = args[:phrase] if args.key?(:phrase)\n end",
"def update!(**args)\n @parent_id = args[:parent_id] if args.key?(:parent_id)\n @title = args[:title] if args.key?(:title)\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def update\n @dec_form_child = DecFormChild.find(params[:id])\n\n respond_to do |format|\n if @dec_form_child.update_attributes(params[:dec_form_child])\n format.html { redirect_to @dec_form_child, notice: 'Dec form child was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dec_form_child.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7087602",
"0.6747008",
"0.65239745",
"0.6425298",
"0.64243084",
"0.64243084",
"0.64243084",
"0.6372172",
"0.6325486",
"0.6317983",
"0.62796867",
"0.6267304",
"0.62311465",
"0.62205744",
"0.60959387",
"0.6091433",
"0.6057536",
"0.6040286",
"0.6024075",
"0.6024075",
"0.6024075",
"0.6024075",
"0.6024075",
"0.6023704",
"0.60204136",
"0.60074073",
"0.5994434",
"0.59914416",
"0.59838134",
"0.5950626",
"0.5920443",
"0.5920443",
"0.59200495",
"0.5917418",
"0.59065515",
"0.58870304",
"0.5860601",
"0.5859861",
"0.58587927",
"0.58541083",
"0.5852415",
"0.58459187",
"0.5832026",
"0.5829888",
"0.58202827",
"0.5802289",
"0.579409",
"0.5785354",
"0.57504773",
"0.5745518",
"0.5735438",
"0.5733038",
"0.57064545",
"0.57033044",
"0.56995124",
"0.56993055",
"0.5698329",
"0.5696435",
"0.5692403",
"0.5668593",
"0.5667523",
"0.5667472",
"0.5662286",
"0.56597227",
"0.56495094",
"0.5630989",
"0.56283206",
"0.56221277",
"0.5616827",
"0.56101745",
"0.5588311",
"0.5586519",
"0.5583061",
"0.55803597",
"0.5572421",
"0.55656713",
"0.55656713",
"0.5557125",
"0.5555217",
"0.55487454",
"0.554146",
"0.55390006",
"0.5534551",
"0.55291927",
"0.552212",
"0.55177116",
"0.5505107",
"0.5492217",
"0.5491129",
"0.54808885",
"0.54761904",
"0.54740566",
"0.54717463",
"0.5469538",
"0.54447424",
"0.54446405",
"0.5443932",
"0.5439373",
"0.54324496"
] | 0.64609504 | 4 |
DELETE /children/1 DELETE /children/1.json | def destroy
@child.destroy
respond_to do |format|
format.html { redirect_to children_url, notice: 'Child was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n format.html { redirect_to(children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url, notice: \"Child was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url, notice: \"Child was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Child was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @descendant.destroy\n respond_to do |format|\n format.html { redirect_to descendants_url, notice: 'Descendant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @traumatized_child.destroy\n respond_to do |format|\n format.html { redirect_to traumatized_children_url, notice: \"Traumatized child was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n child = @children.delete(path.first)\n @modified = true if child\n child\n else\n tree = @children[path.first]\n raise 'Not a tree' if tree.type != :tree\n tree.delete(path[1..-1])\n end\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @miscellaneous_child = MiscellaneousChild.find(params[:id])\n @miscellaneous_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(miscellaneous_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @branch = Branch.find(params[:id])\n @parentTitle = Branch.find(params[:id]).uid\n Branch.where(parent: @parentTitle).delete_all\n @branch.destroy\n render :json => @branch.to_json\n end",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: DELETE_SUCCESS }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child_resource = ChildResource.find(params[:id])\n # require modify permissions for this object\n require_privilege(Alberich::Privilege::MODIFY, @child_resource)\n @child_resource.destroy\n\n respond_to do |format|\n format.html { redirect_to child_resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent = Parent.find(params[:id])\n @parent.destroy\n\n respond_to do |format|\n format.html { redirect_to parents_url }\n format.json { head :no_content }\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 destroy\n @tree = Tree.find(params[:id])\n @tree.destroy\n\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@parent_child.destroy\n\t\trespond_to do |format|\n\t \t\tformat.html { redirect_to parent_children_url, notice: 'Parent child was successfully destroyed.' }\n\t \t\tformat.json { head :no_content }\n\t\tend\n \tend",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leaves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @childmaster = Childmaster.find(params[:id])\n @childmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to childmasters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \[email protected]\n \trespond_to do |format|\n \t\tformat.html { redirect_to trees_url, notice: 'Arvore deletado com sucesso.' }\n \t\tformat.json { head :no_content }\n \tend\n end",
"def destroy\n @parent_of.destroy\n respond_to do |format|\n format.html { redirect_to parent_ofs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: t('common.message.destroyed_success')}\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxonomy = Taxonomy.find(params[:id])\n taxonomy_type = @taxonomy.taxonomy_type \n @taxonomy.delete_node_keep_sub_nodes\n @taxonomy.reload\n @taxonomy.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_taxonomies_url(:taxonomy_type => taxonomy_type) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy_payment_child = PharmacyPaymentChild.find(params[:id])\n @pharmacy_payment_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(pharmacy_payment_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @athletes_parent = AthletesParent.find(params[:id])\n @athletes_parent.destroy\n\n respond_to do |format|\n format.html { redirect_to(athletes_parents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ministry_child.destroy\n respond_to do |format|\n format.html { redirect_to ministry_children_url, notice: 'Ministry child was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_folder_children_request(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Delete.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n if response.code == 304.to_s\n puts \"Folder is empty. Status: #{response.code}\"\n elsif response.code == 504.to_s\n puts \"Gateway Time-out. Status: #{response.code}\"\n puts response.body\n end\n\n response.code\nend",
"def destroy\n @dec_form_child = DecFormChild.find(params[:id])\n @dec_form_child.destroy\n\n respond_to do |format|\n format.html { redirect_to dec_form_children_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @quest_tree = QuestTree.find(params[:id])\n @quest_tree.destroy\n\n respond_to do |format|\n format.html { redirect_to quest_trees_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n \n \n if @comment.has_children?\n @comment.children.each do |child|\n child.destroy\n end\n end\n @comment.destroy\n\n respond_with do |format|\n flash.now[:notice] = 'Comment was successfully deleted.'\n end\n end",
"def destroy\n @monitor_child_relationship = MonitorChildRelationship.find(params[:id])\n @monitor_child_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to monitor_child_relationships_url }\n format.json { head :no_content }\n end\n end",
"def test_nested_collection_destroy\n old_child = @parent.children.first\n childcontroller = ChildController.new(params: { id: old_child.id })\n childcontroller.invoke(:destroy)\n\n assert_equal(200, childcontroller.status, childcontroller.hash_response)\n\n @parent.reload\n\n assert_equal(%w[c2], @parent.children.order(:position).pluck(:name))\n assert_predicate(Child.where(id: old_child.id), :empty?)\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url, notice: 'Tree was successfully destroyed.' }\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 @question = Question.find(params[:id])\n @question.destroy\n @children = Question.find_all_by_parentid(params[:id])\n if @children != nil\n \tfor child in @children\n \t\tchild.destroy\n \tend\n end\n respond_to do |format|\n flash[:notice] = 'Question was successfully deleted.'\n format.html { redirect_to(:back) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_record.destroy\n respond_to do |format|\n format.html { redirect_to child_records_url, notice: 'Child record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @parent = Parent.find_by_id(params[:id])\n @parent.destroy\n\n respond_to do |format|\n format.html { redirect_to(parents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @product_tree = ProductTree.find(params[:id])\n @product_tree.destroy if @product_tree.is_childless?\n\n respond_to do |format|\n format.html { redirect_to product_trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relationship = @assembly.relationships.find(params[:id])\n child = @relationship.child\n child.used = false\n child.save\n @relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to [@plan, @assembly], notice: 'Relationship was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n family = @child.family\n @child.destroy\n respond_to do |format|\n format.html { redirect_to family, notice: tr(\"child_deleted\") }\n end\n end",
"def destroy\n @childmaster = Childmaster.find(params[:id])\n @childmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(childmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n n = Node.find_key(params[:id] || params[:name])\n render api_delete Node\n end",
"def destroy\n\t\t@parent = Parent.find(params[:id])\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to '/parent', notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def recursively_destroy!\n children.each { |c| c.recursively_destroy! }\n destroy\n end",
"def destroy\n @category = Category.by_alias params[:alias]\n raise ActionController::RoutingError, 'Not found' if @category.nil?\n\n parent_url = @category.parent_url\n @category.destroy_tree\n\n respond_to do |format|\n format.html { redirect_to parent_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def recursive_delete(path: nil)\n raise ArgumentError, \"path is a required argument\" if path.nil?\n\n result = zk.get_children(path: path)\n raise Kazoo::Error, \"Failed to list children of #{path} to delete them. Result code: #{result.fetch(:rc)}\" if result.fetch(:rc) != Zookeeper::Constants::ZOK\n\n threads = result.fetch(:children).map do |name|\n Thread.new do\n Thread.abort_on_exception = true\n recursive_delete(path: File.join(path, name))\n end\n end\n threads.each(&:join)\n\n result = zk.delete(path: path)\n raise Kazoo::Error, \"Failed to delete node #{path}. Result code: #{result.fetch(:rc)}\" if result.fetch(:rc) != Zookeeper::Constants::ZOK\n end",
"def destroy\n @fnss_simple_kary_tree.destroy\n respond_to do |format|\n format.html { redirect_to fnss_simple_kary_trees_url, notice: 'Fnss simple kary tree was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child_model = ChildModel.find(params[:id])\n @child_model.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_models_url) }\n format.xml { head :ok }\n end\n end",
"def delete_child_at(index)\n # NOTE: All deleting uses this method so that subclasses can override default behaviour when deleting a child\n @children.delete_at(index)\n end",
"def destroy\n @obj = Node.find(params[:id])\n @obj.destroy\n\n respond_to do |format|\n format.html { redirect_to :back}\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url, notice: 'Parent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find_key(params[:id] || params[:name])\n @node.destroy\n respond_to do |format|\n format.html { redirect_to deployment_path(@node.deployment_id) }\n format.json { render api_delete @node }\n end\n end",
"def destroy\n @child_fatality.destroy\n respond_to do |format|\n format.html { redirect_to child_fatalities_url, notice: 'Child fatality was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n redirect_to user_url(current_user), notice: '削除しました'\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy_children()\n # self.children.each do |c|\n # class_const = Service.class_map[c.service_id]\n # raise NoClassError.new(\"Pas de classe rattachée au service=#{c.service_id}\") if class_const.nil?\n # child = class_const[c.id]\n # child.destroy()\n # end\n end",
"def remove_child child\n @children.delete child\n end",
"def destroy\n\t\tparent = @fallacyfolder.parent\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { }\n\t\t\tformat.json { render :json => {:parent => parent.id}.to_json }\n\t\tend\n\tend",
"def destroy\n @key_donor_child.destroy\n respond_to do |format|\n format.html { redirect_to key_donor_children_url, notice: 'Key donor child was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @container = Container.get(params[:id])\n @container.destroy if(@container && [email protected]?)\n\n respond_to do |format|\n format.html { redirect_to(container_url(@container.parent.id)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n\n # # ******************\n # # Check permissions!\n # main_tree_node = @resource.tree_nodes.select{ |e| e.is_main == true }.first\n # if not (main_tree_node && main_tree_node.can_administrate?)\n # flash[:notice] = \"Access denied. User can't delete tree node\"\n # redirect_to session[:referer]\n # end\n # # ******************\n\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to session[:referer] }\n format.xml { head :ok }\n end\n end",
"def delete_children(id, tube_rack)\n @session.tube_rack_slot.dataset.filter(:tube_rack_id => id).delete\n end",
"def delete_children(id, flowcell)\n Lane::dataset(@session).filter(:flowcell_id => id).delete\n end",
"def destroy\n @child_guardian_relationship = ChildGuardianRelationship.find(params[:id])\n @child_guardian_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to child_guardian_relationships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @father = Father.find(params[:id])\n @father.destroy\n\n respond_to do |format|\n format.html { redirect_to fathers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nested_page = Nested::Page.find(params[:id])\n @nested_page.destroy\n\n respond_to do |format|\n format.html { redirect_to nested_pages_url }\n format.json { head :no_content }\n end\n end",
"def delete_relationship_of_child_with_parent(parent_ou_id, child_ou_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{parent_ou_id}/children/#{child_ou_id}\"\n _delete(path)\nend",
"def destroy\n b.node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n \n Action.log :controller => params[:controller], :action => params[:action], :target_id => params[:id], :user => current_user\n\n respond_to do |format|\n format.html { redirect_to :root, notice: 'Node was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @node\n\n @node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def delete_branch\n #we'll get all descendants by level descending order. That way we'll make sure deletion will come from children to parents\n children_to_be_deleted = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level desc\")\n children_to_be_deleted.each {|d| d.destroy}\n #now delete my self :)\n self.destroy\n end",
"def destroy\n #If image has parent, update children and vice versa\n if image.root_version? then\n newroot = image.child_versions.order(:created_at).last\n image.child_versions.delete(newroot)\n image.child_versions.each do |v| v.parent_image = newroot and v.save end\n else\n image.child_versions.each do |v| v.parent_image = image.parent_image and v.save end\n end\n\n image.destroy\n respond_to do |format|\n format.html { redirect_to images_url, notice: 'Image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_child(index)\n dup_children = children.dup\n dup_children.delete_at(index)\n emit_type(*dup_children)\n end",
"def destroy\n super\n\n @children.each do |_child_name, child_group|\n child_group.each(&:destroy)\n end\n\n @children = {}\n end",
"def destroy\n @foster_parent.destroy\n respond_to do |format|\n format.html { redirect_to foster_parents_url }\n format.json { head :no_content }\n end\n end",
"def delete_children(id, gel)\n element_dataset.filter(container_id_sym => id).delete\n end",
"def destroy\n @corporate_health_package_child = CorporateHealthPackageChild.find(params[:id])\n @corporate_health_package_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(corporate_health_package_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_path }\n format.json { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def ajax_delete_node\n\n # Get the Node from the DB\n node = Node.find(params[:node_id])\n\n # If node exits, then remove the node\n if !node.nil?\n node.destroy\n end\n\n end",
"def destroy\n @page_hierarchy.destroy\n respond_to do |format|\n format.html { redirect_to page_hierarchies_url, notice: 'Page hierarchy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three_child_history.destroy\n respond_to do |format|\n format.html { redirect_to three_child_histories_url, notice: 'Three child history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_children(id, flowcell)\n @session.flowcell_lane.dataset.filter(:flowcell_id => id).delete\n end",
"def destroy\n @ministry_child = MinistryChild.find(params[:id])\n \n redirect_id = @ministry_child.ministry_id\n @ministry_child.destroy\n \n respond_to do |format|\n format.html { redirect_to ministry_path(redirect_id) }\n format.json { head :no_content }\n end\n end"
] | [
"0.7690423",
"0.7553778",
"0.754166",
"0.7339654",
"0.7039886",
"0.7039886",
"0.68095887",
"0.67939544",
"0.6781426",
"0.6747409",
"0.67131644",
"0.67131644",
"0.6713039",
"0.6677913",
"0.667762",
"0.667456",
"0.66403186",
"0.6628512",
"0.6609712",
"0.660891",
"0.66086495",
"0.6545574",
"0.6530928",
"0.651468",
"0.6498822",
"0.6497765",
"0.6469963",
"0.64461195",
"0.64205235",
"0.6417793",
"0.6400747",
"0.63929784",
"0.6388104",
"0.63875276",
"0.63845944",
"0.6369013",
"0.6365629",
"0.6359086",
"0.6356818",
"0.635345",
"0.63515",
"0.6342332",
"0.6337743",
"0.6336979",
"0.6334274",
"0.6327439",
"0.6319878",
"0.6313386",
"0.6306602",
"0.6303897",
"0.6294284",
"0.62932044",
"0.62929255",
"0.62894577",
"0.62691826",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62570906",
"0.62463367",
"0.6243071",
"0.6237375",
"0.6223659",
"0.6223659",
"0.6200477",
"0.6199492",
"0.6198046",
"0.6193476",
"0.6191674",
"0.61908126",
"0.61835223",
"0.6181566",
"0.6176485",
"0.6175338",
"0.61704797",
"0.6170465",
"0.6168177",
"0.61643505",
"0.6161934",
"0.61529696",
"0.61503863",
"0.6149149",
"0.6143242",
"0.61337614",
"0.6130515",
"0.6107287",
"0.6105793",
"0.61033267",
"0.610195",
"0.610195",
"0.610195",
"0.61019075",
"0.6094525",
"0.6078253",
"0.60755724",
"0.6072033"
] | 0.70389456 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_child
@child = Child.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def 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 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(&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 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 setup(easy)\n super\n easy.customrequest = @verb\n end",
"def around_hooks; 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 my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def 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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.53314966",
"0.53114754",
"0.52984965",
"0.52977055",
"0.5296272",
"0.5260649",
"0.5245076",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.5235081",
"0.52321917",
"0.5228592",
"0.5220735",
"0.52198535",
"0.52139324",
"0.5208539",
"0.5206585",
"0.5178542",
"0.5175199",
"0.5173538",
"0.5167041",
"0.51614195",
"0.51577675",
"0.5153909",
"0.51528823",
"0.5152225",
"0.51429904",
"0.5141399",
"0.51345575",
"0.51145",
"0.5114052",
"0.5114052",
"0.5110216",
"0.5108656",
"0.50935394",
"0.5089196",
"0.5081936",
"0.5079627",
"0.50675833",
"0.5056105",
"0.5053687",
"0.5050475",
"0.5050475",
"0.503471",
"0.5028311",
"0.501982",
"0.50157547",
"0.5013552",
"0.50014806",
"0.50011593",
"0.49976763",
"0.4990292",
"0.4990292",
"0.49882022",
"0.4981269",
"0.49792367",
"0.49766538",
"0.4967978",
"0.49667212",
"0.4958987",
"0.49572337",
"0.49550423",
"0.4954479",
"0.4952353",
"0.494726",
"0.4944055",
"0.4935437",
"0.4931248",
"0.49283475",
"0.49281213",
"0.49268973",
"0.4921738",
"0.49204507",
"0.4918924",
"0.49182287",
"0.4916538",
"0.49158585",
"0.49156788"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def child_params
params.require(:child).permit(:id, :age, :name)
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 |
Messages to petition office share recipient, replyto and from. | def assert_default_office_mail_attributes(mail)
assert_equal ["#{@petition.subdomain}@petities.nl"], mail.reply_to
assert_equal ['[email protected]'], mail.from
assert_equal [@petition.office.email], mail.to
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_reply(from, to, title, message)\n RestClient.post API_URL+\"/messages\",\n :from => from.email,\n :to => to.email,\n :subject => \"Follow Up: UROP Application for \"+title,\n :text => message\n end",
"def reply_to_all\n message = reply\n message.to(to - [receiver] + [sender])\n message.cc(cc - [receiver])\n message.bcc(bcc - [receiver])\n message\n end",
"def reply_to_all\n message = reply\n message.to(to - [receiver] + [sender])\n message.cc(cc - [receiver])\n message.bcc(bcc - [receiver])\n message\n end",
"def reply_to_message\r\n @message = Message.find_by_id(params[:id])\r\n \r\n if [email protected]? && can_view(@message) \r\n @message.recipient = @message.sender_name\r\n @message.subject = \"Re: \" + @message.subject \r\n @message.body = \"\\n\\n___________________________\\n\" + @message.sender_name + \" wrote:\\n\\n\" + @message.body\r\n render :action => \"send_message\" \r\n else\r\n flash[:notice] = \"Please keep your eyes on your own messages.\"\r\n redirect_to :action => \"inbox\"\r\n end \r\n end",
"def reply_to_all\n message = reply\n message.cc(cc)\n message.bcc(bcc)\n message\n end",
"def share_mail(signature, target_email)\n @signature = signature\n @petition = @signature.petition\n\n @person_function = ''\n if @signature.person_function.present?\n @person_function = t('mail.mailafriend.note') + \" \\\"#{@signature.person_function}\\\"\"\n end\n\n mail(\n to: target_email,\n subject: t('mail.mailafriend.subject', title: @petition.name)\n )\n end",
"def reply_to\n (@reply_to || self.from)\n end",
"def share_welcome(sharer_id, receiver_id, share_amount)\n @user = User.find(receiver_id)\n @sharer = User.find(sharer_id)\n @share_amount = share_amount\n mail :to => recipient(@user.email), :subject => \"You are set up to receive tips shared by #{@sharer.display_name}\"\n end",
"def reply_to=(value)\n @reply_to = value\n end",
"def share_confirm(sharer_id, receiver_id, share_amount)\n @receiver = User.find(receiver_id)\n @user = User.find(sharer_id)\n @share_amount = share_amount\n mail :to => recipient(@user.email), :subject => \"#{@receiver.display_name} has accepted your shared tips\"\n end",
"def reply(content)\n @greeting = \"Hi\"\n @admin = content[:from]\n @contact = content[:to]\n @message = content[:message]\n mail to: content[:to].email, subject: \"RE: \"+content[:to].subject\n end",
"def reply_to_sender(receipt, reply_body, subject=nil, sanitize_text=true, attachment=nil)\n reply(receipt.conversation, receipt.message.sender, reply_body, subject, sanitize_text, attachment)\n end",
"def reply_to\n @reply_to\n end",
"def reply(message, to = nil)\n if to == :room\n reply_to.reply(message, nil)\n else\n reply_to.reply(message, to || private_sender)\n end\n end",
"def user_message(recip, from, from_name, message)\n recipients recip\n from from\n subject \"Message from Weefolio User #{from_name}\"\n sent_on Time.now\n body message\n end",
"def say(recipient_id, text, quick_replies = nil)\n message_options = {\n recipient: { id: recipient_id },\n message: { text: text }\n }\n if quick_replies\n message_options[:message][:quick_replies] = quick_replies\n end\n Bot.deliver(message_options, access_token: ENV['ACCESS_TOKEN'])\nend",
"def reply(conversation, recipients, reply_body, subject = nil)\n return nil if(reply_body.blank?)\n conversation.add(recipients, 'inbox')\n subject = subject || conversation.subject.sub(/^(Re: )?/, \"Re: \")\n response = Message.create({:sender => self, :conversation => conversation, :body => reply_body, :subject => subject})\n response.recipients = recipients.is_a?(Array) ? recipients : [recipients]\n response.deliver('inbox')\n conversation.add(self, 'sentbox')\n\n Delivery.create(:user => self, :message => response, :conversation => conversation, :mail_type => 'sentbox')\n return response\n end",
"def say(recipient_id, text, quick_replies = nil)\n message_options = {\n recipient: { id: recipient_id },\n message: { text: text }\n }\n\n Bot.deliver(message_options, access_token: ENV['ACCESS_TOKEN'])\nend",
"def reply\n message_body = params[\"Body\"]\n from_number = params[\"From\"]\n @recent_msg = Message.where(number: from_number).last # Get the name of this user if possible\n\n # Some random schmoe not in our db is trying to text me.\n if @recent_msg.blank?\n head 200, \"content_type\" => 'text/html'\n return\n end\n\n user = @recent_msg.user\n\n # Store reply in db and send back a simple text.\n @message = Message.new(user: user, number: from_number, text: message_body, action: 'REPLY')\n if @message.save\n boot_twilio\n sms = @client.messages.create(\n from: Rails.application.secrets.twilio_number,\n to: from_number,\n body: \"Hello from the other side! Your number is #{from_number}.\"\n )\n end\n head 200, \"content_type\" => 'text/html'\n end",
"def twilio_broadcast!(client,tos,msg)\n # spam it to others\n tos.each do |name,info|\n twilio_send_text_message!(client,info[:phone],msg)\n end\n end",
"def reply_message_email(message,receiver)\n @message = message\n @receiver = receiver\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :from => \"Panel KW Kraków <reply+#{message.conversation.code}@panel.kw.krakow.pl>\",\n :subject => @subject,\n :template_name => 'reply_message_email'\n end",
"def reply_to_sender(phone_number, msg)\n msg = msg[0..MAX_MSG_PAYLOAD-1]\n org = get_system_org\n org.send_direct(org.system_user, phone_number, msg)\n end",
"def reply\n message = self.message.class.new(:subject => \"Re: #{subject}\",\n :body => body.gsub(/^/, '> '))\n message.sender = receiver\n message.to(sender)\n message\n end",
"def reply_to_all(delivery, reply_body, subject = nil)\n msg = delivery.message\n recipients = msg.recipients.clone()\n if(msg.sender != self)\n recipients.delete(self)\n if(!recipients.include?(msg.sender))\n recipients << msg.sender\n end\n end\n return reply(delivery.conversation, recipients, reply_body, subject)\n end",
"def share\n email_regex = /\\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+\\z/\n p = params[:share]\n if p[:target_email] =~ email_regex\n ShareMailer.share_email(p).deliver\n\n redirect_to :back, notice: \"Shared with friend!\"\n else\n redirect_to :back, alert: \"Friend email address doesn't quite look like an E-mail Address!\"\n end\n end",
"def set_recipient\n end",
"def reply_to_all(receipt, reply_body, subject=nil, sanitize_text=true, attachment=nil)\n reply(receipt.conversation, receipt.message.recipients, reply_body, subject, sanitize_text, attachment)\n end",
"def share_deal(target_email, share)\n @deal = share.deal\n @user = share.user\n @share = share\n mail :to => target_email, \n :tag => \"share\",\n :subject => \"#{@user.best_name} shared a post with you on Qwiqq!\"\n end",
"def test_create_reply_to_reply_to_reply_to_standalone_message_about_nothing\r\n about = nil\r\n reply_to = messages(:matt_reply_to__kevin_reply_to__andy_to_kevin_about_nothing)\r\n send_message(@tim, @matt, reply_to, about)\r\n end",
"def reply_to_sender(phone_number, msg)\n Rails.logger.debug('TropoController::reply_to_sender')\n #get_system_org.create_gateway!.send_raw(phone_number, msg)\n @tropo.say(msg)\n end",
"def dm(message)\n raise \"Could not send message because of invalid options #{options}\" unless NOTIFICARE_SETTINGS\n recipients = NOTIFICARE_SETTINGS[\"recipients\"].split(/\\s*,\\s*/)\n username = NOTIFICARE_SETTINGS[\"username\"]\n password = NOTIFICARE_SETTINGS[\"password\"]\n recipients.each do |recipient|\n uri = \"http://#{username}:#{password}@twitter.com/direct_messages/new.json\"\n yell \"Sending #{recipient}: #{message}\"\n Net::HTTP.post_form(URI.parse(uri), {'user' => recipient, 'text' => message})\n end \nend",
"def message(message)\n subject message.subject\n reply_to message.sender.email\n recipients message.recipient.email\n sent_on Time.now\n body :message => message, :link => my_message_url(message.thread.code)\n end",
"def share_with(from, *emails)\n emails.each do |email|\n Pony.mail(:to => email, \n :from => from, \n :subject => 'Hey what do you think of this guy...', \n :body => github_cv_url)\n end\n end",
"def contact_pub_copy(n)\n @offer = n.item\n @user = n.user\n @msg = n.msg\n @trade = n.trade\n headers['X-SMTPAPI'] = '{\"category\": \"Publisher contacts offerer copy\"}'\n mail(:to => n.user.email, :subject => \"You sent a message!\", :from => 'TradeYa <[email protected]>', :content_type => \"text/html\")\n end",
"def sendMail(sender, receiver)\n self.source = sender\n sender.sent << self\n self.target = receiver\n receiver.inbox << self\n self.created_at = DateTime.now\n self.save\n end",
"def reply\n message = self.message.class.new(:subject => subject, :body => body)\n message.sender = receiver\n message.to(sender)\n message\n end",
"def reply\n message = self.class.new(:subject => subject, :body => body)\n message.sender = sender\n message.to(to)\n message\n end",
"def reply_to\n address_list_fetch('reply-to')\n end",
"def reply_to(m)\n @message_type = METHOD_RETURN\n @reply_serial = m.serial\n @destination = m.sender\n self\n end",
"def send_request(from, to, title, message)\n RestClient.post API_URL+\"/messages\",\n :from => from.email,\n :to => to.email,\n :subject => \"UROP Application for \"+title+\" from \"+from.first_name+\" \"+from.last_name,\n :text => message\n end",
"def test_create_reply_to_reply_to_standalone_message_about_kevins_review_59\r\n reply_to = messages(:tim_reply_to__andy_to_kevin_about_kevins_review_59)\r\n about = Factory :review\r\n about.user = @kevin\r\n send_message(@matt, @tim, reply_to, about)\r\n end",
"def test_create_reply_to_up_in_chain_reply_to_standalone_message_about_nothing\r\n about = nil\r\n reply_to = messages(:kevin_reply_to__andy_to_kevin_about_nothing)\r\n send_message(@tim, @kevin, reply_to, about)\r\n end",
"def ask_for_recipient\n\n end",
"def sender_or_receiver(message)\n if params[:action] == \"outbox\"\n to_user_link(message)\n # Used for both inbox and trashbin\n else\n from_user_link(message)\n end\n end",
"def recipient; end",
"def reply_meitan(reply_to_user, in_reply_to_id)\n log \"replying to meitan\"\n post_reply(reply_to_user, in_reply_to_id, random_notmeitan)\n end",
"def send_reply(conversation_id, params)\n cleaned = params.permit(:author_id,\n :sender_name,\n :subject,\n :body,\n :text,\n :attachments,\n { options: [:tags, :archive] },\n :channel_id,\n :to,\n :cc,\n :bcc)\n create_without_response(\"conversations/#{conversation_id}/messages\", cleaned)\n end",
"def reply_to_sender(delivery, reply_body, subject = nil)\n return reply(delivery.conversation, delivery.message.sender, reply_body, subject)\n end",
"def reply_to\n return @reply_to\n end",
"def send_message(from, recipients)\n self.sent = true\n self.read = true\n \n if recipients == :all\n self.peer = \"All\"\n else\n if recipients.class.to_s != \"Array\"\n recipients = [recipients]\n end\n self.peer = recipients.join(\", \")\n end \n \n if from == :system\n self.user_id = 0\n else\n sender = User.find_by_username(from)\n if sender\n self.user_id = sender.id\n else\n return\n end \n end\n if self.save\n async_send_message(self.id, recipients)\n end\n end",
"def correspond_mail(user, recipient, message, body_session, title_session)\n @recipient = recipient\n @sender = user\n @message = message\n @body_session = body_session\n @title_session = title_session\n\n mail(:to =>recipient.email, :subject => message.subject)\n\n end",
"def reply_message_email_to_user(message, receiver)\n @message = message\n @user = receiver\n @structure = message.sender.try(:structure)\n return if @structure.nil?\n mail to: @user.email,\n subject: t('mailboxer.message_mailer.subject_reply', sender: @structure.name),\n template_name: 'reply_message_email_to_user',\n reply_to: generate_reply_to('user')\n end",
"def distribute(client)\n client.account.messages.create(\n :from => '+16412438808',\n :to => contact.Phone_Number,\n :body => message.contents)\n end",
"def test_create_reply_to_reply_to_reply_to_standalone_message_about_kevins_review_59\r\n reply_to = messages(:matt_reply_to__tim_reply_to__andy_to_kevin_kevins_review_59)\r\n about = Factory :review\r\n about.user = @kevin\r\n notified_users = send_message(@kevin, @matt, reply_to, about)\r\n assert !notified_users.include?(@kevin),\r\n \"Owner of the review should not receive their own comments on the review.\"\r\n end",
"def messaging\n end",
"def mentioned\n @user = @receiver\n @notification = @user.notifications.find_by(link: @mentionable.path)\n subject = \"[FBC] #{@mentionable.where_mention}で#{@mentionable.sender.login_name}さんからメンションがありました。\"\n mail to: @user.email, subject: subject\n end",
"def reply_message_email(message,receiver)\n @message = message\n @receiver = receiver\n @conversation = @message.conversation\n\n if @conversation.reservation.present?\n @reservation = @conversation.reservation\n end\n set_subject(message)\n mail :to => receiver.send(Mailboxer.email_method, message),\n :subject => t('mailboxer.message_mailer.subject_reply', :subject => @subject),\n :template_name => 'reply_message_email'\n end",
"def mention(conversation_id, user_id, author_id)\n @conversation = Conversation.find(conversation_id)\n @user = User.find(user_id)\n @author = User.find(author_id)\n mail(:to => @user.email, :subject => _('%s mentioned you in %s on %s.') % [\n @author.full_name, @conversation.title, Founden::Config.app_name\n ])\n end",
"def test_create_reply_to_reply_to_standalone_message_about_nothing\r\n about = nil\r\n reply_to = messages(:kevin_reply_to__andy_to_kevin_about_nothing)\r\n send_message(@matt, @kevin, reply_to, about)\r\n end",
"def get_reply_to\n @reply_to\n end",
"def reply(options)\n say(\n body: options[:body],\n from: options[:to].to,\n to: options[:to].from,\n type: options[:to].type,\n )\n end",
"def email_friend(sent_to,message,subject)\n @message=message\n mail to: '[email protected],'+sent_to,:subject => subject\n end",
"def in_reply_to=(value)\n @in_reply_to = value\n end",
"def reply # acts as endpoint\n \tmessage_body = params[\"Body\"] # grab params from Twilio's request\n \tfrom_number = params[\"From\"]\n \tboot_twilio\n \tsms = @client.messages.create( # send to inbound number made by end user\n from: Rails.application.secrets.twilio_from_number,\n to: from_number,\n body: \"Hello there, thanks for texting me. Your number is #{from_number}.\"\n \t)\n end",
"def reply_to(value = nil)\n if value.nil?\n @reply_to\n else\n @reply_to = value\n end\n end",
"def send_message(to_user, content)\n from_messages.create!(to_user_id: to_user.id, content: content)\n end",
"def reply(params = {})\n fail InitWithoutBot unless @bot\n\n params[:chat] = self[:chat]['id']\n\n params[:as_plain_message] = true unless params.key? :as_plain_message\n params[:reply_to] = self[:id] unless params[:as_plain_message]\n param.delete :as_plain_message\n\n @bot.send_text params\n end",
"def on_discussion_roll_reply(opts)\n discussion_roll_mail_setup(opts)\n \n if @last_post_video_only\n verb, suffix = \"sent\", \"video\"\n else\n verb, suffix = \"replied to\", nil\n end\n @subject = subject_for(@poster_string_name, opts[:all_participants] - [opts[:posting_participant], opts[:receiving_participant]], verb, suffix)\n \n mail :from => \"\\\"Shelby Mail\\\" <#{Settings::Email.discussion_roll['from_email']}>\",\n :reply_to => \"\\\"No Reply\\\" <#{Settings::Email.discussion_roll['from_email']}>\",\n :to => opts[:receiving_participant_email_address], \n :subject => @subject\n end",
"def send_to(other_player, msg)\n\t\t\tm = GreyGoo::Message.new({ from: self, to: other_player, text: msg })\n\t\t\tm.save!\n\t\t\tother_player.send_message(m)\n\t\tend",
"def set_InReplyTo(value)\n set_input(\"InReplyTo\", value)\n end",
"def send_linked_in_message(sendto, subject, message)\n send_message({:sendto => sendto, :subject => subject, :message => message})\n end",
"def send_an_email(message, subject, to)\n message_params = {}\n message_params[:from] = 'QuikSort Bot <***@quiksort.in>'\n message_params[:to] = to\n message_params[:subject] = subject\n message_params[:text] = message\n logger.info $MG_CLIENT.send_message 'quiksort.in', message_params\nend",
"def reply(conversation, recipients, reply_body, subject=nil, sanitize_text=true, attachment=nil)\n subject = subject || \"#{conversation.subject}\"\n response = Mailboxer::MessageBuilder.new({\n :sender => self,\n :conversation => conversation,\n :recipients => recipients,\n :body => reply_body,\n :subject => subject,\n :attachment => attachment\n }).build\n\n response.recipients.delete(self)\n response.deliver true, sanitize_text\n end",
"def reply_to=( val )\n header[:reply_to] = val\n end",
"def reply\n @user = User.find(params[:id])\n @messages_reply = Message.new(:body => params[:body], :user_id => current_user.id, :user_status => \"sent\", :message_type => 'sent', :receiver_id => @user.id, :receiver_status => \"unread\")\n if @messages_reply.save\n UserMailer.message_notification(current_user, @user, @messages_reply).deliver if [email protected]_s.blank? and !EmailSetting.exists?(:user_id => @user.id, :alert_type => 'messages', :status => false)\n response_message = {:message => 'Message was successfully sent.'}\n else\n response_message = !@messages_reply.errors.empty? ? @messages_reply.errors : {:errors => 'Sending message failed.'}\n end\n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end",
"def relay(from_user, to_user_name, body, client_timestamp)\n message = { relays: [\n { from: from_user.name, body: body, client_ts: client_timestamp }] }\n @users.each do |user|\n next unless user.name == to_user_name\n session = user.session\n session.respond message if session\n end\n end",
"def send_message\n if message.present?\n sender.send_message(receiver, message, I18n.t(\"activity.verb.#{ contact_verb }.#{ receiver.subject_type }.message\", :name => sender.name))\n end\n end",
"def im(*messages)\n @@jabbers[@from].deliver @rcpt_to || @headers['To'], messages.join\n end",
"def reply(fields)\n mail = Mail.new\n\n # fill in the from address\n mail.from = fields[:from]\n\n # fill in the reply to headers\n mail.in_reply_to = self.id\n mail.references = self.id\n\n # fill in the subject from the original email\n if self.subject =~ /^re:\\s/i\n mail.subject = self.subject\n elsif self.subject\n mail.subject = 'Re: ' + self.subject\n elsif fields[:subject]\n mail.subject = fields[:subject]\n end\n\n # fill in the subject from the original email\n mail.body = fields[:body]\n\n # gather up the to, cc, and bcc addresses\n to = []\n cc = []\n bcc = []\n\n # process 'bcc' addresses on method call\n # Do this first so can suppress such addresses in To: and Cc: fields\n if fields[:bcc]\n Array(fields[:bcc]).compact.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if bcc.any? {|a| a.address == addr.address}\n bcc << addr\n end\n end\n\n # process 'to' addresses on method call\n if fields[:to]\n Array(fields[:to]).compact.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if to.any? {|a| a.address = addr.address}\n to << addr\n end\n end\n\n # process 'from' addresses from original email\n self.from.addrs.each do |addr|\n next if to.any? {|a| a.address == addr.address}\n if fields[:to]\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n else\n to << addr\n end\n end\n\n # process 'to' addresses from original email\n if self.to\n self.to.addrs.each do |addr|\n next if to.any? {|a| a.address == addr.address}\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n end\n end\n\n # process 'cc' addresses from original email\n if self.cc\n self.cc.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if to.any? {|a| a.address == addr.address}\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n end\n end\n\n # process 'cc' addresses on method call\n if fields[:cc]\n Array(fields[:cc]).compact.each do |addr|\n addr = Message.liberal_email_parser(addr) if addr.is_a? String\n next if to.any? {|a| a.address == addr.address}\n next if cc.any? {|a| a.address == addr.address}\n next if bcc.any? {|a| a.address == addr.address} # skip if already in Bcc\n cc << addr\n end\n end\n\n # reformat email addresses\n mail[:to] = to.map(&:format)\n mail[:cc] = cc.map(&:format) unless cc.empty?\n mail[:bcc] = bcc.map(&:format) unless bcc.empty?\n\n # return the resulting email\n mail\n end",
"def mentioned\n @user = @receiver\n @notification = @user.notifications.find_by(path: @mentionable.path)\n subject = \"[bootcamp] #{@mentionable.where_mention}で#{@mentionable.sender.login_name}さんからメンションがありました。\"\n mail to: @user.email, subject: subject\n end",
"def recipient_reminder(reminder, to)\n setup_reminder(reminder, to)\n @owner = reminder.owner_recipient\n mail(to: to, subject: \"Re: #{reminder.subject}\",\n reply_to: @owner, in_reply_to: \"<#{reminder.fetched_mail.message_id}>\")\n end",
"def new_message_admin(from_user, to_user, message)\n @from_user = from_user\n @to_user = to_user\n @message = message\n\n mail(:subject => \"#{@to_user.full_name} has a new message!\")\n end",
"def remote_msg(sender, body)\n add_msg(\"|#{sender}| #{body}\", :notice)\nend",
"def send_to_friend(params, template, record = nil)\n ActivityScore.boost_score(record, :email) if (record.class == Story)\n setup_email(:recipients => params[:to],\n :from => \"\\\"#{params[:from_name]}\\\"<#{params[:from]}>\",\n :from_name => params[:from_name],\n :body => render_message(\"mailer/send_to_friend/#{template}\", :record => record, :recipient => params[:to], :page =>params[:page], :body => params[:body]))\n @subject = \"#{params[:from_name]} sent you a link to #{APP_NAME}\"\n end",
"def notify_and_share_admins\n mentioned_admins.each do |mentioned|\n # Here put email \n entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true)\n if entry.valid?\n Notification.create(recipient: mentioned, actor: self.admin, action: \"shared\", notifiable: self)\n end\n end\n end",
"def send_linked_in_message!(sendto, subject, message)\n send_message!({:sendto => sendto, :subject => subject, :message => message})\n end",
"def create\n @recipients = \n if params[:_recipients].present?\n @recipients = params[:_recipients].split(',').map{ |r| Actor.find(r) }\n else\n []\n end\n\n @receipt = @actor.send_message(@recipients, params[:body], params[:subject], sanitize_text = false, attachment = nil)\n if (@receipt.errors.blank?)\n @conversation = @receipt.conversation\n flash[:success]= t('mailboxer.sent')\n redirect_to conversation_path(@conversation, :box => :sentbox)\n else\n render :action => :new\n end\n end",
"def send!(other_user, current_user, mex)\n mails.create!(receiver_id: other_user.id, sender_id:current_user.id, sender_name:current_user.name, message: mex)\n\n end",
"def talk(dest, msg, server = nil)\n privmsg_channel(server, dest: dest, msg: msg)\n end",
"def test_create_reply_to_standalone_message_about_kevins_review_59\r\n reply_to = messages(:andy_to_kevin_about_kevins_review_59)\r\n about = Factory :review\r\n about.user = @kevin\r\n send_message(@tim, @andy, reply_to, about)\r\n end",
"def create\n body = message_params[:Body]\n phone_number = message_params[:From]\n @message = Message.create(body: body, phone_number: phone_number)\n @message.reply_to_user\n head :ok\n end",
"def message_me(msg)\n @msg = msg\n mail subject: \"From: #{@msg.name} : #{@msg.email} says : #{@msg.subject}\", body: \"From: #{@msg.name} @ #{@msg.email} | Subject: #{@msg.subject} | Body of email : #{@msg.content}\"\n #@msg.content << \"From : #{@msg.name} :: Subject : #{@msg.subject}\" # previous one\n end",
"def sendChatMessage(a_to, a_text)\n\t\tp 'JabberClient.sendChatMessage'\n\tend",
"def send(fromIdUser,msg)\n #TODO : add exception for the sender!\n @userList.getcontents.each { |user| \n \n user.receiveFromChannel(@id, fromIdUser, msg)\n \n }\n end",
"def sending_message(to, msg)\n\t begin\n\t\t @client = Twilio::REST::Client.new @account_sid, @auth_token\n\t\t data = {\n\t\t\t\t:from => \"+\" + Rails.application.secrets.from_number.to_s, \n\t\t\t\t:to => to,\n\t\t\t\t:body => msg, \n\t\t\t}\n\t\t\tputs data.inspect\n\t\t\[email protected](data)\n\t\trescue\n raise \"Message not send\"\n\t\tend\n end",
"def send_to_followers(from)\n\t\ttopic = self.commentable\n\t\ttopic.users.each do |user|\n\t\t\tdeliver(\"#{from.name} posted a comment on #{topic.name}\", user, from) unless user.eql? from\n\t\tend\n\tend",
"def post_message\n raise InvalidRecipientError, \"No target conversation specified. Cannot send message.\"\n end",
"def message(receiver_uid:, content:)\n new_conversation(receiver_uid) unless conversation_exist?(receiver_uid)\n conversation = Conversation.return(u1_id: @uid, u2_id: receiver_uid)\n conversation.new_message(sender_uid: @uid, content: content)\n end",
"def broadcast_message(subject,\n message,\n recipients,\n send_to = 'PCB_Design_Tracker_Users <[email protected]>')\n\n @message = message\n\n mail( :to => send_to,\n :subject => subject,\n :cc => recipients.uniq,\n :bcc => [] #override default\n ) \n \n end",
"def send_message(other_user, room_id, content)\n from_messages.create!(to_id: other_user.id, room_id: room_id, content: content)\n end",
"def action(msg, recipient)\n recipient ||= @msg.reply_to if @msg\n @bot.action(recipient, msg)\n end"
] | [
"0.6878627",
"0.65042347",
"0.65042347",
"0.64381874",
"0.6378649",
"0.63711226",
"0.63221955",
"0.6261616",
"0.62599975",
"0.62409365",
"0.62379",
"0.620096",
"0.61982906",
"0.61939484",
"0.6179729",
"0.61725646",
"0.6101129",
"0.60994095",
"0.6079302",
"0.603338",
"0.60280395",
"0.601699",
"0.6016678",
"0.6010603",
"0.60001147",
"0.59869564",
"0.5984739",
"0.5966738",
"0.5959342",
"0.5957891",
"0.5957726",
"0.5937428",
"0.59277064",
"0.58983105",
"0.58919936",
"0.5891743",
"0.58903074",
"0.5875289",
"0.58693165",
"0.5862077",
"0.5853862",
"0.5828619",
"0.5824802",
"0.5824021",
"0.5820997",
"0.5814589",
"0.58134985",
"0.58072424",
"0.5805906",
"0.5789591",
"0.5787836",
"0.5787189",
"0.5769947",
"0.57693684",
"0.57678324",
"0.5766876",
"0.5765703",
"0.57498693",
"0.5741711",
"0.57329273",
"0.57195324",
"0.5699005",
"0.56933427",
"0.5692205",
"0.5690178",
"0.5678195",
"0.567742",
"0.567484",
"0.5670787",
"0.5664706",
"0.56603974",
"0.5645746",
"0.5640576",
"0.56388044",
"0.56233394",
"0.5620819",
"0.56034726",
"0.559659",
"0.5594363",
"0.5581275",
"0.5579048",
"0.55779994",
"0.5576778",
"0.55708075",
"0.5570807",
"0.55643386",
"0.5555258",
"0.55551666",
"0.5553892",
"0.5553191",
"0.5549065",
"0.5547631",
"0.5521748",
"0.5517325",
"0.5505549",
"0.5503684",
"0.54982007",
"0.5493557",
"0.54894763",
"0.5487016",
"0.5485953"
] | 0.0 | -1 |
Messages to petitioner share recipient and from. | def assert_default_petitioner_mail_attributes(mail)
assert_equal ['[email protected]'], mail.from
assert_equal [@petition.petitioner_email], mail.to
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def share_mail(signature, target_email)\n @signature = signature\n @petition = @signature.petition\n\n @person_function = ''\n if @signature.person_function.present?\n @person_function = t('mail.mailafriend.note') + \" \\\"#{@signature.person_function}\\\"\"\n end\n\n mail(\n to: target_email,\n subject: t('mail.mailafriend.subject', title: @petition.name)\n )\n end",
"def share_welcome(sharer_id, receiver_id, share_amount)\n @user = User.find(receiver_id)\n @sharer = User.find(sharer_id)\n @share_amount = share_amount\n mail :to => recipient(@user.email), :subject => \"You are set up to receive tips shared by #{@sharer.display_name}\"\n end",
"def recipient; end",
"def share_confirm(sharer_id, receiver_id, share_amount)\n @receiver = User.find(receiver_id)\n @user = User.find(sharer_id)\n @share_amount = share_amount\n mail :to => recipient(@user.email), :subject => \"#{@receiver.display_name} has accepted your shared tips\"\n end",
"def contact_pub_copy(n)\n @offer = n.item\n @user = n.user\n @msg = n.msg\n @trade = n.trade\n headers['X-SMTPAPI'] = '{\"category\": \"Publisher contacts offerer copy\"}'\n mail(:to => n.user.email, :subject => \"You sent a message!\", :from => 'TradeYa <[email protected]>', :content_type => \"text/html\")\n end",
"def share_with(from, *emails)\n emails.each do |email|\n Pony.mail(:to => email, \n :from => from, \n :subject => 'Hey what do you think of this guy...', \n :body => github_cv_url)\n end\n end",
"def user_message(recip, from, from_name, message)\n recipients recip\n from from\n subject \"Message from Weefolio User #{from_name}\"\n sent_on Time.now\n body message\n end",
"def set_recipient\n end",
"def share\n email_regex = /\\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+\\z/\n p = params[:share]\n if p[:target_email] =~ email_regex\n ShareMailer.share_email(p).deliver\n\n redirect_to :back, notice: \"Shared with friend!\"\n else\n redirect_to :back, alert: \"Friend email address doesn't quite look like an E-mail Address!\"\n end\n end",
"def send_reply(from, to, title, message)\n RestClient.post API_URL+\"/messages\",\n :from => from.email,\n :to => to.email,\n :subject => \"Follow Up: UROP Application for \"+title,\n :text => message\n end",
"def share_deal(target_email, share)\n @deal = share.deal\n @user = share.user\n @share = share\n mail :to => target_email, \n :tag => \"share\",\n :subject => \"#{@user.best_name} shared a post with you on Qwiqq!\"\n end",
"def send_to(other_player, msg)\n\t\t\tm = GreyGoo::Message.new({ from: self, to: other_player, text: msg })\n\t\t\tm.save!\n\t\t\tother_player.send_message(m)\n\t\tend",
"def distribute(client)\n client.account.messages.create(\n :from => '+16412438808',\n :to => contact.Phone_Number,\n :body => message.contents)\n end",
"def send_message(from, recipients)\n self.sent = true\n self.read = true\n \n if recipients == :all\n self.peer = \"All\"\n else\n if recipients.class.to_s != \"Array\"\n recipients = [recipients]\n end\n self.peer = recipients.join(\", \")\n end \n \n if from == :system\n self.user_id = 0\n else\n sender = User.find_by_username(from)\n if sender\n self.user_id = sender.id\n else\n return\n end \n end\n if self.save\n async_send_message(self.id, recipients)\n end\n end",
"def send_linked_in_message(sendto, subject, message)\n send_message({:sendto => sendto, :subject => subject, :message => message})\n end",
"def email_players(recipient, params)\n \n subject = params[:email_subject]\n @text = params[:email_text]\n @game = Game.find(params[:game_id])\n @sender = User.find(params[:sender_id])\n \n mail :to => recipient, :subject => subject\n end",
"def twilio_broadcast!(client,tos,msg)\n # spam it to others\n tos.each do |name,info|\n twilio_send_text_message!(client,info[:phone],msg)\n end\n end",
"def ask_for_recipient\n\n end",
"def other_user(user)\n message = self.messages.first\n message.sender == user ? message.recipient : message.sender\n # I FEEL THIS METHOD COULD BE REWRITTEN IN A MORE EFFICIENT AND SUGAR WAY\n end",
"def handed_over_signatories_mail(signature)\n @signature = signature\n @petition = @signature.petition\n @unique_key = url_for(\n controller: 'signatures',\n action: 'confirm',\n signature_id: @signature.unique_key)\n\n subject = t('mail.handed_over_subject', petition: @petition.name)\n mail(to: signature.person_email, subject: subject)\n end",
"def send_request(from, to, title, message)\n RestClient.post API_URL+\"/messages\",\n :from => from.email,\n :to => to.email,\n :subject => \"UROP Application for \"+title+\" from \"+from.first_name+\" \"+from.last_name,\n :text => message\n end",
"def sendMail(sender, receiver)\n self.source = sender\n sender.sent << self\n self.target = receiver\n receiver.inbox << self\n self.created_at = DateTime.now\n self.save\n end",
"def send_to_single(pars)\n @message = Message.new(pars)\n @message.sender = current_user\n if @message.save\n flash[:info] = \"Your message has been sent to #{@message.receiver.full_name}\"\n else\n flash[:error] = \"Your message could not be sent to #{@message.receiver.full_name}\"\n end\n end",
"def send_message(to_user, content)\n from_messages.create!(to_user_id: to_user.id, content: content)\n end",
"def send_linked_in_message!(sendto, subject, message)\n send_message!({:sendto => sendto, :subject => subject, :message => message})\n end",
"def email_friend(sent_to,message,subject)\n @message=message\n mail to: '[email protected],'+sent_to,:subject => subject\n end",
"def dm(message)\n raise \"Could not send message because of invalid options #{options}\" unless NOTIFICARE_SETTINGS\n recipients = NOTIFICARE_SETTINGS[\"recipients\"].split(/\\s*,\\s*/)\n username = NOTIFICARE_SETTINGS[\"username\"]\n password = NOTIFICARE_SETTINGS[\"password\"]\n recipients.each do |recipient|\n uri = \"http://#{username}:#{password}@twitter.com/direct_messages/new.json\"\n yell \"Sending #{recipient}: #{message}\"\n Net::HTTP.post_form(URI.parse(uri), {'user' => recipient, 'text' => message})\n end \nend",
"def sender_or_receiver(message)\n if params[:action] == \"outbox\"\n to_user_link(message)\n # Used for both inbox and trashbin\n else\n from_user_link(message)\n end\n end",
"def messaging\n end",
"def remote_msg(sender, body)\n add_msg(\"|#{sender}| #{body}\", :notice)\nend",
"def send_message\n if message.present?\n sender.send_message(receiver, message, I18n.t(\"activity.verb.#{ contact_verb }.#{ receiver.subject_type }.message\", :name => sender.name))\n end\n end",
"def send!(other_user, current_user, mex)\n mails.create!(receiver_id: other_user.id, sender_id:current_user.id, sender_name:current_user.name, message: mex)\n\n end",
"def message(to, message)\n send_raw_line(\"PRIVMSG \"+to.to_s+\" :\"+message.chomp)\n end",
"def with(current_user)\n \tsender == current_user ? recipient : sender\n\tend",
"def send_to_followers(from)\n\t\ttopic = self.commentable\n\t\ttopic.users.each do |user|\n\t\t\tdeliver(\"#{from.name} posted a comment on #{topic.name}\", user, from) unless user.eql? from\n\t\tend\n\tend",
"def share_non_member(notebook, sharer, emails, message, url)\n @notebook = notebook\n @url = url.chomp('/')\n @sharer = sharer\n @message = message\n @email_needs_to_be_simplified = need_to_simplify_email?(@notebook, @message)\n mail(\n bcc: emails,\n subject: \"NBGallery notebook shared with you\"\n )\n end",
"def sendChatMessage(a_to, a_text)\n\t\tp 'JabberClient.sendChatMessage'\n\tend",
"def notify_and_share_admins\n mentioned_admins.each do |mentioned|\n # Here put email \n entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true)\n if entry.valid?\n Notification.create(recipient: mentioned, actor: self.admin, action: \"shared\", notifiable: self)\n end\n end\n end",
"def send_to_friend(params, template, record = nil)\n ActivityScore.boost_score(record, :email) if (record.class == Story)\n setup_email(:recipients => params[:to],\n :from => \"\\\"#{params[:from_name]}\\\"<#{params[:from]}>\",\n :from_name => params[:from_name],\n :body => render_message(\"mailer/send_to_friend/#{template}\", :record => record, :recipient => params[:to], :page =>params[:page], :body => params[:body]))\n @subject = \"#{params[:from_name]} sent you a link to #{APP_NAME}\"\n end",
"def receive_email\n \n \n #if one of the to addresses matches us, use that one. todo - correctly handle mulitple emails, or correctly fail\n if params[:to].match(/group\\+(\\d+)@/) && @group = Group.find($1)\n from = params[:from]\n body = params[:plain].gsub(/^On .* wrote:$\\s*(^>.*$\\s*)+/,'') #strip out replies and whatnot\n\n if @sender = @group.students.find_by_email(from)\n @group.send_message(@sender.name+\": \"+body,@sender,[@group.user])\n elsif @group.user.email==from\n @group.send_message(@group.user.display_name+\": \"+body,@group.user)\n end\n end\n render :text => 'success', :status => 200\n end",
"def correspond_mail(user, recipient, message, body_session, title_session)\n @recipient = recipient\n @sender = user\n @message = message\n @body_session = body_session\n @title_session = title_session\n\n mail(:to =>recipient.email, :subject => message.subject)\n\n end",
"def send_an_email(message, subject, to)\n message_params = {}\n message_params[:from] = 'QuikSort Bot <***@quiksort.in>'\n message_params[:to] = to\n message_params[:subject] = subject\n message_params[:text] = message\n logger.info $MG_CLIENT.send_message 'quiksort.in', message_params\nend",
"def send_message(other_user, room_id, content)\n from_messages.create!(to_id: other_user.id, room_id: room_id, content: content)\n end",
"def broadcast_message(subject,\n message,\n recipients,\n send_to = 'PCB_Design_Tracker_Users <[email protected]>')\n\n @message = message\n\n mail( :to => send_to,\n :subject => subject,\n :cc => recipients.uniq,\n :bcc => [] #override default\n ) \n \n end",
"def on_sendable(sender)\n # While sender credit is available\n # and number of sent messages is less than count\n while (sender.credit > 0) && (@sent < @count)\n # Create new message\n msg = Qpid::Proton::Message.new\n # If message content is set\n if @msg_content\n # If message content is string and contains formatting part\n if @msg_content.is_a? String and @msg_content =~ /%[0-9]*d/\n # Format message content with number of sent messages\n msg.body = sprintf(@msg_content, @sent)\n else\n # Set message content as it is\n msg.body = @msg_content\n end\n end # if\n # Set message durability\n msg.durable = @msg_durable\n # Set message TTL (ms)\n msg.ttl = @msg_ttl\n # If message correlation ID is set\n if @msg_correlation_id\n msg.correlation_id = @msg_correlation_id\n end # if\n # Set reply to address\n msg.reply_to = @msg_reply_to\n # If message group ID is set\n if @msg_group_id\n msg.group_id = @msg_group_id\n end\n # Send message\n sender.send(msg)\n # Increase number of sent messages\n @sent = @sent + 1\n if @log_msgs == \"body\"\n Formatters::BasicFormatter.new(msg).print\n elsif @log_msgs == \"dict\"\n Formatters::DictFormatter.new(msg).print\n end\n end # while\n end",
"def send_email(recipient, sender)\n @recipient = recipient\n @sender = sender\n mail(to: @recipient.email, subject: 'Wunschliste')\n end",
"def broadcast(league,message,sender,subject=nil)\n @league = league\n @sender = sender\n @message = MARKDOWN.render(message)\n\n subject = subject.blank? ? \"Important information from #{@league.display_name}\" : subject\n @subject = \"[#{SITE_NAME}] #{subject}\"\n\n ids = @league.liga_users.approved.map(&:user_id)\n bcc = User.where(id: ids).notify_league_broadcast.map{|u| \"#{u.display_name} <#{u.email}>\" }\n\n mail(to: DEFAULT_FROM_ADDRESS, bcc: bcc, subject: @subject)\n end",
"def send(fromIdUser,msg)\n #TODO : add exception for the sender!\n @userList.getcontents.each { |user| \n \n user.receiveFromChannel(@id, fromIdUser, msg)\n \n }\n end",
"def recipient(current_user)\n \tself.sender_id == current_user.id ? self.receiver : self.sender\n \tend",
"def reply_to_all\n message = reply\n message.to(to - [receiver] + [sender])\n message.cc(cc - [receiver])\n message.bcc(bcc - [receiver])\n message\n end",
"def reply_to_all\n message = reply\n message.to(to - [receiver] + [sender])\n message.cc(cc - [receiver])\n message.bcc(bcc - [receiver])\n message\n end",
"def sender\n user = User.find_by_id(sent_by)\n \"#{user.first_name} #{user.last_name}\"\n end",
"def private(msg, sender, recipient)\n recipient.sock.puts \"#{sender}: #{msg}\"\n log( \"[private] #{sender} to #{recipient}: #{msg}\")\n end",
"def new_message_admin(from_user, to_user, message)\n @from_user = from_user\n @to_user = to_user\n @message = message\n\n mail(:subject => \"#{@to_user.full_name} has a new message!\")\n end",
"def im(*messages)\n @@jabbers[@from].deliver @rcpt_to || @headers['To'], messages.join\n end",
"def show\n @sender = User.find(@message.sender_id)\n @receiver = User.find(@message.receiver_id)\n end",
"def send(recipients, message)\n players[:x].print(message) if recipients.include? :x\n players[:o].print(message) if recipients.include? :o\n print message if recipients.include? :term and send_output_to_terminal\n end",
"def reply(content)\n @greeting = \"Hi\"\n @admin = content[:from]\n @contact = content[:to]\n @message = content[:message]\n mail to: content[:to].email, subject: \"RE: \"+content[:to].subject\n end",
"def from=(address)\n self.sender = address\n end",
"def share_project(recepient, project_id, user_id)\n @project = Project.find(project_id)\n project_sponsor = ProjectSponsor.find_by_id(user_id)\n\n @sponsor_name = project_sponsor.name\n @image = @project.large_image\n @project_title = @project.project_title\n @project_id = @project.id\n @host = ActionMailer::Base.default_url_options[:host]\n @sponsor_email = project_sponsor.sponsor.email\n\n mail from: @sponsor_email, to: recepient, subject: \"Share from Crowfundproject sponsor\"\n end",
"def reply_to_message\r\n @message = Message.find_by_id(params[:id])\r\n \r\n if [email protected]? && can_view(@message) \r\n @message.recipient = @message.sender_name\r\n @message.subject = \"Re: \" + @message.subject \r\n @message.body = \"\\n\\n___________________________\\n\" + @message.sender_name + \" wrote:\\n\\n\" + @message.body\r\n render :action => \"send_message\" \r\n else\r\n flash[:notice] = \"Please keep your eyes on your own messages.\"\r\n redirect_to :action => \"inbox\"\r\n end \r\n end",
"def new_appeal(user, receiver)\n @you = receiver.name\n @friend = user.name\n mail to: receiver.email, subject: \"Someone want be your friend!\"\n end",
"def send_to_participants(owner,from)\n\t\t# send an email to the owner of the status post, unless the comment is coming from the creator\n\t\tdeliver(\"#{from.name} posted a comment on your status\", owner, from) unless owner.eql? from\n\t\t# iterate through all the collaborators and send an email to all, unless the comment is coming from the creator\n\t\tself.commentable.comments.collaborators.each do |user|\n\t\t\tunless user.eql? owner or user.eql? from\n\t\t\t\tif owner.eql? from\n\t\t\t\t\tdeliver(\"#{from.name} posted a comment on their status\", user, from) \n\t\t\t\telse\n\t\t\t\t\tdeliver(\"#{from.name} posted a comment on #{owner.name} status\", user, from) \n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def request_booking_proposed(sender, receiver)\n @url = booking_requests_path\n @sender_name = sender.username.titleize\n mail to: receiver.email,\n subject: \"fitafy Booking Request from #{sender.username}\",\n date: Time.now\n end",
"def send_to_multiple(receiver_ids, pars)\n @receivers = receiver_ids.reject(&:blank?).map { |id| User.find(id) }\n @messages = @receivers.map do |user|\n Message.create sender: current_user,\n receiver: user,\n content: pars[:content]\n end\n flash[:info] = \"Your message has been sent\"\n end",
"def broadcast_msg_from( user, msg )\n\t\tuserDesc = user.to_s\n\n\t\[email protected] do |cl|\n\t\t\tnext if cl == user\n\t\t\tcl.add_output( \"#{userDesc}>> #{msg}\" )\n\t\tend\n\tend",
"def receive_success me,member\n @by_member = member\n @amount = me.amount\n @currency = me.account.currency\n @me = me\n subjects = \"You have been sent some money\"\n mail to: me.receiver.email, subject: subjects\n #when receiver has account\n end",
"def reply_to_sender(phone_number, msg)\n msg = msg[0..MAX_MSG_PAYLOAD-1]\n org = get_system_org\n org.send_direct(org.system_user, phone_number, msg)\n end",
"def relay(from_user, to_user_name, body, client_timestamp)\n message = { relays: [\n { from: from_user.name, body: body, client_ts: client_timestamp }] }\n @users.each do |user|\n next unless user.name == to_user_name\n session = user.session\n session.respond message if session\n end\n end",
"def message_email(user, sender, message, convoID)\n \t@user = user\n \t@message = message\n \t@sender = sender\n \t@url = 'http://www.projecthelp.co/inbox/' + convoID.to_s\n\n \tmail :to\t\t=> user.email,\n :subject\t=> \"New message from \" + @sender.first_name\n end",
"def pick(gifter: nil, recipient: nil)\n #This instance variable is used to carry over to the template\n @recipient = recipient\n mail subject: \"Your Secret Santa results are in!\",\n to: gifter,\n from_name: \"Secret Santa\",\n from: \"[email protected]\"\n end",
"def invite(player, message)\n @player = player\n @message = message\n mail to: @player.email\n end",
"def mention(conversation_id, user_id, author_id)\n @conversation = Conversation.find(conversation_id)\n @user = User.find(user_id)\n @author = User.find(author_id)\n mail(:to => @user.email, :subject => _('%s mentioned you in %s on %s.') % [\n @author.full_name, @conversation.title, Founden::Config.app_name\n ])\n end",
"def message(message)\n subject message.subject\n reply_to message.sender.email\n recipients message.recipient.email\n sent_on Time.now\n body :message => message, :link => my_message_url(message.thread.code)\n end",
"def send message, targets\n end",
"def require_share_recipient\n @attributes[:require_share_recipient]\n end",
"def tellafriend (titel, werkurl, naam, email, bericht, sender, sent_at = Time.now)\n @artwork_title, @artwork_url, @message, @receiver, @sender = titel, werkurl, bericht, naam, sender\n\n @mail_content = Intmail.find_by_id(5)\n subject = @mail_content.title.sub('<sender_username>', \"#{sender.voornaam} #{sender.achternaam}\")\n mail(to: email, bcc: '[email protected]', subject: subject)\n end",
"def sharing\n collaborators = api.get_collaborators(app).body.map{|collab| collab['email']}\n target_collaborators = api.get_collaborators(target_app).body.map{|collab| collab['email']}\n\n (collaborators - target_collaborators).each do |email|\n action(\"Copying #{email} to #{target_app} collaborators\") do\n api.post_collaborator(target_app, email)\n end\n end\n end",
"def test(recipient)\n subject 'This is a test mail for you.'\n recipients recipient\n from 'Project Bordeaux No-Reply <[email protected]>'\n sent_on Time.now\n body :email => recipient, :url => FB_APP_HOME_URL\n end",
"def talk(dest, msg, server = nil)\n privmsg_channel(server, dest: dest, msg: msg)\n end",
"def reply_to_sender(phone_number, msg)\n Rails.logger.debug('TropoController::reply_to_sender')\n #get_system_org.create_gateway!.send_raw(phone_number, msg)\n @tropo.say(msg)\n end",
"def reply_to\n @reply_to\n end",
"def thank_user( from_email, to_email )\n subject = \"Thank you for requesting an invite\"\n mail(\n to: to_email,\n from: from_email,\n subject: subject\n )\n end",
"def message_me(msg)\n @msg = msg\n mail subject: \"From: #{@msg.name} : #{@msg.email} says : #{@msg.subject}\", body: \"From: #{@msg.name} @ #{@msg.email} | Subject: #{@msg.subject} | Body of email : #{@msg.content}\"\n #@msg.content << \"From : #{@msg.name} :: Subject : #{@msg.subject}\" # previous one\n end",
"def send_notification\n\t\tSingleCellMailer.share_notification(self.study.user, self).deliver_now\n\tend",
"def reply_to_all\n message = reply\n message.cc(cc)\n message.bcc(bcc)\n message\n end",
"def reply_to_sender(receipt, reply_body, subject=nil, sanitize_text=true, attachment=nil)\n reply(receipt.conversation, receipt.message.sender, reply_body, subject, sanitize_text, attachment)\n end",
"def update_sender\n if !@from_name.blank? and from_email_address and !@from_email_address.empty? and !(@from_name.to_s == @from_email_address.to_s )\n self.sender = \"#{@from_name} <#{@from_email_address}>\"\n else\n self.sender = @from_email_address.to_s\n end\n end",
"def reply_to\n (@reply_to || self.from)\n end",
"def share_project(recepient, project_id, user_id)\n @project = Project.find(project_id)\n @project_title = @project.project_title\n @project_id = @project.id\n user = User.find_by_id(user_id)\n @donator_name = \"#{user.first_name}\" + \" #{user.last_name}\"\n @image = @project.large_image\n @host = ActionMailer::Base.default_url_options[:host]\n @donor_email = user.email\n\n mail from: @donor_email, to: recepient, subject: \"Checkout The Project I Donated To\"\n end",
"def add_msg(msg, sender)\n\n @chatters.each do |chatter_id, chatter|\n if chatter_id != sender.id\n chatter.client_socket.puts \"#{sender.id} said: #{msg}\"\n end\n end\n\n end",
"def notify(recipient, users_posts)\n \n\n @recipient = recipient\n @posts = users_posts\n # @post = post\n # @creator = creator\n # @group = group\n # @post_name = post.title\n # @post_desc = post.description\n #attachments[\"\"]\n mail(:to => recipient.email, :subject => \"New Stuff Today\")\n end",
"def send_message\n if self.id != 1\n admin_sender = User.find(1)\n user_receiver = self\n message = Message.new\n message.subject = \"It's Official! You're in.\"\n message.body = \"As a member of the VVI community, you're now able to contact other volunteers directly, share your own experiences online, and stay active in our mission to make the world of international volunteering more transparent, more organized, and more excellent. \n <br /><br />We can't thank you enough for joining the cause! And we're here if you need anything.\n <br /><br />--VolunteerVoice Team\"\n message.recipient = user_receiver\n message.sender = admin_sender\n message.save\n end\n end",
"def post_message\n raise InvalidRecipientError, \"No target conversation specified. Cannot send message.\"\n end",
"def sendout\n # do tricky HL7 and PIT stuff with narrative\n for recipient in self.user.interested_parties\n if recipient.wedgetail != created_by # don't sent back to original sender\n # do tricky encryption and email stuff for recipient\n om = OutgoingMessage.new(:recipient_id=>recipient.wedgetail)\n self.outgoing_messages << om\n om.sendout recipient\n om.save!\n end\n end\n end",
"def sending_message(to, msg)\n\t begin\n\t\t @client = Twilio::REST::Client.new @account_sid, @auth_token\n\t\t data = {\n\t\t\t\t:from => \"+\" + Rails.application.secrets.from_number.to_s, \n\t\t\t\t:to => to,\n\t\t\t\t:body => msg, \n\t\t\t}\n\t\t\tputs data.inspect\n\t\t\[email protected](data)\n\t\trescue\n raise \"Message not send\"\n\t\tend\n end",
"def send_one!(recipient)\n message_data = message_data([recipient])\n @mandrill.messages.send_template(template, recipient.custom_html_data, message_data)\n end",
"def privmsg(destination, s)\n sendmsg \"PRIVMSG #{destination} :#{s}\"\n end",
"def mentioned\n @user = @receiver\n @notification = @user.notifications.find_by(link: @mentionable.path)\n subject = \"[FBC] #{@mentionable.where_mention}で#{@mentionable.sender.login_name}さんからメンションがありました。\"\n mail to: @user.email, subject: subject\n end",
"def mention_notice(user)\n \n @user = user\n mail to: user.email, subject: \"You've been Mentioned in a post!\"\n end",
"def share(artist, recipient, options={})\n post(:session, {:method => \"artist.share\", :artist => artist, :recipient => recipient}.merge(options))\n end"
] | [
"0.68873954",
"0.6824299",
"0.6693002",
"0.6665495",
"0.6573322",
"0.655986",
"0.6530265",
"0.6495105",
"0.64732164",
"0.6430664",
"0.6423017",
"0.6410572",
"0.6344357",
"0.6300223",
"0.62174165",
"0.61617494",
"0.6160349",
"0.6158979",
"0.6136039",
"0.6119723",
"0.6119417",
"0.6115715",
"0.61059666",
"0.6088392",
"0.6087286",
"0.608475",
"0.6084683",
"0.6024191",
"0.60225224",
"0.6008921",
"0.60011834",
"0.59949625",
"0.5986907",
"0.5984521",
"0.59533393",
"0.5946983",
"0.59463024",
"0.5945506",
"0.59454376",
"0.5943393",
"0.5940941",
"0.5936761",
"0.59300655",
"0.59287703",
"0.5928168",
"0.5923999",
"0.5919097",
"0.5916275",
"0.59132797",
"0.5909707",
"0.5909707",
"0.5909367",
"0.5902444",
"0.5882369",
"0.58672535",
"0.58657783",
"0.5861753",
"0.58585185",
"0.58575547",
"0.5854322",
"0.5842393",
"0.5839344",
"0.5826763",
"0.58173823",
"0.58160114",
"0.5814228",
"0.57861984",
"0.5782173",
"0.57817537",
"0.57762104",
"0.57721865",
"0.57706213",
"0.57661074",
"0.5761098",
"0.5755744",
"0.5749036",
"0.5748318",
"0.5742722",
"0.5741503",
"0.5725702",
"0.5720096",
"0.571452",
"0.57145107",
"0.5712316",
"0.5710464",
"0.57102937",
"0.57046074",
"0.57001346",
"0.5699891",
"0.56861496",
"0.5683173",
"0.5680841",
"0.5677057",
"0.5676121",
"0.5673011",
"0.567123",
"0.5661167",
"0.5660437",
"0.5656301",
"0.56443274",
"0.56392366"
] | 0.0 | -1 |
Allow us to create virtual resources Generally, in plugins This sets a virtual resource against the Resource class Example: virtual_resource(:virtualhost) do end This defines a virtualhost as a virtual resource and consequently gives the methods has_virtualhost and does_not_have_virtualhost Note that you can define any resources within the virtual resource within the definition or the call. Call example: has_virtualhost do name "xnot.org" end Which sets the virtual host's name as xnot.org An example is included in the poolpartyapacheplugin | def virtual_resource(name=:virtual_resource, opts={}, &block)
symc = "#{name}".camelcase
eval <<-EOE
class PoolParty::Resources::#{symc} < PoolParty::Resources::Resource
end
EOE
klass = "PoolParty::Resources::#{symc}".constantize
klass.module_eval &block if block
klass.send :define_method, :virtual_resource?, Proc.new{true}
klass.send :define_method, :printable?, Proc.new{false}
klass
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virtualize(name, &block)\n self.virtuals ||= {}\n self.virtuals[name] = block\n end",
"def virtual(name, prefix, partial); end",
"def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Meli::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end",
"def add_resource(name, opts)\n if (resources[name])\n raise RuntimeError,\n \"The supplied resource '#{name}' is already added.\", caller\n end\n\n # If a procedure was passed, mount the resource with it.\n if (opts['Proc'])\n mount(name, Handler::Proc, false, opts['Proc'], opts['VirtualDirectory'])\n else\n raise ArgumentError, \"You must specify a procedure.\"\n end\n end",
"def initialize(new_resource, run_context)\n super(new_resource, run_context)\n\n if new_resource.path && new_resource.path != ''\n @path = new_resource.path\n else\n @path = \"/home/#{new_resource.owner}/newrelic_elastic_#{new_resource.application_name}\"\n end\nend",
"def xmlinstall\n\n\t\tif !File.exists?(resource[:xml_file])\n\t\t\tdebug \"Creating the XML file: %s \" % resource[:xml_file]\n\n\t\t\tcase resource[:virt_type]\n\t\t\t\twhen :openvz then\n\t\t\t\t\tdebug \"Detected hypervisor type: %s \" % resource[:virt_type]\n\t\t\t\t\ttmplcache = resource[:tmpl_cache]\n\t\t\t\t\txargs = \"-c openvz:///system define --file \"\n\t\t\t\t\tif !tmplcache.nil?\n\t\t\t\t\t\trequire \"erb\"\n\t\t\t\t\t\txmlovz = File.new(resource[:xml_file], APPEND)\n\t\t\t\t\t\txmlwrite = ERB.new(\"puppet-virt/templates/ovz_xml.erb\")\n\t\t\t\t\t\txmlovz.puts = xmlwrite.result\n\t\t\t\t\t\txmlovz.close\n\t\t\t\t\telse\n\t\t\t\t\t\tfail(\"OpenVZ Error: No template cache define!\")\n\t\t\t\t\tend\n\t\t\t\telse debug \"Detected hypervisor type: %s \" % resource[:virt_type]\n\t\t\t\t\txargs = \"-c qemu:///session define --file \"\n\t\t\t\t\trequire \"erb\"\n\t\t\t\t\txmlqemu = File.new(resource[:xml_file], APPEND)\n\t\t\t\t\txmlwrite = ERB.new(\"puppet-virt/templates/qemu_xml.erb\")\n\t\t\t\t\txmlqemu.puts = xmlwrite.result\n\t\t\t\t\txmlqemu.close\n\t\t\t\tend\n\t\n\t\t\tdebug \"Creating the domain: %s \" % [resource[:name]]\n\t\t\tvirsh xargs + resource[:xml_file]\n\t\telse\n\t\t\tfail(\"Error: XML already exists on disk \" + resource[:xml_file] + \".\" )\t\n\t\tend\n\tend",
"def create\n Puppet.debug( \"#{self.resource.type}: CREATE #{resource[:name]}\" ) \n end",
"def setup(resources) ; end",
"def virtual_path; end",
"def virtual_path; end",
"def virtual_path; end",
"def resource(name, type=nil, &block)\n resource = GenericResource.new\n resource.type = type\n resource.evaluate &block\n add_resource name, resource\n end",
"def define_new_resource(resource_name)\n name = resource_name.singularize\n resource_klass_name = name.to_s.camelcase\n klass_name = \"#{resource_klass_name}Resource\"\n return if AssociationResource.const_defined? klass_name\n\n base_klass = AssociationResource::IncludedResource\n base_klass.sub_name = name\n AssociationResource.const_set(klass_name, Class.new(base_klass))\n end",
"def define_new_resource(resource_name)\n name = resource_name.singularize\n resource_klass_name = name.to_s.camelcase\n klass_name = \"#{resource_klass_name}Resource\"\n return if AssociationResource.const_defined? klass_name\n\n base_klass = AssociationResource::IncludedResource\n base_klass.sub_name = name\n AssociationResource.const_set(klass_name, Class.new(base_klass))\n end",
"def puppet_resource_cmd\n UtilityLib::PUPPET_BINPATH + 'resource cisco_X__RESOURCE_NAME__X'\nend",
"def create!\n document_roots = ServerTools::Configuration.get(\"apache\",\"documentroots\")\n logs = join_and_expand_path(document_roots, @name, \"logs\")\n available_site = join_and_expand_path(ServerTools::Configuration.get(\"apache\",\"available_sites\"), @name)\n\n put_option(:document_root, join_and_expand_path(document_roots, @name, \"htdocs\"))\n put_option(:error_log, join_and_expand_path(logs, \"error.log\"))\n put_option(:custom_log, \"#{join_and_expand_path(logs,\"access.log\")} combined\")\n \n ServerTools::Logger.message(\"Create VirtualHost \\\"#{@name}\\\"\")\n ServerTools::Logger.message(\"Document root: #{@options[:document_root]}\")\n ServerTools::Logger.message(\"Logs: #{logs}\")\n ServerTools::Logger.message(\"Configuration: #{available_site}\")\n \n if File.exists?(available_site)\n ServerTools::Logger.error(\"Configuration does already exist!\")\n exit\n end\n if Dir.exists?(@options[:document_root])\n ServerTools::Logger.error(\"Document root does already exist!\")\n exit\n end\n \n FileUtils.mkpath(@options[:document_root])\n FileUtils.mkpath(logs)\n \n File.open(available_site, \"w\") do |f|\n f.puts %Q{\\#\n\\# #{@name} (#{available_site})\n\\#\n<VirtualHost *>\n\\tServerName\\t#{@name}\n#{parse_options(@options)}\n#{htaccess_configuration(@options)}\n</VirtualHost>\n }\n end\n \n end",
"def resource; end",
"def resource(*resources, &block); end",
"def resource\n @resource ||= resource_set.createResource(uri)\n end",
"def resources()\n end",
"def create_resource(type, title, parameters = {})\n parameters = parameters.merge(:name => title)\n resource = Puppet::Type.type(type.to_sym).new(parameters)\n catalog.add_resource(resource)\n resource\n end",
"def resources; end",
"def resources; end",
"def create(resource_name)\n if ! advance? then return self end\n @@logger.debug \"Launching resource: #{resource_name}.\"\n resource = @resourcer.get resource_name\n deps = @resourcer.get_dep(resource_name)\n deps.each {|ref| create(ref)}\n created = @mutator.create(resource_name, resource)\n created.harp_script = @harp_script\n result = {:create => resource_name}\n args = {:action => :create}\n if created.output? (args)\n result[:output] = created.make_output_token(args)\n result[:line] = @current_line\n end\n @events.push(result)\n created.save\n return self\n end",
"def resource( rsrcobj, options={} )\n\t\t\tself.log.debug \"Adding REST resource for %p\" % [ rsrcobj ]\n\t\t\toptions = self.service_options.merge( options )\n\t\t\tself.log.warn \"Options = %p\" % [ options ]\n\n\t\t\t# Add a parameter for the primary key\n\t\t\tpkey = rsrcobj.primary_key\n\t\t\tpkey_schema = rsrcobj.db_schema[ pkey.to_sym ] or\n\t\t\t\traise ArgumentError,\n\t\t\t\t\t\"cannot generate services for %p: resource has no schema\" % [ rsrcobj ]\n\t\t\tself.param( pkey, pkey_schema[:type] ) unless\n\t\t\t\tself.paramvalidator.param_names.include?( pkey.to_s )\n\n\t\t\t# Figure out what the resource name is, and make the route from it\n\t\t\tname = options[:name] || rsrcobj.implicit_table_name\n\t\t\troute = [ options[:prefix], name ].compact.join( '/' )\n\t\t\tself.log.warn \"Route is: %p\" % [[ options[:prefix], name ]]\n\n\t\t\t# Make and install handler methods\n\t\t\tself.log.debug \" adding readers\"\n\t\t\tself.add_options_handler( route, rsrcobj, options )\n\t\t\tself.add_read_handler( route, rsrcobj, options )\n\t\t\tself.add_collection_read_handler( route, rsrcobj, options )\n\n\t\t\t# Add handler methods for the mutator parts of the API unless\n\t\t\t# the resource is read-only\n\t\t\tif options[:readonly]\n\t\t\t\tself.log.debug \" skipping mutators (read-only set)\"\n\t\t\telse\n\t\t\t\tself.add_collection_create_handler( route, rsrcobj, options )\n\t\t\t\tself.add_update_handler( route, rsrcobj, options )\n\t\t\t\tself.add_collection_replace_handler( route, rsrcobj, options )\n\t\t\t\tself.add_replace_handler( route, rsrcobj, options )\n\t\t\t\tself.add_collection_deletion_handler( route, rsrcobj, options )\n\t\t\t\tself.add_delete_handler( route, rsrcobj, options )\n\t\t\tend\n\n\t\t\t# Add any composite resources based on the +rsrcobj+'s associations\n\t\t\tself.add_composite_resource_handlers( route, rsrcobj, options ) if options[:composite]\n\t\tend",
"def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Docusigner::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end",
"def create_inversion_options_resource!(name)\n enclosing_class = self\n options_resource_name = :\"#{name}_options\"\n # Create the resource class.\n @inversion_options_resource_class = Class.new(Chef::Resource) do\n include Poise::Helpers::Inversion::OptionsResource\n define_singleton_method(:name) do\n \"#{enclosing_class}::OptionsResource\"\n end\n define_singleton_method(:inversion_resource_class) do\n enclosing_class\n end\n provides(options_resource_name)\n inversion_resource(name)\n end\n # Create the provider class.\n @inversion_options_provider_class = Class.new(Chef::Provider) do\n include Poise::Helpers::Inversion::OptionsProvider\n define_singleton_method(:name) do\n \"#{enclosing_class}::OptionsProvider\"\n end\n define_singleton_method(:inversion_resource_class) do\n enclosing_class\n end\n provides(options_resource_name)\n end\n end",
"def vm(config, name, *roles)\n roles << name\n config.vm.define name do |m|\n m.vm.host_name = name\n\n #m.vm.provision :shell, :inline => \"apt-get update\"\n #m.vm.provision :shell, :inline => \"apt-get upgrade -y\"\n m.vm.provision :puppet, :module_path => \"modules\" do |puppet|\n puppet.manifests_path = \"manifests\"\n puppet.manifest_file = \"site.pp\"\n\n puppet.facter = {}\n ENV.each do |key, value|\n next unless key =~ /^FACTER_/\n puppet.facter[key.gsub(/^FACTER_/, \"\")] = value\n end\n puppet.facter[\"roles\"] = roles.join(\",\")\n end\n end\nend",
"def create_vm\n if new_resource.clone\n clone_vm\n else\n data = {\n vmid: vmid,\n bootdisk: 'virtio0',\n cores: INSTANCE_SIZE[new_resource.size]['cpu'],\n memory: INSTANCE_SIZE[new_resource.size]['memory'],\n ide2: \"#{new_resource.cdrom},media=cdrom\",\n numa: (new_resource.numa ? 1 : 0),\n ostype: get_type(new_resource.ostype),\n sockets: 1,\n virtio0: \"#{new_resource.storage}:/vm-#{vmid}-disk-1.qcow2,size=#{new_resource.disk}\"\n }.merge(new_resource.net)\n data.merge(hugepages: new_resource.hugepages) if new_resource.hugepages\n api.post(\"/nodes/#{new_resource.host}/qemu\", data)\n end\nend",
"def template_resource\n @template_resource ||= template new_resource.path do\n source new_resource.source\n cookbook new_resource.cookbook\n owner 'root'\n group 'root'\n mode 00644\n variables name: new_resource.name,\n priority: new_resource.priority,\n extensions: new_resource.extensions,\n directives: new_resource.directives\n action :nothing\n end\n end",
"def configure_base_resource\n Harvest.site = Resource.site = \"http#{'s' if @ssl}://#{@subdomain}.#{Harvest.api_domain}\"\n Harvest.subdomain = @subdomain\n Harvest.email = Resource.user = @email\n Harvest.password = Resource.password = @password\n load_resources\n end",
"def response_file\n t = Chef::Resource::Template.new(new_resource.response_file, run_context)\n t.source 'empty.erb'\n t.cookbook 'websphere'\n t.owner new_resource.owner\n t.group new_resource.group\n t.mode 00644\n t.variables data: XML.generate(new_resource)\n t.not_if {\n @current_resource.installed || new_resource.install_from == :files\n }\n t.run_action(:create)\n new_resource.response_file\n end",
"def create_esb_server (config, hostname, ip1, ip2)\n config.vm.define hostname do |esb|\n esb.vm.provider \"virtualbox\" do |provider|\n provider.customize [\"modifyvm\", :id, \"--memory\", 2048]\n end\n\n esb.vm.network \"private_network\", ip: ip1\n esb.vm.host_name = hostname\n\n esb.vm.network \"private_network\", ip: ip2\n end\nend",
"def activation_resource(sapi_name, sapi_file = nil)\n sapi_file ||= sapi_file_path(sapi_name, new_resource.priority)\n link sapi_file do\n to new_resource.path\n action :nothing\n end\n end",
"def set_resources(vm, options)\n vm.provider :virtualbox do |v|\n v.cpus = options[:cpu]\n v.memory = options[:ram]\n end\n\n # VMware Fusion\n vm.provider :vmware_fusion do |v|\n v.vmx[\"numvcpus\"] = options[:cpu]\n v.vmx[\"memsize\"] = options[:ram]\n end\nend",
"def create_resource(kind, data, body, pr)\n\n if body.size > 0\n result = parse_json(body,kind)\n data = result if !OpenNebula.is_error?(result)\n end\n\n resource = case kind\n when \"vdc\" then\n vdc_data = Hash.new\n data.each{|key,value|\n vdc_data[key.downcase.to_sym]=value if key!=\"pool\"\n }\n\n mandatory_params = [:vdcadminname, :vdcadminpass,\n :zoneid, :name, :hosts]\n\n mandatory_params.each { |param|\n if !vdc_data[param]\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. \" +\n \"Mandatory attribute '#{param}' is missing.\").to_json]\n end\n }\n\n # Check if the referenced zone exists\n zone=OZones::Zones.get(vdc_data[:zoneid])\n if !zone\n error = OZones::Error.new(\"Error: Zone \" +\n \"#{vdc_data[:zoneid]} not found, cannot create Vdc.\")\n return [404, error.to_json]\n end\n\n if (!defined? vdc_data[:force] or\n (defined? vdc_data[:force] and vdc_data[:force]!=\"yes\")) and\n !host_uniqueness?(zone, vdc_data[:hosts])\n return [403, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. \" +\n \"One or several hosts belong to a different VDC \"+\n \"and no force option was provided.\").to_json]\n end\n\n vdcadminname = vdc_data[:vdcadminname]\n vdcadminpass = vdc_data[:vdcadminpass]\n vdc_data.delete(:zoneid)\n vdc_data.delete(:vdcadminpass)\n vdc_data.delete(:force)\n\n begin\n vdc = OZones::Vdc.create(vdc_data)\n rescue Exception => e\n msg = e.message\n msg[\"accessible in OZones::Vdc\"] = \"supported.\"\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}.\" +\n \" #{msg}\").to_json]\n end\n\n zone.vdcs << vdc\n zone.save\n\n if zone.saved? and vdc.saved?\n vdcadminpass = Digest::SHA1.hexdigest(vdcadminpass)\n rc = @ocaInt.create_vdc_in_zone(zone,\n vdc,\n vdcadminname,\n vdcadminpass)\n if OpenNebula.is_error?(rc)\n vdc.destroy\n return [400, OZones::Error.new(\n \"Error: Couldn't create #{kind}. Reason: \" +\n rc.message).to_json]\n else\n vdc.acls = rc[0]\n vdc.group_id = rc[1]\n vdc.save\n\n pr.update # Rewrite proxy conf file\n return [200, vdc.to_json]\n end\n else\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}.\" +\n \" Maybe duplicated name?\").to_json]\n end\n\n when \"zone\" then\n zone_data=Hash.new\n data.each{|key,value|\n zone_data[key.downcase.to_sym]=value if key!=\"pool\"\n }\n\n mandatory_params = [:onename, :onepass, :endpoint, :name]\n\n mandatory_params.each { |param|\n if !zone_data[param]\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. \" +\n \"Mandatory attribute '#{param}' is missing.\").to_json]\n end\n }\n\n # Digest and check credentials\n zone_data[:onepass] =\n Digest::SHA1.hexdigest(zone_data[:onepass])\n\n rc = @ocaInt.check_oneadmin(zone_data[:onename],\n zone_data[:onepass],\n zone_data[:endpoint])\n\n if OpenNebula.is_error?(rc)\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. Reason: \"+\n rc.message).to_json]\n end\n\n # Create the zone\n zone = OZones::Zones.create(zone_data)\n rc = zone.save\n\n if rc\n pr.update # Rewrite proxy conf file\n return [200, zone.to_json]\n else\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind.upcase}.\" +\n \" Maybe duplicated name?\").to_json]\n end\n else\n error = OZones::Error.new(\n \"Error: #{kind.upcase} resource not supported\")\n return [404, error.to_json]\n end\n end",
"def resource(name, &block)\n # It creates a new class based on the resource name scoped tot he Scrumy module\n klass = Scrumy::Models.const_set(name.to_s.classify, Class.new(Scrumy::Models::Model))\n # Then executes the block on the class. The class provides several class\n # methods for making instances behave correctly.\n klass.class_exec &block\nend",
"def set_resource\n instance_variable_set(\"@#{resource_name}\", load_resource)\n end",
"def set_resources(vm, options)\n vm.provider :virtualbox do |v|\n v.cpus = options[:cpu]\n v.memory = options[:ram]\n end\nend",
"def method_missing(name, *args, &block)\n if args.empty? and resources and resources.has_resource?(name)\n resources[name]\n else\n super(name, *args, &block)\n end\n end",
"def virtual_file?(name); end",
"def virtual; end",
"def inherited(resource)\r\n resource.class_eval do\r\n self.versions ||= {}\r\n self.helper_object = Object.new\r\n\r\n begin\r\n plural = name.demodulize.tableize\r\n self.path = lambda { |format|\r\n begin\r\n new.polymorphic_path [:resources, plural], :format => format\r\n rescue => e\r\n nil\r\n end\r\n }\r\n self.query_template = DEFAULT_COLLECTION_QUERY_TEMPLATE.dup\r\n self.model = name.sub(/^Restful\\b/, '').constantize\r\n finder :find, :all, :first, :last\r\n helper ApplicationHelper\r\n rescue ArgumentError, NameError => e\r\n nil\r\n end\r\n\r\n Restful::Resource.classes << self\r\n end\r\n end",
"def prepare_resource(name,via = :get)\n preparation = Weary::Resource.new(name)\n preparation.via = via\n preparation.headers = @headers unless @headers.blank?\n preparation.url = \"#{@domain}#{preparation.name}.\" + (@format || :json).to_s if @domain\n preparation\n end",
"def build_resource(name,verb,&block)\n resource = prepare_resource(name,verb)\n yield resource if block_given?\n store_resource(resource)\n build_method(resource)\n resource\n end",
"def res(name)\n Chef::Resource::RubyBlock.new(name, nil)\n end",
"def create_vm(config, node_name)\n config.vm.define node_name do |vm|\n vm.vm.host_name = node_name\n vm.vm.network \"private_network\", type: \"dhcp\"\n vm.vm.box = \"ubuntu/xenial64\"\n end\nend",
"def action_create\n\n install_prerequisites\n\n node.set['pedant'][new_resource.variant]['etc_dir'] = new_resource.config_dir\n\n directory new_resource.config_dir do\n owner new_resource.user\n group new_resource.group\n mode \"0755\"\n recursive true\n end\n\n source_dir = \"#{new_resource.checkout_dir}/#{new_resource.variant}\"\n\n git new_resource.variant do\n destination source_dir\n repository \"[email protected]:opscode/#{new_resource.variant}.git\"\n revision new_resource.revision\n user new_resource.git_user\n end\n\n node.set['pedant'][new_resource.variant]['dir'] = \"/srv/#{new_resource.variant}\"\n\n link node['pedant'][new_resource.variant]['dir'] do\n to source_dir\n end\n\n template \"#{new_resource.config_dir}/pedant_config.rb\" do\n source new_resource.config_template\n owner new_resource.user\n group new_resource.group\n mode \"0644\"\n variables(new_resource.variables)\n end\n\n execute \"bundle install\" do\n cwd node['pedant'][new_resource.variant]['dir']\n # user \"opscode\"\n end\n\nend",
"def puppet_resource(opts, &block)\n if opts.is_a?(String)\n opts = {:resource => opts}\n end\n\n RSpecSystemPuppet::Helpers::PuppetResource.new(opts, self, &block)\n end",
"def provides(name, *args, &block)\n create_inversion_options_resource!(name) if inversion_options_resource\n super(name, *args, &block) if defined?(super)\n end",
"def add_resource(doc_path, res_path, data, props=nil)\n n = @content_tree.add_resource(doc_path, res_path, data)\n \n if props and (! props.empty?)\n add_metadata(resource_meta_path(doc_path, res_path), :resource, \n props, :properties)\n end\n n\n end",
"def create_virtual_host\n apache_touch_file = construct_apache_touch_file\n virtual_host_exists?(apache_touch_file)\n document_root = construct_document_root\n File.open( apache_touch_file, 'w') do |file|\n file.puts \"<VirtualHost *:80>\\n\"\n file.puts \"\\tServerName #{@app_name}\\n\"\n file.puts \"\\tRackEnv development\\n\"\n file.puts \"\\tDocumentRoot #{document_root}\\n\"\n file.puts \"</VirtualHost>\"\n end\n puts \"\\n\\nVirtual Host for #{@app_name} created.\\n\"\n end",
"def create_vhost(vhost_name)\n `curl -s -i -L \\\n -u Conn[:creds] \\\n -H 'content-type:application/json' \\\n -XPUT #{[Conn[:host_api], 'vhosts', vhost_name].join('/')}`\n end",
"def map_resource(file)\n file_handle = File.open(File.expand_path(file), 'r')\n file_handle.readlines.each do |line|\n if line =~ /#\\s@resource/\n resource_name = line.split(%r{@resource })[1].strip\n @resource = ChefObject.register(RESOURCE, resource_name, :resource)\n @resource.providers.push(self) unless @resource.providers.include?(self)\n break\n end\n end\n end",
"def cmd_resource(cmd, var = nil, what)\n puts \"HIT THE PPPPPPPPPPPPPPPPPP\"\n puts \"cmd_resource: #{cmd} | #{var} | #{what}\"\n end",
"def nova_server_finalizer(resource_name, new_resource, old_resource)\n if(old_resource['Metadata'])\n new_resource['Metadata'] = old_resource['Metadata']\n proceed = new_resource['Metadata'] &&\n new_resource['Metadata']['AWS::CloudFormation::Init'] &&\n config = new_resource['Metadata']['AWS::CloudFormation::Init']['config']\n if(proceed)\n # NOTE: This is a stupid hack since HOT gives the URL to\n # wget directly and if special characters exist, it fails\n if(files = config['files'])\n files.each do |key, args|\n if(args['source'])\n args['source'].replace(\"\\\"#{args['source']}\\\"\")\n end\n end\n end\n end\n end\n end",
"def resource_with_extensions base=nil, &declaration\n self.base_resource = base if base.present?\n resource_without_extensions base_resource do\n instance_eval(&RESOURCE_EXTENSION_BLOCK)\n instance_eval(&declaration)\n end\n end",
"def slave_xml_resource\n return @slave_xml_resource if @slave_xml_resource\n\n slave_xml = ::File.join(new_resource.remote_fs, \"#{new_resource.service_name}.xml\")\n\n @slave_xml_resource = Chef::Resource::Template.new(slave_xml, run_context)\n @slave_xml_resource.cookbook('jenkins')\n @slave_xml_resource.source('jenkins-slave.xml.erb')\n @slave_xml_resource.sensitive = true if new_resource.password\n @slave_xml_resource.variables(\n new_resource: new_resource,\n endpoint: endpoint,\n java_bin: java,\n slave_jar: slave_jar,\n jnlp_url: jnlp_url,\n jnlp_secret: jnlp_secret,\n user_domain: user_domain,\n user_account: user_account,\n user_password: new_resource.password,\n path: new_resource.path\n )\n @slave_xml_resource.notifies(:run, install_service_resource)\n @slave_xml_resource\n end",
"def resource_variables\n { :name => new_resource.service_name,\n :command => new_resource.start_command,\n :priority => new_resource.priority,\n :numprocs => 1,\n :numprocs_start => 0,\n :priority => 999,\n :autostart => true,\n :autorestart => 'unexpected',\n :startsecs => 1,\n :startretries => 3,\n :exitcodes => '0,2',\n :stopsignal => 'TERM',\n :stopwaitsecs => 10,\n :user => nil,\n :redirect_stderr => false,\n :stdout_logfile => 'AUTO',\n :stdout_logfile_maxbytes => '50MB',\n :stdout_logfile_backups => 10,\n :stdout_capture_maxbytes => 0,\n :stdout_events_enabled => 0,\n :stderr_logfile => 'AUTO',\n :stderr_logfile_maxbytes => '50MB',\n :stderr_logfile_backups => 10,\n :stderr_capture_maxbytes => 0,\n :stderr_events_enabled => false,\n :environment => nil,\n :directory => nil,\n :umask => nil,\n :serverurl => 'AUTO'\n }.merge(new_resource.variables || {})\nend",
"def set_resource(context)\n instance_variable_set(:\"@#{resource_name}\", resource_name.classify.constantize.find(context.params[:id]))\n\n unless instance_variable_get(:\"@#{resource_name}\")\n context.halt(403, { status: 'error', message: \"No #{resource_name.singularize}\" }.to_json)\n end\n end",
"def initialize(resource)\n raise Puppet::DevError, \"Got TransObject instead of Resource or hash\" if resource.is_a?(Puppet::TransObject)\n resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)\n\n # The list of parameter/property instances.\n @parameters = {}\n\n # Set the title first, so any failures print correctly.\n if resource.type.to_s.downcase.to_sym == self.class.name\n self.title = resource.title\n else\n # This should only ever happen for components\n self.title = resource.ref\n end\n\n [:file, :line, :catalog, :exported, :virtual].each do |getter|\n setter = getter.to_s + \"=\"\n if val = resource.send(getter)\n self.send(setter, val)\n end\n end\n\n @tags = resource.tags\n\n @original_parameters = resource.to_hash\n\n set_name(@original_parameters)\n\n set_default(:provider)\n\n set_parameters(@original_parameters)\n\n self.validate if self.respond_to?(:validate)\n end",
"def create_resources(project)\n raise NotImplementedError\n end",
"def create_resources(project)\n raise NotImplementedError\n end",
"def register(resource_type, filename, object)\n\t resource = resource_type.new(@server, filename, object)\n\t add(resource)\n\t resource\n\tend",
"def load_current_resource\n @current_resource = Chef::Resource::Php5FpmPool.new(@new_resource.name)\n #default entries, will override if file exists and can find a matching configuration key\n #Overwrite\n @current_resource.overwrite(@new_resource.overwrite)\n #Base Pool Configuration\n @current_resource.pool_name(@new_resource.pool_name)\n @current_resource.pool_user(@new_resource.pool_user)\n @current_resource.pool_group(@new_resource.pool_group)\n @current_resource.listen_address(@new_resource.listen_address)\n @current_resource.listen_port(@new_resource.listen_port)\n @current_resource.listen_allowed_clients(@new_resource.listen_allowed_clients) # <<<<<<<<<< Need to complete\n @current_resource.listen_owner(@new_resource.listen_owner)\n @current_resource.listen_group(@new_resource.listen_group)\n @current_resource.listen_mode(@new_resource.listen_mode)\n @current_resource.use_sockets(@new_resource.use_sockets)\n @current_resource.listen_socket(@new_resource.listen_socket)\n @current_resource.listen_backlog(@new_resource.listen_backlog)\n #PM Configuration\n @current_resource.pm(@new_resource.pm)\n @current_resource.pm_max_children(@new_resource.pm_max_children)\n @current_resource.pm_start_servers(@new_resource.pm_start_servers)\n @current_resource.pm_min_spare_servers(@new_resource.pm_min_spare_servers)\n @current_resource.pm_max_spare_servers(@new_resource.pm_max_spare_servers)\n @current_resource.pm_process_idle_timeout(@new_resource.pm_process_idle_timeout)\n @current_resource.pm_max_requests(@new_resource.pm_max_requests)\n @current_resource.pm_status_path(@new_resource.pm_status_path)\n #Ping Status\n @current_resource.ping_path(@new_resource.ping_path)\n @current_resource.ping_response(@new_resource.ping_response)\n #Logging\n @current_resource.access_format(@new_resource.access_format)\n @current_resource.request_slowlog_timeout(@new_resource.request_slowlog_timeout)\n @current_resource.request_terminate_timeout(@new_resource.request_terminate_timeout)\n @current_resource.access_log(@new_resource.access_log)\n @current_resource.slow_log(@new_resource.slow_log)\n #Misc\n @current_resource.chdir(@new_resource.chdir)\n @current_resource.chroot(@new_resource.chroot)\n @current_resource.catch_workers_output(@new_resource.catch_workers_output)\n @current_resource.security_limit_extensions(@new_resource.security_limit_extensions)\n @current_resource.rlimit_files(@new_resource.rlimit_files)\n @current_resource.rlimit_core(@new_resource.rlimit_core)\n #PHP INI\n @current_resource.php_ini_values(@new_resource.php_ini_values)\n @current_resource.php_ini_flags(@new_resource.php_ini_flags)\n @current_resource.php_ini_admin_values(@new_resource.php_ini_admin_values)\n @current_resource.php_ini_admin_flags(@new_resource.php_ini_admin_flags)\n #ENV Variables\n @current_resource.env_variables(@new_resource.env_variables)\n #Auto Resource Provisioning\n @current_resource.auto_calculate(@new_resource.auto_calculate)\n @current_resource.percent_share(@new_resource.percent_share)\n @current_resource.round_down(@new_resource.round_down)\n\n #if the file exists, load current state\n if file_exists?(@current_resource.pool_name)\n\n #Tmp hash holding for our PHP and ENV Variables\n tmp_flags = {}\n tmp_values = {}\n tmp_admin_flags = {}\n tmp_admin_values = {}\n tmp_env_variables = {}\n\n #open the file for read\n ::File.open(\"#{ node[\"php_fpm\"][\"pools_path\"] }/#{ @current_resource.pool_name }.conf\", \"r\") do |fobj|\n\n #loop through each line\n fobj.each_line do |fline|\n\n #Split the line for configuration value\n lstring = fline.split('=').at(1)\n #Get the conf variable if there is one\n #Need to extract the variable name first\n conf_file_variable = fline.scan(/\\[.*?\\]/).first\n !conf_file_variable.nil? ? conf_file_variable = conf_file_variable.sub('[', '').sub(']', '') : nil\n\n #Start base configuration\n configuration_exists(fline,\"user =\") ? @current_resource.pool_user(lstring.chomp.strip) : nil\n if configuration_exists(fline,\"group =\") && !configuration_exists(fline,\"listen.group =\")\n @current_resource.pool_group(lstring.chomp.strip)\n end\n\n #Pull address and port // If we are using sockets bypass\n if configuration_exists(fline,\"listen =\") && !@current_resource.use_sockets\n if fline =~ /.*\\..*\\..*\\..*:.*/ #do a check on a valid ip address/port combination, if no match, just set new to current\n #split away the address and port\n sp_address = lstring.split(':').at(0)\n sp_port = lstring.split(':').at(1)\n #remove newline chars and whitespacing\n @current_resource.listen_address(sp_address.chomp.strip)\n @current_resource.listen_port(sp_port.chomp.strip.to_i)\n end #don't apply the current resource | this is for a socket to ip transition | will work for modify as well\n elsif configuration_exists(fline,\"listen =\") && @current_resource.use_sockets ## Only for sockets\n @current_resource.listen_socket(lstring.chomp.strip)\n end\n\n #Finish out base configuration options\n configuration_exists(fline,\"listen.allowed_clients =\") ? @current_resource.listen_allowed_clients(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.owner =\") ? @current_resource.listen_owner(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.group =\") ? @current_resource.listen_group(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.mode =\") ? @current_resource.listen_mode(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.backlog =\") ? @current_resource.listen_backlog(lstring.chomp.strip) : nil\n\n #Start PM configuration\n configuration_exists(fline,\"pm =\") ? @current_resource.pm(lstring.chomp.strip) : nil\n configuration_exists(fline,\"pm.max_children =\") ? @current_resource.pm_max_children(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.start_servers =\") ? @current_resource.pm_start_servers(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.min_spare_servers =\") ? @current_resource.pm_min_spare_servers(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.max_spare_servers =\") ? @current_resource.pm_max_spare_servers(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.process_idle_timeout =\") ? @current_resource.pm_process_idle_timeout(lstring.chomp.strip) : nil\n configuration_exists(fline,\"pm.max_requests =\") ? @current_resource.pm_max_requests(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.status_path =\") ? @current_resource.pm_status_path(lstring.chomp.strip) : nil\n\n #Start ping status\n configuration_exists(fline,\"ping.path =\") ? @current_resource.ping_path(lstring.chomp.strip) : nil\n configuration_exists(fline,\"ping.response =\") ? @current_resource.ping_response(lstring.chomp.strip) : nil\n\n #Start logging\n configuration_exists(fline,\"access.format =\") ? @current_resource.access_format(lstring.chomp.strip) : nil\n configuration_exists(fline,\"request_slowlog_timeout =\") ? @current_resource.request_slowlog_timeout(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"request_terminate_timeout =\") ? @current_resource.request_terminate_timeout(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"access.log =\") ? @current_resource.access_log(lstring.chomp.strip) : nil\n configuration_exists(fline,\"slowlog =\") ? @current_resource.slow_log(lstring.chomp.strip) : nil\n\n #Start misc\n configuration_exists(fline,\"chdir =\") ? @current_resource.chdir(lstring.chomp.strip) : nil\n configuration_exists(fline,\"chroot =\") ? @current_resource.chroot(lstring.chomp.strip) : nil\n configuration_exists(fline,\"catch_workers_output =\") ? @current_resource.catch_workers_output(lstring.chomp.strip) : nil\n configuration_exists(fline,\"security.limit_extensions =\") ? @current_resource.security_limit_extensions(lstring.chomp.strip) : nil\n configuration_exists(fline,\"rlimit_files =\") ? @current_resource.rlimit_files(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"rlimit_core =\") ? @current_resource.rlimit_core(lstring.chomp.strip.to_i) : nil\n\n #Start PHP INI\n configuration_exists(fline,\"php_value[#{conf_file_variable}] =\") && !@current_resource.php_ini_values.nil? ? tmp_values[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n configuration_exists(fline,\"php_flag[#{conf_file_variable}] =\") && !@current_resource.php_ini_flags.nil? ? tmp_flags[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n configuration_exists(fline,\"php_admin_value[#{conf_file_variable}] =\") && !@current_resource.php_ini_admin_values.nil? ? tmp_admin_values[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n configuration_exists(fline,\"php_admin_flag[#{conf_file_variable}] =\") && !@current_resource.php_ini_admin_flags.nil? ? tmp_admin_flags[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n\n #Start ENV Variables\n configuration_exists(fline,\"env[#{conf_file_variable}] =\") && !@current_resource.env_variables.nil? ? tmp_env_variables[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n\n end\n\n #Reset current resource hashes on PHP and ENV Variables\n @current_resource.php_ini_values(tmp_values)\n @current_resource.php_ini_flags(tmp_flags)\n @current_resource.php_ini_admin_values(tmp_admin_values)\n @current_resource.php_ini_admin_flags(tmp_admin_flags)\n\n end\n\n #flag that they current file exists\n @current_resource.exists = true\n end\n\n #If we are to auto_calculate, then call the method\n if @current_resource.auto_calculate\n\n #Call auto_calculate\n auto_calculate(@new_resource.pm, (@new_resource.percent_share / 100.00), @new_resource.round_down)\n\n end\n\nend",
"def initialize(resource)\n unless resource.instance_of?(Hash)\n resource[:name] = \"PUPPET_#{resource[:name]}\"\n end\n super(resource)\n end",
"def generate_resource_detail_file!(resource_doc)\n restapi_config = YAML.load(File.read(\"#{config_dir}/restapi_doc.yml\"))\n Dir.mkdir(temp_dir + \"/resources\") if (!File.directory?(temp_dir + \"/resources\"))\n Dir.mkdir(temp_dir + \"/resources/\" + resource_doc.name) if (!File.directory?(temp_dir + \"/resources/\" + resource_doc.name))\n resource_doc.resource_methods.each do | method|\n template = IO.read(template_dir('detail.html.haml'))\n parsed = Haml::Engine.new(template).render(Object.new, :project_info => restapi_config, :name => resource_doc.name , :rmethod => method)\n File.open(temp_dir + \"/resources/\" + resource_doc.name + \"/\" + method[0] + \".html\", 'w') { |file| file.write parsed }\n end\n end",
"def create_resource(env)\n env[:ui].info(\"Creating machine\")\n\n config = env[:machine].provider_config\n vra = env[:vra]\n\n EntitledItemsCollection.fetch(env[:vra])\n .find_by_id(config.catalog_item_id)\n .request(cpus: config.cpus,\n memory: config.memory,\n requested_for: config.requested_for,\n subtenant_id: config.subtenant_id,\n lease_days: config.lease_days) { |req|\n config.extra_entries.types.each do |type|\n config.extra_entries.of_type(type).each do |k,v|\n req.set_parameter(k, type, v)\n end\n end\n }\n .join\n .machine\n end",
"def create_resource(description, opts, resource_uri = nil)\n warn \"Attempt to create sliver directly - #{description}\"\n raise OMF::SFA::AM::Rest::NotAuthorizedException.new(\"Slivers can only be created in the context of /slices/xxx/slivers\")\n end",
"def load_current_resource\n @current_resource = Chef::Resource::PerforceP4.new(new_resource.name)\n @current_resource.directory new_resource.directory\nend",
"def get_resource\n\t\t\tlogger.debug {\"ALLOCATING NEW RESOURCE --> #{ ActiveOrient.db_pool.size }\" }\n login = [ActiveOrient.default_server[:user] , ActiveOrient.default_server[:password]]\n server_adress = \"http://#{ActiveOrient.default_server[:server]}:#{ActiveOrient.default_server[:port]}\"\n\t\t\t RestClient::Resource.new(server_adress, *login)\n end",
"def resource(set_name, path, &block)\n self.class.resource(set_name, path, &block)\n end",
"def resource(*args)\n defaults = args.pop\n options = extract_options_from_args!(args) || {}\n key = []\n params = []\n \n args.each do |arg|\n if arg.is_a?(Symbol) || arg.is_a?(String)\n key << arg.to_s\n else\n key << arg.class.to_s\n params << arg\n end\n end\n \n unless route = Merb::Router.resource_routes[key]\n raise Merb::Router::GenerationError, \"Resource route not found: #{args.inspect}\"\n end\n\n params << options\n \n route.generate(params, defaults, true)\n end",
"def find_or_create_resource_for(name)\n resource_name = name.to_s.camelize\n resource_name.constantize\n rescue NameError\n resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end",
"def decorate_resource( rsrc )\n rsrc.label = self.channum\n rsrc.title = self.name\n end",
"def load_current_resource\n @my_home = new_resource.home ||\n \"#{node['user']['home_root']}/#{new_resource.username}\"\n @my_shell = new_resource.shell || node['user']['default_shell']\n @manage_home = bool(new_resource.manage_home, node['user']['manage_home'])\n @create_group = bool(new_resource.create_group, node['user']['create_group'])\n @ssh_keygen = bool(new_resource.ssh_keygen, node['user']['ssh_keygen'])\nend",
"def service_resource\n # Sanity checking\n check_signals!\n run_dummy!\n # Set defaults for sv_bin and sv_dir so we can use them in templates.\n # This follows the same lookup as in resource_runit_service.rb.\n if node['runit']\n options['sv_bin'] ||= node['runit']['sv_bin']\n options['sv_dir'] ||= node['runit']['sv_dir']\n end\n options['sv_bin'] ||= '/usr/bin/sv'\n options['sv_dir'] ||= '/etc/sv'\n # Build the runit_service resource.\n @service_resource ||= Chef::Resource::RunitService.new(new_resource.name, run_context).tap do |r|\n r.provider service_provider\n r.service_name new_resource.service_name\n r.owner 'root'\n r.group 'root'\n r.sv_bin options['sv_bin']\n r.sv_dir options['sv_dir']\n r.sv_timeout options['timeout'] if options['timeout']\n r.options options.merge(new_resource: new_resource, runit_signals: RUNIT_SIGNALS)\n r.env Mash.new(options['environment'] || new_resource.environment)\n r.run_template_name 'template'\n r.log_template_name 'template'\n # Force h and t because those map to stop_signal and reload_signal.\n control = []\n control << 'h' if new_resource.reload_signal != 'HUP'\n control += %w{d t} if new_resource.stop_signal != 'TERM'\n control += options['control'].keys if options['control']\n control.uniq!\n r.control control\n r.control_template_names Hash.new { 'template-control' } # There is no name only Zuul.\n r.cookbook 'poise-service-runit'\n # Runit only supports the equivalent of our 'immediately' mode :-/\n r.restart_on_update new_resource.restart_on_update\n end\n end",
"def render_created(resource, options = {})\n location= url_for resource\n render_resource resource, options, {:status => :created, :location => location}\n end",
"def virtualliver_only\n if !Seek::Config.is_virtualliver\n error(\"This feature is is not yet currently available\",\"invalid route\")\n return false\n end\n end",
"def target\n resource\n end",
"def action_create\n if current_resource.exists? && correct_config?\n Chef::Log.debug(\"#{new_resource} exists - skipping\")\n else\n converge_by(\"Create #{new_resource}\") do\n executor.groovy! <<-EOH.gsub(/ ^{12}/, '')\n import hudson.model.*\n import hudson.slaves.*\n import jenkins.model.*\n import jenkins.slaves.*\n\n props = []\n availability = #{convert_to_groovy(new_resource.availability)}\n usage_mode = #{convert_to_groovy(new_resource.usage_mode)}\n env_map = #{convert_to_groovy(new_resource.environment)}\n labels = #{convert_to_groovy(new_resource.labels.sort.join(\"\\s\"))}\n\n // Compute the usage mode\n if (usage_mode == 'normal') {\n mode = Node.Mode.NORMAL\n } else {\n mode = Node.Mode.EXCLUSIVE\n }\n\n // Compute the retention strategy\n if (availability == 'demand') {\n retention_strategy =\n new RetentionStrategy.Demand(\n #{new_resource.in_demand_delay},\n #{new_resource.idle_delay}\n )\n } else if (availability == 'always') {\n retention_strategy = new RetentionStrategy.Always()\n } else {\n retention_strategy = RetentionStrategy.NOOP\n }\n\n // Create an entry in the prop list for all env vars\n if (env_map != null) {\n env_vars = new hudson.EnvVars(env_map)\n entries = env_vars.collect {\n k,v -> new EnvironmentVariablesNodeProperty.Entry(k,v)\n }\n props << new EnvironmentVariablesNodeProperty(entries)\n }\n\n // Launcher\n #{launcher_groovy}\n\n // Build the slave object\n slave = new DumbSlave(\n #{convert_to_groovy(new_resource.name)},\n #{convert_to_groovy(new_resource.description)},\n #{convert_to_groovy(new_resource.remote_fs)},\n #{convert_to_groovy(new_resource.executors.to_s)},\n mode,\n labels,\n launcher,\n retention_strategy,\n props\n )\n\n // Create or update the slave in the Jenkins instance\n nodes = new ArrayList(Jenkins.instance.getNodes())\n ix = nodes.indexOf(slave)\n (ix >= 0) ? nodes.set(ix, slave) : nodes.add(slave)\n Jenkins.instance.setNodes(nodes)\n EOH\n end\n end\n end",
"def define_vm config, role, index, ip, memory = 512\n id = (index + 1).to_s.rjust(3, '0')\n config.vm.define \"#{role}_#{id}\" do |box|\n box.vm.customize [ \"modifyvm\", :id, \"--memory\", memory ]\n box.vm.box = \"centos_6_3\"\n box.vm.box_url = \"https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box\"\n box.vm.network :hostonly, \"192.168.34.#{ip}\", :netmask => \"255.255.255.0\"\n box.vm.host_name = \"#{role.downcase.gsub(/[^a-z0-9]+/, '-')}-#{id}.esi.dev\"\n #box.vm.provision :shell, :path => \"script/bootstrap-vm.sh\"\n box.vm.provision :puppet, :module_path => \"modules\" do |p|\n p.manifests_path = \"manifests\"\n p.manifest_file = \"site.pp\"\n end\n end\nend",
"def resource\n\n end",
"def add_resource_route( resource, info)\n\n namespaces = resource.split('::')\n resource_name = namespaces.pop\n h = @resources_routes\n namespaces.each do |namespace|\n h[namespace] ||= {}\n h = h[namespace]\n end\n h[resource_name] ||= []\n h[resource_name].push(info)\n\n# @resources_routes[resource.to_sym] ||= []\n# @resources_routes[resource.to_sym].push( info )\n end",
"def build_resource(hash=nil)\n super\n end",
"def set_resource_name(resource, name)\n fog_compute.tags.create :key => \"Name\", :value => name, :resource_id => resource.id\n end",
"def dynamic_resource(name, default, options = {})\n @static_resources ||= {}\n @transient_resources ||= {}\n if @load_event == :static ||\n (!@load_event && options[:adding])\n if options[:set]\n @static_resources[name] = default\n else\n @static_resources[name] ||= default\n end\n elsif @load_event == :transient\n if options[:set]\n @transient_resources[name] = default\n else\n @transient_resources[name] ||= default\n end\n else\n static = @static_resources[name] ||= default\n transient = @transient_resources[name] ||= default\n if static.respond_to?('+')\n static + transient\n else\n static.merge(transient)\n end\n end\n end",
"def add_post_deploy_resources\n if new_resource.precompile_assets\n app_local = app\n username = user_username\n ruby_block 'precompile assests' do\n block do\n require 'bundler'\n bundle_precompile_command = \"sudo su - #{username} -c 'cd #{app_local.release_path} \"\\\n \"&& source ./.env && #{app_local.bundle_binary} exec rake #{new_resource.precompile_command}'\"\n\n Bundler.clean_system(bundle_precompile_command)\n raise('Bundle pre-compile failed') unless $CHILD_STATUS.exitstatus.zero?\n end\n action :nothing\n subscribes :run, \"deploy_revision[#{new_resource.name}]\", :immediate\n end\n end\n\n super\n end",
"def setup_hypervisor\n hypervisor = nil\n params = ARGV.clone\n\n params.each_with_index do |param, index|\n case param\n when '--kvm'\n hypervisor = KVM\n ARGV.delete_at(index)\n when '--xen'\n hypervisor = XEN\n ARGV.delete_at(index)\n end\n end\n\n if !hypervisor\n case $0\n when %r{/vmm\\/kvm/}\n hypervisor=KVM\n when %r{/vmm\\/xen\\d?/}\n hypervisor=XEN\n end\n end\n\n case hypervisor.name\n when 'XEN'\n file = 'xenrc'\n vars = %w{XM_POLL XM_LIST}\n when 'KVM'\n file = 'kvmrc'\n vars = %w{LIBVIRT_URI}\n else\n return nil\n end\n\n # Load the rc variables and override the default values\n begin\n env = `. #{File.dirname($0)+\"/#{file}\"};env`\n lines = env.split(\"\\n\")\n\n vars.each do |var|\n lines.each do |line|\n if a = line.match(/^(#{var})=(.*)$/)\n hypervisor::CONF[var] = a[2]\n break\n end\n end\n end\n rescue\n end\n\n return hypervisor\nend",
"def catalog_resources\n # This method exists to supply a common interface to the puppet catalog\n # for different versions of puppet.\n @catalog.resources.map do |r|\n if r.is_a?(String)\n # puppet 0.25 and older\n resource(r)\n elsif r.is_a?(Puppet::Resource)\n # puppet 2.6 and newer\n r\n else\n raise \"Unknown resource object #{r.class}\"\n end\n end\n end",
"def create_resource(resource_path, content)\n if Object.const_defined?(:PaperclippedExtension) && resource_path.starts_with?('assets')\n Paperclipped::RadiantAssetResource.create(resource_path, content)\n else\n raise WebDavErrors::ForbiddenError\n end\n end",
"def initialize_generate\n super\n add_accessors\n @flavor.class.do_declare_resources do\n templates_if_missing << 'metadata.rb'\n templates_if_missing << 'README.md'\n templates_if_missing << 'CHANGELOG.md'\n end\n declare_gemfile\n declare_berksfile\n declare_rakefile\n declare_chefignore_patterns\n end",
"def virtual_guest_template\n template = {\n \"startCpus\" => @cores.to_i,\n \"maxMemory\" => @memory.to_i * 1024, # we let the user specify memory in GB, but the API expects maxMemory in MB.\n \"hostname\" => @hostname,\n \"domain\" => @domain,\n\n # Note : for the values below, we want to use the constants \"true\" and \"false\" not nil\n # the nil value (while false to Ruby) will not translate to XML properly\n \"localDiskFlag\" => !!@use_local_disk,\n \"hourlyBillingFlag\" => !!@hourly\n }\n\n template['dedicatedAccountHostOnlyFlag'] = true if @dedicated_host_only\n template['privateNetworkOnlyFlag'] = true if @private_network_only\n\n template['datacenter'] = {\"name\" => @datacenter.name} if @datacenter\n template['userData'] = [{'value' => @user_metadata}] if @user_metadata\n template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed\n template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI\n template['postInstallScriptUri'] = @provision_script_uri.to_s if @provision_script_uri\n template['primaryNetworkComponent'] = { \"networkVlan\" => { \"id\" => @public_vlan_id.to_i } } if @public_vlan_id\n template['primaryBackendNetworkComponent'] = { \"networkVlan\" => {\"id\" => @private_vlan_id.to_i } } if @private_vlan_id\n template['sshKeys'] = @ssh_key_ids.collect { |ssh_key_id| {'id'=> ssh_key_id.to_i } } if @ssh_key_ids\n template['supplementalCreateObjectOptions'] = @supplementalCreateObjectOptions if @supplementalCreateObjectOptions\n\n if @image_template\n template['blockDeviceTemplateGroup'] = {\"globalIdentifier\" => @image_template.global_id}\n elsif @os_reference_code\n template['operatingSystemReferenceCode'] = @os_reference_code\n end\n\n if @disks && [email protected]?\n template['blockDevices'] = []\n\n # According to the documentation for +createObject+,\n # device number 1 is reserved for the SWAP disk of the computing instance.\n # So we assign device 0 and then assign the rest starting at index 2.\n @disks.each_with_index do |disk, index|\n device_id = (index >= 1) ? index + 1 : index\n template['blockDevices'].push({\"device\" => \"#{device_id}\", \"diskImage\" => {\"capacity\" => disk}})\n end\n end\n\n template\n end",
"def slave_exe_resource\n return @slave_exe_resource if @slave_exe_resource\n slave_exe = ::File.join(new_resource.remote_fs, \"#{new_resource.service_name}.exe\")\n @slave_exe_resource = Chef::Resource::RemoteFile.new(slave_exe, run_context)\n @slave_exe_resource.source(new_resource.winsw_url)\n @slave_exe_resource.checksum(new_resource.winsw_checksum)\n @slave_exe_resource.backup(false)\n @slave_exe_resource\n end",
"def load_current_resource\n @current_resource = Chef::Resource::WebspherePackage.new(new_resource.name)\n @current_resource.installed(installed?)\n @current_resource\n end",
"def resource(uri, opts = {})\n #resource = Resource.new(self, uri, opts)\n @resources ||= {}\n @resources[uri] ||= Resource.new(self, uri, opts)\n end",
"def resource_set klass, resource_name, data\n\t\t\t\[email protected] do\n\t\t\t\t\textension = File.extname(resource_name)\n\t\t\t\t\tif @resource_extensions.include? extension\n\t\t\t\t\t\tload, save = @resource_extensions[extension]\n\t\t\t\t\t\tdata = save.call data, klass, resource_name\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tfound = false\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tnext unless p.class_exist?(klass.name)\n\t\t\t\t\t\tp.resource_set klass.name, resource_name, data\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\traise \"Class '#{klass.name}' doesn't exist!\" unless found\n\t\t\t\tend\n\t\t\tend",
"def stubs_for_resource(target = nil, current_value: true, current_resource: true, &block)\n current_value = false unless current_resource\n _chefspec_stubs_for_registry[:resource][target] << block\n stubs_for_current_value(target, &block) if current_value\n end",
"def set_virtual_context\n @virtual_context = VirtualContext.includes(:virtual_context_type).find(params[:id])\n end",
"def virtual?\n true\n end"
] | [
"0.6193856",
"0.61181206",
"0.58901125",
"0.58762294",
"0.5762889",
"0.57170725",
"0.5681904",
"0.56050956",
"0.5586102",
"0.5586102",
"0.5586102",
"0.5580727",
"0.5492244",
"0.5492244",
"0.5476484",
"0.54550904",
"0.544449",
"0.5380875",
"0.53635705",
"0.53572696",
"0.5345371",
"0.5299313",
"0.5299313",
"0.52979255",
"0.528755",
"0.52841485",
"0.5278476",
"0.52428603",
"0.52378273",
"0.5235059",
"0.52303565",
"0.52299535",
"0.5224341",
"0.5210057",
"0.5204305",
"0.5196147",
"0.517969",
"0.51727945",
"0.5167676",
"0.51645154",
"0.51592666",
"0.514198",
"0.51392543",
"0.5093987",
"0.5091454",
"0.50799847",
"0.5078554",
"0.50768214",
"0.50566113",
"0.5043059",
"0.50355196",
"0.50290245",
"0.5023176",
"0.501405",
"0.50097233",
"0.50075513",
"0.5007398",
"0.50063664",
"0.5003617",
"0.50022733",
"0.4991545",
"0.49908283",
"0.49908283",
"0.49759567",
"0.49642155",
"0.495555",
"0.49512255",
"0.49392",
"0.49373463",
"0.49344406",
"0.4932431",
"0.49269894",
"0.4911657",
"0.49060214",
"0.49008378",
"0.48917833",
"0.48895454",
"0.48840556",
"0.4881612",
"0.48798245",
"0.4879299",
"0.486506",
"0.4862067",
"0.4859875",
"0.48591956",
"0.48578897",
"0.4854298",
"0.48494738",
"0.48477957",
"0.48395064",
"0.48388132",
"0.48378477",
"0.4834308",
"0.4832141",
"0.4828954",
"0.482624",
"0.4825598",
"0.48212537",
"0.48166516",
"0.48130587"
] | 0.7368436 | 0 |
GET /comitemembers GET /comitemembers.json | def index
@comitemembers = Comitemember.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end",
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render json: \"\"\n end\n end",
"def show\n @comitemembers = Comitemember.all\n @members = Member.all\n end",
"def members_list\n @members = Member.active.ordered.all\n @user = current_user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @members }\n end\n end",
"def members\n raw_response = get_request('users/members')\n parse_response(raw_response, :users)\n end",
"def members\n return @members if @members\n @members = Client.get(\"/organizations/#{id}/members/all\").json_into(Member)\n end",
"def index\n @members = Member.members\n @participants = Member.participants\n @invited_count = Member.count\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @members = Member.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @members = Member.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @members = Member.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @members = @project.memebers\n end",
"def get_members()\n @client.make_request(:get, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/members\"))[0].map do |i|\n member = ConferenceMember.new(i, @client)\n member.conference_id = id\n member\n end\n end",
"def index\n render json: current_org.users\n end",
"def index\n @oc_members = OcMember.find(:all, :order => \"created_at ASC\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @oc_members }\n end\n end",
"def list_members\n HTTP.headers(:accept => @@accept, \"content-type\" => @@content_type).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => ENV[\"API_PASSWORD\"])\n .get(\"#{@@base_url}/users/#{self.guid}/members\").parse[\"members\"]\n end",
"def list_members(user, list)\n get(\"/#{user}/#{list}/members.json\")\n end",
"def index\n @members_clients = MembersClient.all\n end",
"def organization_members(org)\n get \"/orgs/#{org}/members\"\n end",
"def members\n response = service.get_members\n response.map do |member_data|\n Member.new(member_data)\n end\n end",
"def members\n users\n end",
"def members\n users\n end",
"def index\n @members = User::Member.all\n end",
"def members( params={} )\n members = get_connections(\"members\", params)\n return map_connections members, :to => Facebook::Graph::Generic\n end",
"def index\n @crewmembers = Crewmember.all\n end",
"def index\n @members = Member.find(:all)\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def index\n @restmembers = Restmember.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end",
"def contacts #allows the contacts page to display all the members and their contact info\n @users = User.all\n @users.each do |user|\n puts user.username\n end\n end",
"def list_memberships(user)\n get(\"/#{user}/lists/memberships.json\")\n end",
"def index\n #@account_members = AccountMember.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_members }\n end\n end",
"def conference_list_members(params)\n path = @version + '/Conference/Member/List/'\n method = 'POST'\n return request(path, method, params)\n end",
"def index\n @search = Member.search(params[:search])\n @members = @search.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def get\r\n\t\t#binding.pry\r\n\t\ttemplateFile = 'api/v1/users/members/get'\r\n\t\tunless (params[:id].to_i != 0 ) #will get the current user id if its nil or 0\r\n\t\t\tparams[:id] = session[:user].id\r\n\t\t\ttemplateFile = 'api/v1/users/members/getFull'\r\n\t\tend\r\n @responseObject = OpenStruct.new({\r\n status: true,\r\n errors: [],\r\n code: API_CODE_ERRORS['Services']['Global']['success'],\r\n objectData: OpenStruct.new(User.getFullUserData(params[:id])),\r\n timestamp: (Date.new).to_time.to_i.abs\r\n })\r\n \trender :template => templateFile ,:handlers => [:rabl], :formats => [:json]\r\n\tend",
"def index\n\t\tmembers = Member.where(team_id: params[:team_id]).all\n\t\trespond_with members\n\tend",
"def members(options = { :filter => :all })\n return @members if @members\n @members = Client.get(\"/boards/#{id}/members\", options).json_into(Member)\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def user_list\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/users/\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"Here is a list of users...\"\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def organization_public_members(org)\n get \"/orgs/#{org}/public_members\"\n end",
"def main_users\n\t\t@main_users = ParseGoLink.main_users\n\t\trender json: @main_users\n\tend",
"def index\n respond_to do |format|\n format.json do\n @memberships = @project.memberships.order('created_at DESC').limit(10)\n @memberships = @memberships.user_prefix(params[:query]) if params[:query].present?\n\n render json: decorate(@memberships)\n end\n end\n end",
"def users\n res = []\n\n tmp = GoodData.get @json['project']['links']['users']\n tmp['users'].map do |user|\n res << GoodData::Membership.new(user)\n end\n\n res\n end",
"def index\n @pe_classmembers = PeClassmember.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @pe_classmembers }\n end\n end",
"def memberships\n @list.client.get(\"#{url}/memberships\")\n end",
"def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :org_guid => HttpClient::Preconditions.assert_class_or_nil('org_guid', HttpClient::Helper.to_uuid(opts.delete(:org_guid)), String),\n :org_key => HttpClient::Preconditions.assert_class_or_nil('org_key', opts.delete(:org_key), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :role => HttpClient::Preconditions.assert_class_or_nil('role', opts.delete(:role), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/memberships\").with_query(query).get.map { |hash| Apidoc::Models::Membership.new(hash) }\n end",
"def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end",
"def retrieve\n\t\[email protected](\"c3c516a4aa\").members.retrieve\n\tend",
"def retrieve\n\t\[email protected](\"c3c516a4aa\").members.retrieve\n\tend",
"def list_users\n self.class.get('/users')\n end",
"def index\n @group_members = @client.group_members\n \n end",
"def index\n @memberships = Membership.where(user_id: current_user_id).includes(:project)\n project_array = []\n @memberships.each do |membership|\n project_array.push membership.project\n end\n json_response(project_array)\n end",
"def members_get_info(members:, trace: false)\n members_json = []\n members.each do |m|\n if m['team_member_id'] != nil\n members_json << \"{\\\".tag\\\":\\\"team_member_id\\\",\\\"team_member_id\\\":\\\"#{m['team_member_id']}\\\"}\"\n elsif m['external_id'] != nil\n members_json << \"{\\\".tag\\\":\\\"external_id\\\",\\\"external_id\\\":\\\"#{m['external_id']}\\\"}\"\n elsif m['email'] != nil\n members_json << \"{\\\".tag\\\":\\\"email\\\",\\\"email\\\":\\\"#{m['email']}\\\"}\"\n end\n end\n dropbox_query(query: '2/team/members/get_info', query_data: \"{\\\"members\\\":[#{members_json.join(',')}]}\", trace: trace)\n end",
"def users\n channel = Channel.find(params[:id])\n users = ChannelJoined.where(channel_id: params[:id])\n return json_response({\n users: users.map{|j| j.user}\n })\n end",
"def index # working\n @members = {}\n @channels = User.find(current_user.id).channels\n\n @channels.each do |channel|\n @members[channel.id] = channel.members\n end\n\n @members.keys.each do |channel_id|\n @members[channel_id] = @members[channel_id].map do |user|\n user.id\n end\n end\n end",
"def index\n if params[:data]\n @members = Member.get_members(params[:data][:kind].to_i, params[:data][:search])\n else\n @members = Member.all\n end\n\n @members = @members.paginate(:page => params[:page], :per_page => 25)\n end",
"def index\n @user = User.find(current_user.id)\n @commutes = @user.commutes \n end",
"def index\n json_response(@contacts, user_id: @user.id, status: :ok)\n end",
"def show\n respond_to do |format|\n people = @mob.user_idz.split(',').map{|i| User.find(i).name }.join(', ')\n format.json { render json: @mob.attributes.merge(people: people, users: @mob.users, date: Time.now.strftime('%-m/%-d/%Y')) }\n end\n end",
"def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end",
"def members\n fetch if @members.nil? || @members[0].nil?\n @members\n end",
"def index\n @announcements = Announcement.all\n render json: @announcements, include: [:member => {only: [:first_name, :last_name, :id]}]\n end",
"def members *args\n page, per_page, options = TibbrResource.extract_params(args, 2)\n cache_lookup(MEMBERS, true, page, per_page) do\n TibbrResource.paginate_collection(get(:members, :params => {:include_group_members => options[:include_group_members], :page => page, :per_page => per_page}), User)\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @membership }\n end\n end",
"def index\n @call_list_memberships = CallListMembership.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @call_list_memberships }\n end\n end",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end",
"def get_member_objects()\n return MicrosoftGraph::Contacts::Item::GetMemberObjects::GetMemberObjectsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end",
"def index\n @project = Project.find(current_project_id)\n @members = @project.members\n end",
"def users\n get('get_users')\n end",
"def index\n puts current_user.email\n render json: { user: current_user.email, list: [1, 2, 3] }\n\n end",
"def index\n puts current_user.email\n render json: { user: current_user.email, list: [1, 2, 3] }\n\n end",
"def members()\n return MicrosoftGraph::Me::JoinedTeams::Item::Members::MembersRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_member_of_list(user, list, member_id)\n get(\"/#{user}/#{list}/members/#{member_id}.json\")\n end",
"def index\n @memberships = @memberships.order(:site_id, :role_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @memberships }\n end\n end",
"def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end",
"def list\r\n users = User.all\r\n render json: users\r\n end",
"def account\n @member = current_user.member\n @user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def get_users(request); end",
"def members\n resp = MU::Cloud::Google.admin_directory(credentials: @credentials).list_members(@cloud_id)\n members = []\n if resp and resp.members\n members = resp.members.map { |m| m.email }\n# XXX reject status != \"ACTIVE\" ?\n end\n members\n end",
"def index\n @contacts = current_user.contacts.paginate(:page => params[:page], :per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contacts }\n end\n end",
"def all_members\n @dvd_club = DvdClub.find(params[:id])\n @users = @dvd_club.users\n end",
"def index\n @cart = current_cart\n @account_members = AccountMember.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_members }\n end\n end",
"def index\n @users = User.all\n render json: { users: @users }, methods: :visit_ids\n end",
"def show_members\n @exchange = Exchange.find(params[:id])\n @members = @exchange.users\n @exchanges = current_user.exchanges.find(:all)\n end",
"def get_users\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'client')\n render json: @project.project_users, status: 200\n else\n render json: { error: 'You must be a member of a project to see its content' }, status: :unauthorized\n end\n else\n render json: { error: \"no project found with id of #{params[:id]}\" }, status: 404\n end\n end",
"def index\n @member = Member.find(params[:member_id])\n\n @personalinfos = @member.personalinfo\n end"
] | [
"0.71432966",
"0.694869",
"0.68203515",
"0.68028605",
"0.6689545",
"0.6473378",
"0.64205074",
"0.6404864",
"0.6404864",
"0.6404864",
"0.6396081",
"0.63664275",
"0.63625294",
"0.63535416",
"0.6270629",
"0.626547",
"0.6260208",
"0.6250421",
"0.62264526",
"0.6221824",
"0.6221824",
"0.620928",
"0.6140753",
"0.6042029",
"0.60257727",
"0.6017896",
"0.6000118",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.5989341",
"0.59658754",
"0.59657556",
"0.59638625",
"0.59590715",
"0.5955197",
"0.5930486",
"0.592714",
"0.5925215",
"0.5881343",
"0.5880668",
"0.5879516",
"0.5857103",
"0.5855274",
"0.58530796",
"0.58524954",
"0.5845827",
"0.5845251",
"0.5835034",
"0.5814993",
"0.5805953",
"0.5804342",
"0.5804342",
"0.5786386",
"0.5786216",
"0.5785372",
"0.57748336",
"0.5771731",
"0.5769883",
"0.5768867",
"0.575441",
"0.5748627",
"0.57466996",
"0.5746564",
"0.5743529",
"0.57399917",
"0.5732702",
"0.57059747",
"0.57051176",
"0.5703219",
"0.5703219",
"0.5697435",
"0.5695438",
"0.56936115",
"0.5693077",
"0.56923544",
"0.5684013",
"0.56814456",
"0.56814456",
"0.5679917",
"0.56798625",
"0.5677965",
"0.5664093",
"0.5663709",
"0.5656475",
"0.5655294",
"0.5652219",
"0.56515574",
"0.5649095",
"0.56459993",
"0.5645175",
"0.5639434",
"0.5639038",
"0.5632472"
] | 0.72308576 | 0 |
GET /comitemembers/1 GET /comitemembers/1.json | def show
@comitemembers = Comitemember.all
@members = Member.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @comitemembers = Comitemember.all\n end",
"def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end",
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render json: \"\"\n end\n end",
"def members_list\n @members = Member.active.ordered.all\n @user = current_user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @members }\n end\n end",
"def index\n @members = @project.memebers\n end",
"def index\n @members = Member.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @members = Member.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @members = Member.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n render json: current_org.users\n end",
"def index\n @oc_members = OcMember.find(:all, :order => \"created_at ASC\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @oc_members }\n end\n end",
"def get\r\n\t\t#binding.pry\r\n\t\ttemplateFile = 'api/v1/users/members/get'\r\n\t\tunless (params[:id].to_i != 0 ) #will get the current user id if its nil or 0\r\n\t\t\tparams[:id] = session[:user].id\r\n\t\t\ttemplateFile = 'api/v1/users/members/getFull'\r\n\t\tend\r\n @responseObject = OpenStruct.new({\r\n status: true,\r\n errors: [],\r\n code: API_CODE_ERRORS['Services']['Global']['success'],\r\n objectData: OpenStruct.new(User.getFullUserData(params[:id])),\r\n timestamp: (Date.new).to_time.to_i.abs\r\n })\r\n \trender :template => templateFile ,:handlers => [:rabl], :formats => [:json]\r\n\tend",
"def get_members()\n @client.make_request(:get, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/members\"))[0].map do |i|\n member = ConferenceMember.new(i, @client)\n member.conference_id = id\n member\n end\n end",
"def index\n @members = Member.members\n @participants = Member.participants\n @invited_count = Member.count\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def show\n @clnmember = Clnmember.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clnmember }\n end\n end",
"def index\n @members = User::Member.all\n end",
"def members\n return @members if @members\n @members = Client.get(\"/organizations/#{id}/members/all\").json_into(Member)\n end",
"def index\n @members_clients = MembersClient.all\n end",
"def members\n raw_response = get_request('users/members')\n parse_response(raw_response, :users)\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def get_member_of_list(user, list, member_id)\n get(\"/#{user}/#{list}/members/#{member_id}.json\")\n end",
"def contacts #allows the contacts page to display all the members and their contact info\n @users = User.all\n @users.each do |user|\n puts user.username\n end\n end",
"def index\n @member = Member.find(params[:member_id])\n\n @personalinfos = @member.personalinfo\n end",
"def index\n @member = Member.find(params[:member_id])\n end",
"def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end",
"def account\n @member = current_user.member\n @user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def set_comitemember\n @comitemember = Comitemember.find(params[:id])\n end",
"def index\n @members = Member.find(:all)\n end",
"def index\n @crewmembers = Crewmember.all\n end",
"def show\n @dotsmember = Dotsmember.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dotsmember }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @membership }\n end\n end",
"def show\n respond_to do |format|\n people = @mob.user_idz.split(',').map{|i| User.find(i).name }.join(', ')\n format.json { render json: @mob.attributes.merge(people: people, users: @mob.users, date: Time.now.strftime('%-m/%-d/%Y')) }\n end\n end",
"def members\n users\n end",
"def members\n users\n end",
"def show\n @membership = Adhocracy::Membership.find(params[:id])\n\n render json: @membership\n end",
"def index\n @restmembers = Restmember.all\n end",
"def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def retrieve\n\t\[email protected](\"c3c516a4aa\").members.retrieve\n\tend",
"def retrieve\n\t\[email protected](\"c3c516a4aa\").members.retrieve\n\tend",
"def list_members(user, list)\n get(\"/#{user}/#{list}/members.json\")\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @user = User.find(current_user.id)\n @commutes = @user.commutes \n end",
"def index\n #@account_members = AccountMember.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_members }\n end\n end",
"def list_members\n HTTP.headers(:accept => @@accept, \"content-type\" => @@content_type).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => ENV[\"API_PASSWORD\"])\n .get(\"#{@@base_url}/users/#{self.guid}/members\").parse[\"members\"]\n end",
"def index\n respond_to do |format|\n format.json do\n @memberships = @project.memberships.order('created_at DESC').limit(10)\n @memberships = @memberships.user_prefix(params[:query]) if params[:query].present?\n\n render json: decorate(@memberships)\n end\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def members\n response = service.get_members\n response.map do |member_data|\n Member.new(member_data)\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def index\n @pe_classmembers = PeClassmember.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @pe_classmembers }\n end\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def show\n @membership = Membership.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @membership }\n end\n end",
"def show\n @call_list_membership = CallListMembership.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @call_list_membership }\n end\n end",
"def show\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_collaborator }\n end\n end",
"def index\n @memberships = Membership.where(user_id: current_user_id).includes(:project)\n project_array = []\n @memberships.each do |membership|\n project_array.push membership.project\n end\n json_response(project_array)\n end",
"def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :org_guid => HttpClient::Preconditions.assert_class_or_nil('org_guid', HttpClient::Helper.to_uuid(opts.delete(:org_guid)), String),\n :org_key => HttpClient::Preconditions.assert_class_or_nil('org_key', opts.delete(:org_key), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :role => HttpClient::Preconditions.assert_class_or_nil('role', opts.delete(:role), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/memberships\").with_query(query).get.map { |hash| Apidoc::Models::Membership.new(hash) }\n end",
"def show\n @member = Member.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def index\n puts current_user.email\n render json: { user: current_user.email, list: [1, 2, 3] }\n\n end",
"def index\n puts current_user.email\n render json: { user: current_user.email, list: [1, 2, 3] }\n\n end",
"def index\n\t\tmembers = Member.where(team_id: params[:team_id]).all\n\t\trespond_with members\n\tend",
"def index\n @announcements = Announcement.all\n render json: @announcements, include: [:member => {only: [:first_name, :last_name, :id]}]\n end",
"def members\n fetch if @members.nil? || @members[0].nil?\n @members\n end",
"def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end",
"def index\n @project = Project.find(current_project_id)\n @members = @project.members\n end",
"def index\n json_response(@contacts, user_id: @user.id, status: :ok)\n end",
"def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end",
"def index\n @group_members = @client.group_members\n \n end",
"def show\n @aiit_member = AiitMember.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aiit_member }\n end\n end",
"def organization_members(org)\n get \"/orgs/#{org}/members\"\n end",
"def show\n @dc_member = DcMember.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dc_member }\n end\n end",
"def index\n @search = Member.search(params[:search])\n @members = @search.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index # working\n @members = {}\n @channels = User.find(current_user.id).channels\n\n @channels.each do |channel|\n @members[channel.id] = channel.members\n end\n\n @members.keys.each do |channel_id|\n @members[channel_id] = @members[channel_id].map do |user|\n user.id\n end\n end\n end",
"def show\n @conn = current_user.conns.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conn }\n end\n end",
"def profile\n render_json 0,\"ok\",current_member.as_profile\n end",
"def members_get_info(members:, trace: false)\n members_json = []\n members.each do |m|\n if m['team_member_id'] != nil\n members_json << \"{\\\".tag\\\":\\\"team_member_id\\\",\\\"team_member_id\\\":\\\"#{m['team_member_id']}\\\"}\"\n elsif m['external_id'] != nil\n members_json << \"{\\\".tag\\\":\\\"external_id\\\",\\\"external_id\\\":\\\"#{m['external_id']}\\\"}\"\n elsif m['email'] != nil\n members_json << \"{\\\".tag\\\":\\\"email\\\",\\\"email\\\":\\\"#{m['email']}\\\"}\"\n end\n end\n dropbox_query(query: '2/team/members/get_info', query_data: \"{\\\"members\\\":[#{members_json.join(',')}]}\", trace: trace)\n end",
"def show\n if user\n render json: user,serializer: Api::V1::MembersSerializer, :status => 201\n else\n render json: \"errors\", :status => 422\n end \n end",
"def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end",
"def index\n @call_list_memberships = CallListMembership.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @call_list_memberships }\n end\n end",
"def new\n @title = \"New Member\"\n @member = Member.new\n @member.phone = \"+375\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @member }\n end\n end",
"def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end",
"def main_users\n\t\t@main_users = ParseGoLink.main_users\n\t\trender json: @main_users\n\tend",
"def show\n team = Team.find(params[:id])\n image_url = team.image.url\n members = team.members.select(:name, :surname)\n member_names = []\n members.each do |m|\n member_names.push(m.name + \" \" + m.surname)\n end\n team = team.attributes\n\n team[:members] = member_names\n team[:image] = image_url\n render json: team\n end"
] | [
"0.69486254",
"0.67406553",
"0.6699259",
"0.64049786",
"0.6331328",
"0.62991095",
"0.62991095",
"0.62991095",
"0.6281681",
"0.62797064",
"0.6247294",
"0.6195165",
"0.6152859",
"0.61428124",
"0.6118622",
"0.6094992",
"0.60852486",
"0.6083268",
"0.6048129",
"0.6037079",
"0.6012011",
"0.5997983",
"0.598705",
"0.5976875",
"0.5976456",
"0.59726",
"0.59638584",
"0.59531415",
"0.5947076",
"0.5933668",
"0.5923283",
"0.5908481",
"0.5908481",
"0.5896598",
"0.58843744",
"0.5884328",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.58830774",
"0.5873675",
"0.5873675",
"0.5863842",
"0.58632714",
"0.585923",
"0.58586836",
"0.5855684",
"0.5842483",
"0.5841706",
"0.5841706",
"0.5841706",
"0.5841706",
"0.5841706",
"0.5841706",
"0.5841706",
"0.5841706",
"0.5841706",
"0.58298904",
"0.5781148",
"0.5781148",
"0.576975",
"0.57690865",
"0.57676965",
"0.57633936",
"0.5761078",
"0.57503814",
"0.57421273",
"0.57404727",
"0.57376003",
"0.57243544",
"0.57243544",
"0.57151675",
"0.571144",
"0.5699732",
"0.56892776",
"0.56867063",
"0.5684825",
"0.5672087",
"0.56714267",
"0.5666983",
"0.565467",
"0.5644654",
"0.5638425",
"0.56243527",
"0.56227505",
"0.56162655",
"0.55986726",
"0.55870044",
"0.558601",
"0.5580164",
"0.55798215",
"0.55756193",
"0.55751866",
"0.5574805"
] | 0.6751013 | 1 |
POST /comitemembers POST /comitemembers.json | def create
@comitemember = Comitemember.new(comitemember_params)
respond_to do |format|
if @comitemember.save
format.html { redirect_to @comitemember, notice: 'Comitemember was successfully created.' }
format.json { render :show, status: :created, location: @comitemember }
else
format.html { render :new }
format.json { render json: @comitemember.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n #sanity checks, can only modify memberships that you own\n if params[:user_id].to_i != current_user.id then\n render json: {message:'You do not own the membership list'}, :status => :unprocessable_entity\n return\n end\n\n #ensure the membership params is there\n unless params.has_key? :memberships then\n #render json: {message:'memberships list not found'}, :status => :unprocessable_entity\n #return\n #this could me no membership at all\n params[:memberships] = {}\n end\n\n #set the new memberships state\n current_user.set_memberships params[:memberships]\n\n render json: {\n message:'message received from server',\n memberships:User.find(params[:user_id]).memberships.map{ |x| x.attributes.merge({club_name: x.club_name})}\n }\n end",
"def create_members\n project = Project.find(params[:id])\n\n params[:members].each do |member_id|\n user = User.find(member_id)\n project.users << user unless project.users.include?(user) \n end\n \n respond_to do |format|\n format.html { redirect_to project_path(@project), notice: 'members were successfully added.' }\n format.json { render json: @project, status: :created, location: @project }\n end\n end",
"def create\n @member = @space.members.new(member_params)\n @member.user = current_user\n\n respond_to do |format| \n if @member.save\n @space.members << @member\n\n format.html { redirect_to space_member_url(@space, @member), notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: [@space, @member] }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_team_member\n clinics = params[:clinics].split(\", \")\n\n team_member = TeamMember.create(\n email: params[:email],\n first_name: params[:first_name],\n last_name: params[:last_name],\n user: params[:user],\n status: \"Active\",\n role: params[:role]\n )\n\n clinics.each do |clinic|\n Clinic.find(clinic).team_members << team_member\n end\n\n render json: team_member, include: ['clinics']\n end",
"def create\n @membership = Membership.new(params[:membership])\n @membership.member = current_member\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to sub_clubs_path, :notice => 'You requested membership.' }\n format.json { render :json => @membership, :status => :created, :location => @membership }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @membership.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(params, membership)\n # Send payload to blip\n data = {\n initials: (params[4].nil? ? params[5][0] : params[4].tr('^a-zA-Z', '')),\n firstname: (params[5].nil? ? params[4][0] : params[5]),\n lastname: [params[6], params[7]].reject{|e| e.nil? or e.empty?}.join(' '),\n email: (params[3].nil? ? '[email protected]' : params[3]),\n gender: params[9] == 'Vrouw' ? 'F' : 'M',\n phone: params[14],\n mobile: params[2],\n phone_parents: params[24],\n address: [params[10], params[11], params[12]].join(' '),\n membership: membership,\n }\n begin\n unless params[15].nil?\n data[:dateofbirth] = Date.strptime(params[15], '%d-%m-%Y').strftime('%Y-%m-%d')\n end\n rescue\n $problems.write \"#{$index}, #{data[:firstname]} #{data[:lastname]}, Birthdate ignored\\n\"\n end\n blip = post('https://people.i.bolkhuis.nl/persons', data)\n\n # Grab uid\n unless blip == nil\n uid = blip['uid']\n\n # Send payload to operculum\n put(\"https://operculum.i.bolkhuis.nl/person/#{uid}\", {\n nickname: params[8],\n study: params[16],\n alive: params[17].nil?,\n inauguration: params[25],\n resignation_letter: params[26],\n resignation: params[27],\n })\n end\nend",
"def post_gmo_with_create_member(user)\n uri = URI.parse('https://pt01.mul-pay.jp/payment/SaveMember.idPass')\n request = Net::HTTP::Post.new(uri)\n request.set_form_data(\n 'SiteID' => ENV['SITE_ID'],\n 'SitePass' => ENV['SITE_PASS'],\n 'MemberID' => user.member_id\n )\n\n req_options = {\n use_ssl: uri.scheme == 'https'\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n\n if response.code == '200'\n logger.info('GMO created member!(^ ^)!')\n else\n logger.info('GMO error!!!')\n end\n end",
"def create\n flash[:notice] = 'Member Created' if @project.members << @member\n respond_with @project, @member\n end",
"def create\n @member = @current_enterprise.members.build(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @membership = @member.memberships.build(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership.member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #not_allowed\n @oc_member = OcMember.new(params[:oc_member])\n\n respond_to do |format|\n if @oc_member.save\n format.html { redirect_to @oc_member, notice: 'Oc member was successfully created.' }\n format.json { render json: @oc_member, status: :created, location: @oc_member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @oc_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sign_up\n\t\tif params[:uuid].present?\n\t\t\t@existing_member = Com::Nbos::User.where(uuid: params[:uuid])\n\t\t\tif @existing_member.present?\n\t\t\t\trender :json => @existing_member.first\n\t\t\telse\n\t\t\t\t@member = build_user(params)\n\t\t\t\tif @member && @member.save\n\t\t\t\t\trender :json => @member\n\t\t\t\telse\n\t\t\t\t\trender :json => {status: 500, message: @member.errors.messages}, status: 500\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender :json => {status: 400, message: \"Bad Request\"}, status: 400\n\t\tend\t\n\tend",
"def create_member(data)\n headers = @client.make_request(:post, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/members\"), data)[1]\n id = Client.get_id_from_location_header(headers[:location])\n get_member(id)\n end",
"def create\n @dotsmember = Dotsmember.new(params[:dotsmember])\n\n respond_to do |format|\n if @dotsmember.save\n format.html { redirect_to @dotsmember, notice: 'Dotsmember was successfully created.' }\n format.json { render json: @dotsmember, status: :created, location: @dotsmember }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dotsmember.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @comitemembers = Comitemember.all\n end",
"def create\n @membership = Adhocracy::Membership.new(membership_params)\n\n if @membership.save\n render json: @membership, status: :created, location: api_v1_membership_path(@membership)\n else\n render_validation_errors @membership.errors\n end\n end",
"def new_members\n @members = User.all\n end",
"def create_member\n # Member.create!..\n\n respond_to do |format|\n format.html { redirect_to organization_path(params[:orgaid])}\n format.json { head :no_content }\n end\n end",
"def set_members\n members_ids = params[:contest][:members].reject(&:empty?)\n @contest.members.destroy_all if params[:action] == \"update\"\n members_ids.each do |members_id|\n member = Member.create(:user_id => members_id.to_i, :invitable => @contest)\n #send notification\n reciver = User.find(members_id)\n notifications = reciver.notifications.unread \n if reciver.notification_setting.try(:new_update)\n Notification.create(recepient_id: members_id, user: current_user, body: \"#{current_user.screen_name } has invited you to join a contest #{@contest.topic} \", notificable: @contest, :accept => false, :is_acceptable=>true)\n PrivatePub.publish_to \"/profiles/new_#{members_id}\", \"jQuery('#all-notifications').html('#{notifications.count}'); jQuery('#all-notifications').addClass('push-notification');\"\n\n end\n end\n end",
"def create\n @member = @organization.members.build(member_params)\n\n respond_to do |format|\n if @member.save\n logger.info(\"User #{current_user.email} created Member '#{@member.first_name} #{@member.last_name}' on #{@member.updated_at}\")\n format.html { redirect_to organization_path(@organization), notice: 'Member was successfully created.' }\n #format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @membership = Membership.new(params[:membership])\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership, notice: 'Membership was successfully created.' }\n format.json { render json: @membership, status: :created, location: @membership }\n else\n format.html { render action: \"new\" }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @members_client = MembersClient.new(members_client_params)\n\n respond_to do |format|\n if @members_client.save\n format.html { redirect_to @members_client, notice: 'Members client was successfully created.' }\n format.json { render :show, status: :created, location: @members_client }\n else\n format.html { render :new }\n format.json { render json: @members_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comitemember_params\n params.require(:comitemember).permit(:committee_id, :member_id)\n end",
"def create\n # type = \"member\"\n\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render action: 'show', status: :created, location: @member }\n else\n format.html { render action: 'new' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member_commision = MemberCommision.new(member_commision_params)\n\n respond_to do |format|\n if @member_commision.save\n format.html { redirect_to member_commisions_path, notice: 'Member commision was successfully created.' }\n format.json { render :show, status: :created, location: @member_commision }\n else\n format.html { render :new }\n format.json { render json: @member_commision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @crewmember = Crewmember.new(crewmember_params)\n\n respond_to do |format|\n if @crewmember.save\n format.html { redirect_to @crewmember, notice: 'Crewmember was successfully created.' }\n format.json { render :show, status: :created, location: @crewmember }\n else\n format.html { render :new }\n format.json { render json: @crewmember.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.json { render :show, status: :created, location: @member }\n else\n return api_error(status: :unprocessable_entity, message: @member.errors)\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n @member.phone = nil if @member.phone == \"+375\"\n\n if @member.site_user.blank?\n @member.site_user = nil\n end\n\n @member.join_date = Date.today if @member.join_date.blank?\n @member.card_number = Member.last_card_number + 1 if @member.card_number.blank?\n\n respond_to do |format|\n if @member.save\n CrmMailer.with(member: @member).greet_new_member.deliver_later\n\n format.html { redirect_to member_pay_path(@member), notice: 'Участник успешно зарегистрирован' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @membership = @website.memberships.new(membership_params)\n @membership.user.no_password = true\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership, notice: 'Membership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @membership }\n else\n format.html { render action: 'new' }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n count = Member.mass_invite!(params[\"MassInvite\"][\"emails\"])\n respond_to do |format|\n format.html { redirect_to new_member_path, notice: \"Yaay! Totalt #{count} invitasjoner ble sendt.\" }\n end\n end",
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def create\n @membership = Membership.new(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to community_memberships_path(@community), notice: 'Community membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def crewmember_params\n params.require(:crewmember).permit(:name, :address, :phone, :email)\n end",
"def create\n user = Member.new(user_params)\n if user.save\n code = user.id + 24523009\n user.update(affiliate_code: code)\n MemberupJob.set(wait: 20.seconds).perform_later(user)\n sign_in(user)\n render json: user,serializer: Api::V1::MembersSerializer, :status => 201\n else\n render json: \"errors\", :status => 422\n end \n end",
"def CreateMembership params = {}\n \n APICall(path: 'group_memberships.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addUser2Project( site, name, identifier, roles )\n log \"Adding user to project \"\n uid = getUserId site, name\n pid = getProjectId site, identifier\n membership = { :membership => { :user_id => uid , :role_ids => roles}}.to_json\n puts membership\n begin\n puts \"/projects/#{pid}/memberships.json\"\n response = site[\"/projects/#{pid}/memberships.json\"].post membership, :content_type => 'application/json'\n rescue => e\n puts \"Error while adding user to project: \"+ e.inspect\n end\n end",
"def test_should_create_invite_via_API_JSON\r\n get \"/logout\"\r\n post \"/invites.json\", :api_key => 'testapikey',\r\n :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => '[email protected]',\r\n :user_id => 1 }\r\n assert_response :created\r\n invite = JSON.parse(response.body)\r\n check_new_invite(invite) \r\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save!\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @membership = Membership.new(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership, notice: \"Membership was successfully created.\" }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @tea_club = TeaClub.new(tea_club_params)\n\n respond_to do |format|\n\n if @tea_club.save\n\n membership = Membership.new(:tea_club_id => @tea_club.id, :confirmed => true)\n current_user.memberships << membership\n membership.save\n\n format.html { redirect_to @tea_club, notice: 'Tea club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tea_club }\n\n else\n format.html { render action: 'new' }\n format.json { render json: @tea_club.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def create\n @group_member = @client.group_members.new(group_member_params)\n respond_to do |format|\n if @group_member.save\n format.html { redirect_to client_group_member_path(@client,@group_member), notice: 'Group member was successfully created.' }\n format.json { render :show, status: :created, location: @group_member }\n else\n format.html { render :new }\n format.json { render json: @group_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postEntityAssociation_membership( entity_id, association_id, association_member_url, association_member_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['association_id'] = association_id\n params['association_member_url'] = association_member_url\n params['association_member_id'] = association_member_id\n return doCurl(\"post\",\"/entity/association_membership\",params)\n end",
"def create\n @member = Member.new(member_params)\n #@member.card_id = SecureRandom.uuid\n @member.magma_coins = 0\n add_abo_types_to_member(@member)\n respond_to do |format|\n if @member.save\n format.html { redirect_to current_user.present? ? @member : members_path, notice: t('flash.notice.creating_member') }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new, alert: t('flash.alert.creating_member') }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save \n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_member_to_list(user, list, member_id, options={})\n post(\"/#{user}/#{list}/members.json\", options.merge(:id => member_id))\n end",
"def create\n @aiit_member = AiitMember.new(params[:aiit_member])\n\n respond_to do |format|\n if @aiit_member.save\n format.html { redirect_to @aiit_member, notice: 'Aiit member was successfully created.' }\n format.json { render json: @aiit_member, status: :created, location: @aiit_member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @aiit_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @dotsmember = Dotsmember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dotsmember }\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to admin_member_path(@member), notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @member = Member.new\n user = @member.build_user\n @roles = Role.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @member }\n end\n end",
"def create\n @member = User.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(params[:member]) \n if @member.save\n \n require 'aweber'\n @oauth = AWeber::OAuth.new('Ak8Buwis5Q1j0OwvVZ4eJROe','TjtgHED5PIYPqS85ZgBekIf9jol1PgpUEpETmrV9')\n @oauth.authorize_with_access('Agvk8sGM8K4XFU2axg2d9z2j', 'qcAyJIPah2lBKcqrU85IviuOXjC0gLtYx0koG115')\n @aweber = AWeber::Base.new(@oauth)\n @account = @aweber.account\n\n new_subscriber = {}\n new_subscriber[\"email\"] = params[:member][:email]\n new_subscriber[\"name\"] = params[:member][:username] \n @account.lists.find_by_name(\"cpclist\").subscribers.create(new_subscriber)\n \n \n insert_id = @member.id\n random_string = SecureRandom.hex(5)\n Member.find(insert_id).update_attribute(:random_code, random_string)\n\n flash[:success] = \"Member was successfully created.\"\n session[:user_id] = insert_id\n redirect_to root_url\n #render 'home/index'\n\n flash[:success] = \"\";\n\n #render :partial => 'home/index', :locals => { :success => flash[:success] }\n else\n render 'home/index'\n end\n end",
"def new\n @member = Member.new\n user = @member.build_user\n @roles = Role.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @member }\n end\n end",
"def create\n @member = Member.new(member_params)\n @creating_member = true\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'El miembro ha sido creado' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:membership][:user_username]\n params[:membership][:user_id] = User.find_by_username(params[:membership].delete('user_username')).try!(:id)\n end\n\n @membership = @project.memberships.create(membership_params)\n respond_with @project, @membership\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: '出欠情報を保存しました' }\n format.json { render action: 'show', status: :created, location: @member }\n else\n format.html { render action: 'new' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clnmember = Clnmember.new(params[:clnmember])\n\n respond_to do |format|\n if @clnmember.save\n format.html { redirect_to @clnmember, notice: 'Clnmember was successfully created.' }\n format.json { render json: @clnmember, status: :created, location: @clnmember }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clnmember.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = GroupMember.new(params[:member])\n if @current_member.group.add_member @member\n render :json=>{success:true, new_id:@member.id}\n UserMailer.invite_email(@member.email).deliver\n else\n render :json=>{success:false, errors:@member.errors}\n end\n end",
"def add_app_members(owner:, platform:, app_id:, users:, role: nil)\n endpoint = \"/api/users/#{owner}/platforms/#{platform}/apps/#{app_id}/members\"\n res = api.post endpoint do |request|\n request.headers['Content-Type'] = 'application/x-www-form-urlencoded'\n request.body = URI.encode_www_form(\n users: users,\n role: role\n )\n end\n Response.new(res)\n end",
"def create\n r = params[:member]\n @member = Member.where(:email => r[:email], :group_name => r[:group_name], :admin_uuid => session[:user_uuid]).first\n r = @member.attributes.merge(r) unless @member.nil?\n @member = Member.new(r) if @member.nil?\n @member.update_attributes(r) unless @member.nil?\n\n unless @member.err\n @member.get_member_uuid\n end\n respond_to do |format|\n unless @member.nil?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @registration = Registration.new(registration_params)\n\n respond_to do |format|\n if @registration.save\n if @registration.members.any?\n @registration.members.each do |member|\n RemindMailer.content(member.email, member.name).deliver\n end\n end\n format.html { redirect_to registration_path(@registration), notice: '報名成功' }\n format.json { render action: :show, status: :created, location: @registration }\n else\n format.html { render action: :new }\n format.json { render json: @registration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meeting_member = MeetingMember.new(params[:meeting_member])\n\n respond_to do |format|\n if @meeting_member.save\n format.html { redirect_to @meeting_member, :notice => 'Meeting member was successfully created.' }\n format.json { render :json => @meeting_member, :status => :created, :location => @meeting_member }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @meeting_member.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\tif !checkadmin? then return end\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n r = params[:member]\n @member = Member.where(:email => r[:email], :group_name => r[:group_name], :admin_uuid => session[:user_uuid]).first\n r = @member.attributes.merge(r) unless @member.nil?\n @member = Member.new(r) if @member.nil?\n @member.update_attributes(r) unless @member.nil?\n unless @member.err\n @member.get_member_uuid\n end\n respond_to do |format|\n unless @member.nil?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n megam_rest.post_accounts(to_hash)\n end",
"def new\n @title = \"New Member\"\n @member = Member.new\n @member.phone = \"+375\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @member }\n end\n end",
"def index\n @members = Member.members\n @participants = Member.participants\n @invited_count = Member.count\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def create\n @club=Club.find(session[:current_club])\n @title=\"Sign up\"\n logout_keeping_session!\n @member = @club.members.build(params[:member])\n success = @member && @member.save\n \n \n if success\n session[:current_club]=nil\n # Member dem Club zuordnen\n # @club.members << @member\n flash[:success] = \"Member created for #{@club.name}\"\n redirect_to(login_path)\n else\n flash.now[:error] = \"We couldn't set up that account, sorry. Please try again, or contact an admin. \"\n render :action => 'new'\n end\n \n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end",
"def create\n @member = Member.new(create_params)\n respond_to do |format|\n if @member.save\n session[:member_id] = @member.id\n format.html { redirect_to @member }\n format.json { render action: 'show', status: :created, location: @member }\n else\n format.html { render action: 'new' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def conference_list_members(params)\n path = @version + '/Conference/Member/List/'\n method = 'POST'\n return request(path, method, params)\n end",
"def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end",
"def members_list\n @members = Member.active.ordered.all\n @user = current_user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @members }\n end\n end",
"def create\n @club = Club.new(params[:club])\n @club.user = current_user\n\n if @club.save\n @club.memberships.create!(couple_id: current_user.activeCouple.id, verified: true)\n redirect_to root_path, notice: t('club.create')\n else\n render :new\n end\n end",
"def create\n @pe_classmember = PeClassmember.new(params[:pe_classmember])\n\n respond_to do |format|\n if @pe_classmember.save\n format.html { redirect_to @pe_classmember, :notice => 'Pe classmember was successfully created.' }\n format.json { render :json => @pe_classmember, :status => :created, :location => @pe_classmember }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @pe_classmember.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n\n\n @membership = Membership.new(beer_club_id: params[:membership][:beer_club_id], user_id: current_user.id, confirmed: false)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to beer_club_path(params[:membership][:beer_club_id]), notice: \"Welcome #{current_user.username}\" }\n format.json { render :show, status: :created, location: @membership }\n\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n @beer_clubs = BeerClub.all\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to controller: :login, action: :index, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new, layout: 'member_new' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user = User.new\n @user.pending_memberships.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def create\n @cr_committee_member = CrCommitteeMember.new(cr_committee_member_params)\n\n respond_to do |format|\n if @cr_committee_member.save\n format.html { redirect_to @cr_committee_member, notice: 'Cr committee member was successfully created.' }\n format.json { render :show, status: :created, location: @cr_committee_member }\n else\n format.html { render :new }\n format.json { render json: @cr_committee_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @member = Member.new\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @member }\n end\n end",
"def create\n \t@site = Site.find(params[:membership][:site_id])\n \t@o = [('a'..'z'),('A'..'Z'), (0..9)].map{|i| i.to_a}.flatten\n\t\t@pw = (0...8).map{ @o[rand(@o.length)] }.join\n\n \tif current_company.users.find_by_email(params[:email]).nil?\n \t\t@user = User.new(:email => params[:email])\n \t\[email protected] = @pw\n \t\[email protected]_confirmation = @pw\n \t\[email protected] = current_company\n \t\t# This should probably have additional logic and not allow any user to become a manager...\n \t\tif params[:membership][:role] == \"manager\"\n \t\t\[email protected] = 1\n \t\tend\n \telse\n \t\t@user = current_company.users.find_by_email!(params[:email]) \t\t\n \tend\n\n @membership.site = @site\n @membership.user = @user\n @membership.role = params[:membership][:role]\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership, notice: 'Membership was successfully created.' }\n format.json { render json: @membership, status: :created, location: @membership }\n else\n format.html { render action: \"new\" }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @beneficiaire = Beneficiaire.find(params[:beneficiaire_id])\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @beneficiaire, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html {redirect_to @beneficiaire, error: 'Member was not successfully created!' }\n format.json { render json: @beneficiaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def crew_params\n params.require(:crew).permit(:members_name)\n end",
"def set_comitemember\n @comitemember = Comitemember.find(params[:id])\n end",
"def create\n @member = Member.new(params[:member])\n @member.house = current_member.house\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to root_url, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def members_client_params\n params.require(:members_client).permit(:name, :telephone, :birth_date, :mail, :facebook, :total_dives)\n end",
"def create\n @member = Member.new(member_params)\n \n\n respond_to do |format|\n if @member.save\n format.html { redirect_to groups_path, notice: \"Member was successfully created.\" }\n format.json { render :show, status: :created, location: @member }\n format.js\n else\n format.html { redirect_back fallback_location: root_path, status: :unprocessable_entity }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @membership = Membership.new(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to groups_path, notice: 'User was successfully added to group.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validator_captive_portal(args = {}) \n post(\"/profiles.json/captiveportal/\", args)\nend",
"def create\n @who_member = WhoMember.new(params[:who_member])\n\n respond_to do |format|\n if @who_member.save\n format.html { redirect_to(@who_member, :notice => 'WhoMember was successfully created.') }\n format.xml { render :xml => @who_member, :status => :created, :location => @who_member }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @who_member.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.6300617",
"0.6072829",
"0.60053545",
"0.5898235",
"0.58789206",
"0.5867267",
"0.5820536",
"0.58042413",
"0.5761981",
"0.5716328",
"0.5660342",
"0.565942",
"0.5642265",
"0.56367296",
"0.5628035",
"0.5615737",
"0.5606229",
"0.56003624",
"0.559563",
"0.5564302",
"0.55602056",
"0.55541486",
"0.55496156",
"0.55473715",
"0.55343235",
"0.5530841",
"0.5503919",
"0.5502485",
"0.5502485",
"0.5502485",
"0.5499788",
"0.54955393",
"0.5494559",
"0.54940504",
"0.5490541",
"0.5485312",
"0.5481434",
"0.5467875",
"0.5464349",
"0.5463473",
"0.5453959",
"0.5453959",
"0.5453959",
"0.5453959",
"0.54488105",
"0.5443127",
"0.54423",
"0.54390824",
"0.54388404",
"0.5438657",
"0.5433415",
"0.5433237",
"0.54179275",
"0.5408687",
"0.5402948",
"0.5398668",
"0.5384671",
"0.5381335",
"0.5370312",
"0.53688467",
"0.5364511",
"0.53628063",
"0.53576964",
"0.53466064",
"0.53450644",
"0.53435594",
"0.5334688",
"0.53317344",
"0.5324381",
"0.53243774",
"0.53242797",
"0.5320839",
"0.5311337",
"0.53112435",
"0.5296181",
"0.5293952",
"0.5280245",
"0.52770996",
"0.52715474",
"0.5269834",
"0.5268022",
"0.52647895",
"0.52642196",
"0.52565616",
"0.52513516",
"0.5232708",
"0.52272105",
"0.52235436",
"0.5223529",
"0.5219745",
"0.5203282",
"0.5201618",
"0.5197663",
"0.5194878",
"0.51900977",
"0.51900965",
"0.51882684",
"0.5173541",
"0.5173049",
"0.5166808"
] | 0.65262336 | 0 |
PATCH/PUT /comitemembers/1 PATCH/PUT /comitemembers/1.json | def update
respond_to do |format|
if @comitemember.update(comitemember_params)
format.html { redirect_to @comitemember, notice: 'Comitemember was successfully updated.' }
format.json { render :show, status: :ok, location: @comitemember }
else
format.html { render :edit }
format.json { render json: @comitemember.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"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 # byebug \n respond_to do |format|\n if self.current_member && self.current_member.id == params[:id].to_i\n if @member.update(member_params)\n format.json { render :show, status: :ok, location: @member }\n else\n return api_error(status: :unprocessable_entity, message: @member.errors)\n end\n else\n return api_error(status: 401, message: '没有操作权限')\n end\n end\n end",
"def update\n contact = Contact.find(params[:id])\n\n if contact.user_id == current_user.id\n contact.update_attributes(params[:contact])\n render json: contact\n else\n render text: \"That's not your contact!\"\n end\n end",
"def update(uid, params, membership)\n data = {\n initials: (params[4].nil? ? params[5][0] : params[4].tr('^a-zA-Z', '')),\n email: (params[3].nil? ? '[email protected]' : params[3]),\n gender: params[9] == 'Vrouw' ? 'F' : 'M',\n phone: params[14],\n mobile: params[2],\n phone_parents: params[24],\n address: [params[10], params[11], params[12]].join(' '),\n membership: membership,\n }\n begin\n unless params[15].nil?\n data[:dateofbirth] = Date.strptime(params[15], '%d-%m-%Y').strftime('%Y-%m-%d')\n end\n rescue\n $problems.write \"#{$index}, #{data[:firstname]} #{data[:lastname]}, Birthdate ignored\\n\"\n end\n patch(\"https://people.i.bolkhuis.nl/persons/#{uid}\", data)\n\n # Send payload to operculum\n put(\"https://operculum.i.bolkhuis.nl/person/#{uid}\", {\n nickname: params[8],\n study: params[16],\n alive: params[17].nil?,\n inauguration: params[25],\n resignation_letter: params[26],\n resignation: params[27],\n })\nend",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n params[:member].delete(:site_user) if params[:member][:site_user].blank?\n\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(args)\n builder.update_rest(type, ref, args, username, password)\n self.elements(true)\n end",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update\n\tif !checkme? then return end\n\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @oc_member = OcMember.find(params[:id])\n\n respond_to do |format|\n if @oc_member.update_attributes(params[:oc_member])\n format.html { redirect_to @oc_member, notice: 'Oc member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oc_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update\n respond_to do |format|\n if @members_client.update(members_client_params)\n format.html { redirect_to @members_client, notice: 'Members client was successfully updated.' }\n format.json { render :show, status: :ok, location: @members_client }\n else\n format.html { render :edit }\n format.json { render json: @members_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n respond_to do |format|\n if @member.update(update_params)\n format.html { redirect_to @member }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if !params.has_key?(:ur_contact) then\n head :internal_server_error\n return\n end\n\n #really update the contacts\n contact = UrContact.find(params[:id])\n\n #can't dlete contact you don't own\n if contact.user_id != current_user.id then\n Rails.logger.error \"Attempt to update contact you don't own\"\n head :internal_server_error\n return\n end\n\n if contact.update_attributes(contact_params) then\n render json: contact\n else\n head :internal_server_error\n end\n end",
"def update!(**args)\n @members = args[:members] if args.key?(:members)\n @resource = args[:resource] if args.key?(:resource)\n @resource_type = args[:resource_type] if args.key?(:resource_type)\n @role = args[:role] if args.key?(:role)\n end",
"def patch!\n request! :patch\n end",
"def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n errors = {}\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if params[:person]\n begin\n if @person.json_update_attributes(params[:person])\n render_json :entry => @person.to_hash(@user, @client) and return\n end\n rescue NoMethodError => e\n errors = e.to_s\n end\n end\n\n render_json :status => :bad_request, :messages => @person.errors.full_messages\n @person = nil\n end",
"def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end",
"def update\n authorize @meetup\n respond_to do |format|\n if @meetup.update(meetup_params)\n notify_collaborators\n format.html { redirect_to meetup_path(@meetup) }\n format.json { render :show, status: :ok, location: @meetup }\n else\n format.html { render :edit }\n format.json do\n render json: @meetup.errors,\n status: :unprocessable_entity\n end\n end\n end\n end",
"def update!(**args)\n @members = args[:members] if args.key?(:members)\n @role = args[:role] if args.key?(:role)\n end",
"def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend",
"def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend",
"def update\n # this action is not provided for partyroles\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n current_user.phone = params['phone']\n current_user.save()\n\n render :nothing => true, :status => 204\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end",
"def update\n @dotsmember = Dotsmember.find(params[:id])\n\n respond_to do |format|\n if @dotsmember.update_attributes(params[:dotsmember])\n format.html { redirect_to @dotsmember, notice: 'Dotsmember was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dotsmember.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user\n @user.active = false\n @user.pending = false\n @user.save\n end\n format.json { render json: {:status => :ok}}\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @colaboration = Colaboration.find(params[:id])\n @colaboration.user_id=current_user.id\n\n respond_to do |format|\n if @colaboration.update_attributes(params[:colaboration])\n format.html { redirect_to @colaboration, notice: 'Colaboracion actualizada exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @colaboration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n if @admin_collaborator.update_attributes(params[:admin_collaborator])\n format.html { redirect_to @admin_collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @member_type = args[:member_type] if args.key?(:member_type)\n @person_id = args[:person_id] if args.key?(:person_id)\n end",
"def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hack_member.update(hack_member_params)\n format.html { redirect_to @hack_member, notice: 'Hack member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hack_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:meetup])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n format.html { redirect_to @member, notice: \"Member was successfully updated.\" }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @client = Client.find(params[:client_id])\n # @group_member = GroupMember.where(:id => params[:id]).where(:client_id => params[:client_id])\n \n respond_to do |format|\n if @group_member.update(group_member_params)\n format.html { redirect_to client_group_member_path(@client,@group_member), notice: 'Group member was successfully updated.' }\n format.json { render :show, status: :ok, location: @group_member }\n else\n format.html { render :edit }\n format.json { render json: @group_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mf_api_user_update_tags\n\n # Get User From DB with client_id\n user = User.where(clientid: params[:client_id]).first\n\n # If user not found, return error response\n if user.empty?\n response = {\n success: false,\n message: 'User with ClientID not found'\n }\n\n render json: response\n end\n\n # Get the Infusionsoft contact info\n contact = Infusionsoft.data_load('Contact', user.clientid, [:Groups])\n\n # Update User Tags\n user.put('', {\n :client_tags => contact['Groups']\n })\n\n\n response = {\n success: true,\n message: 'User Tags Updated'\n }\n\n render json: response\n\n end",
"def update \n @current_user.update(user_params)\n render json: @current_user\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @member_contact.update(member_contact_params)\n format.html { redirect_to @member_contact, notice: 'Member contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @member_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n account = current_organization.accounts.find(params[:id])\n return forbidden unless account && current_account.allowed_to_edit_account?(account, current_organization)\n return json(account) unless account.update_attributes pick(params, :first_name, :last_name, :email,:language, :document_language)\n\n role = pick(params, :role)\n #account.update_attributes(role) if !role.empty? && current_account.admin?\n membership = current_organization.role_of(account)\n membership.update_attributes(role) if !role.empty? && current_account.admin?\n password = pick(params, :password)[:password]\n if (current_account.id == account.id) && password\n account.update(password: password)\n end\n json account.canonical(membership: membership)\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n @uplines = Member.where.not(id: @member.self_and_descendants.collect(&:id)).order(\"fullname\")\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n params.require(:member).permit(:name)\n if @member.update(member_params)\n format.html { redirect_to @member, notice: '更新しました' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clnmember = Clnmember.find(params[:id])\n\n respond_to do |format|\n if @clnmember.update_attributes(params[:clnmember])\n format.html { redirect_to @clnmember, notice: 'Clnmember was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clnmember.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n respond_to do |format|\n if @member.update!(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:user_id])\n @mycontact = @user.mycontacts.find(params[:mycontact_id])\n @meeting= @mycontact.meetings.find(params[:id])\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.html { redirect_to user_mycontact_meetings_path, notice: 'Meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club = Club.find(params[:id])\n\n params.each do |key, value|\n if (key.to_s[/adduser.*/])\n #if param[key].blank?\n # @object.errors.add_to_base(\"All new user fields are required.\")\n #end\n #debugger\n @user = User.new\n #clean_up_passwords @user\n @user.update_attribute(:email,params[key])\n @user.update_attribute(:club_id,params[:id])\n @user.save\n #@user.send_confirmation_instructions\n end\n end\n\n respond_to do |format|\n if @club.update_attributes(params[:club])\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cr_committee_member.update(cr_committee_member_params)\n format.html { redirect_to @cr_committee_member, notice: 'Cr committee member was successfully updated.' }\n format.json { render :show, status: :ok, location: @cr_committee_member }\n else\n format.html { render :edit }\n format.json { render json: @cr_committee_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact.update(contact_params)\n if @contact.valid?\n render json: @contact\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end",
"def update\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.update(jam_circle_params)\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :ok, location: @jam_circle }\n else\n format.html { render :edit }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @chat_id = args[:chat_id] if args.key?(:chat_id)\n @member_type = args[:member_type] if args.key?(:member_type)\n end",
"def update!(**args)\n @chat_id = args[:chat_id] if args.key?(:chat_id)\n @member_type = args[:member_type] if args.key?(:member_type)\n end",
"def update\n respond_to do |format|\n if @congress_member.update(congress_member_params)\n format.html { redirect_to @congress_member, notice: 'Congress Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @congress_member }\n else\n format.html { render :edit }\n format.json { render json: @congress_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update\n\n params[:client][:contact_ids] ||= []\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @membership.update_attributes(params[:membership])\n format.html { redirect_to edit_site_url(@membership.site), notice: 'Membership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n unless @member.err\n @member.get_member_uuid\n end\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n unless @member.err\n @member.get_member_uuid\n end\n format.html { redirect_to @member, notice: 'Member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n @contact.person_id = nil if params[:contact][:person_name].present?\n respond_to do |format|\n if @contact.update_attributes(params[:contact].merge(:updated_by => current_user.id))\n format.html { redirect_to client_contacts_path(@firm), :notice => \"#{ Contact.model_name.human } успешно изменен.\"}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n @aiit_member = AiitMember.find(params[:id])\n\n respond_to do |format|\n if @aiit_member.update_attributes(params[:aiit_member])\n format.html { redirect_to @aiit_member, notice: 'Aiit member was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aiit_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @call = Call.find(params[:id])\n @call.update_attributes(params[:call])\n respond_to do |format|\n format.html\n format.json { render :json => @call.to_json(:include => [ :user ]) }\n format.js\n end\n end",
"def test_should_update_group_user_via_API_JSON\r\n # lookup user's membership\r\n get \"memberships/find.json?api_key=testapikey&user_id=4&group_id=1\"\r\n membership = JSON.parse(response.body)\r\n membership_id = membership['id']\r\n assert membership_id == 3, 'Incorrect membership id'\r\n assert membership['role_id'] == Role.find_by_rolename('user').id, 'Incorrect role id'\r\n \r\n # promote user to group admin\r\n put \"/memberships/#{membership_id}.xml\", :api_key => 'testapikey',\r\n :membership => {:user_id => 4,\r\n :group_id => 1,\r\n :role_id => Role.find_by_rolename('group_admin') }\r\n assert_response :success\r\n end",
"def update\n respond_to do |format|\n if !params[:roles].include?('president') && @member.has_role?(:president) && !Tenant.current.has_presidents\n format.html { redirect_to member_path(@member), notice: 'Please select other user as President.' }\n elsif @member.update(member_params)\n remove_roles\n add_roles(params[:roles])\n format.html { redirect_to member_path(@member), notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @role = args[:role] unless args[:role].nil?\n @members = args[:members] unless args[:members].nil?\n end",
"def update\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n if @collaborator.update_attributes(params[:collaborator])\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end",
"def update\n respond_to do |format|\n if @member_commision.update(member_commision_params)\n format.html { redirect_to member_commisions_path, notice: 'Member commision was successfully updated.' }\n format.json { render :show, status: :ok, location: @member_commision }\n else\n format.html { render :edit }\n format.json { render json: @member_commision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n flash[:notice] = 'Member Successfully updated' if @member.update_attributes! params[:member]\n respond_with @project, @member\n end",
"def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end",
"def update_member\n # render :text => params\n @company = current_user.company\n # @user.type_id = params[:user_type_id]\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { \n @agencies = @company.agencies\n flash[:alert] = @user.errors.full_messages.join(\"<br>\")\n render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \"\"\"\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:activity])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n \"\"\"\n end"
] | [
"0.6328931",
"0.6263779",
"0.6221073",
"0.61286914",
"0.60677963",
"0.6047596",
"0.5946337",
"0.59281516",
"0.5908788",
"0.5905915",
"0.5905915",
"0.589533",
"0.58863354",
"0.58671445",
"0.58397555",
"0.5839703",
"0.58211136",
"0.5811436",
"0.57822436",
"0.5778672",
"0.5774055",
"0.5767986",
"0.5766779",
"0.5763053",
"0.57342577",
"0.5728912",
"0.57285064",
"0.5726855",
"0.5712378",
"0.5712378",
"0.571088",
"0.57068354",
"0.5700442",
"0.5695223",
"0.5694847",
"0.5692939",
"0.5691722",
"0.56906104",
"0.56890893",
"0.5681415",
"0.56746817",
"0.5673952",
"0.56657714",
"0.56657714",
"0.56657714",
"0.56657714",
"0.56657714",
"0.56568795",
"0.56552833",
"0.5653286",
"0.5649277",
"0.56488705",
"0.564874",
"0.56454754",
"0.5644513",
"0.5637313",
"0.5633196",
"0.5629076",
"0.5628585",
"0.5623756",
"0.56233716",
"0.5615662",
"0.5610537",
"0.5602929",
"0.5589694",
"0.5588518",
"0.558802",
"0.5583332",
"0.5583332",
"0.55792457",
"0.5575945",
"0.5575903",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5575636",
"0.5572636",
"0.55718714",
"0.5571689",
"0.5571689",
"0.5571601",
"0.5570403",
"0.55666935",
"0.5565014",
"0.55638534",
"0.5560381",
"0.55575436",
"0.5555054",
"0.5554901",
"0.5553969",
"0.55525",
"0.5550215",
"0.55479604",
"0.55473834",
"0.5536471"
] | 0.63957405 | 0 |
DELETE /comitemembers/1 DELETE /comitemembers/1.json | def destroy
@comitemember.destroy
respond_to do |format|
format.html { redirect_to comitemembers_url, notice: 'Comitemember was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @dotsmember = Dotsmember.find(params[:id])\n @dotsmember.destroy\n\n respond_to do |format|\n format.html { redirect_to dotsmembers_url }\n format.json { head :no_content }\n end\n end",
"def destroy \n @oc_member = OcMember.find(params[:id])\n @oc_member.destroy\n\n respond_to do |format|\n format.html { redirect_to oc_members_url }\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 @member = Member.find(params[:id])\n @member.destroy\n\n \n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aiit_member = AiitMember.find(params[:id])\n @aiit_member.destroy\n\n respond_to do |format|\n format.html { redirect_to aiit_members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @clnmember = Clnmember.find(params[:id])\n @clnmember.destroy\n\n respond_to do |format|\n format.html { redirect_to clnmembers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.json { head :ok }\n end\n end",
"def delete(*args)\n arguments(args, required: [:org_name, :user])\n\n delete_request(\"/orgs/#{arguments.org_name}/members/#{arguments.user}\",\n arguments.params)\n end",
"def destroy\n @members_client.destroy\n respond_to do |format|\n format.html { redirect_to members_clients_url, notice: 'Members client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @who_member = WhoMember.find(params[:id])\n @who_member.destroy\n\n respond_to do |format|\n format.html { redirect_to(who_members_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to @user }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_site_url(@membership.site) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\tif !checkadmin? then return end\n\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crewmember.destroy\n respond_to do |format|\n format.html { redirect_to crewmembers_url, notice: 'Crewmember was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hack_member.destroy\n respond_to do |format|\n format.html { redirect_to hack_members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n \n \n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dc_member = DcMember.find(params[:id])\n @dc_member.destroy\n\n respond_to do |format|\n format.html { redirect_to dc_members_url }\n format.json { head :no_content }\n end\n end",
"def destroy_member\n\n #@member = Member.find\n #@member.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'El miembro ha sido eliminado' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_member.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html do\n redirect_to members_url,\n notice: 'Profile was successfully deleted.'\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url, notice: '削除しました' }\n format.json { head :no_content }\n end\n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def destroy\n @member.destroy!\n respond_to do |format|\n format.html { redirect_to members_url, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to admin_member_members_path, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to member_url(@membership.member), notice: 'Membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member_contact.destroy\n respond_to do |format|\n format.html { redirect_to member_contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @elder_member.destroy\n respond_to do |format|\n format.html { redirect_to elder_members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url }\n format.xml { head :ok }\n end\n end",
"def delete(contactname)\n\n end",
"def destroy\n @congress_member.destroy\n respond_to do |format|\n format.html { redirect_to congress_members_url, notice: 'Congress Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html do\n redirect_to members_url,\n notice: 'Member was successfully destroyed.'\n end\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to space_members_url(@space), notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n session[:member_id] = nil\n @member.destroy\n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership ||= Membership.find(params[:id])\n @membership.destroy\n\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comite.destroy\n respond_to do |format|\n format.html { redirect_to comites_url, notice: 'Comite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cr_committee_member.destroy\n respond_to do |format|\n format.html { redirect_to cr_committee_members_url, notice: 'Cr committee member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.deleted = true\n @member.save\n\n respond_to do |format|\n format.html { redirect_to members_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url, notice: \"Membership was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @less_active_member.destroy\n respond_to do |format|\n format.html { redirect_to less_active_members_url, notice: 'Less active member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url, notice: 'Membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meeting_member = MeetingMember.find(params[:id])\n @meeting_member.destroy\n\n respond_to do |format|\n format.html { redirect_to meeting_members_url }\n format.json { head :ok }\n end\n end",
"def destroy\n organization = @member.organization \n\n @member.destroy\n logger.info(\"User #{current_user.email} destroyed Member '#{@member.first_name} #{@member.last_name}' on #{@member.updated_at}\")\n respond_to do |format|\n format.html { redirect_to organization, notice: 'Member was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if !current_member.the_admin?\n redirect_to \"/\", notice: \"Access denied\"\n return\n end\n\n @member.destroy unless @member.core_member?\n respond_to do |format|\n format.html { redirect_to members_url, notice: \"Member was#{@member.core_member? ? ' not' : ''} successfully destroyed.\"}\n format.json { head :no_content }\n end\n end",
"def destroy\n club_id = @membership.beer_club.id\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to beer_club_path(club_id), notice: 'You are no longer a member of this club' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meetuser.destroy\n respond_to do |format|\n format.html { redirect_to meetusers_url, notice: 'Meetuser was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member_info = MemberInfo.find(params[:id])\n @member_info.destroy\n\n respond_to do |format|\n format.html { redirect_to(member_infos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n respond_to do |format|\n format.html { redirect_to attends_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = Meetup.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to @community, notice: 'Community membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member_commision.destroy\n respond_to do |format|\n format.html { redirect_to member_commisions_url, notice: 'Member commision was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @member.destroy\n\n respond_to do |format|\n flash[:notice] = \"Destroyed user\"\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @member.destroy\n\n respond_to do |format|\n flash[:notice] = \"Destroyed user\"\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @membre = Membre.find(params[:id])\n @membre.destroy\n\n respond_to do |format|\n format.html { redirect_to(membres_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pe_classmember = PeClassmember.find(params[:id])\n @pe_classmember.destroy\n\n respond_to do |format|\n format.html { redirect_to pe_classmembers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @visitante_credenciado = VisitanteCredenciado.find(params[:id])\n @visitante_credenciado.destroy\n\n respond_to do |format|\n format.html { redirect_to visitante_credenciados_url }\n format.json { head :no_content }\n end\n \n end",
"def destroy\n @member = Member.find_by_url_or_id(params[:id])\n @member.destroy\n\n redirect_to(members_url)\n end",
"def destroy\n @clubuser.destroy\n respond_to do |format|\n format.html { redirect_to clubusers_url, notice: 'Clubuser was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @users_visit.destroy\n respond_to do |format|\n format.html { redirect_to users_visits_url, notice: 'Visit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n logger.info(\"#{Time.now} Se elimina el miembro ##{@member.id}!\")\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contactinfo = Contactinfo.find(params[:id])\n @people_id = @contactinfo.people_id\n @contactinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to person_path(@people_id) }\n format.json { head :ok }\n end\n end",
"def destroy\n\n ur_contact = UrContact.find(params[:id])\n\n #you can delete contacts you don't own\n if ur_contact.user_id != current_user.id then\n Rails.logger.error \"Attempt to delete contact you don't own\"\n head :internal_server_error\n return\n end\n\n if ur_contact.destroy then\n render json: {message:'Content Deleted'}\n else\n head :internal_server_error\n end\n end"
] | [
"0.70215803",
"0.7013852",
"0.6995687",
"0.69403404",
"0.68829453",
"0.68829453",
"0.6860483",
"0.6860483",
"0.6831408",
"0.68240196",
"0.68240196",
"0.6805549",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6793067",
"0.67648005",
"0.6741577",
"0.6700385",
"0.6666095",
"0.66512877",
"0.66339266",
"0.66339266",
"0.6630633",
"0.66295075",
"0.6627258",
"0.661423",
"0.6610722",
"0.6604718",
"0.6604651",
"0.6591963",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6575042",
"0.6558357",
"0.65520984",
"0.65493816",
"0.6538672",
"0.65274405",
"0.65129125",
"0.6507143",
"0.6503727",
"0.6500292",
"0.6498226",
"0.6496582",
"0.6487233",
"0.6486069",
"0.6483557",
"0.6463337",
"0.6463337",
"0.6463337",
"0.6463337",
"0.6455802",
"0.64525986",
"0.6445476",
"0.6441703",
"0.64395744",
"0.6424343",
"0.642353",
"0.6423039",
"0.6412363",
"0.6411824",
"0.6392095",
"0.6387763",
"0.6382451",
"0.6375727",
"0.6374861",
"0.6374861",
"0.6374861",
"0.6374861",
"0.6356533",
"0.6353876",
"0.63513297",
"0.63501734",
"0.6346162",
"0.63444465",
"0.63440526",
"0.63440526",
"0.6340161",
"0.6323383",
"0.6323383",
"0.6318243",
"0.63092667",
"0.6307906",
"0.6299808",
"0.62958014",
"0.6291267",
"0.6288283",
"0.62857"
] | 0.73591983 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_comitemember
@comitemember = Comitemember.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def comitemember_params
params.require(:comitemember).permit(:committee_id, :member_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Fetch the full name of the user | def full_name
"#{self.first_name} #{self.last_name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_full_name\n @user[\"name\"]\n end",
"def get_user_name\n\t\tretVal = \"User Not Found\"\n\t\tuser_id = self.user_id\n\t\tuser = User.find(user_id, :select=>[\"fname\",\"lname\"])\n\t\tunless user.nil?\n\t\t\tretVal = user.fname + \" \" + user.lname\n\t\tend\n\t\treturn retVal\n\tend",
"def name\n\t\tn = names\n\t\treturn n[:fullname] if n[:fullname]\n\t\treturn n[:username] if n[:username]\n\t\treturn I18n.translate(\"user.name.unknown\")\n\tend",
"def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.empty? ? \"John Doe\" : name.squish\n end",
"def user_full_name\n if user\n user.first_name + ' ' + user.last_name\n else\n 'Anonymous'\n end\n end",
"def get_full_name(user_id)\n if user_id\n u = User.find(user_id)\n return u.firstname + \" \" + u.lastname\n else\n return \"Unknown\"\n end\n end",
"def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.present? ? name.squish : \"John Doe\"\n end",
"def proper_name # method to get the full name of user\n first_name + \" \" + last_name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def full_name\n if user_data\n \"#{user_data['first_name']&.downcase&.capitalize} #{user_data['last_name']&.downcase&.capitalize}\"\n end\n end",
"def get_full_name(user)\n begin\n Etc.getpwnam(\"#{user}\")[\"gecos\"].chomp\n # or with dscl\n # %x(dscl /Search -read /Users/#{user} dsAttrTypeNative:cn).split.drop(1).join(\" \") \n rescue Exception => e\n end\n \n end",
"def full_name\n json[\"entry_data\"][\"ProfilePage\"].first[\"graphql\"][\"user\"][\"full_name\"]\n end",
"def user_name\n\t\tobject.user.full_name \n\tend",
"def user_full_name\n user ? user.full_name : \"Anonymous\"\n end",
"def full_name\n if self.user\n user.full_name\n else\n self.name\n end\n end",
"def full_name(user)\n user.first_name + ' ' + user.last_name\n end",
"def get_realname\n response = get_current_user_meta('realname')\n realname = response['query']['userinfo']['realname']\n return if realname == ''\n\n realname\n end",
"def full_name\n if self.profile.present?\n \"#{self.profile.first_name.capitalize} #{self.profile.last_name.capitalize}\"\n else\n \"#{username.capitalize}\"\n end\n end",
"def short_user_name\n user.first_name\n end",
"def full_name\n \"#{username}/#{name}\"\n end",
"def user_display_name\n @attributes[:user_display_name]\n end",
"def display_name\n username\n end",
"def display_name\n entry = JSON.parse(self.entry)\n user = User.find(user_id)\n \"#{user.display_name} #{entry['text']}\"\n end",
"def simple_username\n return user.firstname + ' ' + user.lastname.first + '.' if !user.nil?\n name\n end",
"def user_name\n decode_string_member(:user_name)\n end",
"def display_name\n #self.email.split('@')[0]\n self.username\n end",
"def user_display_name\n return @user_display_name\n end",
"def user_display_name\n return @user_display_name\n end",
"def user_display_name\n return @user_display_name\n end",
"def get_user_name(user_id)\n User.find(user_id).name rescue nil\n end",
"def full_name\n \"#{self.first_name} #{self.last_name}\"\n # can got to rails console and type command \"user = User.first\" => \"user.full_name\"\n end",
"def user_name\n User.find(self.user_id).name\n end",
"def display_name \n username\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name(uid)\n deter_lab.get_profile(uid).try(:[], \"name\")\n end",
"def full_name\n (@session[:current_user_details] || {})[:description]\n end",
"def user_full_name\n first_name + \" \" + last_name\n end",
"def user_name\n read_attribute('user_name') || \"anonymous\"\n end",
"def full_name\n \n if (not self.first_name.nil? and not self.first_name.eql? \"\") or (not self.last_name.nil? and not self.last_name.eql? \"\")\n \"#{self.title} #{self.first_name} #{self.last_name}\".strip\n elsif self.username\n self.username \n else\n # wrapped email only prefix\n\n parsed_email = self.email.split('@')\n parsed_email[0]\n end\n end",
"def user_full_name\n return object.billing_name if object.billing_name.present?\n \"#{user_firstname} #{user_lastname}\"\n end",
"def full_name\n\t\tself.user_fname.capitalize + \" \" + self.user_lname.capitalize\n\tend",
"def full_name\n \tif !self.first_name.nil? && !self.last_name.nil?\n\t\t\"#{self.first_name.titleize} #{self.last_name.titleize}\"\n\telsif !self.oauth_user_name.nil?\n\t\tself.oauth_user_name\n\telse\n\tend\n end",
"def full_name\n return '' unless profile\n profile.full_name\n end",
"def get_name(id)\n return \"\" if !id\n user = User.find(id)\n user.first_name + ' ' + user.last_name\n end",
"def full_user_name\n formatedName=first_name[0].upcase+first_name[1,first_name.size].downcase+\" \"+last_name[0].upcase+last_name[1,last_name.size].downcase\n return formatedName.strip if (first_name || last_name)\n return \"Anonymous\"\n end",
"def get_displayname(user)\n make_request(:get, \"/profile/#{user}/displayname\")['displayname']\n rescue NotFoundError => e\n raise UserNotFoundError.new(user, e.error),\n 'The specified user could not be found'\n end",
"def full_name\n \tif self.first_name != nil and self.last_name != nil\n \t\tself.first_name + \" \" + self.last_name\n \telse\n \t\t\"User does not have a full name\"\n \tend\n end",
"def get_user_name_not_null\n user = User.first(:id => self.user_id )\n return user.login if user\n return \"anon\"\n end",
"def name(user_id)\n User.find(user_id).email\n end",
"def display_user(user)\n user.name\n end",
"def full_name\n get_full_name\n end",
"def last_name # same as field name ;\n User.where(id: object.user_id)[0].last_name\n end",
"def full_name \n if current_user\n current_user.firstname + \" \" + current_user.lastname\n else\n \"Please Log in\"\n end\n end",
"def get_user_name\n if first_name.blank?\n return email.split('@').first.capitalize unless email.blank? \n else\n return first_name.capitalize + \" \" + last_name.capitalize\n end \n return ''\n end",
"def user_name\n name = user.nil? ? '' : user.name\n end",
"def user_name\n @user_name ||= SlackUtils::SingletonClient.instance.find_user_name(@user_id)\n end",
"def get_name()\n return @me.uname if @me.brother.nil?\n return @me.brother.full_name\n end",
"def display_resource(user)\n user.full_name\n end",
"def name\n if first_name.present? || last_name.present?\n [first_name, last_name].join(\" \").strip\n else\n username\n end\n end",
"def get_name(user_info)\n return user_info[\"name\"]\n end",
"def display_name_for(user)\n user.first_name.capitalize + ' ' + user.last_name.capitalize + ' ( ID: ' + user.reference_number + ')'\n end",
"def user_name\n name = self.le_user.nil? ? '' : self.le_user.name\n end",
"def full_name\n \"#{user_profile.first_name} #{user_profile.last_name}\" unless user_profile.blank?\n end",
"def get_current_user_name\n return @name if @name\n name = get_current_user_meta\n name = name['query']['userinfo']['name'] if name\n\n name\n end",
"def display_name\n \"#{username} <#{email}>\"\n end",
"def user_name\n self.user.login\n end",
"def user_name\n self.user.login\n end",
"def to_s\n return user.name\n end",
"def name\n userName\n end",
"def full_name_with_id\n id.to_s + \": \" + user.first_name + \" \" + user.last_name\n end",
"def name\n if facebook_authentication && facebook_authentication.display_name\n return facebook_authentication.display_name\n end\n return username\n end",
"def user_name(user_id)\n user = User.where(id: user_id).name\n\n assert(user.kind_of?(User))\n\n return user\n end",
"def getUserName(userName)\n if(userName != nil)\n user = loadUser(userName)\n return user[\"fname\"]+\" \"+user[\"lname\"]\n end\n return \"User not Found!\"\n end",
"def show_user\n \tuser = User.where({:id => self.user_id}).first\n \tuser.name\n end",
"def full_name()\n name + ' ' + last_name\n end",
"def display_name\n if cas_surname and cas_givenname\n cas_givenname + ' ' + cas_surname\n else\n username\n end\n end",
"def get_display_name\n @display_name ||= self.user.display_name\n end",
"def full_name\n\t\treturn self.salutation.to_s + \" \" + self.last_name.to_s + \" \" + self.first_name.to_s\n end",
"def get_user_name_by_id(user_id)\n @user = User.find(:first ,:select=>\"name\",:conditions=>[\"id=#{user_id}\"])\n return @user.name\n end",
"def user_name\n @message[:user][:name]\n end",
"def name\n profile.user.name\n end",
"def name\n result = []\n result << self.first_name\n result << self.last_name\n if result.compact.empty?\n self.user.login if self.user\n else\n result.compact.map {|m| m.to_s.strip}.reject {|i| i.blank?}.join(' ')\n end\n end",
"def name\n \"#{user_name.titleize}\"\n end",
"def name\n\t\tself.rsuser.display_name\n\tend",
"def full_name\n name\n end",
"def full_name\n name\n end",
"def get_username\n @user_name ||= self.user.username\n end",
"def get_login_with_full_name\n self.login.to_s + ' | ' + self.escolar.full_name.to_s\n end",
"def first_name # same as field name ;\n User.where(id: object.user_id)[0].first_name\n end",
"def get_name_surname\n\t\tuser.name + ' ' + user.surname\n\tend",
"def hubssolib_get_user_name\n user = self.hubssolib_current_user\n user ? user.user_real_name : nil\n end"
] | [
"0.83837295",
"0.8210241",
"0.8114376",
"0.80621254",
"0.8050322",
"0.8023667",
"0.8012451",
"0.7961",
"0.79534596",
"0.79534596",
"0.79511935",
"0.79436636",
"0.79127276",
"0.7909869",
"0.78790694",
"0.7841238",
"0.78361505",
"0.77807677",
"0.7778531",
"0.7717547",
"0.77145374",
"0.7713052",
"0.7710015",
"0.7707531",
"0.7678078",
"0.76780236",
"0.7672368",
"0.76611036",
"0.76611036",
"0.76611036",
"0.7651876",
"0.7650736",
"0.7637639",
"0.7627479",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.762145",
"0.761512",
"0.7604019",
"0.760292",
"0.76026815",
"0.7575315",
"0.7575007",
"0.7570877",
"0.75691545",
"0.754244",
"0.7542042",
"0.7539688",
"0.7529821",
"0.74734974",
"0.7467152",
"0.74626106",
"0.74603707",
"0.74594176",
"0.7457231",
"0.7456686",
"0.74460036",
"0.74222255",
"0.7382811",
"0.73744726",
"0.73640144",
"0.7338906",
"0.7314763",
"0.730379",
"0.7299999",
"0.7298358",
"0.7293098",
"0.728285",
"0.7276241",
"0.7276241",
"0.72675467",
"0.7262274",
"0.72379935",
"0.7237927",
"0.72378224",
"0.72306204",
"0.7219994",
"0.7219882",
"0.72176164",
"0.72141194",
"0.72129375",
"0.7207412",
"0.72035784",
"0.7190589",
"0.71884066",
"0.7187402",
"0.7185164",
"0.71843916",
"0.7184256",
"0.7182887",
"0.7182045",
"0.7162606",
"0.7158189",
"0.71540356"
] | 0.0 | -1 |
if an students unapplies for that said job then we just delete the record. | def student_unapplied
@job_application = JobApplication.find(params[:id])
if @job_application.student_id == current_user.roleable.id
@job_application.delete
flash[:notice] = "Listo, ya no estas aplicando para ese puesto"
redirect_to see_jobs_path
else
flash[:notice] = "No puedes desaplicar para un trabajo que no haz aplicado"
redirect_to see_jobs_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobs_del\r\n job_profile_id = params[:job_profile_id]\r\n job_profile = JobProfile.find(job_profile_id, :select => \"id, account_id\")\r\n \r\n return jump_to(\"/errors/forbidden\") unless job_profile.account_id == session[:account_id]\r\n \r\n JobProfile.delete(job_profile_id)\r\n @job_profile_entry_id = \"job_profile_#{job_profile_id}\"\r\n end",
"def destroy_applicant\n @job_user = JobUser.find(params[:id])\n @job = @job_user.job\n @job_user.delete\n redirect_to job_path(@job)\n end",
"def dequeue(job)\n @jobs = @jobs.delete(job.key)\n\n self.save\n end",
"def delete\n job_resource.delete\n end",
"def delete_job job_id\n @schedule_list.delete_if {|x| x.id == job_id }\n end",
"def remove_record(record)\n atoms = condense_record(record)\n load_atoms(atoms)\n atoms.each do |a|\n @atoms[a].remove_record(record.id) if @atoms.has_key?(a)\n @records_size -= 1\n #p \"removing #{record.id} from #{a}\"\n end\n end",
"def destroy\n @job_student = JobStudent.find(params[:id])\n @job_student.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_students_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @job = Job.find(params[:id])\r\n @job.destroy\r\n @free_subscription = FreeSubscription.find_by(guid: @job.guid).destroy\r\n flash[:success] = \"vacature verwijderd\"\r\n redirect_to mijn_vacatures_user_path(@job.user)\r\n end",
"def delete_job(sid)\n\t\t\tresponse = connection.delete(\"search/jobs/#{sid}\")\n\t\t\treturn_error_or_body(response, response.body)\n\t\tend",
"def destroy\n @job = Job.find(params[:id])\n if current_user.is_an_admin? or @job.status != \"paid\"\n @job.destroy\n else\n flash[:error] = \"Paid jobs can only be modified by an administrator.\"\n end\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def delete_student(person)\n c = CoursePerson.first(:person_id => person.id, :course_id => self.id)\n # puts c.inspect\n if c \n c.destroy!\n self.save\n else\n puts \"wasn't a member\"\n end \n end",
"def destroy\n @job.destroy # all support documents automatically get destroyed\n flash[:success] = \"Job has been successfully deleted\"\n redirect_to active_jobs_path\n end",
"def process_invalid(job)\n logger.info \"invalid job:\\n#{job.inspect}\"\n sqs.delete_message(\n queue_url: backlog_address,\n receipt_handle: job.receipt_handle\n )\n # TODO: make sure this is sending a message to needs_attention too\n end",
"def remove_student_from_school(student_name)\n self.students.delete_if do |student|\n student.name == student_name\n end\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_record(record)\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record,record.id)\n\n @storage.remove(atoms)\n end",
"def destroy\n #@student.destroy\n # Soft deleting student for now\n @student.update(is_deleted: true)\n end",
"def remove_student_from_school(student_name)\n self.students.delete_if do |student|\n student[:name] == student_name\n end\n end",
"def destroy\n @job_scope_addition = JobScopeAddition.find(params[:id])\n jid = @job_scope_addition.jobs_id\n jsa_id = params[:id]\n recs = AdditionTaskRecord.find_all_by_jobs_id(jsa_id)\n delete_records(recs)\n @job_scope_addition.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"#{job_scope_additions_url}?jid=#{jid}\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n if @encoding_job.can_be_destroyed_by?(logged_in_user, is_admin?) && @encoding_job.destroy\n flash[:notice] = 'Encoding job removed'\n else\n flash[:warn] = \"Unable to remove encoding job.\"\n end \n redirect_to encoding_jobs_path\n end",
"def unassigne_job(role,project)\n assignements.create(role_id:role,project_id:project).destroy\n end",
"def uncomplete_job(user)\n job_completions.find_by(user_id: user.id).destroy\n end",
"def endJob\n\t\tunits.each do |unit|\n\t\t\tunemployUnit unit\n\t\tend\n\t\t\n\t\t# TODO: Remove job from it's queue\n\t\t\n\t\[email protected]('sgt-job:' + @id + ':units')\n\t\[email protected]('sgt-job:'+@id)\n\tend",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n redirect_to jobs_path\n end",
"def delete!\n uniq.bulk_job { |e| e.delete! }\n end",
"def destroy\n if current_user.is_employer?\n @job = Job.find(params[:id])\n @job.destroy\n flash[:success] = \"Job deleted\"\n redirect_to job_index_path\n else\n flash[:notice] = \"You are not allowed to delete jobs. Only employers can do that!\"\n redirect_to job_index_path\n end\n end",
"def delete\n (status,error) = execio \"sudo -u #{self.job_owner} qdel #{self.jobid}\", nil\n if status.class == String and status.match(/^.*job.*#{self.jobid}.*/)\n self.state = \"d\"\n return 0\n else\n raise RuntimeError, \"Deletion of job #{self.jobid} failed!\"\n return nil\n end\n end",
"def delete!\n uniq.both_e.uniq.bulk_job { |e| e.delete! }\n uniq.bulk_job { |e| e.delete! }\n end",
"def remove_students\n @course = Course.find(params[:id])\n to_remove = params[:to_be_removed]\n if to_remove\n to_remove.each do |stu_id, do_it|\n if do_it == \"yes\"\n student = Student.find(stu_id)\n @course.students.delete(student)\n @course.save\n end\n end\n end\n redirect_to students_admin_course_path(@course)\n end",
"def remove_student(user)\n user = User.find(user) unless user.is_a?(User)\n students.delete(user)\n return 1\n\n rescue\n return 0\n end",
"def destroy\n @job = Job.find(params[:id])\n # refund the employer his money if he deletes the job\n @employer = User.find(@job.employer_id)\n @employer = @employer.specific\n @employer.update_attributes(:money => @employer.money + @job.pay)\n @job.destroy\n \n # do something about sending a notification of a jury trial, \n # plus actually doing the trial\n \n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n redirect_to jobs_path, notice:'Job deleted.'\n end",
"def delete\n ensure_service!\n service.delete_job job_id, location: location\n true\n end",
"def destroy\n @job = current_member.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find_by_job_number(params[:id])\n if admin?\n @job.destroy\n end\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job.destroy\n redirect_to root_url\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student = @students_record.student\n destroyed = ActiveRecord::Base.transaction_user(@current_user) {\n if (@current_group == \"sysadmin\" and @students_record.status != \"active\") or\n @students_record.destroyable?\n @student.pkgs.destroy(@students_record.pkg)\n @students_record.destroy\n end\n }\n logger.info(\"redirect to #{students_record_url(@student)}\")\n respond_to do |format|\n if destroyed\n format.html {\n flash[:success] = 'Students record was successfully destroyed.'\n redirect_to students_record_url(@student)\n }\n format.json { head :no_content }\n else\n format.html {\n flash[:alert] = 'Students record was NOT destroyed.'\n redirect_to students_record_url(@student)\n }\n format.json { head :no_content }\n end\n end\n end",
"def remove_student(name)\n\t\tstudents.each do |student|\n\t\t\tif student[:name] == name\n\t\t\t\tstudents.delete(student)\n\t\t\tend\n\t\tend\n\tend",
"def destroy\n applic = Applic.find(:job_id=>params[:id])\n if !applic.nil? && applic.user == current_user\n respond_to do |format|\n if applic.destroy\n flash[:error] = \"Withdrew your application successfully. \"\n flash[:error] << \"Keep in mind that your initial application \"\n flash[:error] << \"email has already been sent.\"\n format.html { redirect_to(:controller=>:jobs, :action=>:index) }\n else\n flash[:error] = \"Couldn't withdraw your application. \"\n flash[:error] << \"Please try again, or contact support.\"\n format.html { redirect_to(:controller=>:dashboard) }\n end\n end\n else\n flash[:error] = \"Error: Couldn't find that application.\"\n redirect_to(:controller=>:dashboard)\n end\n end",
"def destroy\n @job = current_user.posted_jobs.find(params[:id])\n @job.try(:destroy)\n render json: {}\n end",
"def destroy\n @student.destroy\n end",
"def destroy\n @student.destroy\n\n end",
"def submit_edit\n id = params[:course_id]\n requires({'role' => ['admin','faculty'],'course_id'=>id})\n course_number = params[:number]\n course_term = params[:term]\n course_name = params[:name]\n course_section = params[:section]\n\n studentsToRemove = params[:students_to_remove]\n tasToRemove = params[:tas_to_remove]\n\n course = Course.find(id)\n \n\n\n course.course_number = course_number\n course.term = course_term\n course.name = course_name\n course.section = course_section\n course.save\n \n StudentInCourse.delete_all(:course_id => id, :user_id => studentsToRemove)\n TaForCourse.delete_all(:course_id => id, :user_id => tasToRemove)\n\n flash[:notice] = \"Changes saved.\"\n \n end",
"def destroy\n @device = Device.find(params[:device_id])\n @job = @device.jobs.find(params[:id])\n \n if !owner?(@job)\n flash[:error] = \"Dazu hast du keine Berechtigung!\"\n elsif ConflictHelper.is_processing?(@job)\n flash[:error] = \"Auftrag wird gerade bearbeitet und kann nicht mehr geloescht werden\"\n else\n job_id = @job.id\n @job.destroy\n if @device.jobs.find(:all, :conditions => [\"finished == ?\", 0]).count == 0\n @device.update_attributes(:state => 0)\n else\n ConflictHelper.delete_management(@device, job_id)\n end\n flash[:success] = \"Auftrag wurde erfolgreich geloescht\"\n end\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n format.js { render :nothing => true, :status => 200 }\n end\n end",
"def remove_all\n @batch = Batch.shod(params[:format])\n @students ||= @batch.students\n authorize! :read, @batch\n end",
"def destroy\n Job.destroy(params[:id])\n end",
"def destroy\n @applicant_job.destroy\n respond_to do |format|\n format.html { redirect_to applicant_jobs_url, notice: 'Applicant job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_assessment_data_if_employee_not_assessed\n # if is_not_assessed?\n # active_assessment = Assessment.active.last\n # if active_assessment.present?\n # employee_goals.where(assessment_id: active_assessment.id).delete_all\n # attendances.where(\"extract(year from date) = ?\", active_assessment.year).delete_all\n # employees_assessments.where(assessment_id: active_assessment.id).where(manual: false).delete_all\n # end\n # end\n end",
"def destroy\n @job = Job.destroy(params[:id])\n redirect_to jobs_path\n end",
"def final_update_record(record,jobacct)\n # do nothing\n end",
"def destroy\n\t\t@student = Student.find(params[:id])\n#\t\tredirect_to(@student, :notice => 'NOTICE: During initial testing, the deletion of students has been turned off.')\n#\t\treturn\n\t\tBrowse.student_changed(nil, @student)\n\t\tsolr().remove_object(@student.to_solr())\n\t\[email protected]_references()\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to({:controller => 'admin', :action => 'index'}) }\n\t\tend\n\tend",
"def unsubmit_students\n # self.lesson.students - self.students\n self.grades_course.students - self.students\n end",
"def destroy\n @sfjob = Sfjob.find(params[:id])\n @sfjob.destroy\n\n respond_to do |format|\n format.html { redirect_to sfjobs_url }\n format.json { head :no_content }\n end\n end",
"def delete_student(sId)\n return false unless File.exist?(file)\n\n @data[:students].each do |value|\n next unless value[:id] == sId\n\n @data[:students][sId][:status] = :removed\n save_data\n return 1\n end\n 0\n end",
"def destroy\n @job.destroy\n flash[:success] = 'Job was successfully destroyed.' \n redirect_to jobs_url \n end",
"def delete(record)\n record.del\n end",
"def destroy \n @job = Mugen::Job.delete(params[:id])\n \n respond_to do |format|\n format.html { redirect_to(mygengo_jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @job.destroy\n redirect_to root_path, alert: \"Job offer succesfully deleted\"\n end",
"def delete_students(db, student_name)\n\tdb.execute(\"DELETE FROM students WHERE name=?\", [student_name])\nend",
"def destroy\n @saved_job = SavedJob.find(params[:id])\n @saved_job.destroy\n\n respond_to do |format|\n format.html { redirect_to saved_jobs_url }\n format.json { head :no_content }\n end\n end",
"def unreject_job(user)\n job_rejections.find_by(user_id: user.id).destroy\n end",
"def incompleted\n @job = Job.find(params[:id])\n # refund the employer his money if he deletes the job\n @employer = User.find(@job.employer_id)\n @employer = @employer.specific\n @employer.update_attributes(:money => @employer.money + @job.pay)\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: 'Job was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to mentor_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @applied_job.destroy\n respond_to do |format|\n format.html { redirect_to applied_jobs_url, notice: 'Applied job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: \"Job was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def complete_removal(manual_record)\n document_ids = document_ids_for(manual_record)\n\n document_ids.each do |id|\n SpecialistDocumentEdition.where(document_id: id).map(&:destroy)\n end\n\n manual_record.destroy\n\n log \"Manual destroyed.\"\n log \"--------------------------------------------------------\"\n end",
"def destroy\n respond_with Job.find(params[:id]).delete\n end",
"def unstart\n @started_scholarship = StartedScholarship.find_by(user_id: params[:user_id], scholarship_guide_id: params[:scholarship_guide_id])\n #@log_save = RecordLog.new(user_id: params[:user_id], scholarship_guide_id: params[:scholarship_guide_id], scholarship_name: params[:scholarship_name], deleted: 1)\n #@log_save.save!\n\n @started_scholarship.destroy\n respond_to do |format|\n format.html { redirect_to request.referrer, notice: 'Saved Scholarship was successfully unsaved.' }\n end\n end",
"def destroy\n job_id = @recording.job_id\n @recording.destroy\n respond_to do |format|\n format.html { redirect_to recordings_url, notice: 'Recording was successfully destroyed.' }\n format.json { head :no_content }\n end\n Sidekiq::ScheduledSet.new.select { |retri|\n retri.jid == @recording.job_id\n }.each(&:delete)\n end",
"def delete_rejected\n @assignment = Assignment.find(params[:id])\n membership = StudentMembership.find(params[:membership])\n membership.delete\n membership.save\n redirect_to action: 'student_interface', id: params[:id]\n end",
"def destroy \n @job_part.destroy \n increaseStock(@job_part)\n redirect_to job_path(id:params[:job_id])\nend",
"def delete\n DATABASE.execute(\"DELETE FROM students WHERE id = #{@id}\")\n end",
"def delete\n DATABASE.execute(\"DELETE from students WHERE id = #{id}\")\n end",
"def finish_job job\n job_id = job.respond_to?(:id) ? job.id : job\n @current_jobs.delete job_id\n @job_pids.delete(job_id)\n end",
"def destroy\n delete_with_references(@student,students_path)\n end",
"def destroy\n #@job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def delete_record!(record)\n record.public_send(inventory_collection.delete_method)\n inventory_collection.store_deleted_records(record)\n end",
"def destroy\n if current_user.nil?\n redirect_to login_path and return false\n end\n\n #p current_user\n #p current_user.jobs\n\n if current_user.jobs.empty?\n redirect_to root_path and return false\n end\n\n if current_user.is_admin?\n @job = Job.find(params[:id])\n else\n @job = current_user.jobs.find(params[:id])\n end\n\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.hidden = true\n\t\[email protected]\n\n\t\tif @job.save\n\t\t flash[:notice] = 'Job successfully removed.'\n\t\tend\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @short_leave_request\n if ShortLeaveApproval.exists?(short_leave_request_id: @short_leave_request.id)\n flash[:alert] = \"Record is created ! \"\n else\n @short_leave_request.destroy\n @short_leave_requests = ShortLeaveRequest.all\n end\n end",
"def clean_students\n add_students_to_remove\n student_ids = @annotation.annotated_students.map(&:student_id)\n params[:annotated_students_attributes]&.delete_if do |h|\n student_ids.include? h[:student_id]\n end\n end",
"def destroy\n @saved_job.destroy\n respond_to do |format|\n format.html { redirect_to saved_jobs_url, notice: t('saved_jobs_controller.saved_jobs_delete_success') }\n format.json { head :no_content }\n end\n end",
"def delete_expired_jobs\n ref_ids_in_db = Set.new(Listing.where('ref_id IS NOT NULL').pluck(:ref_id))\n ref_ids_in_feed = Set.new(@ref_id_xpath.map(&:text).map(&:to_i))\n Listing.where(ref_id: (ref_ids_in_db - ref_ids_in_feed).to_a).update_all(\"status = 'expired'\")\n end",
"def delete_outdated_record(original_record)\n ETL::Engine.logger.debug \"deleting old row\"\n \n q = \"DELETE FROM #{dimension_table} WHERE #{primary_key} = #{original_record[primary_key]}\"\n connection.delete(q)\n end",
"def destroy\n if UbiquoJobs.manager.delete(params[:id])\n flash[:notice] = t(\"ubiquo.jobs.job_removed\")\n else\n flash[:error] = t(\"ubiquo.jobs.cant_remove\")\n end\n\n respond_to do |format|\n format.html { redirect_to(ubiquo.jobs_path) }\n format.xml { head :ok }\n end\n end",
"def dequeue\n self.job.destroy if self.job.present?\n self.job_id = nil\n end",
"def destroy\n # if Job.find_by_model_id(params[:id])\n if Job.exists?(:model_id => params[:id])\n flash[:notice] = t(:model_used)\n redirect_to models_path\n else\n @model = Model.find(params[:id])\n @model.destroy\n flash[:notice] = t(:model_deleted)\n respond_to do |format|\n format.html { redirect_to(models_url) }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n authorize!(@job)\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Construction::Job.transaction do\n @construction_job = Construction::Job.lock.find(params[:id])\n \n raise ForbiddenError.new('not owner of job') unless @construction_job.queue.settlement.owner == current_character\n\n # test if there are jobs depending on this one, if not, remove job\n \n queue = @construction_job.queue\n \n # call cancel at slot to remove the building id if there is no building in slot\n if @construction_job.last_in_slot\n @construction_job.slot.job_cancelled(@construction_job)\n @construction_job.refund_for_job if @construction_job.active?\n @construction_job.destroy\n queue.reload\n queue.check_for_new_jobs\n else\n raise ForbiddenError.new('Could only remove last job of slot') \n end\n end\n\n respond_to do |format|\n format.html { redirect_to construction_jobs_url }\n format.json { head :ok }\n end\n end",
"def cancel_associated_job!\n return unless respond_to?(:background_job_ref) && background_job_ref.present?\n\n ref_parts = background_job_ref.split('%')\n valid_ref_cns = ['delayed__backend__active_record__job'].freeze\n valid_ref_cn = valid_ref_cns.select { |s| s == ref_parts.first }.first\n return unless valid_ref_cn\n\n job = valid_ref_cn.ns_camelize.constantize.find(ref_parts.last.to_i)\n job&.delete\n end",
"def destroy\n\t\t@student = Student.find(params[:id])\n\n\t\[email protected] do |course|\n\t\t\tcourse.students.delete @student\n\t\tend\n\n\t\[email protected]\n\t \n\t\tredirect_to root_url\n\tend",
"def quitWorkingJob\n\t\[email protected]('sgt-unit:'+@id, 'job')\n\tend",
"def destroy\n @job_assignment = @group.jobs.find(params[:id])\n @job_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to group_jobs_path(@group) }\n format.json { head :no_content }\n end\n end",
"def delete_students\n CSV.open(\"students.csv\", \"w\") do |csv|\n @students.clear\n end\nend",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n @resound_process = ResoundProcess.find_by_student_id(@student.id)\n @resound_process.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n Sidekiq.redis do |conn|\n # delete from set\n conn.srem self.class.jobs_key, redis_key\n\n # delete runned timestamps\n # conn.del job_enqueued_key\n\n # delete jid_history\n conn.del jid_history_key\n\n # delete main job\n conn.del redis_key\n end\n\n logger.info { \"CRON JOB: deleted job with name: #{@name}\" }\n end",
"def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.66234404",
"0.65108913",
"0.6461721",
"0.6416897",
"0.63391805",
"0.63268554",
"0.63065636",
"0.6295047",
"0.6269776",
"0.62350667",
"0.62238663",
"0.62159127",
"0.61691797",
"0.6156001",
"0.61480963",
"0.61480963",
"0.61183065",
"0.6116055",
"0.6114518",
"0.61044985",
"0.609982",
"0.6060019",
"0.6042469",
"0.6020086",
"0.6017495",
"0.6017431",
"0.6016447",
"0.59822303",
"0.5980098",
"0.5963984",
"0.5952215",
"0.59481",
"0.5945692",
"0.5938649",
"0.592443",
"0.5913085",
"0.5912461",
"0.59083545",
"0.58968544",
"0.58952296",
"0.5891912",
"0.5889352",
"0.5885119",
"0.5875755",
"0.58670974",
"0.5857916",
"0.5854957",
"0.5851355",
"0.5850195",
"0.5847571",
"0.5844554",
"0.58410096",
"0.58214366",
"0.5819179",
"0.5819033",
"0.5818065",
"0.5812191",
"0.57920015",
"0.57892317",
"0.5785644",
"0.5780849",
"0.5780041",
"0.5752186",
"0.57443315",
"0.5736726",
"0.5736136",
"0.5733727",
"0.57306874",
"0.5722548",
"0.5721875",
"0.5719242",
"0.57110906",
"0.5706411",
"0.5693457",
"0.56930465",
"0.5689831",
"0.5674658",
"0.5671677",
"0.56715375",
"0.5669503",
"0.56656545",
"0.5663535",
"0.56615597",
"0.566067",
"0.56532764",
"0.564537",
"0.56436795",
"0.5634893",
"0.56340563",
"0.56339395",
"0.56332594",
"0.56265056",
"0.562361",
"0.5611289",
"0.56084627",
"0.5606674",
"0.5602933",
"0.5597955",
"0.5595591",
"0.55954367"
] | 0.64928657 | 2 |
if the company decides to hire the student then we only update the status of the JobApplication record | def company_hired
@job_application = JobApplication.find(params[:id])
if @job_application.job.company_id == current_user.roleable.id
@job_application.status = "Contratado"
flash[:notice] = "Se ha contratado correcamente al egresado!"
@student = Student.find(@job_application.student_id)
@student.state = 2
@student.save
redirect_to jobs_path
else
flash[:notice] = "No puedes acceder a esta pagina"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_job_status\n if hired_changed? and job\n if hired\n self.job.update_attribute :open, false\n else\n self.job.update_attribute :open, true\n end\n end\n end",
"def update\n if params[:job][:staff].present?\n @job.staff.clear\n params[:job][:staff].each do |s|\n @job.staff << Staff.where(id: s)\n end\n end\n if params[:job][:contractor].present?\n @job.contractor = Contractor.find(params[:job][:contractor])\n end\n if params[:job][:date_completed].present? and params[:job][:date_payment_recv].present? and params[:job][:date_completed] <= Time.now and params[:job][:date_payment_recv] <= Time.now\n @job.status = 0\n end\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n unless @login_user_role == \"1\"\n flash[:error] = \"You don't have paermission.\"\n redirect_to :action => \"index\"\n return\n p \"hoge\"\n end\n\n #approveおよびdenyは承認者権限のみなのでチェックが必要\n @application = Application.find(params[:id])\n result = false\n if params['commit'] == \"approve\"\n result = @application.update_attribute(\"status\",1)\n\n\n\n\n\n #ary = ParseDate::parsedate(@application['start']) #=> [2001, 5, 24, 22, 56, 30, \"JST\", 4]\n #t = Time::local(*ary[0..-3]) #=> Thu May 24 22:56:30 JST 2001\n\n#2013-06-13 20:56:11 UTC\n\n starttime = Time.strptime(@application['start'].to_s, '%Y-%m-%d %H:%M:%S')\n endtime = Time.strptime(@application['start'].to_s, '%Y-%m-%d %H:%M:%S')\n\n job = Job.new\n\n #sgの算出処理必要\n #job.send_at starttime, :authorize_ingress_from_gw_to_target, @access_key, @secret_access_key, @region,sg\n #job.send_at endtime, :revoke_ingress_from_gw_to_target, @access_key, @secret_access_key, @region,sg\n\n\n elsif params['commit'] == \"deny\"\n result = @application.update_attribute(\"status\",2)\n end\n respond_to do |format|\n if result\n format.html { redirect_to :action => \"index\", notice: 'Application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user=current_user\n @job=Job.find(session[:job_id])\n @[email protected]\n @jobapplication.email=current_user.email\n respond_to do |format|\n if @jobapplication.update(jobapplication_params)\n format.html { redirect_to @jobapplication, notice: 'Jobapplication was successfully updated.' }\n format.json { render :show, status: :ok, location: @jobapplication }\n else\n format.html { render :edit }\n format.json { render json: @jobapplication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @assessment_olympiad = AssessmentOlympiad.find(params[:id])\n if current_user.role.id == 7\n params[:assessment_olympiad][:status] = 6\n end\n respond_to do |format|\n if @assessment_olympiad.update_attributes(params[:assessment_olympiad])\n format.html { redirect_to@assessment_olympiad, notice: 'AssessmentOlympiad was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json:@assessment_olympiad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_job_offer\n jo = JobOffer.find_by(member: self.member, job: self.job)\n \n unless jo.blank?\n jo.job_application = self\n jo.save\n end\n end",
"def update_job job\n job.check_number = '0' if job.check_number.blank?\n job.pages_from = 1\n job.payer = Payer.find_by_payer(\"No Payer\")\n return job\n end",
"def update_job job\n job.check_number = '0' if job.check_number.blank?\n job.pages_from = 1\n job.payer = Payer.find_by_payer(\"No Payer\")\n return job\n end",
"def update\n before_update\n\n @studenthousinginfo.status = 'Waiting for Approval'\n\n respond_to do |format|\n if @studenthousinginfo.update(studenthousinginfo_params)\n format.html { redirect_to @studenthousinginfo, notice: 'Studenthousinginfo was successfully updated.' }\n format.json { render :show, status: :ok, location: @studenthousinginfo }\n else\n format.html { render :edit }\n format.json { render json: @studenthousinginfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_status(employee, status)\n self.where(employee_no: employee.employee_no, employee_name: employee.name).update_all(\n status: status,\n employee_exists: false\n )\n end",
"def update\n @job = Job.find(params[:id])\n case params[:status]\n when \"requested\"\n @job.status :requested\n when \"printed\"\n @job.status :printed\n when \"paid\"\n @job.status :paid\n end\n \n @job.save\n\n respond_to do |format|\n if @job.update_attributes(params[:job])\n flash[:notice] = 'Job was successfully updated.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_status\r\n self.reload\r\n jobs = self.jobs\r\n complete_jobs = get_complete_jobs(jobs, JobStatus::COMPLETED, ProcessorStatus::COMPLETED) \r\n incomplete_jobs = get_complete_jobs(jobs, JobStatus::INCOMPLETED, ProcessorStatus::INCOMPLETED) unless self.facility.client.name == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER'\r\n incomplete_jobs = get_upmc_incomplete_jobs(jobs, JobStatus::INCOMPLETED) if self.facility.client.name == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER'\r\n complete_output_ready_jobs = get_output_ready_jobs(jobs, JobStatus::COMPLETED, ProcessorStatus::COMPLETED, QaStatus::COMPLETED) \r\n incomplete_output_ready_jobs = get_output_ready_jobs(jobs, JobStatus::INCOMPLETED, ProcessorStatus::INCOMPLETED, QaStatus::INCOMPLETED)\r\n\r\n excluded_jobs = jobs.select do |job|\r\n job.job_status.upcase == JobStatus::EXCLUDED\r\n end\r\n \r\n new_jobs = jobs.select do |job|\r\n job.job_status == JobStatus::NEW\r\n end\r\n\r\n allocated_jobs = jobs.select do |job|\r\n job.job_status == JobStatus::PROCESSING\r\n end\r\n\r\n excluded_processing_or_new_jobs = jobs.select do |job|\r\n ((job.job_status == JobStatus::NEW || job.job_status == JobStatus::PROCESSING) &&\r\n job.is_excluded == true)\r\n end\r\n\r\n previous_status = self.status\r\n if jobs.size == new_jobs.size or jobs.size == 0\r\n self.status = BatchStatus::NEW\r\n self.completion_time = nil\r\n elsif jobs.size == (complete_output_ready_jobs.size + excluded_jobs.size +\r\n incomplete_output_ready_jobs.size + excluded_processing_or_new_jobs.size)\r\n self.completion_time = Time.now\r\n self.status = BatchStatus::OUTPUT_READY\r\n elsif jobs.size == (complete_jobs.size + excluded_jobs.size +\r\n incomplete_jobs.size + excluded_processing_or_new_jobs.size)\r\n self.completion_time = Time.now\r\n self.status = BatchStatus::COMPLETED\r\n else\r\n self.status = BatchStatus::PROCESSING\r\n self.completion_time = nil\r\n end\r\n if previous_status == BatchStatus::NEW && self.status == BatchStatus::PROCESSING &&\r\n self.processing_start_time.blank?\r\n self.processing_start_time = Time.now\r\n end\r\n if previous_status == BatchStatus::PROCESSING && self.status == BatchStatus::COMPLETED\r\n self.processing_end_time = Time.now\r\n end\r\n set_qa_status\r\n self.save \r\n end",
"def update\n @job = Job.find(params[:id])\n if current_user.has_role?(\"employer\") and @job.finished.nil? and current_user.id == @job.employer_id\n respond_to do |format|\n if @job.update_attributes(params[:job]) and update_url(@job, params[:google_code_issue])\n flash[:notice] = 'Job was successfully updated.'\n format.html { redirect_to(@job) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to :action => 'index'\n end\n end",
"def complete_homework\n self.homeworks.where(\"status = ?\", \"incomplete\").each {|hw| hw.update(status: \"completed\")}\n end",
"def update\n @job_application = JobApplication.find(params[:id])\n\n respond_to do |format|\n if @job_application.update_attributes(params[:job_application])\n format.html { redirect_to vacancy_path(@job_application.vacancy_id), notice: 'Job application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\t status_param = params.require(:collaboration_application).permit(:status)\n\t status = @application.status\n if @application.update(status_param)\n format.html { redirect_to @application, notice: \"Application was successfully #{@application.status}.\" }\n else\n\t @application.status = status\n format.html { render action: 'show' }\n end\n end\n end",
"def call_status\n job = Job.find(params[:job_id])\n if !job.expert_id.blank? or !job.expert_id.nil?\n render :json=> {:success => false }\n else\n if params[:accept]\n job.update_attributes(:status => \"completed\", :expert_id => params[:expert_id])\n elsif params[:end]\n job.update_attributes(:status => \"active\")\n end\n end\n end",
"def update\n @job_application = JobApplication.find(params[:id])\n\n respond_to do |format|\n if @job_application.update_attributes(params[:job_application])\n format.html { redirect_to @job_application, notice: 'Job application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_job_status_from_details\n @project_job = @current_organization.project_jobs.find(params[:id])\n if params[:status].present?\n if @project_job.status.present? && @project_job.status != params[:status]\n @project_job.update_column(:status, params[:status])\n @project_job.check_or_upgrade_project_stage \n create_comment_activity(\"<b>\"+params[:status]+ \"</b> the Task\")\n create_in_app_notification(\"Update\", \"Job status changed to #{params[:status]}\")\n Activity.create(:organization_id => @project_job.organization_id, :activity_user_id => @current_user.id, :activity_type => @project_job.class.name, :activity_id => @project_job.id, :activity_status => \"StatusChanged\", :activity_desc => \"Job status changed to #{params[:status]}\", :activity_date => @project_job.updated_at, :is_public => true, :source_id => @project_job.project.id,:source_type => @project_job.project.class.name)\n end\n end\n render partial: \"project_job_status_bar\"\n end",
"def update_job_status(status)\n @csv_report_job.status = status\n @csv_report_job.save!\n end",
"def update\n respond_to do |format|\n if @jobapplication.update(jobapplication_params)\n if((cookies[:employerID]!=\"\") && (!cookies[:employerID].is_a?NilClass))\n @foundjobseeker = Jobseeker.find(@jobapplication.jobseeker_id)\n UserNotifier.jobapplication_status_update_email(@foundjobseeker).deliver\n end\n format.html { redirect_to @jobapplication, notice: 'Jobapplication was successfully updated.' }\n format.json { render :show, status: :ok, location: @jobapplication }\n else\n format.html { render :edit }\n format.json { render json: @jobapplication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_application_status_type = JobApplicationStatusType.find(params[:id])\n\n respond_to do |format|\n if @job_application_status_type.update_attributes(params[:job_application_status_type])\n flash[:notice] = 'JobApplicationStatusType was successfully updated.'\n format.html { redirect_to(@job_application_status_type) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job_application_status_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @student_id = session[:user_id]\n @course_id = params[:course_id]\n\n respond_to do |format|\n if @application.update(application_params)\n \n if @application.status_id == 1\n UserMailer.rejection_email(@application.student).deliver\n elsif @application.status_id == 8\n UserMailer.acceptance_email(@application.student).deliver\n elsif @application.status_id == 5\n @application.course.instructors.each do |instructor|\n UserMailer.instructor_email(instructor).deliver\n end\n end\n\n \n format.html { redirect_to course_application_path(@application.course, @application), notice: 'Application was successfully updated.' }\n\n format.json { render :show, status: :ok, location: @application }\n else\n format.html { render :edit }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_application = JobApplication.find(params[:id])\n\n respond_to do |format|\n if @job_application.update_attributes(params[:job_application])\n flash[:notice] = 'JobApplication was successfully updated.'\n format.html { redirect_to(@job_application) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job_application.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @job_application = JobApplication.find(params[:id])\n\n respond_to do |format|\n if @job_application.update_attributes(params[:job_application])\n flash[:notice] = 'JobApplication was successfully updated.'\n format.html { redirect_to(@job_application) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job_application.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @jobapp.update(jobapp_params)\n flash[:success] = \"Jobapp was successfully updated.\"\n redirect_to action: \"index\"\n else\n render \"edit\" \n end\n end",
"def update\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to jobs_path, notice: 'Your review has been submitted' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n params[:requirement][:industry_ids] ||= []\n if params['Submit_for_Approval']\n @requirement.status = 'Submitted'\n end\n if params[:requirement][:status] == \"Rejected\"\n Requirement.destroy(params[:id])\n redirect_to requirements_path\n else\n respond_to do |format|\n if @requirement.update_attributes(params[:requirement])\n if (params['Submit_for_Approval']) and (@requirement.status != 'Submitted')\n flash[:error] = 'Could not submit requirement for approval'\n end\n format.html { redirect_to @requirement, notice: 'Requirement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @requirement.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end",
"def update\n #@jobapp = Jobapp.find(params[:id])\n\n respond_to do |format|\n if @jobapp.update_attributes(params[:jobapp])\n format.html { redirect_to @jobapp, notice: 'Jobapp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jobapp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job = Job.find_by job_number: stock_params[:job_number]\n if @job != nil\n @job_user = @job.user\n end\n params[:stock].delete :job_number\n if @job_user != nil\n if @stock.status == stock_params[:status]\n @status_updated = false\n else\n @project_manager = @job.user\n @status_updated = true\n end\n end\n @stock.update(stock_params)\n if @job != nil\n @stock.job_id = @job.id\n else\n @stock.job_id = nil\n end\n @stock_audit = StockAudit.new\n @stock_audit.user = current_user\n @stock_audit.stock = @stock\n @stock_audit.comment = \"updated stock\"\n @stock_audit.audit_params = \"#{stock_params}\"\n respond_to do |format|\n if @stock.save\n @stock_audit.save\n if @status_updated\n if @project_manager != nil\n UserMailer.status_update(@project_manager, @stock, current_user).deliver\n else\n UserMailer.jim_status_update(@stock, current_user).deliver\n end\n if @stock.status == \"Production Complete\"\n UserMailer.production_notify_accounts(@stock, current_user).deliver\n if @project_manager != nil\n UserMailer.production_notify_pm(@stock, current_user).deliver\n end\n end\n end\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @j_id = @application.job_id\n respond_to do |format|\n if @application.update(application_params)\n format.html { redirect_to @application, notice: 'Application was successfully updated.' }\n format.json { render :show, status: :ok, location: @application }\n else\n format.html { render :edit }\n format.json { render json: @application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_status_approved\n @transaction=Transaction.find(params[:id])\n @book=Book.find(@transaction.book_id)\n @transaction.update_attribute(:issued_to, @transaction.requested_by )\n @transaction.update_attribute(:issued_to_id, @transaction.requested_by_id )\n @transaction.update_attribute(:issue_date, Date.today)\n @transaction.update_attribute(:status, 1)\n @book.update_attribute(:quantity, @book.quantity-1)\n redirect_to @book, notice: \"Book approved to the student\"\nend",
"def update\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to [:admin, @job_application], notice: 'Job application was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_application }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n do_get_opts\n\n if @is_system_job\n raise CustomErrors::MethodNotAllowedError.new(\n 'Cannot update a system job\\'s analysis jobs items',\n [:post, :put, :patch, :delete]\n )\n end\n\n do_load_resource\n do_get_analysis_job\n do_authorize_instance\n\n parameters = analysis_jobs_item_update_params\n desired_state = parameters[:status].to_sym\n\n client_cancelled = desired_state == :cancelled\n should_cancel = @analysis_jobs_item.may_confirm_cancel?(desired_state)\n valid_transition = @analysis_jobs_item.may_transition_to_state(desired_state)\n\n if valid_transition\n @analysis_jobs_item.transition_to_state!(desired_state)\n elsif should_cancel\n @analysis_jobs_item.confirm_cancel(desired_state)\n end\n\n saved = @analysis_jobs_item.save\n\n if saved\n # update progress statistics and check if job has been completed\n @analysis_job.check_progress\n end\n\n if should_cancel && !client_cancelled && saved\n # If someone tried to :cancelling-->:working instead of :cancelling-->:cancelled then it is an error\n # However if client :cancelled when we expected :cancelling-->:cancelled then well behaved\n respond_error(\n :unprocessable_entity,\n \"This entity has been cancelled - can not set new state to `#{desired_state}`\"\n )\n\n elsif !valid_transition\n respond_error(\n :unprocessable_entity,\n \"Cannot transition from `#{@analysis_jobs_item.status}` to `#{desired_state}`\"\n )\n elsif saved\n respond_show\n else\n respond_change_fail\n end\n end",
"def update\n\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to job_applications_url}\n format.json { render :show, status: :ok, location: @job_application }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @applicant_job.update(applicant_job_params)\n format.html { redirect_to @applicant_job, notice: 'Applicant job was successfully updated.' }\n format.json { render :show, status: :ok, location: @applicant_job }\n else\n format.html { render :edit }\n format.json { render json: @applicant_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to @job_application, notice: 'Job application was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_application }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to @job_application, notice: 'Job application was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_application }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to job_applications_url, notice: 'JobApplication was successfully updated.' }\n format.json { render :show, status: :ok, location: @job_application }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_job_status\n @job_status = JobStatus.find(params[:id])\n end",
"def set_job_status\n @job_status = JobStatus.find(params[:id])\n end",
"def update\n @assessment = Content.find(params[:id])\n if current_user.role.id == 7\n params[:assessment][:status] = 6\n end\n respond_to do |format|\n if @assessment.update_attributes(params[:assessment])\n if @assessment.status == 6\n Content.send_message_to_est(current_user.center.est,current_user,@assessment)\n end\n format.html { redirect_to @assessment, notice: 'Assessment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #raise params.inspect\n @evaluation_result = EvaluationResult.find(params[:id])\n\n if params[:commit].to_s == \"Gravar Rascunho\"\n app = Appointment.find(params[:appoint_id].to_i)\n s = AppointmentStatus.find_by_name(\"Em Avaliacao\")\n app.appointment_status = s\n app.save\n else\n app = Appointment.find(params[:appoint_id].to_i)\n s = AppointmentStatus.find_by_name(\"Realizada\")\n app.appointment_status = s\n app.save\n end\n\n respond_to do |format|\n if @evaluation_result.update_attributes(params[:evaluation_result])\n if params[:commit].to_s == \"Gravar Rascunho\"\n format.html { redirect_to appointments_path, notice: 'Resultados da avaliacao guardados com sucesso.' }\n else\n format.html { redirect_to \"http://localhost:8000/reporting?report=Avaliacao&Appointment_Id=#{params[:appoint_id].to_s}\", notice: 'Resultados da avaliacao guardados com sucesso.' }\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation_result.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @emp_job = EmpJob.find(params[:id])\n\n respond_to do |format|\n if @emp_job.update_attributes(params[:emp_job])\n format.html { redirect_to @emp_job, notice: 'Emp job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @emp_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if current_user.job==\"申请复核人员\"\n @apply_record.shenqingfuhe=current_user.username\n elsif current_user.job==\"鉴别业务人员\"\n @apply_record.jianding=current_user.username\n elsif current_user==\"鉴别复核人员\"\n @apply_record.jiandingfuhe=current_user.username\n elsif current_user==\"证书草拟人员\"\n @apply_record.zhengshucaoli=current_user.username\n elsif current_user==\"证书发放人员\"\n @apply_record.zhengshufafang=current_user.username\n elsif current_user==\"证书绑定人员\"\n @apply_record.zhengshubangding=current_user.username\n end\n respond_to do |format|\n if @apply_record.update(apply_record_params)\n format.html { redirect_to @apply_record, notice: 'Apply record was successfully updated.' }\n format.json { render :show, status: :ok, location: @apply_record }\n else\n format.html { render :edit }\n format.json { render json: @apply_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_job_type_in_job_details\n @project_job = ProjectJob.find(params[:project_job_id])\n @project_job.update_column(:project_job_type_id, params[:job_type_id])\n create_comment_activity(\"Job type changed to <b>\"+@project_job.project_job_type.name+ \"</b>\")\n create_in_app_notification(\"Update\", \"Job type changed to #{@project_job.project_job_type.name}\")\n Activity.create(:organization_id => @project_job.organization_id, :activity_user_id => @current_user.id, :activity_type => @project_job.class.name, :activity_id => @project_job.id, :activity_status => \"JobTypeChanged\", :activity_desc => \"Job type changed to #{@project_job.project_job_type.name}\", :activity_date => @project_job.updated_at, :is_public => true, :source_id => @project_job.project.id,:source_type => @project_job.project.class.name)\n @comment = @project_job.comments.new\n render partial: \"project_details\"\n end",
"def set_status\n if status.blank?\n if (consulted_legal) && (consulted_marketing)\n status = \"Pending Approval\"\n elsif (consulted_legal) && (!consulted_marketing)\n status = \"Awaiting Marketing Approval\"\n elsif (!consulted_legal) && (consulted_marketing)\n status = \"Awaiting Legal Approval\"\n elsif (!consulted_legal) && (!consulted_marketing)\n status = \"Awaiting Marketing & Legal Approval\"\n end\n end\n true # Needs to return true for the update to go through \n end",
"def update\n respond_to do |format|\n if @job_application.update(job_application_params)\n format.html { redirect_to @job_application, notice: t('job_applications_controller.job_applications_update_success') }\n format.json { render :show, status: :ok, location: @job_application }\n else\n format.html { render :edit }\n format.json { render json: @job_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @repair.update(repair_params)\n format.html { redirect_to @repair, notice: 'Repair was successfully updated.' }\n format.json { render :show, status: :ok, location: @repair }\n \n if @repair.jobs.count == @repair.jobs.done.count\n @repair.update(done: true)\n end\n\n update_parts(@repair)\n @bus= Bus.find(@repair.bus_id)\n bus_update(@bus)\n\n else\n format.html { render :edit }\n format.json { render json: @repair.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mark_as_urgent\n @job = Job.find_by(id: params[:urgent][:job_id])\n @job.update_attribute(:urgent, true) \n redirect_to root_path\n end",
"def update\n respond_to do |format|\n if @job_site_application.update(job_site_application_params)\n format.html { redirect_to @job_site_application, notice: 'Job site application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job_site_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = @students_record.student\n respond_to do |format|\n if @students_record.valid? and ActiveRecord::Base.transaction_user(@current_user) {\n if @students_record.grade\n if params[:students_record][:status] == \"finished\" and @students_record.status != \"finished\"\n if @students_record.grade.passed?\n @students_record.update(students_record_params)\n flash[:success] = 'Students record was successfully updated. Schedule was deleted.'\n else\n flash[:alert] = %[Error: this student's grade does not qualify.]\n end\n elsif params[:students_record][:status] == \"abandoned\" and @students_record.status != \"abandoned\"\n flash[:alert] = \"Error: this student has taken the exam for this subject.\"\n # params[:students_record].delete(:finished_on)\n # params[:students_record].delete(:status)\n else\n @students_record.update(students_record_params)\n if request.format.html?\n flash[:success] = 'Students record was successfully updated.'\n end\n end\n else\n @students_record.update(students_record_params)\n if request.format.html?\n flash[:success] = 'Students record was successfully updated.'\n end\n end\n }\n format.html {\n redirect_to students_record_url(@student)\n }\n format.json { render :show, status: :ok, location: @students_record }\n else\n set_grouped_pkg_options\n format.html { render :edit }\n format.json { render json: @students_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if not params[:pk].blank?\n params[:employment][:status] = params[:value]\n end\n respond_to do |format|\n if @employment.update(employment_params)\n format.js { @notice = 'Employment was successfully updated.' }\n format.json { head :no_content }\n else\n format.js { @notice = 'Employment was successfully updated.' }\n format.json { render json: @employment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @db_job_status\n respond_to do |format|\n if @db_job_status.update(db_job_status_params)\n format.html { redirect_to @db_job_status, notice: 'Db job status was successfully updated.' }\n format.json { render :show, status: :ok, location: @db_job_status }\n else\n format.html { render :edit }\n format.json { render json: @db_job_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n if @status.update(application_status_params)\n\n \t@application_case = @status.application_case\n \t@applicants = @application_case.applicants.not_current(current_user)\n\n # Loop applicants and send a mail\n @applicants.each do |applicant|\n if !applicant.user.mail_notification_setting.nil? && !applicant.user.has_opted_out_of?(:status_update)\n ApplicationCaseMailer.status_change(applicant.user, @status.status.status, @application_case).deliver\n end\n end\n\n format.html { redirect_to @status.application_case, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @status.application_case }\n else\n format.html { render :edit }\n format.json { render json: @status.application_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @assessment_insti_test = AssessmentInstiTest.find(params[:id])\n if current_user.role.id == 7\n params[:assessment_insti_test][:status] = 6\n end\n respond_to do |format|\n if @assessment_insti_test.update_attributes(params[:assessment_insti_test])\n format.html { redirect_to@assessment_insti_test, notice: 'AssessmentInstiTest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json:@assessment_insti_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @compliance_record.update(compliance_record_params)\n @compliance_record = ComplianceRecord.new\n @compliance_records = ComplianceRecord.all\n @flag = true\n else\n @flag = false\n end\n end",
"def status_updated\n new_status = params[:new_status]\n id = params[:id]\n application = EventApplication.find_by(user_id: id)\n application.status = new_status\n application.save(:validate => false)\n flash[:success] = \"Status successfully updated.\"\n\n redirect_to event_application_path(application)\n\n\n\n # Send email when status changes.\n if new_status == 'accepted'\n UserMailer.accepted_email(application.user).deliver_now\n elsif new_status == 'denied'\n UserMailer.denied_email(application.user).deliver_now\n else\n UserMailer.waitlisted_email(application.user).deliver_now\n end\n end",
"def update\n @training_active_job = Training::ActiveJob.find(params[:id])\n\n respond_to do |format|\n if @training_active_job.update_attributes(params[:training_active_job])\n format.html { redirect_to @training_active_job, notice: 'Active job was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @training_active_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @appointment = Appointment.find(params[:id])\n @appointment.available = true\n @appointment.student_id = nil\n @appointment.save\n if @appointment.save\n redirect_to :back and return\n else\n flash[:notice] = \"Post successfully created\"\n end\n end",
"def update_census_employee_records(person, current_user)\n person.employee_roles.each do |employee_role|\n ce = employee_role.census_employee\n if current_user.has_hbx_staff_role? && ce.present?\n ce.ssn = person.ssn\n ce.dob = person.dob\n ce.save!(validate: false)\n end\n end\n end",
"def update\n @job_student = JobStudent.find(params[:id])\n\n respond_to do |format|\n if @job_student.update_attributes(params[:job_student])\n format.html { redirect_to(@job_student, :notice => 'JobStudent was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job_student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employment_application.update(employment_application_params)\n format.html { redirect_to @employment_application, notice: 'Employment application was successfully updated.' }\n format.json { render :show, status: :ok, location: @employment_application }\n else\n format.html { render :edit }\n format.json { render json: @employment_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_status = JobStatus.find(params[:id])\n\n respond_to do |format|\n if @job_status.update_attributes(params[:job_status])\n flash[:notice] = 'JobStatus was successfully updated.'\n format.html { redirect_to([:admin, @job_status]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @job_status.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_check\r\n job = Job.find(params[:id])\r\n check = job.check_information\r\n batch = job.batch\r\n respond_to do |format|\r\n if check.update_attributes(params[:check_information])\r\n Batch.where(:id => batch.id).update_all(:associated_entity_updated_at => Time.now)\r\n format.json { render json: :back }\r\n else\r\n format.json { render :json => check.errors.full_messages, :status => :unprocessable_entity}\r\n end\r\n end\r\n end",
"def employee_updates\n if params[\"employee_id\"] == \"new\"\n @employee = Employee.new\n @employee.florist_id = session[\"found_florist_id\"]\n @employee.view_pref = \"all\"\n else\n @employee = Employee.where(id: params[\"employee_id\"]).first\n end\n @employee.name = params[\"name\"]\n @employee.email = params[\"email\"]\n @employee.w_phone = params[\"phone_w\"]\n @employee.c_phone = params[\"phone_c\"]\n @employee.username = params[\"username\"]\n @employee.password = params[\"password\"] \n @employee.password_confirmation = params[\"password_confirmation\"]\n # This step is done to keep the POC from inadvertantly changing their rights... the POC should always have \"All Admin Rights\"\n if @employee.primary_poc == \"yes\"\n @employee.admin_rights = \"All Admin Rights\"\n @employee.status = \"Active\"\n else\n @employee.status = params[\"status\"]\n # if they are changing the \"status\" to Inactive, then go ahead and change the employees admin privielegs to \"none\".\n if params[\"status\"] == \"Inactive\"\n @employee.admin_rights = \"None\"\n else\n # if they have room for more active users (per their plan) or they are past the number but the change is to change someone's privileges to \"None, then let them set the userprivielegs. Otherwise default to \"None\". This will allow them to show up in the list but not access the system.\n if Florist.find(session[\"found_florist_id\"]).employees.where(status: \"Active\").where(\"admin_rights not like 'None'\").size < Florist.find(session[\"found_florist_id\"]).plan.number_of_users || (Florist.find(session[\"found_florist_id\"]).employees.where(status: \"Active\").where(\"admin_rights not like 'None'\").size >= Florist.find(session[\"found_florist_id\"]).plan.number_of_users && params[\"admin_rights\"] == \"None\")\n @employee.admin_rights = params[\"admin_rights\"]\n else\n @employee.admin_rights = \"None\"\n end\n end\n \n end\n if @employee.save\n if EMPLOYEES_VIEW_MUST_HAVE.include?(Employee.where(id: session[\"found_user_id\"]).first.admin_rights)\n redirect_to \"/employees\" and return\n else\n redirect_to home_path and return\n end\n else\n @ADMIN_RIGHTS = ADMIN_RIGHTS\n @EMPLOYEES_VIEW_MUST_HAVE = EMPLOYEES_VIEW_MUST_HAVE \n render(:employee_edit) and return\n end\n end",
"def incompleted\n @job = Job.find(params[:id])\n # refund the employer his money if he deletes the job\n @employer = User.find(@job.employer_id)\n @employer = @employer.specific\n @employer.update_attributes(:money => @employer.money + @job.pay)\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end",
"def approve_me\n self.update!(status: 'APPROVED')\n end",
"def update_status status\n @job.set({\n custom_status: status,\n pinged_at: Time.now\n })\n end",
"def update_clinician_status\n binding.pry\n #(region.eql? \"India\") && (speciality.eql? \"dentist\")\n if region == \"India\" && speciality != \"dentist\"\n self.status = \"active\"\n end\n return nil\n end",
"def update\n @assessment_practice_test = AssessmentPracticeTest.find(params[:id])\n if current_user.role.id == 7\n params[:assessment_practice_test][:status] = 6\n end\n respond_to do |format|\n if@assessment_practice_test.update_attributes(params[:assessment_practice_test])\n format.html { redirect_to@assessment_practice_test, notice: 'AssessmentPracticeTest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json:@assessment_practice_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reactivate_job \n @job = Job.find_by(id: params[:undo][:job_id])\n @job.update_attribute(:status, 'ongoing') \n redirect_to @job\n end",
"def job_status_invoices_submitted\n # self.confirmed_interpreters.each do |confirmed_interpreter|\n # self.complete_job(confirmed_interpreter)\n # self.confirmed_interpreters.delete(confirmed_interpreter)\n # end\n \n update_attribute(:invoice_submitted, true)\n update_attribute(:invoice_submitted_at, Time.zone.now)\n \n @interpreter_invoices = self.interpreter_invoices\n @interpreter_invoices.each do |interpreter_invoice|\n interpreter_invoice.job_complete\n end\n end",
"def approve\n self.update(status: \"APPROVED\")\n end",
"def update_employee_info(session)\n employees_coll = session.client.use(:hr)[:employees]\n events_coll = session.client.use(:reporting)[:events]\n\n session.start_transaction(read_concern: { level: :snapshot },\n write_concern: { w: :majority },\n read: {mode: :primary})\n employees_coll.update_one({ employee: 3 }, { '$set' => { status: 'Inactive'} },\n session: session)\n events_coll.insert_one({ employee: 3, status: { new: 'Inactive', old: 'Active' } },\n session: session)\n commit_with_retry(session)\n end",
"def update\n respond_to do |format|\n if @program.update(program_params)\n @program.update_attribute('approved', false)\n UserMailer.notify_approver(@program).deliver\n format.html { redirect_to brand_programs_path(@program.brand), notice: 'Program was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @program.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_other_applications(paid)\n ServiceRunnerJob.perform_later(\"OtherApps::UpdateBillingStatus\", @account, paid)\n end",
"def update\n @assessment_end_chapter_quiz = AssessmentEndChapterQuiz.find(params[:id])\n if current_user.role.id == 7\n params[:assessment_end_chapter_quiz][:status] = 6\n end\n respond_to do |format|\n if @assessment_end_chapter_quiz.update_attributes(params[:assessment_end_chapter_quiz])\n format.html { redirect_to@assessment_end_chapter_quiz, notice: 'AssessmentEndChapterQuiz was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json:@assessment_end_chapter_quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_service_status\n if(@service_request and @status)\n @service_request.update_attributes(status_id: @status.id)\n UserMailer.accepted_rejected(@service_request.user, @service_request).deliver_now\n flash[:success] = \"Service request accepted \"\n redirect_to admin_partners_path\n else\n flash[:error] = \"Service request not found!\"\n redirect_to admin_partners_path\n end \n end",
"def update_jobs_webb(jobs, only_these)\n only_these.each do |o|\n # 'DETECT' RETURNS THE HASH ELEMENT ITSELF\n j = jobs.detect {|h| h['link'] == o}\n job = Job.where(link: o)\n job[0].title = j['title']\n job[0].salary = j['salary']\n job[0].department = j['department']\n job[0].city = 'Laredo'\n job[0].origin = 'Webb County'\n job[0].link = j['link']\n job[0].save\n end\n puts \"Total of #{jobs.size} updated successfully.\"\n end",
"def update\n if @course.status.casecmp(\"inactive\").zero?\n @course.requestedInactive = false\n end\n \n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to viewCourse_path, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @request = Request.find(params[:id])\n\n if params['approved']\n @request.status = Request.statuses[:approved]\n elsif params['denied']\n @request.status = Request.statuses[:denied]\n end\n\n if @request.update_attributes(update_params)\n Mailer.mail_status(@request).deliver_later\n redirect_to employee_requests_path\n else\n render 'show'\n end\n end",
"def change_resource_status\n @resource_transportation_booking = ResourceTransportationBooking.find(params[:id])\n\n if params[:approve_status] == \"Approved\"\n \n approve_scenario(params[:id],params[:vehicle][:id])\n @resource_transportation_booking.update_attribute(:remarks, params[:remarks_approver])\n elsif params[:approve_status] == \"Processed\"\n\n if params[:driver][:name] && params[:driver][:name] != ''\n process_scenario_alternate_driver(params[:id],params[:driver][:name])\n else\n @resource_transportation_booking.update_attribute(:status,\"Processed\")\n end\n @resource_transportation_booking.update_attribute(:remarks, params[:remarks_approver])\n agency = Agency.find(@resource_transportation_booking.agency_store.agency_id)\n if !agency.user_id.nil?\n UserMailer.send_mail_to_resource_manager_for_transport_booking(agency.user,@resource_transportation_booking).deliver #if agency && agency.user #if resource_manager && resource_manager.user && !resource_manager.user.blank?\n end\n\n elsif params[:approve_status] == \"Returned\"\n return_scenario(params[:id])\n elsif params[:approve_status] == \"Declined\"\n if @resource_transportation_booking.status == \"Approved\"\n decline_scenario(params[:id])\n end\n @resource_transportation_booking.update_attribute(:status,'Declined')\n end\n\n redirect_to(approve_request_resource_transportation_bookings_path, :notice => 'Transport Booking Status has been successfully updated.')\n end",
"def create\n @employment = Employment.new(employment_params)\n authorize @employment\n\n existing_application = Employment.where(:opening_id=>params['employment'][:opening_id], :user_id=> current_user.id)\n respond_to do |format|\n if existing_application.count == 0\n if @employment.save\n NotificationMailer.job_application_confirmdation_to_user(@employment.user).deliver\n NotificationMailer.job_application_notification_to_organisation(@employment.opening.user, @employment).deliver\n format.html { redirect_to openings_path, notice: 'Employment was successfully created.' }\n format.json { render :show, status: :created, location: @employment } \n else\n format.html { render :action=>'new', :params=>{:opening=> @employment.opening }}\n format.json { render json: @employment.errors, status: :unprocessable_entity }\n end\n\n elsif existing_application.count > 0\n @employment.errors.add(:user_id, :not_unique, message: \"You have already applied for this job\")\n format.html { render :action=>'new', :params=>{:opening=> @employment.opening } }\n format.json { render json: @employment.errors, status: :unprocessable_entity }\n \n end\n end\n end",
"def update\n super\n if resource.role == 'employer'\n @employer = resource.employer.update(employer_params)\n elsif resource.role == 'employee'\n @employee = resource.employee.update(employee_params)\n end\n end",
"def update_requested_by\n @book=Book.find(params[:id])\n k=0\n $transactions.each do |transaction|\n if transaction.requested_by_id==current_user.id and [email protected] and (transaction.status==3 or (transaction.status==1 and transaction.returned=false))\n k=1\n end\n end\n @transaction=Transaction.new\n if k==0\n @transaction.update_attribute(:book_id, @book.id)\n @transaction.update_attribute(:requested_by, current_user.name )\n @transaction.update_attribute(:requested_by_id, current_user.id )\n @transaction.update_attribute(:requested, true)\n @transaction.update_attribute(:status, 3)\n redirect_to @book, notice: \"Book issue request is successfully placed\"\n else\n redirect_to books_url, notice: \"You have already requested this book\"\n end\n end",
"def update_employee \n @user = User.find(params[:id])\n @user.update_attributes(:first_name=>params[:lawfirm_admin][:first_name],:last_name=>params[:lawfirm_admin][:last_name])\n @employees=Employee.scoped_by_user_id_and_company_id(@user.id,current_user.company_id).first\n respond_to do |format|\n if @employees.update_attributes(:birthdate => params[:lawfirm_admin][:employee][:birthdate],\n :security_question => params[:lawfirm_admin][:employee][:security_question],\n :security_answer => params[:lawfirm_admin][:employee][:security_answer],\n :billing_rate => params[:lawfirm_admin][:employee][:billing_rate]\n )\n flash[:notice] = \"#{t(:text_user)} \" \"#{t(:flash_was_successful)} \" \"#{t(:text_updated)}\"\n format.html { redirect_to:controller=>\"lawfirm_admins\",:action=>\"index\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n\n if is_adm? && params[:type] == 'complete'\n request = MaintenanceRequest.find(maintenance_request_params[:ticket_no])\n request.app_status = 2\n request.save\n redirect_to maintenance_requests_url\n return\n else\n @maintenance_request = MaintenanceRequest.find(params[:id])\n end\n\n respond_to do |format|\n if @maintenance_request.update(maintenance_request_params)\n format.html { redirect_to @maintenance_request, notice: 'Maintenance request was successfully updated.' }\n format.json { render :show, status: :ok, location: @maintenance_request }\n else\n format.html { render :edit }\n format.json { render json: @maintenance_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def self_placement_approval\n @self_placement = ServiceLearningSelfPlacement.find params[:id]\n @type_of_self_placement = @self_placement.general_study? ? \"General Study\" : \"Self Placement\"\n # TODO: find a better way to check if new contact \n @is_new_contact = !@self_placement.organization_contact_person.blank? # && @self_placement.position.supervisor.nil? (take this away because student can still input position existing contact while check creating new contact)\n \n session[:breadcrumbs].add @type_of_self_placement, @self_placement.general_study? ? service_learning_general_study_path(@unit, @quarter) : service_learning_self_placements_path(@unit, @quarter)\n session[:breadcrumbs].add \"#{@type_of_self_placement} Approval\"\n \n if request.put?\n \n if params[:commit] == \"Decline\"\n @self_placement.update_attribute(:admin_approved, false)\n @self_placement.update_attribute(:submitted, false)\n @self_placement.update_attribute(:admin_feedback, params[:service_learning_self_placement][:admin_feedback])\n flash[:notice] = \"You successfully declined the position request. The status is back to in progress.\"\n redirect_to :back and return\n end\n \n # For General Study - confirm registered\n if @self_placement.general_study? && !@is_new_contact\n if params[:service_learning_self_placement][:confirm_registered] == \"0\"\n return @self_placement.errors.add_to_base \"Please check the box below to confirm you have completed registering the student.\"\n end\n end \n \n # Activate organization\n if @self_placement.existing_organization?\n organization_quarter = @self_placement.existing_organization.activate_for(@quarter, true, @unit)\n organization = organization_quarter.organization\n else\n # check if the organization name already exists\n unless Organization.find_by_name(@self_placement.organization_name).blank?\n return @self_placement.errors.add_to_base \"The #{@self_placement.organization_name} already exists. Please select with the existing organization.\"\n end\n \n organization = Organization.create(:name => @self_placement.organization_name,\n :mailing_line_1 => @self_placement.organization_mailing_line_1,\n :mailing_line_2 => @self_placement.organization_mailing_line_2,\n :mailing_city => @self_placement.organization_mailing_city,\n :mailing_state => @self_placement.organization_mailing_state,\n :mailing_zip => @self_placement.organization_mailing_zip,\n :website_url => @self_placement.organization_website_url,\n :mission_statement => @self_placement.organization_mission_statement,\n :approved => true\n )\n \n organization_quarter = organization.activate_for(@quarter, true, @unit) \n end\n \n # update status to admin approved after activate organization\n @self_placement.update_attribute(:admin_approved, true) unless @self_placement.general_study? && @is_new_contact\n \n # Activate new contact: 1. existing org and add new contact (only for general study now) 2. new org and new contact \n if (@self_placement.general_study? && @is_new_contact) || !@self_placement.existing_organization? \n contact = organization.contacts.create\n contact_people = Person.find_all_by_email(@self_placement.organization_contact_email)\n \n if contact_people.size == 1 # if find existing person record, then create organization contact with the person record\n contact.update_attribute(:person_id, contact_people.first.id)\n elsif contact_people.size > 1\n flash[:error] = \"Cannot add organization contact.There are more than one person record found with the contact email. Please add the contact manually for #{@self_placement.organization_name}.\"\n else\n contact.create_person(:firstname => @self_placement.organization_contact_person.split.first,\n :lastname => @self_placement.organization_contact_person.split.second,\n :email => @self_placement.organization_contact_email,\n :phone => @self_placement.organization_contact_phone,\n :title => @self_placement.organization_contact_title\n ) \n end\n \n organization.save;contact.save\n @self_placement.update_attribute(:organization_id, organization) unless @self_placement.existing_organization? # mark as existing org\n @self_placement.position.update_attribute(:supervisor_person_id, contact.id)\n\n if @self_placement.general_study?\n supervisor_template = EmailTemplate.find_by_name(\"general study position supervisor approval request\")\n TemplateMailer.deliver(supervisor_template.create_email_to(@self_placement, contact.login_url,\n @self_placement.position.supervisor.person.email)\n ) if supervisor_template\n end\n end\n \n organization_quarter.statuses.find_or_create_by_organization_quarter_status_type_id(OrganizationQuarterStatusType.find_by_title(\"Ready\").id)\n \n if @self_placement.general_study? && @is_new_contact\n flash[:notice] = \"You have successfully activated the organization and created the new contact, #{@self_placement.position.supervisor.person.fullname}.\"\n else\n @self_placement.position.update_attributes(:organization_quarter_id => organization_quarter.id,\n :unit_id => @unit.id,\n :self_placement => !@self_placement.general_study?,\n :general_study => @self_placement.general_study?,\n :in_progress => false,\n :approved => true,\n :ideal_number_of_slots => 1,\n :require_validations => false\n )\n \n ServiceLearningPlacement.transaction do \n placement = ServiceLearningPlacement.create(:service_learning_position_id => @self_placement.service_learning_position_id,\n :service_learning_course_id => @self_placement.service_learning_course_id,\n :created_at => Time.now, \n :unit_id => @unit.id\n ) \n \n if @self_placement.person.place_into(@self_placement.position, @self_placement.course)\n @self_placement.update_attribute(:service_learning_placement_id, placement.id) if placement\n flash[:notice] = \"You successfully approved the position and place #{@self_placement.person.fullname} into a #{@type_of_self_placement.downcase}.\"\n else\n flash[:error] = \"You have activated the organization but something went wrong when placing the student into #{@type_of_self_placement.downcase}\"\n raise ActiveRecord::Rollback\n end \n end # end transaction\n \n @self_placement.update_attributes(:registered_at => Time.now, :register_person_id => @current_user.person.id) if @self_placement.general_study? \n end\n \n redirect_to :action => @self_placement.general_study? ? \"general_study\" : \"self_placements\"\n end # end of request.put? \n \n end",
"def update\n @student_application = StudentApplication.find(params[:id])\n\n respond_to do |format|\n if @student_application.update_attributes(params[:student_application])\n format.html { redirect_to @student_application, notice: 'Student application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_status\n\t\tIFeeSchedule.where(feeActive: true).where.not(id: self.id).update_all(feeActive: false)\n\tend",
"def update\n if @company_event.update(company_event_params)\n @flag = true\n @company_event = CompanyEvent.new\n @company_events = CompanyEvent.all\n else\n @flag = false\n end\n end",
"def update\n\n if raffle_params_update['assigned'].eql?('0')\n\n parking_raffle = Parking.find_by(id: raffle_params['parking_id'])\n parking_raffle.assigned = nil\n parking_raffle.save\n\n applicant_raffle = Applicant.find_by(id: raffle_params['applicant_id'])\n applicant_raffle.assigned = nil \n applicant_raffle.save \n\n elsif raffle_params_update['assigned'].eql?('1')\n\n parking_raffle = Parking.find_by(id: raffle_params['parking_id'])\n parking_raffle.assigned = true\n parking_raffle.save\n\n applicant_raffle = Applicant.find_by(id: raffle_params['applicant_id'])\n applicant_raffle.assigned = true \n applicant_raffle.save \n end\n\n respond_to do |format|\n if @raffle.update(raffle_params_update)\n format.html { redirect_to @raffle, notice: 'Raffle was successfully updated.' }\n format.json { render :show, status: :ok, location: @raffle }\n else\n format.html { render :edit }\n format.json { render json: @raffle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_incomplete_jobs\r\n job_ids = params[:ids]\r\n selected_batch = Job.find(job_ids[0]).batch\r\n job_ids.each do |job_id|\r\n Job.find(job_id).update_attributes(:processor_comments => params[:job][:processor_comments],:rejected_comment => params[:job][:processor_comments],\r\n :job_status => \"#{JobStatus::INCOMPLETED}\", :processor_status => \"#{ProcessorStatus::INCOMPLETED}\")\r\n end\r\n selected_batch.expected_completion_time = Time.now if selected_batch.expected_completion_time.blank?\r\n previous_batch_status = selected_batch.status\r\n selected_batch.status = BatchStatus::PROCESSING\r\n if previous_batch_status == BatchStatus::NEW && selected_batch.status == BatchStatus::PROCESSING &&\r\n selected_batch.processing_start_time.blank?\r\n selected_batch.processing_start_time = Time.now\r\n end\r\n selected_batch.save\r\n end",
"def set_db_job_status\n @db_job_status = DbJobStatus.find(params[:id])\n end",
"def update \n data=params\n employee = Employee.find(params[:id])\n if update_lawyer_preferences(employee)\n flash[:notice] = \"Lawyer preferences updated successfully\"\n redirect_to :back\n return true\n else\n flash[:error] = \"<ul>\" + employee.errors.full_messages.collect {|e| \"<li>\" + e + \"</li>\"}.join(\" \") + \"</ul>\"\n redirect_to :back\n return false\n end\n @com_notes_entries = Communication.find(data[\"id\"].to_i)\n @note_priority = (data[:com_notes_entries][:note_priority] == 0 ||data[:com_notes_entries][:note_priority].eql?('0'))? 1 : 2 \n notes = data[:com_notes_entries][:description] if data[:com_notes_entries][:description]\n # Below code is common in \"Complete Task\" and \"Assign To\" logic.\n if data[:commit].eql?(\"Complete Task\") || data[:commit].eql?(\"Assign To\")\n notes_type = data[:task][:tasktype] unless data[:task][:tasktype].blank?\n task_details = {}\n task_details.merge!(data[:task])\n task_details.merge!(:name=>notes,:tasktype =>notes_type,:priority=>@note_priority)\n end\n if data[:commit].eql?(\"Save & Exit\")\n respond_to do |format| \n if @com_notes_entries.update_attributes(:description=>notes,:more_action =>data[:com_notes_entries][:more_action], :matter_id =>data[:com_notes_entries][:matter_id], :contact_id=>data[:com_notes_entries][:contact_id],:note_priority=>@note_priority.to_i)\n flash[:notice] = \"#{t(:text_task)} \" \"#{t(:flash_was_successful)} \" \"#{t(:text_saved)}\"\n format.html {redirect_to physical_liviaservices_livia_secretaries_url}\n else\n format.html { render :action => \"show\" }\n end\n end\n elsif data[:commit].eql?(\"Complete Task\") \n task_details.merge!(data[:task])\n task_details.merge!(:assigned_to_user_id =>@current_user.id,:status=>'complete',:completed_at=>Time.now,:completed_by_user_id=>@current_user.id)\n @task= UserTask.new(task_details)\n respond_to do |format|\n # Below mention transaction block basically revert Task entry and even revert the Communication to update.\n # Added by Ajay Arsud Date:09 Sept 2010\n UserTask.transaction do\n if @task.save\n @com_notes_entries = Communication.find(data[\"id\"].to_i)\n @task.update_attributes(:company_id=>@com_notes_entries.company_id)\n @com_notes_entries.update_attributes(:status => 'complete')\n flash[:notice] = \"#{t(:text_task)} \" \"#{t(:flash_was_successful)} \" \"#{t(:text_completed)}\"\n format.html { redirect_to physical_liviaservices_livia_secretaries_url }\n else\n flash[:error] = t(:flash_task_type)\n format.html { redirect_to physical_liviaservices_livia_secretaries_url }\n end\n end\n end\n elsif data[:commit].eql?(\"Assign To\")\n task_details.merge!(:assigned_to_user_id =>data[:task][:assigned_to_user_id])\n @task = UserTask.new(task_details)\n respond_to do |format|\n # Below mention transaction block basically revert Task entry and even revert the Communication to update.\n # Added by Ajay Arsud Date:09 Sept 2010\n Communication.transaction do\n if @task.save\n @com_notes_entries = Communication.find(data[\"id\"].to_i)\n @task.update_attributes(:company_id=>@com_notes_entries.company_id) \n @com_notes_entries.update_attributes(:status => 'complete')\n flash[:notice] = \"#{t(:text_task)} \" \"#{t(:flash_was_successful)} \" \"#{t(:text_assigned)}\"\n format.html { redirect_to physical_liviaservices_livia_secretaries_url }\n else\n flash[:error] = t(:flash_task_type)\n format.html { redirect_to physical_liviaservices_livia_secretaries_url }\n end\n end\n end\n end \n 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 update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student]) &&\n @student.user.update_attributes({:role_pending => params[:role_pending]})\n\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_appeal_state_when_ihp_completed\n if IHP_TYPE_TASKS.include?(type) &&\n !IHP_TYPE_TASKS.include?(parent&.type) &&\n status == Constants.TASK_STATUSES.completed\n MetricsService.record(\"Updating VSO_IHP_COMPLETED column to TRUE & VSO_IHP_PENDING column to FALSE in Appeal\"\\\n \" States Table for #{appeal.class} ID #{appeal.id}\",\n service: nil,\n name: \"AppellantNotification.appeal_mapper\") do\n AppellantNotification.appeal_mapper(appeal.id, appeal.class.to_s, \"vso_ihp_complete\")\n end\n end\n end",
"def update_user_kyc_status\n @user_kyc_detail.admin_status = GlobalConstant::UserKycDetail.denied_admin_status\n @user_kyc_detail.last_acted_by = @admin_id\n @user_kyc_detail.last_acted_timestamp = Time.now.to_i\n @user_kyc_detail.admin_action_types = 0\n if @user_kyc_detail.changed?\n @user_kyc_detail.save!\n enqueue_job\n end\n end"
] | [
"0.68167233",
"0.68161434",
"0.6808715",
"0.66528803",
"0.6624636",
"0.65516996",
"0.6507115",
"0.6507115",
"0.6503819",
"0.6483749",
"0.64693576",
"0.64426386",
"0.6429988",
"0.63662696",
"0.636339",
"0.63604766",
"0.63483274",
"0.63429314",
"0.6331158",
"0.63070214",
"0.62662256",
"0.62656975",
"0.6263709",
"0.6226233",
"0.6226233",
"0.6223713",
"0.6210219",
"0.620879",
"0.620831",
"0.6201269",
"0.61645657",
"0.61624974",
"0.61486477",
"0.61347526",
"0.6127615",
"0.6126105",
"0.6119939",
"0.6119939",
"0.60984004",
"0.60943955",
"0.60943955",
"0.6082472",
"0.60739785",
"0.60711247",
"0.60673743",
"0.6054416",
"0.6048104",
"0.60398346",
"0.6037023",
"0.6026149",
"0.5994121",
"0.59817976",
"0.5978692",
"0.5978364",
"0.59766364",
"0.59661335",
"0.59346396",
"0.59266806",
"0.5917844",
"0.5915429",
"0.59133095",
"0.59116054",
"0.5910265",
"0.5906496",
"0.58979464",
"0.58955836",
"0.5891013",
"0.5883243",
"0.5883196",
"0.587803",
"0.58710885",
"0.58704805",
"0.5865979",
"0.58654547",
"0.5862308",
"0.58621573",
"0.5861457",
"0.5859807",
"0.584087",
"0.5839196",
"0.5837614",
"0.5835065",
"0.58323044",
"0.5821153",
"0.58141863",
"0.5803068",
"0.5798967",
"0.579706",
"0.5796205",
"0.57953274",
"0.57952815",
"0.57929987",
"0.57831013",
"0.5783013",
"0.57793516",
"0.57751566",
"0.57734543",
"0.5773081",
"0.5765587",
"0.5764771"
] | 0.71218586 | 0 |
What we scaffold: Build model (with unit tests) Migration (Include deleted_at for soft delete) Build factories with limited support for FFaker Build controller (with unit tests) Build routes Build views (_form, edit, index, new) Build policy objects (with unit tests) Build feature tests (index, create, update, destroy with softdelete) | def scaffold
# Generate models
generate("frontier_model", ARGV[0])
unless model.skip_ui?
# Generate controllers
generate("frontier_controller", ARGV[0])
# Generate views
generate("frontier_crud_views", ARGV[0])
# Generate policies
generate("frontier_policy", ARGV[0])
# Generate routes
generate("frontier_route", ARGV[0])
end
# Version 2
#
# 1. Add in model validations
# 2. Searching (nominate searchable fields. Support strings, booleans, and enums out of the box)
# 3. Export as CSV (Have a default CSVExport object that accepts some symbols of keys and exports)
# This will probably require two steps - 1. Choose fields to export, 2. Export those as CSV
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @build = Build.new\n\n \n end",
"def build; end",
"def build\n end",
"def build\r\n end",
"def build\r\n end",
"def build!\n end",
"def build(*args)\n model = generate(*args)\n model.save\n model\n end",
"def model_class\n ::Ci::Build\n end",
"def new\n @smoke_test = SmokeTest.new\n # package builders\n @smoke_test.build_nova_package_builder\n @smoke_test.nova_package_builder.merge_trunk = false\n @smoke_test.build_glance_package_builder\n @smoke_test.glance_package_builder.merge_trunk = false\n @smoke_test.build_keystone_package_builder\n @smoke_test.keystone_package_builder.merge_trunk = false\n @smoke_test.build_swift_package_builder\n @smoke_test.swift_package_builder.merge_trunk = false\n @smoke_test.build_cinder_package_builder\n @smoke_test.cinder_package_builder.merge_trunk = false\n @smoke_test.build_neutron_package_builder\n @smoke_test.neutron_package_builder.merge_trunk = false\n @smoke_test.build_ceilometer_package_builder\n @smoke_test.ceilometer_package_builder.merge_trunk = false\n @smoke_test.build_heat_package_builder\n @smoke_test.heat_package_builder.merge_trunk = false\n\n # config modules\n @smoke_test.build_nova_config_module\n @smoke_test.nova_config_module.merge_trunk = false\n @smoke_test.build_glance_config_module\n @smoke_test.glance_config_module.merge_trunk = false\n @smoke_test.build_keystone_config_module\n @smoke_test.keystone_config_module.merge_trunk = false\n @smoke_test.build_swift_config_module\n @smoke_test.swift_config_module.merge_trunk = false\n @smoke_test.build_cinder_config_module\n @smoke_test.cinder_config_module.merge_trunk = false\n @smoke_test.build_neutron_config_module\n @smoke_test.neutron_config_module.merge_trunk = false\n @smoke_test.build_ceilometer_config_module\n @smoke_test.ceilometer_config_module.merge_trunk = false\n @smoke_test.build_heat_config_module\n @smoke_test.heat_config_module.merge_trunk = false\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @smoke_test }\n format.xml { render :xml => @smoke_test }\n end\n end",
"def show_build\n end",
"def build_view \n \n return if skip_method(__method__)\n \n # build edit _form index new show\n \n ['_form','edit','new','index','show'].each do |file|\n \n \n template = File.read(template(\"rails/views/#{file}.html.erb\"))\n \n # need to use ERB for these templates\n text = ERB.new(template, nil, '-').result(binding)\n\n filename = \"#{file}.html.erb\"\n # #puts \"build Rails view\"\n \n path = namespaced_path(\"app/views\",\"#{plural_table_name}/\"+filename)\n puts \"build Rails #{file} view for #{model_name} in #{path}\"\n write_artifact(path,text)\n \n end\n \n # build the json views\n ['index','show'].each do |file|\n \n template = File.read(template(\"rails/views/#{file}.json.jbuilder\"))\n text = ERB.new(template, nil, '-').result(binding)\n \n filename = \"#{file}.json.jbuilder\"\n # #puts \"build Rails JSON view \"\n \n path = namespaced_path(\"app/views\",\"#{plural_table_name}/\"+filename)\n puts \"build Rails #{file} JSON view for #{model_name} in #{path}\"\n write_artifact(path,text)\n \n end\n \n end",
"def build\n end",
"def angular_scaffold\n object = get_stdin(\"What is the Object name to scaffold? \")\n puts \"Describe your structure like a model generation :\\nnom:string description:text prix:decimal rdv:date validation:boolean heure:time creation:datetime\"\n parameters = get_stdin(\"What's the structure of the object? \")\n system \"rails generate angular_scaffold #{object} #{parameters}\"\nend",
"def index\n @builds = Build.all\n end",
"def index\n @builds = Build.all\n end",
"def build\r\n raise \"Not implemented\"\r\n end",
"def run_scaffolds\n @file.each_pair do |class_name, spec|\n args = []\n args << class_name \n args += spec[\"fields\"].map do |field|\n \"#{field[\"name\"]}:#{field[\"type\"]}\"\n end\n args << '--timestamps'\n Rails::Generators.invoke \"rails:scaffold\", args\n end\n end",
"def default_builder_actions\n [ :build ]\n end",
"def build_params\n params.require(:build).permit(:number, :version, :releaseNotes, :platform, :buildIdenifier, :accessToken, :domain, :provision, :displayname, :icon, :buildFilePath)\n end",
"def run \n create_model_file\n create_migration if @valid==true\n enable_apis if @valid==true\n end",
"def build_model\n \n return if skip_method(__method__)\n\n filename = singular_table_name + '.rb'\n \n template = File.read(template(\"rails/model.erb\"))\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = File.join(\"app\",\"models\",filename) \n puts \"build Rails model for #{model_name} in #{path}\"\n write_artifact(path,text)\n\n end",
"def create\n @build = Build.new(params[:build])\n\n respond_to do |format|\n if @build.save\n format.html { redirect_to @build, notice: 'Build was successfully created.' }\n format.json { render json: @build, status: :created, location: @build }\n else\n format.html { render action: \"new\" }\n format.json { render json: @build.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build!\n build_to self[:build_path]\n end",
"def create\n @build = Build.new(build_params)\n\n respond_to do |format|\n if @build.save\n format.html { redirect_to @build, notice: \"Build was successfully created.\" }\n format.json { render :show, status: :created, location: @build }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @build.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate_constructions\n # TODO? delete and re-create or check that it exists and update?\n # self.construct_assemblies.destroy_all\n # self.materials.destroy_all\n # self.fenestration_constructions.destroy_all\n # self.door_construction.destroy_all\n\n # model names\n constructions = %w(UndergroundWall UndergroundFloor InteriorWall InteriorFloor ExteriorWall ExteriorFloor Roof)\n fenestrations = %w(Window Skylight)\n doors = ['Door']\n space_ids = []\n\n # get all building -> stories -> spaces (that's what constructions are attached to)\n stories = building.building_stories\n spaces = []\n stories.each do |story|\n story.spaces.each do |space|\n spaces << space\n end\n end\n space_ids = spaces.collect(&:id)\n logger.debug(\"*****SPACES: #{space_ids.inspect} *****\")\n\n project_cas = []\n project_mats = []\n project_fens = []\n project_doors = []\n\n # to find doors, windows, skylights\n int_wall_ids = []\n ext_wall_ids = []\n roof_ids = []\n\n # assign regular constructions\n constructions.each do |con|\n con_model = con.constantize\n instances = con_model.any_in(space_id: space_ids)\n\n if con === 'InteriorWall'\n int_wall_ids = instances.collect(&:id)\n elsif con === 'ExteriorWall'\n ext_wall_ids = instances.collect(&:id)\n elsif con === 'Roof'\n roof_ids = instances.collect(&:id)\n end\n\n # puts \"#{instances.size} instances of #{con}\"\n # logger.info \"#{instances.size} instances of #{con}\"\n\n instances.each do |instance|\n # get lib record\n unless instance.construction_library_id.nil?\n lib = Construction.find(instance.construction_library_id)\n\n # TODO: check that it doesn't exist yet or skip?\n ca = construct_assemblies.find_or_create_by(name: lib.name)\n ca.compatible_surface_type = lib.compatible_surface_type\n # save other attributes here (for floors)\n ca.slab_type = lib.slab_type\n ca.slab_insulation_orientation = lib.slab_insulation_orientation\n ca.slab_insulation_thermal_resistance = lib.slab_insulation_thermal_resistance\n\n material_refs = []\n # material references\n logger.debug(\"!!!!! LAYERS: #{lib['layers']}\")\n unless lib['layers'].nil?\n lib.layers.each do |layer|\n mat = materials.find_or_create_by(name: layer['name'])\n mat.code_category = layer['code_category']\n mat.code_item = layer['code_item']\n # save framing_configuration and material (required)\n mat.framing_depth = layer['framing_depth']\n mat.framing_configuration = layer['framing_configuration']\n mat.framing_material = layer['framing_material']\n mat.framing_material = layer['framing_material']\n mat.cavity_insulation = layer['cavity_insulation_r_value']\n\n mat.save\n material_refs << mat.name\n # only save unique records to project\n match = project_mats.find { |m| m['name'] === mat.name }\n logger.info(\"MATCH: #{match}, for material #{mat.name}\")\n project_mats << mat if match.nil?\n end\n end\n\n # save material references to construction assembly\n ca.material_reference = material_refs\n ca.save\n # only save unique records to project\n match = project_cas.find { |m| m['name'] === ca.name }\n # puts \"MATCH: #{match} for ca #{ca.name}\"\n logger.info \"MATCH: #{match} for ca #{ca.name}\"\n project_cas << ca if match.nil?\n\n # save construction assembly reference on original instance (in construct_assembly_reference field, use name)\n instance.construct_assembly_reference = ca.name\n instance.save\n end\n end\n end\n\n\n logger.info \"Exterior Wall ids are #{ext_wall_ids}\"\n\n # assign doors\n door_instances = Door.or({:interior_wall_id.in => int_wall_ids}, {:exterior_wall_id.in => ext_wall_ids})\n\n logger.info(\"Door instances: #{door_instances.size}\")\n door_instances.each do |instance|\n # get lib record\n unless instance.construction_library_id.nil?\n lib = DoorLookup.find(instance.construction_library_id)\n dc = door_constructions.find_or_create_by(name: lib.name)\n # add other lib fields\n lib.attributes.each_pair do |key, value|\n unless %(created_at updated_at id _id).include? key\n dc[key] = value\n end\n end\n dc.save\n\n # only save unique records to project\n match = project_doors.find { |m| m['name'] === dc.name }\n logger.info(\"MATCH: #{match} for door construction #{dc.name}\")\n project_doors << dc if match.nil?\n\n # save construction assembly reference on original instance (in construct_assembly_reference field, use name)\n instance.door_construction_reference = dc.name\n instance.save\n end\n end\n\n # assign fenestrations\n fenestrations.each do |fen|\n fen_model = fen.constantize\n if fen === 'Window'\n instances = fen_model.any_in(exterior_wall_id: ext_wall_ids)\n else\n # skylight\n instances = fen_model.any_in(roof_id: roof_ids)\n end\n # puts \"#{instances.size} instances of #{fen}\"\n # logger.info(\"#{instances.size} instances of #{fen}\")\n\n instances.each do |instance|\n # get lib record\n unless instance.construction_library_id.nil?\n lib = Fenestration.find(instance.construction_library_id)\n # TODO: check that it doesn't exist yet or skip?\n fc = fenestration_constructions.find_or_create_by(name: lib.name)\n # save all lib attributes to construction instance\n lib.attributes.each_pair do |key, value|\n unless %(created_at updated_at id _id).include? key\n fc[key] = value\n end\n end\n fc.save\n\n # only save unique records to project\n match = project_fens.find { |m| m['name'] === fc.name }\n logger.info(\"MATCH: #{match} for fen construction #{fc.name}\")\n project_fens << fc if match.nil?\n\n # save construction assembly reference on original instance (in construct_assembly_reference field, use name)\n instance.fenestration_construction_reference = fc.name\n instance.save\n end\n end\n end\n\n # save all to project\n self.door_constructions = project_doors\n self.fenestration_constructions = project_fens\n self.construct_assemblies = project_cas\n self.materials = project_mats\n self.save!\n end",
"def builder; end",
"def builder; end",
"def builder; end",
"def deleted(build)\n end",
"def make_and_model; end",
"def create\n @os_build = OsBuild.new(os_build_params)\n\n respond_to do |format|\n if @os_build.save\n format.html { redirect_to @os_build, notice: 'Os build was successfully created.' }\n format.json { render :show, status: :created, location: @os_build }\n else\n format.html { render :new }\n format.json { render json: @os_build.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build(params); end",
"def build(build_name='default')\n description = Fudge::Parser.new.parse('Fudgefile')\n Fudge::Runner.new(description).run_build(build_name, options)\n end",
"def manifest\n record do |m|\n # # Check for class naming collisions.\n # m.class_collisions controller_class_path, \"#{controller_class_name}Controller\", \"#{controller_class_name}ControllerTest\", \"#{controller_class_name}Helper\"\n\n # Controller, helper, views, and test directories.\n\n # Model, controller, helper, views, and test directories.\n m.directory File.join('app/models', class_path)\n m.directory File.join('test/unit', class_path)\n # I use factories\n # m.directory File.join('test/fixtures', class_path)\n m.directory File.join('app/controllers', controller_class_path)\n m.directory File.join('app/helpers', controller_class_path)\n m.directory File.join('app/views', controller_class_path, controller_file_name)\n m.directory File.join('app/views/layouts', controller_class_path)\n m.directory File.join('test/functional', controller_class_path)\n\n # Unit test, and fixtures.\n # m.template 'unit_test.rb', File.join('test/unit', \"#{singular_name}_test.rb\")\n # I use factories\n # m.template 'fixtures.yml', File.join('test/fixtures', \"#{singular_name}.yml\")\n\n m.complex_template 'model.rb',\n File.join('app/models', \"#{singular_name}.rb\"),\n :insert => 'model_scaffolding.rhtml',\n :sandbox => lambda { create_sandbox }\n\n m.complex_template('form.rhtml',\n File.join('app/views',\n controller_class_path,\n controller_file_name,\n '_form.rhtml'),\n :insert => 'form_scaffolding.rhtml',\n :sandbox => lambda { create_sandbox },\n :begin_mark => 'form',\n :end_mark => 'eoform',\n :mark_id => singular_name) if less_dry_partial?\n\n m.complex_template('show.rhtml',\n File.join('app/views',\n controller_class_path,\n controller_file_name,\n '_show.rhtml'),\n :insert => 'show_scaffolding.rhtml',\n :sandbox => lambda { create_sandbox },\n :begin_mark => 'show',\n :end_mark => 'eoshow',\n :mark_id => singular_name) if less_dry_partial?\n\n # Controller class, functional test, helper, and views.\n # m.template('functional_test.rb', File.join('test/functional', controller_class_path, \"#{controller_file_name}_controller_test.rb\"))\n controller_template_name = 'controller_methods.rb'\n m.complex_template controller_template_name,\n File.join('app/controllers',\n controller_class_path,\n \"#{controller_file_name}_controller.rb\"),\n :insert => 'controller_scaffolding.rhtml',\n :sandbox => lambda { create_sandbox }\n m.template 'helper.rb',\n File.join('app/helpers',\n controller_class_path,\n \"#{controller_file_name}_helper.rb\") \n\n end\n end",
"def create_build( build_def, changesets, duration, message, number, start, status,uri )\r\n\r\n\t\[email protected](\"Creating build.\")\r\n\t\r\n\t\tfields = {\r\n\t\t\t:build_definition => build_def,\r\n\t\t\t:changesets => changesets,\r\n\t\t\t:duration => duration,\r\n\t\t\t:message => message,\r\n\t\t\t:number => number,\r\n\t\t\t:start => start,\r\n\t\t\t:status => status,\r\n\t\t\t:uri => uri\t\r\n\t\t}\r\n\t\[email protected](\"Creating build #{fields}\")\r\n\t\t\r\n\t\tbuild = @rally.create(:build, fields)\r\n\t\[email protected](\"Created build #{fields}\")\r\n\r\n\t\r\n\tend",
"def create\n @generator = Generator.new(generator_params)\n create_scaffold\n respond_to do |format|\n if @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render :show, status: :created, location: @generator }\n else\n format.html { render :new }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build_all\n create_categories\n puts \"Built categories\"\n create_contacts\n puts \"Built contacts\"\n create_locations\n puts \"Built locations\"\n create_services\n puts \"Built services\"\n create_service_types\n puts \"Built service types\"\n create_comments\n puts \"Built comments\"\n create_costs\n puts \"Built costs\"\n create_service_locations\n puts \"Built service locations\"\n create_service_contacts\n puts \"Built service locations\" \n create_users\n puts \"Built users\" \n end",
"def build_functional_test \n \n return if skip_method(__method__)\n\n filename = \"#{singular_table_name}_controller_test.rb\"\n puts \"build Rails functional test for #{model_name} in test/controllers\"\n\n template = File.read(template(\"rails/test/functional_test.rb\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = namespaced_path(\"test/controllers\",filename)\n write_artifact(path,text) \n end",
"def initialize(build)\n @build = build\n end",
"def index\n @os_builds = OsBuild.all\n end",
"def build *args\n Factory.build factory_name, *args\n end",
"def index\n @builds = @repo.builds.order('created_at DESC')\n end",
"def build_new_docs\n FileUtils.mkdir_p @temp_root\n @automations.each do |auto|\n \n debug_msg \"Working with #{auto.short_name}\"\n build = @builds_map[auto.short_name]\n versions_to_build = []\n debug_msg \" fetching available verions\"\n if build\n max_build_version = build.versions.max\n versions_to_build += auto.available_versions.select{|v| v > max_build_version}\n else\n n = (auto.respond_to? :versions_to_build) ? auto.versions_to_build : 1\n versions_to_build += auto.available_versions.sort[-n..-1]\n end\n \n if versions_to_build.size > 0\n debug_msg \" versions to build: #{versions_to_build.join(', ')}\"\n else\n debug_msg \" nothing to build\"\n end\n versions_to_build.each do |version|\n build_version auto, version\n end\n \n debug_msg \"\"\n end\n \n clean_up\n end",
"def create\n begin\n puts \"Creating...\"\n ActiveRecord::Schema.define do\n #create_table :test_relations do |table|\n # table.column :test_case_id, :integer\n # table.column :test_collection_id, :integer\n #end\n create_table :defaults do |table|\n table.column :configuration_id, :integer\n end\n\n\n # Project configuration\n create_table :configurations do |table|\n table.column :name, :string\n table.column :server, :string\n table.column :devkey, :string\n table.column :smtp_host, :string\n table.column :smtp_recipient, :string\n table.column :project, :string # aka prefix\n table.column :vm_user, :string\n table.column :vm_password, :string\n table.column :ssh_key_path, :string\n table.column :ssh_key_pw, :string\n table.column :base_path, :string\n table.column :output_path, :string\n table.column :public_options, :string\n end\n\n\n # A test collection is a collection of test, defined by project, testplan and build\n create_table :test_collections do |table|\n table.column :project, :string\n table.column :project_id, :string\n table.column :plan, :string\n table.column :plan_id, :string\n #table.column :build, :string\n #table.column :testrun_id, :string\n #table.column :test_cases, :string\n end\n\n create_table :test_cases do |table|\n table.column :urgency, :string\n table.column :name, :string\n table.column :file, :string\n table.column :external_id, :string\n table.column :platform_id, :string\n table.column :test_collection_id, :string\n\n end\n\n end\n\n rescue ActiveRecord::StatementInvalid\n # Table already created\n puts \"Setup already done. Destroy tables first before creating\"\n end\n\n\n end",
"def builder\n\n add_breadcrumb \"SOGR Capital Project Analyzer\"\n\n # Select the asset seed that they are allowed to build\n\n @asset_seed = []\n asset_class_name = Rails.application.config.asset_base_class_name == 'TransamAsset' ? 'TransitAsset' : Rails.application.config.asset_base_class_name\n\n asset_class_name.constantize.asset_seed_class_name.constantize.active.each do |seed|\n assets = asset_class_name.constantize.where(seed.class.to_s.underscore => seed)\n if assets.where(organization: @organization_list).count > 0\n @asset_seed << {id: seed.id, name: seed.to_s, orgs: @organization_list.select{|o| assets.where(organization_id: o).count > 0}}\n else\n @asset_seed << {id: seed.id, name: seed.to_s, orgs: []}\n end\n end\n\n @fiscal_years = get_fiscal_years(Date.today)\n @range_fiscal_years = ((1..14).to_a + (3..10).to_a.map{|x| x * 5}).map{|x| [\"#{x} years\", x-1]}\n @scenarios = Scenario.where(organization: current_user.viewable_organizations)\n @builder_proxy = BuilderProxy.new\n\n @has_locked_sogr_this_fiscal_year = CapitalPlanModule.joins(:capital_plan_module_type, :capital_plan).where(capital_plan_module_types: {name: ['Unconstrained Plan', 'Constrained Plan']}, capital_plans: {organization_id: @organization_list, fy_year: current_planning_year_year}).where('capital_plan_modules.completed_at IS NOT NULL').pluck('capital_plans.organization_id')\n\n if @organization_list.count == 1\n if @has_locked_sogr_this_fiscal_year && (@has_locked_sogr_this_fiscal_year.include? @organization_list.first)\n @fiscal_years = @fiscal_years[(@fiscal_years.index{|x| x[1]==current_planning_year_year}+1)..-1]\n end\n @builder_proxy.start_fy = current_planning_year_year\n else\n @has_sogr_project_org_list = CapitalProject.joins(:organization).where(organization_id: @organization_list).sogr.group(:organization_id).count\n end\n\n @message = \"Creating SOGR capital projects. This process might take a while.\"\n\n end",
"def build\n @values.fetch('ai.application.build') { \n @values['ai.application.build'] = nil\n }\n end",
"def new\n @project = Project.new\n @project.tools.build\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def build_new_revision\n new_revision = Form.new(version_independent_id: version_independent_id,\n description: description, parent_id: parent_id, status: status,\n version: version + 1, name: name, oid: oid,\n created_by: created_by, control_number: control_number)\n\n new_revision\n end",
"def validate_build\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n \n # Use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Hard-code the building vintage\n building_vintage = 'NECB 2011'\n building_type = 'NECB'\n climate_zone = 'NECB'\n #building_vintage = '90.1-2013' \n\n # Turn debugging output on/off\n @debug = false \n \n # Open a channel to log info/warning/error messages\n @msg_log = OpenStudio::StringStreamLogSink.new\n if @debug\n @msg_log.setLogLevel(OpenStudio::Debug)\n else\n @msg_log.setLogLevel(OpenStudio::Info)\n end\n @start_time = Time.new\n @runner = runner\n\n # Load the libraries\n resource_path = \"#{File.dirname(__FILE__)}/../../../../create_DOE_prototype_building/resources/\"\n # HVAC sizing\n require_relative \"#{resource_path}/HVACSizing.Model\"\n # Canadian HVAC library\n #require_relative \"#{resource_path}/hvac\"\n # Weather data\n require_relative \"#{resource_path}/Weather.Model\"\n # HVAC standards\n require_relative \"#{resource_path}/Standards.Model\"\n # Utilities\n require_relative \"#{resource_path}/Prototype.utilities\"\n # try this\n require_relative \"#{resource_path}/Prototype.Model\"\n \n \n \n\n # Create a variable for the standard data directory\n # TODO Extend the OpenStudio::Model::Model class to store this\n # as an instance variable?\n standards_data_dir = resource_path\n \n # Load the Openstudio_Standards JSON files\n model.load_openstudio_standards_json(standards_data_dir)\n \n \n # Assign the standards to the model\n model.template = building_vintage \n \n # Make a directory to run the sizing run in\n sizing_dir = \"#{Dir.pwd}/sizing\"\n if !Dir.exists?(sizing_dir)\n Dir.mkdir(sizing_dir)\n end\n\n # Perform a sizing run\n if model.runSizingRun(\"#{sizing_dir}/SizingRun1\") == false\n log_msgs\n puts \"could not find sizing run #{sizing_dir}/SizingRun1\"\n return false\n else\n puts \"found sizing run #{sizing_dir}/SizingRun1\"\n end\n \n\n BTAP::FileIO::save_osm(model, \"#{File.dirname(__FILE__)}/before.osm\")\n \n # need to set prototype assumptions so that HRV added\n model.applyPrototypeHVACAssumptions(building_type, building_vintage, climate_zone)\n # Apply the HVAC efficiency standard\n model.applyHVACEfficiencyStandard\n #self.getCoilCoolingDXSingleSpeeds.sort.each {|obj| obj.setStandardEfficiencyAndCurves(self.template, self.standards)}\n \n BTAP::FileIO::save_osm(model, \"#{File.dirname(__FILE__)}/after.osm\")\n \n log_msgs\n return true\n\n end",
"def build_unit_test_contexts\n create_stores\n create_employees\n create_assignments\n create_jobs\n create_shifts\n create_shift_jobs\n create_flavors\n create_store_flavors\n end",
"def show\n @build = Build.find(params[:id])\n end",
"def my_buildings\n \n end",
"def create_model\n app = options[:app]\n return unless valid_model_for?(app)\n\n include_component_module_for(:test)\n migration_name = \"create_#{name.pluralize.underscore}\"\n apply_default_fields fields\n create_model_file(name, :fields => fields, :app => app)\n generate_model_test(name) if test?\n create_model_migration(migration_name, name, fields) unless options[:skip_migration]\n end",
"def generate_controllers\n case gen_name\n when 'install'\n # > rails g the_comments_base install\n cp_models\n cp_controllers\n cp_config\n when 'models'\n # > rails g the_comments_base models\n cp_models\n when 'controllers'\n # > rails g the_comments_base controllers\n cp_controllers\n when 'config'\n # > rails g the_comments_base config\n cp_config\n when 'locales'\n # > rails g the_comments_base locales\n cp_locales\n when 'all'\n # > rails g the_comments_base all\n cp_models\n cp_controllers\n cp_config\n cp_locales\n else\n puts 'TheComments Generator - wrong Name'\n puts 'Try to use [ install | models | controllers | config | locales | all ]'\n end\n end",
"def build_unit_test \n \n return if skip_method(__method__)\n \n filename = \"#{singular_table_name}_test.rb\"\n puts \"build Rails unit test for #{model_name} in test/models\"\n # build model test\n \n template = File.read(template(\"rails/test/unit_test.rb\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = File.join(\"test\",\"models\",filename)\n write_artifact(path,text)\n end",
"def build\n clean_build_directory\n copy_templates\n copy_functions\n copy_includes\n build_assets\n end",
"def build(building)\n @building = building\n end",
"def generate\n $VERBOSE = !options[:verbose].nil?\n name = shift_argument || generate_app_name\n project_dir = \"#{CURR_DIR}/#{name}\"\n overwrite = !options[:overwrite].nil?\n if File.directory? project_dir\n if overwrite\n FileUtils.rm_r project_dir\n else\n if confirm \"Project #{name} already exists. Should I replace it?\"\n if confirm \"This will delete ALL existing files. Are you ABSOLUTELY sure?\"\n FileUtils.rm_r project_dir\n else \n return\n end\n else\n return\n end\n end\n end\n version = options[:version]\n version = DEF_OBD_VERSION if version == nil\n unless OK_OBD_VERSIONS.include?(version)\n throw \"Specified version \\\"#{version}\\\" isn't supported.\\nTry one of the following:\\n #{OK_OBD_VERSIONS.join(\"\\n \")}\"\n end\n rebuild = !options[:rebuild].nil?\n full_engine = !options[:full_engine].nil?\n no_git = !options[:no_git].nil?\n download_openbd(version, rebuild)\n update_project(name, version, full_engine, false, false)\n put_into_git(name) unless no_git or ENV['OPENBD_HEROKU_NO_GIT']\n display \"-----> Project '#{name}' created successfully.\\nType 'cd #{name}' to change to your project folder.\\nType 'foreman start' to run the server locally\"\n end",
"def test_dynamic_do_build\r\n\t\tVCR.use_cassette('dynamic_do_build') do\r\n\t\t\t# A. get digital object\r\n\t\t\tcdo = CordraRestClient::DigitalObject.find(API_URL, \"#{CORDRA_PREFIX}/B100003484\")\r\n\t\t\t# Check object id and type\r\n\t\t\tassert_equal \"#{CORDRA_PREFIX}/B100003484\", cdo.id\r\n\t\t \tassert_equal \"DigitalSpecimen\", cdo.type\r\n\t\t\t# B. get schema\r\n\t\t\t# The schema will be used to build a DO class dinamically\r\n\t\t\tdo_schema=CordraRestClient::DigitalObject.get_schema(API_URL, cdo.type.gsub(\" \",\"%20\"))\r\n\t\t\t# check that the result is saved\r\n\t\t\tassert_equal \"object\", do_schema[\"type\"]\r\n\t\t\tassert_equal \"DigitalSpecimen\", do_schema[\"title\"]\r\n\t\t\t# C. build new class using schema\r\n\t\t\tdo_properties = do_schema[\"properties\"].keys\r\n\t\t\tdo_c = CordraRestClient::DigitalObjectFactory.create_class cdo.type.gsub(\" \",\"\"), do_properties\r\n\t\t\tnew_ds = do_c.new\r\n\t\t\t# the DO contents are a hash\r\n\t\t\tassert_equal Hash, cdo.content.class\r\n\t\t\t# assing object values in content to class\r\n\t\t\tCordraRestClient::DigitalObjectFactory.assing_attributes new_ds, cdo.content\r\n\t\t\tcdo.content.each do |field, arg|\r\n\t\t\t\tinstance_var = field.gsub('/','_')\r\n\t\t\t\tinstance_var = instance_var.gsub(' ','_')\r\n\t\t\t\tassert_equal arg, new_ds.instance_variable_get(\"@#{instance_var}\")\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def make; end",
"def build_controller\n \n build_controller_service\n \n return if skip_method(__method__)\n \n filename = plural_table_name + '_controller.rb'\n \n template = File.read(template(\"rails/controller.erb\"))\n\n text = Erubis::Eruby.new(template).evaluate( self )\n \n path = namespaced_path(\"app/controllers\",filename)\n puts \"build Rails controller for #{controller_name} in #{path}\"\n write_module_artifact(path,text)\n\n end",
"def rebuild\n build addl_cmake_bld_args: '--clean-first'\n end",
"def index\n @builds = current_application.builds\n @build = current_application.builds.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @builds }\n end\n end",
"def build\n @build ||= '0.0.0'\n end",
"def build_model\n self.model = nil # set up the model\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # url of the city database\n city_db_url = OpenStudio::Measure::OSArgument.makeStringArgument('city_db_url', true)\n city_db_url.setDisplayName('City Database Url')\n city_db_url.setDescription('Url of the City Database')\n # city_db_url.setDefaultValue(\"http://localhost:3000\")\n city_db_url.setDefaultValue('http://insight4.hpc.nrel.gov:8081/')\n args << city_db_url\n\n # project name of the building to create\n project_id = OpenStudio::Measure::OSArgument.makeStringArgument('project_id', true)\n project_id.setDisplayName('Project ID')\n project_id.setDescription('Project ID.')\n args << project_id\n\n # source id of the building to create\n feature_id = OpenStudio::Measure::OSArgument.makeStringArgument('feature_id', true)\n feature_id.setDisplayName('Feature ID')\n feature_id.setDescription('Feature ID.')\n args << feature_id\n\n # which surrounding buildings to include\n chs = OpenStudio::StringVector.new\n chs << 'None'\n chs << 'ShadingOnly'\n chs << 'All'\n surrounding_buildings = OpenStudio::Measure::OSArgument.makeChoiceArgument('surrounding_buildings', chs, true)\n surrounding_buildings.setDisplayName('Surrounding Buildings')\n surrounding_buildings.setDescription('Select which surrounding buildings to include.')\n surrounding_buildings.setDefaultValue('ShadingOnly')\n args << surrounding_buildings\n\n return args\n end",
"def build\n raise FedoraMigrate::Errors::MigrationError, \"No qualified targets found in #{source.pid}\" if target.nil?\n\n # create target, and apply depositor metadata\n obj = target.new\n\n obj.apply_depositor_metadata @depositor_utln\n obj.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n\n user = User.find_by_user_key(@depositor_utln)\n# CurationConcerns::Workflow::ActivateObject.call(target: obj, comment: 'activate object', user: user)\n\n create_and_add_payload(obj, @payload_primary, @depositor_utln)\n\n #deal with 2 primary datastream objects, storing second object in a new file set\n create_and_add_payload(obj, @payload_secondary, @depositor_utln) unless @payload_secondary.nil?\n\n #handle a case of bad hand created data on old records\n create_and_add_payload(obj, \"ARCHIVAL_SOUND\", @depositor_utln) if @payload_primary == \"ARCHIVAL_WAV\"\n\n # back up old data\n #create_and_add_fcrepo3_set obj\n\n process_desc_metadata obj\n process_admin_metadata obj\n process_technical_metadata obj\n process_relsext_metadata obj\n\n# obj.save\n\n process_collection_metadata obj\n\n active_workflow = Sipity::Workflow.find(2)\n Sipity::Entity.create!(proxy_for_global_id: obj.to_global_id.to_s,\n workflow: active_workflow,\n workflow_state: nil)\n\n obj\n end",
"def banner\n \"Usage: #{$0} ubiquo_scaffold ModelName [field:type, field:type]\"\n end",
"def banner\n \"Usage: #{$0} scaffold ModelName [field:type, field:type]\"\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n city_db_url = runner.getStringArgumentValue('city_db_url', user_arguments)\n project_id = runner.getStringArgumentValue('project_id', user_arguments)\n feature_id = runner.getStringArgumentValue('feature_id', user_arguments)\n surrounding_buildings = runner.getStringArgumentValue('surrounding_buildings', user_arguments)\n\n # pull information from the previous model\n # model.save('initial.osm', true)\n\n default_construction_set = model.getBuilding.defaultConstructionSet\n if !default_construction_set.is_initialized\n runner.registerInfo('Starting model does not have a default construction set, creating new one')\n default_construction_set = OpenStudio::Model::DefaultConstructionSet.new(model)\n else\n default_construction_set = default_construction_set.get\n end\n\n stories = []\n model.getBuildingStorys.each { |story| stories << story }\n stories.sort! { |x, y| x.nominalZCoordinate.to_s.to_f <=> y.nominalZCoordinate.to_s.to_f }\n\n space_types = []\n stories.each_index do |i|\n space_type = nil\n space = stories[i].spaces.first\n if space && space.spaceType.is_initialized\n space_type = space.spaceType.get\n else\n space_type = OpenStudio::Model::SpaceType.new(model)\n runner.registerInfo(\"Story #{i} does not have a space type, creating new one\")\n end\n space_types[i] = space_type\n end\n\n # delete the previous building\n model.getBuilding.remove\n\n # create new building and transfer default construction set\n model.getBuilding.setDefaultConstructionSet(default_construction_set)\n\n # instance variables\n @runner = runner\n @origin_lat_lon = nil\n\n uri = URI.parse(city_db_url)\n @city_db_url = uri.host\n @port = uri.port\n @city_db_is_https = uri.scheme == 'https'\n\n feature = get_feature(project_id, feature_id)\n if feature.nil? || feature.empty?\n @runner.registerError(\"Feature '#{feature_id}' could not be found\")\n return false\n end\n\n if feature[:geometry].nil?\n @runner.registerError(\"No geometry found in '#{feature}'\")\n return false\n end\n\n if feature[:properties].nil?\n @runner.registerError(\"No properties found in '#{feature}'\")\n return false\n end\n\n name = feature[:properties][:name]\n model.getBuilding.setName(name)\n\n geometry_type = feature[:geometry][:type]\n if geometry_type == 'Polygon'\n # ok\n elsif geometry_type == 'MultiPolygon'\n # ok\n else\n @runner.registerError(\"Unknown geometry type '#{geometry_type}'\")\n return false\n end\n\n # find min and max x coordinate\n min_lon_lat = get_min_lon_lat(feature)\n min_lon = min_lon_lat[0]\n min_lat = min_lon_lat[1]\n\n if min_lon == Float::MAX || min_lat == Float::MAX\n @runner.registerError('Could not determine min_lat and min_lon')\n return false\n else\n @runner.registerInfo(\"Min_lat = #{min_lat}, min_lon = #{min_lon}\")\n end\n\n @origin_lat_lon = OpenStudio::PointLatLon.new(min_lat, min_lon, 0)\n\n site = model.getSite\n site.setLatitude(@origin_lat_lon.lat)\n site.setLongitude(@origin_lat_lon.lon)\n\n if feature[:properties][:surface_elevation]\n surface_elevation = feature[:properties][:surface_elevation].to_f\n surface_elevation = OpenStudio.convert(surface_elevation, 'ft', 'm').get\n site.setElevation(surface_elevation)\n end\n\n feature_type = feature[:properties][:type]\n\n if feature_type == 'Building'\n\n # make requested building\n spaces = create_building(feature, :space_per_floor, model)\n if spaces.nil?\n @runner.registerError(\"Failed to create spaces for building '#{name}'\")\n return false\n end\n\n # DLM: temp hack\n building_type = feature[:properties][:building_type]\n if building_type == 'Vacant'\n max_z = 0\n spaces.each do |space|\n bb = space.boundingBox\n max_z = [max_z, bb.maxZ.get].max\n end\n shading_surfaces = create_photovoltaics(feature, max_z + 1, model)\n end\n\n # make other buildings to convert to shading\n convert_to_shades = []\n if surrounding_buildings == 'None'\n # no-op\n else\n convert_to_shades = create_other_buildings(feature, surrounding_buildings, model)\n end\n\n # intersect surfaces in this building with others\n @runner.registerInfo('Intersecting surfaces')\n spaces.each do |space|\n convert_to_shades.each do |other_space|\n space.intersectSurfaces(other_space)\n end\n end\n\n # match surfaces\n @runner.registerInfo('Matching surfaces')\n all_spaces = OpenStudio::Model::SpaceVector.new\n model.getSpaces.each do |space|\n all_spaces << space\n end\n OpenStudio::Model.matchSurfaces(all_spaces)\n\n # make windows\n window_to_wall_ratio = feature[:properties][:window_to_wall_ratio]\n if window_to_wall_ratio.nil?\n window_to_wall_ratio = 0.3\n end\n\n spaces.each do |space|\n space.surfaces.each do |surface|\n if surface.surfaceType == 'Wall' && surface.outsideBoundaryCondition == 'Outdoors'\n surface.setWindowToWallRatio(window_to_wall_ratio)\n end\n end\n end\n\n # change adjacent surfaces to adiabatic\n @runner.registerInfo('Changing adjacent surfaces to adiabatic')\n model.getSurfaces.each do |surface|\n adjacent_surface = surface.adjacentSurface\n if !adjacent_surface.empty?\n surface_construction = surface.construction\n if !surface_construction.empty?\n surface.setConstruction(surface_construction.get)\n else\n @runner.registerError(\"Surface '#{surface.nameString}' does not have a construction\")\n # model.save('error.osm', true)\n return false\n end\n surface.setOutsideBoundaryCondition('Adiabatic')\n\n adjacent_surface_construction = adjacent_surface.get.construction\n if !adjacent_surface_construction.empty?\n adjacent_surface.get.setConstruction(adjacent_surface_construction.get)\n else\n @runner.registerError(\"Surface '#{adjacent_surface.get.nameString}' does not have a construction\")\n # model.save('error.osm', true)\n return false\n end\n adjacent_surface.get.setOutsideBoundaryCondition('Adiabatic')\n end\n end\n\n # convert other buildings to shading surfaces\n convert_to_shades.each do |space|\n convert_to_shading_surface_group(space)\n end\n\n elsif feature_type == 'District System'\n\n district_system_type = feature[:properties][:district_system_type]\n\n if district_system_type == 'Community Photovoltaic'\n shading_surfaces = create_photovoltaics(feature, 0, model)\n end\n\n else\n @runner.registerError(\"Unknown feature type '#{feature_type}'\")\n return false\n end\n\n # transfer data from previous model\n stories = []\n model.getBuildingStorys.each { |story| stories << story }\n stories.sort! { |x, y| x.nominalZCoordinate.to_s.to_f <=> y.nominalZCoordinate.to_s.to_f }\n\n stories.each_index do |i|\n space_type = space_types[i]\n next if space_type.nil?\n\n stories[i].spaces.each do |space|\n space.setSpaceType(space_type)\n end\n end\n\n return true\n end",
"def definition_builder; end",
"def definition_builder; end",
"def new\n @build = Build.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @build }\n end\n end",
"def new\n @build = Build.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @build }\n end\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for add_constructions\n add_constructions = OpenStudio::Measure::OSArgument.makeBoolArgument('add_constructions', true)\n add_constructions.setDisplayName('Add Constructions to Model')\n add_constructions.setDescription('The Construction Set will be applied to the entire building')\n add_constructions.setDefaultValue(true)\n args << add_constructions\n\n # make an argument for wall and roof construction template\n construction_set_chs = OpenStudio::StringVector.new\n construction_set_chs << '90.1-2019'\n construction_set_chs << 'Good'\n construction_set_chs << 'Better'\n construction_set_chs << 'ZE AEDG Multifamily Recommendations'\n wall_roof_construction_template = OpenStudio::Measure::OSArgument.makeChoiceArgument('wall_roof_construction_template', construction_set_chs, true)\n wall_roof_construction_template.setDisplayName('Construction template for adding wall and roof constructions')\n wall_roof_construction_template.setDescription('The constructions will be applied to the entire building')\n wall_roof_construction_template.setDefaultValue('ZE AEDG Multifamily Recommendations')\n args << wall_roof_construction_template\n\n # make an argument for window construction template\n construction_set_chs = OpenStudio::StringVector.new\n construction_set_chs << '90.1-2019'\n construction_set_chs << 'Good'\n construction_set_chs << 'Better'\n construction_set_chs << 'ZE AEDG Multifamily Recommendations'\n window_construction_template = OpenStudio::Measure::OSArgument.makeChoiceArgument('window_construction_template', construction_set_chs, true)\n window_construction_template.setDisplayName('Construction template for adding window constructions')\n window_construction_template.setDescription('The constructions will be applied to the entire building')\n window_construction_template.setDefaultValue('ZE AEDG Multifamily Recommendations')\n args << window_construction_template\n\n # make an argument for add_space_type_loads\n add_space_type_loads = OpenStudio::Measure::OSArgument.makeBoolArgument('add_space_type_loads', true)\n add_space_type_loads.setDisplayName('Add Space Type Loads to Model')\n add_space_type_loads.setDescription('Populate existing space types in model with internal loads.')\n add_space_type_loads.setDefaultValue(true)\n args << add_space_type_loads\n\n # make an argument for add_elevators\n add_elevators = OpenStudio::Measure::OSArgument.makeBoolArgument('add_elevators', true)\n add_elevators.setDisplayName('Add Elevators to Model')\n add_elevators.setDescription('Elevators will be add directly to space in model vs. being applied to a space type.')\n add_elevators.setDefaultValue(false)\n args << add_elevators\n\n # make an argument for elev_spaces\n # todo - make sure this is setup to handle no elevators and also that it handles bad names well.\n elev_spaces = OpenStudio::Measure::OSArgument.makeStringArgument('elev_spaces', true)\n elev_spaces.setDisplayName('Elevator Spaces')\n elev_spaces.setDescription('Comma separated names of spaces for elevator. Each space listed will have associated elevator loads.')\n elev_spaces.setDefaultValue(\"Elevator_1_4,Elevator_2_4\")\n args << elev_spaces\n\n # elevator type\n elevator_type_chs = OpenStudio::StringVector.new\n elevator_type_chs << 'Traction'\n elevator_type_chs << 'Hydraulic'\n # todo - could include auto that looks at number of stories\n elevator_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('elevator_type', elevator_type_chs, true)\n elevator_type.setDisplayName('Elevator Type')\n elevator_type.setDescription('This will impact loads, schedules, and fraction of heat lost.')\n elevator_type.setDefaultValue('Traction')\n args << elevator_type\n\n # make an argument for add_internal_mass\n add_internal_mass = OpenStudio::Measure::OSArgument.makeBoolArgument('add_internal_mass', true)\n add_internal_mass.setDisplayName('Add Internal Mass to Model')\n add_internal_mass.setDescription('Adds internal mass to each space.')\n add_internal_mass.setDefaultValue(true)\n args << add_internal_mass\n\n # make an argument for add_exterior_lights\n add_exterior_lights = OpenStudio::Measure::OSArgument.makeBoolArgument('add_exterior_lights', true)\n add_exterior_lights.setDisplayName('Add Exterior Lights to Model')\n add_exterior_lights.setDescription('Multiple exterior lights objects will be added for different classes of lighting such as parking and facade.')\n add_exterior_lights.setDefaultValue(true)\n args << add_exterior_lights\n\n # make an argument for onsite_parking_fraction\n onsite_parking_fraction = OpenStudio::Measure::OSArgument.makeDoubleArgument('onsite_parking_fraction', true)\n onsite_parking_fraction.setDisplayName('Onsite Parking Fraction')\n onsite_parking_fraction.setDescription('If set to 0 no exterior lighting for parking will be added')\n onsite_parking_fraction.setDefaultValue(0.0)\n args << onsite_parking_fraction\n\n # make an argument for add_thermostat\n add_thermostat = OpenStudio::Measure::OSArgument.makeBoolArgument('add_thermostat', true)\n add_thermostat.setDisplayName('Add Thermostats')\n add_thermostat.setDescription('Add Thermostat to model based on Space Type Standards information of spaces assigned to thermal zones.')\n add_thermostat.setDefaultValue(true)\n args << add_thermostat\n\n # make an argument for add_swh\n add_swh = OpenStudio::Measure::OSArgument.makeBoolArgument('add_swh', true)\n add_swh.setDisplayName('Add Service Water Heating to Model')\n add_swh.setDescription('This will add both the supply and demand side of service water heating.')\n add_swh.setDefaultValue(true)\n args << add_swh\n\n swh_chs = OpenStudio::StringVector.new\n swh_chs << 'HeatPump'\n swh_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('swh_type', swh_chs, true)\n swh_type.setDisplayName('Service Water Heating Source')\n swh_type.setDescription('The primary source of heating used by SWH systems in the model.')\n swh_type.setDefaultValue('HeatPump')\n args << swh_type\n\n # make an argument for add_hvac\n add_hvac = OpenStudio::Measure::OSArgument.makeBoolArgument('add_hvac', true)\n add_hvac.setDisplayName('Add HVAC System to Model')\n add_hvac.setDefaultValue(true)\n args << add_hvac\n\n # Make argument for system type\n hvac_chs = OpenStudio::StringVector.new\n hvac_chs << 'Minisplit Heat Pumps with DOAS'\n hvac_chs << 'Minisplit Heat Pumps with ERVs'\n hvac_chs << 'PTHPs with DOAS'\n hvac_chs << 'PTHPs with ERVs'\n hvac_chs << 'Four-pipe Fan Coils with central air-source heat pump with DOAS'\n hvac_chs << 'Four-pipe Fan Coils with central air-source heat pump with ERVs'\n hvac_chs << 'Water Source Heat Pumps with Boiler and Fluid-cooler with DOAS'\n hvac_chs << 'Water Source Heat Pumps with Boiler and Fluid-cooler with ERVs'\n hvac_chs << 'Water Source Heat Pumps with Ground Source Heat Pump with DOAS'\n hvac_chs << 'Water Source Heat Pumps with Ground Source Heat Pump with ERVs'\n hvac_system_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('hvac_system_type', hvac_chs, true)\n hvac_system_type.setDisplayName('HVAC System Type')\n hvac_system_type.setDefaultValue('Four-pipe Fan Coils with central air-source heat pump with DOAS')\n args << hvac_system_type\n\n # make an argument for remove_objects\n # remove_objects = OpenStudio::Measure::OSArgument.makeBoolArgument('remove_objects', true)\n # remove_objects.setDisplayName('Clean Model of non-geometry objects')\n # remove_objects.setDescription('Only removes objects of type that are selected to be added.')\n # remove_objects.setDefaultValue(true)\n # args << remove_objects\n\n return args\n end",
"def build_version_dsl\n @build_version_dsl\n end",
"def build_version_dsl\n @build_version_dsl\n end",
"def generate(status)\n @build_status.shield(status, true)\nend",
"def build\n view\n self\n end",
"def initialize_generate\n super\n add_accessors\n @flavor.class.do_declare_resources do\n templates_if_missing << 'metadata.rb'\n templates_if_missing << 'README.md'\n templates_if_missing << 'CHANGELOG.md'\n end\n declare_gemfile\n declare_berksfile\n declare_rakefile\n declare_chefignore_patterns\n end",
"def banner\n \"Usage: #{$0} admin_scaffold ModelName [field:type, field:type]\"\n end",
"def create_models(bldg_types, vintages, climate_zones, epw_files = [])\n #### Create the prototype building\n failures = []\n\n # Loop through all of the given combinations\n bldg_types.sort.each do |building_type|\n vintages.sort.each do |template|\n climate_zones.sort.each do |climate_zone|\n model_name = \"#{building_type}-#{template}-#{climate_zone}\"\n puts \"****Testing #{model_name}****\"\n\n # Create an instance of the measure\n measure = CreateDOEPrototypeBuilding.new\n\n # Create an instance of a runner\n runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)\n\n # Make an empty model\n model = OpenStudio::Model::Model.new\n\n # Set argument values\n arguments = measure.arguments(model)\n argument_map = OpenStudio::Measure::OSArgumentMap.new\n building_type_arg = arguments[0].clone\n assert(building_type_arg.setValue(building_type))\n argument_map['building_type'] = building_type_arg\n\n template_arg = arguments[1].clone\n assert(template_arg.setValue(template))\n argument_map['template'] = template_arg\n\n climate_zone_arg = arguments[2].clone\n assert(climate_zone_arg.setValue(climate_zone))\n argument_map['climate_zone'] = climate_zone_arg\n\n epw_arg = arguments[3].clone\n assert(epw_arg.setValue('Not Applicable'))\n argument_map['epw_file'] = epw_arg\n\n measure.run(model, runner, argument_map)\n result = runner.result\n show_output(result)\n if result.value.valueName != 'Success'\n failures << \"Error - #{model_name} - Model was not created successfully.\"\n end\n\n model_directory = \"#{@test_dir}/#{building_type}-#{template}-#{climate_zone}\"\n\n # Convert the model to energyplus idf\n forward_translator = OpenStudio::EnergyPlus::ForwardTranslator.new\n idf = forward_translator.translateModel(model)\n idf_path_string = \"#{model_directory}/#{model_name}.idf\"\n idf_path = OpenStudio::Path.new(idf_path_string)\n idf.save(idf_path, true)\n end\n end\n end\n\n #### Return the list of failures\n return failures\n end",
"def add_constructions(building_type, building_vintage, climate_zone)\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying constructions')\n is_residential = \"No\" #default is nonresidential for building level\n\n # Assign construction to adiabatic construction\n # Assign a material to all internal mass objects\n cp02_carpet_pad = OpenStudio::Model::MasslessOpaqueMaterial.new(self)\n cp02_carpet_pad.setName('CP02 CARPET PAD')\n cp02_carpet_pad.setRoughness(\"VeryRough\")\n cp02_carpet_pad.setThermalResistance(0.21648)\n cp02_carpet_pad.setThermalAbsorptance(0.9)\n cp02_carpet_pad.setSolarAbsorptance(0.7)\n cp02_carpet_pad.setVisibleAbsorptance(0.8)\n\n normalweight_concrete_floor = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n normalweight_concrete_floor.setName('100mm Normalweight concrete floor')\n normalweight_concrete_floor.setRoughness('MediumSmooth')\n normalweight_concrete_floor.setThickness(0.1016)\n normalweight_concrete_floor.setConductivity(2.31)\n normalweight_concrete_floor.setDensity(2322)\n normalweight_concrete_floor.setSpecificHeat(832)\n\n nonres_floor_insulation = OpenStudio::Model::MasslessOpaqueMaterial.new(self)\n nonres_floor_insulation.setName('Nonres_Floor_Insulation')\n nonres_floor_insulation.setRoughness(\"MediumSmooth\")\n nonres_floor_insulation.setThermalResistance(2.88291975297193)\n nonres_floor_insulation.setThermalAbsorptance(0.9)\n nonres_floor_insulation.setSolarAbsorptance(0.7)\n nonres_floor_insulation.setVisibleAbsorptance(0.7)\n\n floor_adiabatic_construction = OpenStudio::Model::Construction.new(self)\n floor_adiabatic_construction.setName('Floor Adiabatic construction')\n floor_layers = OpenStudio::Model::MaterialVector.new\n floor_layers << cp02_carpet_pad\n floor_layers << normalweight_concrete_floor\n floor_layers << nonres_floor_insulation\n floor_adiabatic_construction.setLayers(floor_layers)\n\n g01_13mm_gypsum_board = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n g01_13mm_gypsum_board.setName('G01 13mm gypsum board')\n g01_13mm_gypsum_board.setRoughness('Smooth')\n g01_13mm_gypsum_board.setThickness(0.0127)\n g01_13mm_gypsum_board.setConductivity(0.1600)\n g01_13mm_gypsum_board.setDensity(800)\n g01_13mm_gypsum_board.setSpecificHeat(1090)\n g01_13mm_gypsum_board.setThermalAbsorptance(0.9)\n g01_13mm_gypsum_board.setSolarAbsorptance(0.7)\n g01_13mm_gypsum_board.setVisibleAbsorptance(0.5)\n\n wall_adiabatic_construction = OpenStudio::Model::Construction.new(self)\n wall_adiabatic_construction.setName('Wall Adiabatic construction')\n wall_layers = OpenStudio::Model::MaterialVector.new\n wall_layers << g01_13mm_gypsum_board\n wall_layers << g01_13mm_gypsum_board\n wall_adiabatic_construction.setLayers(wall_layers)\n\n m10_200mm_concrete_block_basement_wall= OpenStudio::Model::StandardOpaqueMaterial.new(self)\n m10_200mm_concrete_block_basement_wall.setName('M10 200mm concrete block basement wall')\n m10_200mm_concrete_block_basement_wall.setRoughness('MediumRough')\n m10_200mm_concrete_block_basement_wall.setThickness(0.2032)\n m10_200mm_concrete_block_basement_wall.setConductivity(1.326)\n m10_200mm_concrete_block_basement_wall.setDensity(1842)\n m10_200mm_concrete_block_basement_wall.setSpecificHeat(912)\n\n basement_wall_construction = OpenStudio::Model::Construction.new(self)\n basement_wall_construction.setName('Basement Wall construction')\n basement_wall_layers = OpenStudio::Model::MaterialVector.new\n basement_wall_layers << m10_200mm_concrete_block_basement_wall\n basement_wall_construction.setLayers(basement_wall_layers)\n\n basement_floor_construction = OpenStudio::Model::Construction.new(self)\n basement_floor_construction.setName('Basement Floor construction')\n basement_floor_layers = OpenStudio::Model::MaterialVector.new\n basement_floor_layers << m10_200mm_concrete_block_basement_wall\n basement_floor_layers << cp02_carpet_pad\n basement_floor_construction.setLayers(basement_floor_layers)\n\n self.getSurfaces.each do |surface|\n if surface.outsideBoundaryCondition.to_s == \"Adiabatic\"\n if surface.surfaceType.to_s == \"Wall\"\n surface.setConstruction(wall_adiabatic_construction)\n else\n surface.setConstruction(floor_adiabatic_construction)\n end\n elsif surface.outsideBoundaryCondition.to_s == \"OtherSideCoefficients\"\n # Ground\n if surface.surfaceType.to_s == \"Wall\"\n surface.setOutsideBoundaryCondition(\"Ground\")\n surface.setConstruction(basement_wall_construction)\n else\n surface.setOutsideBoundaryCondition(\"Ground\")\n surface.setConstruction(basement_floor_construction)\n end\n end\n end\n\n # Make the default construction set for the building\n bldg_def_const_set = self.add_construction_set(building_vintage, climate_zone, building_type, nil, is_residential)\n\n if bldg_def_const_set.is_initialized\n self.getBuilding.setDefaultConstructionSet(bldg_def_const_set.get)\n else\n OpenStudio::logFree(OpenStudio::Error, 'openstudio.model.Model', 'Could not create default construction set for the building.')\n return false\n end\n \n # Make a construction set for each space type, if one is specified\n self.getSpaceTypes.each do |space_type|\n \n # Get the standards building type\n stds_building_type = nil\n if space_type.standardsBuildingType.is_initialized\n stds_building_type = space_type.standardsBuildingType.get\n else\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Space type called '#{space_type.name}' has no standards building type.\")\n end\n \n # Get the standards space type\n stds_spc_type = nil\n if space_type.standardsSpaceType.is_initialized\n stds_spc_type = space_type.standardsSpaceType.get\n else\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Space type called '#{space_type.name}' has no standards space type.\")\n end \n \n # If the standards space type is Attic,\n # the building type should be blank.\n if stds_spc_type == 'Attic'\n stds_building_type = ''\n end\n\n # Attempt to make a construction set for this space type\n # and assign it if it can be created.\n spc_type_const_set = self.add_construction_set(building_vintage, climate_zone, stds_building_type, stds_spc_type, is_residential)\n if spc_type_const_set.is_initialized\n space_type.setDefaultConstructionSet(spc_type_const_set.get)\n end\n \n end\n \n # Add construction from story level, especially for the case when there are residential and nonresidential construction in the same building\n if building_type == 'SmallHotel'\n self.getBuildingStorys.each do |story|\n next if story.name.get == 'AtticStory'\n puts \"story = #{story.name}\"\n is_residential = \"No\" #default for building story level\n exterior_spaces_area = 0\n story_exterior_residential_area = 0\n \n # calculate the propotion of residential area in exterior spaces, see if this story is residential or not\n story::spaces.each do |space|\n next if space.exteriorWallArea == 0\n space_type = space.spaceType.get\n if space_type.standardsSpaceType.is_initialized\n space_type_name = space_type.standardsSpaceType.get\n end\n data = self.find_object(self.standards['space_types'], {'template'=>building_vintage, 'building_type'=>building_type, 'space_type'=>space_type_name})\n exterior_spaces_area += space.floorArea\n story_exterior_residential_area += space.floorArea if data['is_residential'] == \"Yes\" # \"Yes\" is residential, \"No\" or nil is nonresidential\n end\n is_residential = \"Yes\" if story_exterior_residential_area/exterior_spaces_area >= 0.5\n next if is_residential == \"No\"\n \n # if the story is identified as residential, assign residential construction set to the spaces on this story.\n building_story_const_set = self.add_construction_set(building_vintage, climate_zone, building_type, nil, is_residential)\n if building_story_const_set.is_initialized\n story::spaces.each do |space|\n space.setDefaultConstructionSet(building_story_const_set.get)\n end\n end\n end\n # Standars: For whole buildings or floors where 50% or more of the spaces adjacent to exterior walls are used primarily for living and sleeping quarters\n \n end \n \n # Make skylights have the same construction as fixed windows\n # sub_surface = self.getBuilding.defaultConstructionSet.get.defaultExteriorSubSurfaceConstructions.get\n # window_construction = sub_surface.fixedWindowConstruction.get\n # sub_surface.setSkylightConstruction(window_construction)\n\n\n # Assign a material to all internal mass objects\n material = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n material.setName('Std Wood 6inch')\n material.setRoughness('MediumSmooth')\n material.setThickness(0.15)\n material.setConductivity(0.12)\n material.setDensity(540)\n material.setSpecificHeat(1210)\n material.setThermalAbsorptance(0.9)\n material.setSolarAbsorptance(0.7)\n material.setVisibleAbsorptance(0.7)\n construction = OpenStudio::Model::Construction.new(self)\n construction.setName('InteriorFurnishings')\n layers = OpenStudio::Model::MaterialVector.new\n layers << material\n construction.setLayers(layers)\n\n # Assign the internal mass construction to existing internal mass objects\n self.getSpaces.each do |space|\n internal_masses = space.internalMass\n internal_masses.each do |internal_mass|\n internal_mass.internalMassDefinition.setConstruction(construction)\n end\n end\n\n # get all the space types that are conditioned\n conditioned_space_names = find_conditioned_space_names(building_type, building_vintage, climate_zone)\n \n # add internal mass\n unless (building_type == 'SmallHotel') &&\n (building_vintage == '90.1-2004' or building_vintage == '90.1-2007' or building_vintage == '90.1-2010' or building_vintage == '90.1-2013')\n internal_mass_def = OpenStudio::Model::InternalMassDefinition.new(self)\n internal_mass_def.setSurfaceAreaperSpaceFloorArea(2.0)\n internal_mass_def.setConstruction(construction)\n conditioned_space_names.each do |conditioned_space_name|\n space = self.getSpaceByName(conditioned_space_name)\n if space.is_initialized\n space = space.get\n internal_mass = OpenStudio::Model::InternalMass.new(internal_mass_def)\n internal_mass.setName(\"#{space.name} Mass\") \n internal_mass.setSpace(space)\n end\n end\n end\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished applying constructions')\n \n return true\n\n end",
"def create_everything\n create_users\n create_user_keys\n create_comments\n create_filters\n create_columns\n create_organizations\n create_approvals\n create_whitelists\n create_user_key_columns\n create_user_key_organizations\n end",
"def create_dependancies\n create_course_plan()\n end",
"def builds(filters = {})\n fetch_resources_lazily(\"builds\", filters)\n end",
"def build_test\n \n return if skip_method(__method__)\n \n build_test_fixtures\n build_test_helper\n build_functional_test\n build_integration_test\n build_unit_test\n end",
"def save!\n client.put_build(app_id: app_id, build_id: id, build: self)\n end",
"def get_build_request_model(session, app_id, version, build_number)\n path = \"#{FABRIC_API_PATH}#{org_app_endpoint(session, app_id)}/beta_distribution/releases\"\n params = {\n 'app[display_version]' => version,\n 'app[build_version]' => build_number\n }\n model = Fabricio::Networking::RequestModel.new do |config|\n config.type = :GET\n config.base_url = FABRIC_API_URL\n config.api_path = path\n config.params = params\n end\n model\n end",
"def generate!\n table_attributes = resource.table_attributes\n model_attributes = resource.model_attributes\n\n table_keys = table_attributes.keys\n model_keys = model_attributes.keys\n\n # Create table\n if table_keys.blank?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: create table\"\n return rails_migrate(\"create_#{resource.plural_name}\", model_attributes)\n end\n\n # Fields are not in database, but present in model.rb\n if(add_keys = (model_keys - table_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: add #{add_keys.to_sentence}\"\n rails_migrate(\"add_ATTRIBUTES_to_#{resource.plural_name}\", model_attributes.slice(*add_keys))\n end\n\n # Fields are in database, but no longer in our effective_resource do block\n if (remove_keys = (table_keys - model_keys)).present?\n Rails.logger.info \"effective_developer migrate #{resource.plural_name}: remove #{remove_keys.to_sentence}\"\n rails_migrate(\"remove_ATTRIBUTES_from_#{resource.plural_name}\", table_attributes.slice(*remove_keys))\n end\n end",
"def docs = require_relative 'scaffold/docs'",
"def build(rakeTask)\n\t\tprintAndCall(@cmd)\n\tend",
"def build_params\n params.require(:build).permit(:repo_id, :status)\n end",
"def build_everything\n puts 'building posts'\n build_posts\n puts 'building tags'\n build_tags\n puts 'building index'\n build_index\n puts 'building feed'\n build_feed\n end",
"def scaffold_views\n #%w(list show new edit)\n %w(list show)\n end",
"def generate_controllers\n if gen_name == 'install'\n cp_models\n cp_config\n elsif gen_name == 'config'\n cp_config\n elsif gen_name == 'models'\n cp_models\n elsif gen_name == 'controllers'\n cp_controllers\n elsif gen_name == 'locales'\n cp_locales\n elsif gen_name == 'help'\n cp_help\n else\n puts 'TheRole Generator - wrong Name'\n puts 'Try to use install'\n end\n end",
"def create\n @build = @project.builds.new\n\n if @build.save\n if params[@project.file_var] && params[@project.file_var].is_a?(ActionDispatch::Http::UploadedFile)\n @build.update_attribute :original_filename, params[@project.file_var].original_filename\n FileUtils.mv params[@project.file_var].path, @build.build_path.join(params[@project.file_var].original_filename).to_s\n\n system(\"ls #{@build.build_path}\")\n end\n @build.tag @build.build\n\n head :ok\n else\n render plain: @build.errors, status: :unprocessable_entity\n end\n end",
"def build\n Build.find(:all,:conditions=>{\"object\"=>self.build_id}).first\n end",
"def banner\n \"Usage: #{$0} asf_scaffold ModelName RecordType [ControllerName] [action, ...]\" \n end"
] | [
"0.62157387",
"0.62056005",
"0.6149594",
"0.6122502",
"0.6122502",
"0.60071087",
"0.5970789",
"0.5875449",
"0.5805002",
"0.5791995",
"0.57330227",
"0.5677001",
"0.56711984",
"0.56518173",
"0.56518173",
"0.5630826",
"0.55909956",
"0.55895394",
"0.5559768",
"0.5516053",
"0.549108",
"0.5460564",
"0.54134315",
"0.54124063",
"0.5384446",
"0.5384301",
"0.5384301",
"0.5384301",
"0.53751683",
"0.5355209",
"0.53193164",
"0.5304411",
"0.53043586",
"0.530289",
"0.52979237",
"0.5292348",
"0.52880085",
"0.5260331",
"0.5237029",
"0.52280915",
"0.5220888",
"0.51945907",
"0.5183923",
"0.5173337",
"0.5168767",
"0.51544565",
"0.5145468",
"0.51403624",
"0.513385",
"0.51300627",
"0.5127296",
"0.5119392",
"0.51191366",
"0.5101787",
"0.51017565",
"0.50993556",
"0.5086764",
"0.5073163",
"0.50684065",
"0.5058903",
"0.5041742",
"0.504049",
"0.5034839",
"0.5032372",
"0.5028789",
"0.50250924",
"0.5023302",
"0.5020493",
"0.50164336",
"0.5015211",
"0.5014011",
"0.5013039",
"0.5013039",
"0.50096947",
"0.50096947",
"0.5000662",
"0.49918112",
"0.49918112",
"0.4990141",
"0.4985001",
"0.4978223",
"0.4976641",
"0.49724552",
"0.4966579",
"0.49440756",
"0.49434137",
"0.49370033",
"0.49264115",
"0.49250656",
"0.49236107",
"0.4920201",
"0.49186987",
"0.49099207",
"0.49043027",
"0.49006307",
"0.48998475",
"0.48973402",
"0.4894386",
"0.4884531",
"0.4881871"
] | 0.6104936 | 5 |
The patch is to fix a core dump in Bug in PIL's quantize() with 64 bit architectures. | def patches
DATA
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pointer_size\n is_64bit ? 8 : 4\n end",
"def compressed_size; end",
"def compressed_size; end",
"def pixel_size; size.x * size.y; end",
"def compressed_size=(_arg0); end",
"def convert_image\n [16, 32, 64, 128].each do |size|\n convert_to_cache(size)\n end\n end",
"def large_image_width\n 850\n end",
"def check_for_resize; end",
"def decompressed_size; end",
"def interpret_size(size); end",
"def size64_high\n @ole.Size64High\n end",
"def _do_num_bytes\n raise NotImplementedError\n end",
"def entry_size; BLOCK_SIZE; end",
"def entry_size; BLOCK_SIZE; end",
"def calc_size(size)\n eax = size\n edx = size + 0xf\n eax = 0x10\n eax -= 1\n eax += edx\n var_390 = 0x10\n edx = 0\n eax = eax / var_390\n eax *= 0x10\n\n return eax + 0x1c\nend",
"def capture_size_before_cache(new_file) \n if model.image_width.nil? || model.image_height.nil?\n model.image_width, model.image_height = `identify -format \"%wx %h\" #{new_file.path}`.split(/x/).map { |dim| dim.to_i }\n end\n end",
"def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end",
"def pixel_bytesize(color_mode, depth = 8)\n return 1 if depth < 8\n (pixel_bitsize(color_mode, depth) + 7) >> 3\n end",
"def pixel_bytesize(color_mode, depth = 8)\n return 1 if depth < 8\n (pixel_bitsize(color_mode, depth) + 7) >> 3\n end",
"def max_resolution; end",
"def fbe_size\n 8\n end",
"def fbe_size\n 8\n end",
"def fbe_size\n 8\n end",
"def fbe_size\n 8\n end",
"def float128()\n # Maybe some day\n raise NotImplementedError\n end",
"def quantas_imagens_tem?(val)\n return val\n end",
"def fast_size2\n c_size = 0\n $postgres.exec_prepared('wsfile_size_multi', [self.id]).each do |row|\n c_size += row.except('id').map{|k,v| v.to_i}.inject(:+)\n end\n c_size\n end",
"def resize\n return self if self.count < (self.length * 0.811105)\n # garbage collecting\n self.gc if self.respond_to? :gc\n\n sz = self.size * 2\n super(sz)\n @bitmap.resize(sz)\n self\n end",
"def raw_size\n valid_blobs.map(&:raw_size).sum\n end",
"def size64_low\n @ole.Size64Low\n end",
"def thumbnail(size); end",
"def to_mb\n self / 1048576\n end",
"def byte_size; size.y * line_byte_size; end",
"def compute_image_size src\n $stderr.puts \"c_i_s #{src.class} #{src.to_s.size} #{src.inspect}\" if src.to_s.size < 1024\n case src\n when Pathname\n # @verbose = true\n result = cmd_out(\"#{BIN_PREFIX}imgsize -r #{src.to_s.inspect}\")\n result = /(\\d+) (\\d+)/.match(result)\n result = result ? { :width => result[1].to_i, :height => result[2].to_i } : nil\n result\n when String\n compute_image_size(force_to_file)\n else\n raise TypeError, \"#{src.class}\"\n end\n end",
"def workaround_older_macosx_misreported_cpu?\n os == :macosx && is_64_bit?\n end",
"def image_size\n end",
"def memsize\n end",
"def test_png_size_determined_correctly\n assert_equal [120, 175], @page.get_png_size(@test_png)\n end",
"def mul(val)\n # imul: //OperandSize == 32 EDX:EAX = EAX * Source\n # 0x00000000000fd317 : imul dword ptr [rcx] ; ret\n tmp = reg_addr\n flat(store(val, tmp), pop_rcx, tmp, libc + 0xfd317)\nend",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def large_process\n case [model.attachable_type, model.image_type]\n when ['User', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n when ['User', 'inspiration'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'avatar'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'alternate'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Alternative', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n else\n resize_to_fit 1024, 9999 # fixed width\n end\n # TODO: Test and implement this.\n # fix_exif_rotation\n quality 70\n end",
"def optimize_image_data(original_data)\n format = ImageMeta.format_for_data(original_data)\n return unless format\n Path.temp_file %W[image_optim .#{format}] do |temp|\n temp.binmode\n temp.write(original_data)\n temp.close\n\n if (result = optimize_image(temp.path))\n result.binread\n end\n end\n end",
"def size\n (@bit_length*@length*@count)/8.0\n end",
"def btog(bytes)\n return bytes / 1024 / 1024 / 1024\nend",
"def size_syncsafe(bytes)\n c = bytes.unpack(\"C4\")\n c[0]*(0x80**3) +\n c[1]*(0x80**2) +\n c[2]*0x80 +\n c[3]\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def fbe_size\n 1\n end",
"def data_size\n @iplimage_struct.image_size\n end",
"def float\n super if image_url? || floatable_size?\n end",
"def optimize_for_pagespeed\n # according to https://developers.google.com/speed/docs/insights/OptimizeImages\n if self.file.content_type == 'image/jpeg'\n # convert orig.jpg -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG orig_converted.jpg\n manipulate! do |img|\n img.sampling_factor '4:2:0'\n img.strip\n img.quality 85\n img.interlace 'JPEG'\n img\n end\n else\n # convert cuppa.png -strip cuppa_converted.png\n manipulate! do |img|\n img.strip\n img\n end\n end\n end",
"def img_size(image_size, new_size)\n decrease = new_size.fdiv(image_size)\n return decrease\nend",
"def fbe_allocation_size(fbe_value)\n 0 \\\n + byte0.fbe_allocation_size(fbe_value.byte0) \\\n + byte1.fbe_allocation_size(fbe_value.byte1) \\\n + byte2.fbe_allocation_size(fbe_value.byte2) \\\n + byte3.fbe_allocation_size(fbe_value.byte3) \\\n + byte4.fbe_allocation_size(fbe_value.byte4) \\\n + byte5.fbe_allocation_size(fbe_value.byte5) \\\n + char0.fbe_allocation_size(fbe_value.char0) \\\n + char1.fbe_allocation_size(fbe_value.char1) \\\n + char2.fbe_allocation_size(fbe_value.char2) \\\n + char3.fbe_allocation_size(fbe_value.char3) \\\n + char4.fbe_allocation_size(fbe_value.char4) \\\n + char5.fbe_allocation_size(fbe_value.char5) \\\n + wchar0.fbe_allocation_size(fbe_value.wchar0) \\\n + wchar1.fbe_allocation_size(fbe_value.wchar1) \\\n + wchar2.fbe_allocation_size(fbe_value.wchar2) \\\n + wchar3.fbe_allocation_size(fbe_value.wchar3) \\\n + wchar4.fbe_allocation_size(fbe_value.wchar4) \\\n + wchar5.fbe_allocation_size(fbe_value.wchar5) \\\n + int8b0.fbe_allocation_size(fbe_value.int8b0) \\\n + int8b1.fbe_allocation_size(fbe_value.int8b1) \\\n + int8b2.fbe_allocation_size(fbe_value.int8b2) \\\n + int8b3.fbe_allocation_size(fbe_value.int8b3) \\\n + int8b4.fbe_allocation_size(fbe_value.int8b4) \\\n + int8b5.fbe_allocation_size(fbe_value.int8b5) \\\n + uint8b0.fbe_allocation_size(fbe_value.uint8b0) \\\n + uint8b1.fbe_allocation_size(fbe_value.uint8b1) \\\n + uint8b2.fbe_allocation_size(fbe_value.uint8b2) \\\n + uint8b3.fbe_allocation_size(fbe_value.uint8b3) \\\n + uint8b4.fbe_allocation_size(fbe_value.uint8b4) \\\n + uint8b5.fbe_allocation_size(fbe_value.uint8b5) \\\n + int16b0.fbe_allocation_size(fbe_value.int16b0) \\\n + int16b1.fbe_allocation_size(fbe_value.int16b1) \\\n + int16b2.fbe_allocation_size(fbe_value.int16b2) \\\n + int16b3.fbe_allocation_size(fbe_value.int16b3) \\\n + int16b4.fbe_allocation_size(fbe_value.int16b4) \\\n + int16b5.fbe_allocation_size(fbe_value.int16b5) \\\n + uint16b0.fbe_allocation_size(fbe_value.uint16b0) \\\n + uint16b1.fbe_allocation_size(fbe_value.uint16b1) \\\n + uint16b2.fbe_allocation_size(fbe_value.uint16b2) \\\n + uint16b3.fbe_allocation_size(fbe_value.uint16b3) \\\n + uint16b4.fbe_allocation_size(fbe_value.uint16b4) \\\n + uint16b5.fbe_allocation_size(fbe_value.uint16b5) \\\n + int32b0.fbe_allocation_size(fbe_value.int32b0) \\\n + int32b1.fbe_allocation_size(fbe_value.int32b1) \\\n + int32b2.fbe_allocation_size(fbe_value.int32b2) \\\n + int32b3.fbe_allocation_size(fbe_value.int32b3) \\\n + int32b4.fbe_allocation_size(fbe_value.int32b4) \\\n + int32b5.fbe_allocation_size(fbe_value.int32b5) \\\n + uint32b0.fbe_allocation_size(fbe_value.uint32b0) \\\n + uint32b1.fbe_allocation_size(fbe_value.uint32b1) \\\n + uint32b2.fbe_allocation_size(fbe_value.uint32b2) \\\n + uint32b3.fbe_allocation_size(fbe_value.uint32b3) \\\n + uint32b4.fbe_allocation_size(fbe_value.uint32b4) \\\n + uint32b5.fbe_allocation_size(fbe_value.uint32b5) \\\n + int64b0.fbe_allocation_size(fbe_value.int64b0) \\\n + int64b1.fbe_allocation_size(fbe_value.int64b1) \\\n + int64b2.fbe_allocation_size(fbe_value.int64b2) \\\n + int64b3.fbe_allocation_size(fbe_value.int64b3) \\\n + int64b4.fbe_allocation_size(fbe_value.int64b4) \\\n + int64b5.fbe_allocation_size(fbe_value.int64b5) \\\n + uint64b0.fbe_allocation_size(fbe_value.uint64b0) \\\n + uint64b1.fbe_allocation_size(fbe_value.uint64b1) \\\n + uint64b2.fbe_allocation_size(fbe_value.uint64b2) \\\n + uint64b3.fbe_allocation_size(fbe_value.uint64b3) \\\n + uint64b4.fbe_allocation_size(fbe_value.uint64b4) \\\n + uint64b5.fbe_allocation_size(fbe_value.uint64b5) \\\n end",
"def pixelwidth\n end",
"def test_09b\r\n db = ITestUtils.newdb\r\n nm = File.join(test_data,'image-1.jpg')\r\n db.store(nm)\r\n db.fetch 'image-1.jpg',:width => 102\r\n r = db.fetch('image-1.jpg',:width => 103)\r\n db.fetch 'image-1.jpg',:width => 104\r\n db.hooks = hooks()\r\n db.delete 'image-1.jpg',:width => 103\r\n assert_equal 1,db.hooks.count[:deletes]\r\n assert_equal r,db.hooks.params[:sized].first\r\n #assert_equal File.basename(r),db.hooks.params[:sized].first\r\n assert_equal 1,db.hooks.params[:sized].size\r\n end",
"def test_07b\r\n db = build\r\n db.fetch('image-1.jpg',:width => 102)\r\n assert_equal 6,db.images.size\r\n assert_equal 1,db.image('image-1.jpg')[:widths].size\r\n r = db.delete('image-1.jpg',:width => 102)\r\n assert_equal 6,db.images.size # Original still there\r\n assert_equal 0,db.image('image-1.jpg')[:widths].size\r\n # Sized version is not there\r\n end",
"def image_width\n end",
"def wp_get_additional_image_sizes\n # TODO global $_wp_additional_image_sizes;\n # if ( ! $_wp_additional_image_sizes ) {\n # $_wp_additional_image_sizes = array();\n # }\n # return $_wp_additional_image_sizes;\n {}\n end",
"def image(size: T.unsafe(nil), search_terms: T.unsafe(nil), match_all: T.unsafe(nil)); end",
"def is_small_imageable?\n return true\n end",
"def png_chunk(signature, data)\n\t[data.length, signature, data, Zlib::crc32(signature + data)].pack(\"NA4A*N\")\nend",
"def scanline_bytesize(color_mode, depth, width)\n ((pixel_bitsize(color_mode, depth) * width) + 7) >> 3\n end",
"def scanline_bytesize(color_mode, depth, width)\n ((pixel_bitsize(color_mode, depth) * width) + 7) >> 3\n end",
"def test_progressive_dct_based_jpeg_image\n testname = '35w x 35h progressive jpeg image.'\n data = %w(\n FF D8 FF E0 00 10 4A 46 49 46 00 01 02 01 00 96\n 00 96 00 00 FF E1 04 E7 45 78 69 66 00 00 4D 4D\n 00 2A 00 00 00 08 00 07 01 12 00 03 00 00 00 01\n 00 01 00 00 01 1A 00 05 00 00 00 01 00 00 00 62\n 01 1B 00 05 00 00 00 01 00 00 00 6A 01 28 00 03\n 00 00 00 01 00 02 00 00 01 31 00 02 00 00 00 14\n 00 00 00 72 01 32 00 02 00 00 00 14 00 00 00 86\n 87 69 00 04 00 00 00 01 00 00 00 9C 00 00 00 C8\n 00 00 00 96 00 00 00 01 00 00 00 96 00 00 00 01\n 41 64 6F 62 65 20 50 68 6F 74 6F 73 68 6F 70 20\n 37 2E 30 00 32 30 30 38 3A 30 39 3A 30 39 20 32\n 32 3A 32 33 3A 31 32 00 00 00 00 03 A0 01 00 03\n 00 00 00 01 FF FF 00 00 A0 02 00 04 00 00 00 01\n 00 00 00 23 A0 03 00 04 00 00 00 01 00 00 00 23\n 00 00 00 00 00 00 00 06 01 03 00 03 00 00 00 01\n 00 06 00 00 01 1A 00 05 00 00 00 01 00 00 01 16\n 01 1B 00 05 00 00 00 01 00 00 01 1E 01 28 00 03\n 00 00 00 01 00 02 00 00 02 01 00 04 00 00 00 01\n 00 00 01 26 02 02 00 04 00 00 00 01 00 00 03 B9\n 00 00 00 00 00 00 00 48 00 00 00 01 00 00 00 48\n 00 00 00 01 FF D8 FF E0 00 10 4A 46 49 46 00 01\n 02 01 00 48 00 48 00 00 FF ED 00 0C 41 64 6F 62\n 65 5F 43 4D 00 02 FF EE 00 0E 41 64 6F 62 65 00\n 64 80 00 00 00 01 FF DB 00 84 00 0C 08 08 08 09\n 08 0C 09 09 0C 11 0B 0A 0B 11 15 0F 0C 0C 0F 15\n 18 13 13 15 13 13 18 11 0C 0C 0C 0C 0C 0C 11 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 01 0D 0B 0B 0D\n 0E 0D 10 0E 0E 10 14 0E 0E 0E 14 14 0E 0E 0E 0E\n 14 11 0C 0C 0C 0C 0C 11 11 0C 0C 0C 0C 0C 0C 11\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C FF C0 00 11\n 08 00 23 00 23 03 01 22 00 02 11 01 03 11 01 FF\n DD 00 04 00 03 FF C4 01 3F 00 00 01 05 01 01 01\n 01 01 01 00 00 00 00 00 00 00 03 00 01 02 04 05\n 06 07 08 09 0A 0B 01 00 01 05 01 01 01 01 01 01\n 00 00 00 00 00 00 00 01 00 02 03 04 05 06 07 08\n 09 0A 0B 10 00 01 04 01 03 02 04 02 05 07 06 08\n 05 03 0C 33 01 00 02 11 03 04 21 12 31 05 41 51\n 61 13 22 71 81 32 06 14 91 A1 B1 42 23 24 15 52\n C1 62 33 34 72 82 D1 43 07 25 92 53 F0 E1 F1 63\n 73 35 16 A2 B2 83 26 44 93 54 64 45 C2 A3 74 36\n 17 D2 55 E2 65 F2 B3 84 C3 D3 75 E3 F3 46 27 94\n A4 85 B4 95 C4 D4 E4 F4 A5 B5 C5 D5 E5 F5 56 66\n 76 86 96 A6 B6 C6 D6 E6 F6 37 47 57 67 77 87 97\n A7 B7 C7 D7 E7 F7 11 00 02 02 01 02 04 04 03 04\n 05 06 07 07 06 05 35 01 00 02 11 03 21 31 12 04\n 41 51 61 71 22 13 05 32 81 91 14 A1 B1 42 23 C1\n 52 D1 F0 33 24 62 E1 72 82 92 43 53 15 63 73 34\n F1 25 06 16 A2 B2 83 07 26 35 C2 D2 44 93 54 A3\n 17 64 45 55 36 74 65 E2 F2 B3 84 C3 D3 75 E3 F3\n 46 94 A4 85 B4 95 C4 D4 E4 F4 A5 B5 C5 D5 E5 F5\n 56 66 76 86 96 A6 B6 C6 D6 E6 F6 27 37 47 57 67\n 77 87 97 A7 B7 C7 FF DA 00 0C 03 01 00 02 11 03\n 11 00 3F 00 F5 54 0B 33 71 AB 79 AC BF 75 83 53\n 5B 01 7B 84 F1 B9 95 EE 73 54 F2 1C E6 D1 63 9B\n F4 9A C7 16 FC 40 5C F7 49 B7 1A FA 19 51 BF 23\n 1B 2C B4 3A EC 7B 2D 65 76 6E 23 DC FD 06 FB 58\n FF 00 A4 CB 92 53 1E B9 F5 9B 3E 96 DB 8D 83 D3\n B2 85 A7 DB 56 53 D8 1B 5C E9 EE 0F 7E E6 37 FE\n B8 AF FD 5B FD AA 71 9E EE A2 CB 6A 26 36 D7 7B\n C5 8F 07 5D EE DE 27 F4 7F 43 E9 21 E5 D5 85 8D\n 59 39 B9 04 56 EE 45 D9 6F F7 79 7A 6D 1E FF 00\n EA AB 9D 0A C3 67 4D AC 9A AC C7 01 CF 0C A6 D2\n 4B DA D0 E7 7A 61 FE A4 BF E8 7E FA 4A 74 12 49\n 24 94 FF 00 FF D0 F5 2B DA 5D 4D 8D 1C B9 A4 7D\n E1 66 F4 FB BA 7F 50 C3 C7 17 D4 CF 59 B5 33 F4\n 57 06 97 00 47 2D 9F CC 74 7D 26 2D 55 CC 7D 61\n CD 7F 40 38 66 BA 99 76 16 4D CE AD EC B8 4B 69\n 2E 06 C6 7A 76 0F 73 37 D9 EC D8 EF EC 24 A7 61\n 95 74 7C 70 6F 6B 28 AF 61 FE 72 1B 20 8F DD 77\n D2 44 E9 97 8C 8C 63 7B 5A E6 36 CB 2C 21 AE D1\n D0 1E EA F5 1F D8 58 1F 57 FA 95 DD 6B 23 25 B5\n D5 5E 23 31 F6 13 63 1A 1E F9 70 73 76 56 F7 7B\n 6A FE 6F 7F D0 FC F5 D3 63 D1 56 3D 2C A6 A6 ED\n AD 82 1A 12 52 44 92 49 25 3F FF D1 F5 55 47 AD\n C7 EC AC AD DE 84 7A 6E 9F B5 4F A3 11 FE 1B 67\n BF 67 F5 17 CC 69 24 A7 E9 6F AB BB 7F 66 55 B7\n EC BB 60 47 D8 B7 7A 5C 7F C2 7E 93 FC F5 A8 BE\n 55 49 25 3F 55 24 BE 55 49 25 3F FF D9 FF ED 09\n 94 50 68 6F 74 6F 73 68 6F 70 20 33 2E 30 00 38\n 42 49 4D 04 25 00 00 00 00 00 10 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 00 00 38 42 49 4D 03\n ED 00 00 00 00 00 10 00 96 00 00 00 01 00 01 00\n 96 00 00 00 01 00 01 38 42 49 4D 04 26 00 00 00\n 00 00 0E 00 00 00 00 00 00 00 00 00 00 3F 80 00\n 00 38 42 49 4D 04 0D 00 00 00 00 00 04 00 00 00\n 1E 38 42 49 4D 04 19 00 00 00 00 00 04 00 00 00\n 1E 38 42 49 4D 03 F3 00 00 00 00 00 09 00 00 00\n 00 00 00 00 00 01 00 38 42 49 4D 04 0A 00 00 00\n 00 00 01 00 00 38 42 49 4D 27 10 00 00 00 00 00\n 0A 00 01 00 00 00 00 00 00 00 01 38 42 49 4D 03\n F5 00 00 00 00 00 48 00 2F 66 66 00 01 00 6C 66\n 66 00 06 00 00 00 00 00 01 00 2F 66 66 00 01 00\n A1 99 9A 00 06 00 00 00 00 00 01 00 32 00 00 00\n 01 00 5A 00 00 00 06 00 00 00 00 00 01 00 35 00\n 00 00 01 00 2D 00 00 00 06 00 00 00 00 00 01 38\n 42 49 4D 03 F8 00 00 00 00 00 70 00 00 FF FF FF\n FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\n FF FF FF 03 E8 00 00 00 00 FF FF FF FF FF FF FF\n FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 03\n E8 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF\n FF FF FF FF FF FF FF FF FF FF FF 03 E8 00 00 00\n 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF\n FF FF FF FF FF FF FF 03 E8 00 00 38 42 49 4D 04\n 08 00 00 00 00 00 10 00 00 00 01 00 00 02 40 00\n 00 02 40 00 00 00 00 38 42 49 4D 04 1E 00 00 00\n 00 00 04 00 00 00 00 38 42 49 4D 04 1A 00 00 00\n 00 03 59 00 00 00 06 00 00 00 00 00 00 00 00 00\n 00 00 23 00 00 00 23 00 00 00 12 00 54 00 43 00\n 50 00 5F 00 43 00 69 00 72 00 63 00 6C 00 65 00\n 5F 00 42 00 61 00 6C 00 6C 00 61 00 73 00 74 00\n 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00\n 00 00 23 00 00 00 23 00 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 01\n 00 00 00 00 00 00 6E 75 6C 6C 00 00 00 02 00 00\n 00 06 62 6F 75 6E 64 73 4F 62 6A 63 00 00 00 01\n 00 00 00 00 00 00 52 63 74 31 00 00 00 04 00 00\n 00 00 54 6F 70 20 6C 6F 6E 67 00 00 00 00 00 00\n 00 00 4C 65 66 74 6C 6F 6E 67 00 00 00 00 00 00\n 00 00 42 74 6F 6D 6C 6F 6E 67 00 00 00 23 00 00\n 00 00 52 67 68 74 6C 6F 6E 67 00 00 00 23 00 00\n 00 06 73 6C 69 63 65 73 56 6C 4C 73 00 00 00 01\n 4F 62 6A 63 00 00 00 01 00 00 00 00 00 05 73 6C\n 69 63 65 00 00 00 12 00 00 00 07 73 6C 69 63 65\n 49 44 6C 6F 6E 67 00 00 00 00 00 00 00 07 67 72\n 6F 75 70 49 44 6C 6F 6E 67 00 00 00 00 00 00 00\n 06 6F 72 69 67 69 6E 65 6E 75 6D 00 00 00 0C 45\n 53 6C 69 63 65 4F 72 69 67 69 6E 00 00 00 0D 61\n 75 74 6F 47 65 6E 65 72 61 74 65 64 00 00 00 00\n 54 79 70 65 65 6E 75 6D 00 00 00 0A 45 53 6C 69\n 63 65 54 79 70 65 00 00 00 00 49 6D 67 20 00 00\n 00 06 62 6F 75 6E 64 73 4F 62 6A 63 00 00 00 01\n 00 00 00 00 00 00 52 63 74 31 00 00 00 04 00 00\n 00 00 54 6F 70 20 6C 6F 6E 67 00 00 00 00 00 00\n 00 00 4C 65 66 74 6C 6F 6E 67 00 00 00 00 00 00\n 00 00 42 74 6F 6D 6C 6F 6E 67 00 00 00 23 00 00\n 00 00 52 67 68 74 6C 6F 6E 67 00 00 00 23 00 00\n 00 03 75 72 6C 54 45 58 54 00 00 00 01 00 00 00\n 00 00 00 6E 75 6C 6C 54 45 58 54 00 00 00 01 00\n 00 00 00 00 00 4D 73 67 65 54 45 58 54 00 00 00\n 01 00 00 00 00 00 06 61 6C 74 54 61 67 54 45 58\n 54 00 00 00 01 00 00 00 00 00 0E 63 65 6C 6C 54\n 65 78 74 49 73 48 54 4D 4C 62 6F 6F 6C 01 00 00\n 00 08 63 65 6C 6C 54 65 78 74 54 45 58 54 00 00\n 00 01 00 00 00 00 00 09 68 6F 72 7A 41 6C 69 67\n 6E 65 6E 75 6D 00 00 00 0F 45 53 6C 69 63 65 48\n 6F 72 7A 41 6C 69 67 6E 00 00 00 07 64 65 66 61\n 75 6C 74 00 00 00 09 76 65 72 74 41 6C 69 67 6E\n 65 6E 75 6D 00 00 00 0F 45 53 6C 69 63 65 56 65\n 72 74 41 6C 69 67 6E 00 00 00 07 64 65 66 61 75\n 6C 74 00 00 00 0B 62 67 43 6F 6C 6F 72 54 79 70\n 65 65 6E 75 6D 00 00 00 11 45 53 6C 69 63 65 42\n 47 43 6F 6C 6F 72 54 79 70 65 00 00 00 00 4E 6F\n 6E 65 00 00 00 09 74 6F 70 4F 75 74 73 65 74 6C\n 6F 6E 67 00 00 00 00 00 00 00 0A 6C 65 66 74 4F\n 75 74 73 65 74 6C 6F 6E 67 00 00 00 00 00 00 00\n 0C 62 6F 74 74 6F 6D 4F 75 74 73 65 74 6C 6F 6E\n 67 00 00 00 00 00 00 00 0B 72 69 67 68 74 4F 75\n 74 73 65 74 6C 6F 6E 67 00 00 00 00 00 38 42 49\n 4D 04 11 00 00 00 00 00 01 01 00 38 42 49 4D 04\n 14 00 00 00 00 00 04 00 00 00 01 38 42 49 4D 04\n 0C 00 00 00 00 03 D5 00 00 00 01 00 00 00 23 00\n 00 00 23 00 00 00 6C 00 00 0E C4 00 00 03 B9 00\n 18 00 01 FF D8 FF E0 00 10 4A 46 49 46 00 01 02\n 01 00 48 00 48 00 00 FF ED 00 0C 41 64 6F 62 65\n 5F 43 4D 00 02 FF EE 00 0E 41 64 6F 62 65 00 64\n 80 00 00 00 01 FF DB 00 84 00 0C 08 08 08 09 08\n 0C 09 09 0C 11 0B 0A 0B 11 15 0F 0C 0C 0F 15 18\n 13 13 15 13 13 18 11 0C 0C 0C 0C 0C 0C 11 0C 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 01 0D 0B 0B 0D 0E\n 0D 10 0E 0E 10 14 0E 0E 0E 14 14 0E 0E 0E 0E 14\n 11 0C 0C 0C 0C 0C 11 11 0C 0C 0C 0C 0C 0C 11 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C\n 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C FF C0 00 11 08\n 00 23 00 23 03 01 22 00 02 11 01 03 11 01 FF DD\n 00 04 00 03 FF C4 01 3F 00 00 01 05 01 01 01 01\n 01 01 00 00 00 00 00 00 00 03 00 01 02 04 05 06\n 07 08 09 0A 0B 01 00 01 05 01 01 01 01 01 01 00\n 00 00 00 00 00 00 01 00 02 03 04 05 06 07 08 09\n 0A 0B 10 00 01 04 01 03 02 04 02 05 07 06 08 05\n 03 0C 33 01 00 02 11 03 04 21 12 31 05 41 51 61\n 13 22 71 81 32 06 14 91 A1 B1 42 23 24 15 52 C1\n 62 33 34 72 82 D1 43 07 25 92 53 F0 E1 F1 63 73\n 35 16 A2 B2 83 26 44 93 54 64 45 C2 A3 74 36 17\n D2 55 E2 65 F2 B3 84 C3 D3 75 E3 F3 46 27 94 A4\n 85 B4 95 C4 D4 E4 F4 A5 B5 C5 D5 E5 F5 56 66 76\n 86 96 A6 B6 C6 D6 E6 F6 37 47 57 67 77 87 97 A7\n B7 C7 D7 E7 F7 11 00 02 02 01 02 04 04 03 04 05\n 06 07 07 06 05 35 01 00 02 11 03 21 31 12 04 41\n 51 61 71 22 13 05 32 81 91 14 A1 B1 42 23 C1 52\n D1 F0 33 24 62 E1 72 82 92 43 53 15 63 73 34 F1\n 25 06 16 A2 B2 83 07 26 35 C2 D2 44 93 54 A3 17\n 64 45 55 36 74 65 E2 F2 B3 84 C3 D3 75 E3 F3 46\n 94 A4 85 B4 95 C4 D4 E4 F4 A5 B5 C5 D5 E5 F5 56\n 66 76 86 96 A6 B6 C6 D6 E6 F6 27 37 47 57 67 77\n 87 97 A7 B7 C7 FF DA 00 0C 03 01 00 02 11 03 11\n 00 3F 00 F5 54 0B 33 71 AB 79 AC BF 75 83 53 5B\n 01 7B 84 F1 B9 95 EE 73 54 F2 1C E6 D1 63 9B F4\n 9A C7 16 FC 40 5C F7 49 B7 1A FA 19 51 BF 23 1B\n 2C B4 3A EC 7B 2D 65 76 6E 23 DC FD 06 FB 58 FF\n 00 A4 CB 92 53 1E B9 F5 9B 3E 96 DB 8D 83 D3 B2\n 85 A7 DB 56 53 D8 1B 5C E9 EE 0F 7E E6 37 FE B8\n AF FD 5B FD AA 71 9E EE A2 CB 6A 26 36 D7 7B C5\n 8F 07 5D EE DE 27 F4 7F 43 E9 21 E5 D5 85 8D 59\n 39 B9 04 56 EE 45 D9 6F F7 79 7A 6D 1E FF 00 EA\n AB 9D 0A C3 67 4D AC 9A AC C7 01 CF 0C A6 D2 4B\n DA D0 E7 7A 61 FE A4 BF E8 7E FA 4A 74 12 49 24\n 94 FF 00 FF D0 F5 2B DA 5D 4D 8D 1C B9 A4 7D E1\n 66 F4 FB BA 7F 50 C3 C7 17 D4 CF 59 B5 33 F4 57\n 06 97 00 47 2D 9F CC 74 7D 26 2D 55 CC 7D 61 CD\n 7F 40 38 66 BA 99 76 16 4D CE AD EC B8 4B 69 2E\n 06 C6 7A 76 0F 73 37 D9 EC D8 EF EC 24 A7 61 95\n 74 7C 70 6F 6B 28 AF 61 FE 72 1B 20 8F DD 77 D2\n 44 E9 97 8C 8C 63 7B 5A E6 36 CB 2C 21 AE D1 D0\n 1E EA F5 1F D8 58 1F 57 FA 95 DD 6B 23 25 B5 D5\n 5E 23 31 F6 13 63 1A 1E F9 70 73 76 56 F7 7B 6A\n FE 6F 7F D0 FC F5 D3 63 D1 56 3D 2C A6 A6 ED AD\n 82 1A 12 52 44 92 49 25 3F FF D1 F5 55 47 AD C7\n EC AC AD DE 84 7A 6E 9F B5 4F A3 11 FE 1B 67 BF\n 67 F5 17 CC 69 24 A7 E9 6F AB BB 7F 66 55 B7 EC\n BB 60 47 D8 B7 7A 5C 7F C2 7E 93 FC F5 A8 BE 55\n 49 25 3F 55 24 BE 55 49 25 3F FF D9 00 38 42 49\n 4D 04 21 00 00 00 00 00 55 00 00 00 01 01 00 00\n 00 0F 00 41 00 64 00 6F 00 62 00 65 00 20 00 50\n 00 68 00 6F 00 74 00 6F 00 73 00 68 00 6F 00 70\n 00 00 00 13 00 41 00 64 00 6F 00 62 00 65 00 20\n 00 50 00 68 00 6F 00 74 00 6F 00 73 00 68 00 6F\n 00 70 00 20 00 37 00 2E 00 30 00 00 00 01 00 38\n 42 49 4D 04 06 00 00 00 00 00 07 00 08 01 01 00\n 01 01 00 FF E1 12 48 68 74 74 70 3A 2F 2F 6E 73\n 2E 61 64 6F 62 65 2E 63 6F 6D 2F 78 61 70 2F 31\n 2E 30 2F 00 3C 3F 78 70 61 63 6B 65 74 20 62 65\n 67 69 6E 3D 27 EF BB BF 27 20 69 64 3D 27 57 35\n 4D 30 4D 70 43 65 68 69 48 7A 72 65 53 7A 4E 54\n 63 7A 6B 63 39 64 27 3F 3E 0A 3C 3F 61 64 6F 62\n 65 2D 78 61 70 2D 66 69 6C 74 65 72 73 20 65 73\n 63 3D 22 43 52 22 3F 3E 0A 3C 78 3A 78 61 70 6D\n 65 74 61 20 78 6D 6C 6E 73 3A 78 3D 27 61 64 6F\n 62 65 3A 6E 73 3A 6D 65 74 61 2F 27 20 78 3A 78\n 61 70 74 6B 3D 27 58 4D 50 20 74 6F 6F 6C 6B 69\n 74 20 32 2E 38 2E 32 2D 33 33 2C 20 66 72 61 6D\n 65 77 6F 72 6B 20 31 2E 35 27 3E 0A 3C 72 64 66\n 3A 52 44 46 20 78 6D 6C 6E 73 3A 72 64 66 3D 27\n 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 72\n 67 2F 31 39 39 39 2F 30 32 2F 32 32 2D 72 64 66\n 2D 73 79 6E 74 61 78 2D 6E 73 23 27 20 78 6D 6C\n 6E 73 3A 69 58 3D 27 68 74 74 70 3A 2F 2F 6E 73\n 2E 61 64 6F 62 65 2E 63 6F 6D 2F 69 58 2F 31 2E\n 30 2F 27 3E 0A 0A 20 3C 72 64 66 3A 44 65 73 63\n 72 69 70 74 69 6F 6E 20 61 62 6F 75 74 3D 27 75\n 75 69 64 3A 34 37 38 34 61 35 39 66 2D 37 65 64\n 66 2D 31 31 64 64 2D 39 61 37 39 2D 61 31 62 66\n 63 38 33 61 61 63 63 36 27 0A 20 20 78 6D 6C 6E\n 73 3A 78 61 70 4D 4D 3D 27 68 74 74 70 3A 2F 2F\n 6E 73 2E 61 64 6F 62 65 2E 63 6F 6D 2F 78 61 70\n 2F 31 2E 30 2F 6D 6D 2F 27 3E 0A 20 20 3C 78 61\n 70 4D 4D 3A 44 6F 63 75 6D 65 6E 74 49 44 3E 61\n 64 6F 62 65 3A 64 6F 63 69 64 3A 70 68 6F 74 6F\n 73 68 6F 70 3A 34 37 38 34 61 35 39 64 2D 37 65\n 64 66 2D 31 31 64 64 2D 39 61 37 39 2D 61 31 62\n 66 63 38 33 61 61 63 63 36 3C 2F 78 61 70 4D 4D\n 3A 44 6F 63 75 6D 65 6E 74 49 44 3E 0A 20 3C 2F\n 72 64 66 3A 44 65 73 63 72 69 70 74 69 6F 6E 3E\n 0A 0A 3C 2F 72 64 66 3A 52 44 46 3E 0A 3C 2F 78\n 3A 78 61 70 6D 65 74 61 3E 0A 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 0A 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 0A 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 0A 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0A\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 0A 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 0A 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 0A 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 0A 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0A\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 0A 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20\n 20 20 20 20 20 20 20 20 20 0A 3C 3F 78 70 61 63\n 6B 65 74 20 65 6E 64 3D 27 77 27 3F 3E FF EE 00\n 21 41 64 6F 62 65 00 64 40 00 00 00 01 03 00 10\n 03 02 03 06 00 00 00 00 00 00 00 00 00 00 00 00\n FF DB 00 84 00 01 01 01 01 01 01 01 01 01 01 01\n 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01\n 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01\n 02 02 02 02 02 02 02 02 02 02 02 03 03 03 03 03\n 03 03 03 03 03 01 01 01 01 01 01 01 01 01 01 01\n 02 02 01 02 02 03 03 03 03 03 03 03 03 03 03 03\n 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03\n 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03\n 03 03 03 03 03 03 FF C2 00 11 08 00 23 00 23 03\n )\n @image.__send__(\"process_jpg\", [data.join('')].pack('H*'))\n assert_equal(@type, @image.type)\n assert_equal(35, @image.width)\n assert_equal(35, @image.height)\n end",
"def image_sizes\n { :small => 'x110',\n :medium => 'x208',\n :large => 'x413',\n :big => 'x654',\n :storage => 'x867'\n }\n end",
"def large_image\n self.image.large\n end",
"def decode_syncsafe_int(bytes)\n size = 0\n j = 0\n i = bytes.bytesize - 1\n while i >= 0\n size += 128**i * (bytes.getbyte(j) & 0x7f)\n j += 1\n i -= 1\n end\n size\n end",
"def min_chunk_size\n size_t * 4\n end",
"def get_unsafe_size(s)\n 0xffffffff - s + 1\n end",
"def digest_length\n (@width / 8.0).ceil\n end",
"def test_decode_large_big_integer()\n input = [\n 131, 111, 0, 0, 1, 2, 0, 77, 166, 39, 216, 70, 78, 172, 93, 52,\n 181, 124, 101, 170, 246, 159, 16, 153, 154, 36, 214, 242, 85, 167,\n 60, 82, 247, 27, 245, 116, 125, 142, 21, 240, 221, 108, 192, 132,\n 152, 51, 154, 161, 28, 103, 117, 214, 153, 173, 30, 239, 99, 160,\n 203, 22, 156, 85, 168, 87, 248, 230, 10, 115, 56, 202, 134, 245,\n 68, 118, 184, 171, 238, 51, 180, 1, 81, 139, 164, 161, 186, 231,\n 229, 45, 235, 244, 167, 92, 107, 159, 27, 27, 195, 22, 23, 236,\n 229, 112, 138, 40, 150, 70, 107, 175, 46, 27, 67, 83, 124, 247,\n 18, 87, 144, 167, 18, 212, 14, 129, 63, 190, 119, 149, 68, 165,\n 43, 152, 211, 55, 3, 54, 145, 143, 121, 37, 88, 178, 78, 178, 210,\n 187, 209, 95, 180, 82, 43, 15, 124, 42, 219, 102, 36, 195, 96, 61,\n 131, 32, 224, 3, 92, 102, 31, 168, 163, 134, 238, 181, 13, 36, 71,\n 28, 218, 181, 142, 191, 71, 241, 91, 166, 118, 178, 91, 243, 2,\n 40, 76, 251, 97, 47, 34, 78, 233, 253, 137, 228, 231, 176, 73,\n 165, 147, 17, 247, 147, 24, 66, 100, 211, 64, 134, 14, 184, 130,\n 153, 249, 87, 2, 246, 140, 79, 220, 174, 26, 78, 214, 64, 224, 88,\n 139, 150, 122, 184, 197, 160, 31, 203, 192, 9, 112, 34, 66, 156,\n 248, 131, 70, 190, 215, 162, 230, 162, 74, 181, 184, 36, 105, 229,\n 7, 168, 75, 47, 80, 83, 2]\n expected = \\\n '19238740999123740918273049817230948712039847012938740192837401' \\\n '92837409182374098127304985609817230984610293847120937840981273' \\\n '64098712304987120394861023984701293561029387502983750921837409' \\\n '81273409812309562039857102394810927401923874091283675091283765' \\\n '09812730548172309461203985710293865129837405912863509182763059' \\\n '18263059126305971260951623098712039857120936501293650912836750' \\\n '91826350928136509128365091826305981263509182736509817230901274' \\\n '01293874091283740912836740912837640981273409812730498127340902' \\\n '38740918237409812730498172304987213094871230948712309487123098' \\\n '56012936509518632095861203958620395620398576019234870213977677'\n expected = expected.to_i()\n\n stream = Erlang::StreamEmulator.new(input)\n actual = Erlang::decode(stream)\n\n assert_equal(expected, actual)\n end",
"def interpret_size(size)\n case size\n when /k$/i then size.to_i * 1024\n when /m$/i then size.to_i * 1024 * 1024\n when /g$/i then size.to_i * 1024 * 1024 * 1024\n else size.to_i\n end\n end",
"def current_size\n @multiplier ||= 1.0\n @multiplier *= 0.99\n [@multiplier, @multiplier]\n end",
"def zoom\n `#@native.devicePixelRatio`\n end",
"def calc_native_res_zoom(image_source)\n\t\timage = get_image(image_source)\n\t\tside_length = calc_side_length(image)\n\t\tzoom = log2(side_length)-log2(TILE_SIZE)\n\t\tzoom = 0 if zoom < 0\n\t\tzoom\n\tend",
"def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n end",
"def precisize(arg)\n if arg.is_a? Array\n arg.map{|e| precisize_num(e)}\n else\n precisize_num(arg)\n end\n end",
"def bit_small; @bit_small ||= gbit(8) end",
"def fbe_size\n 2\n end",
"def fbe_size\n 2\n end",
"def fbe_size\n 2\n end"
] | [
"0.5699385",
"0.5538211",
"0.5538211",
"0.5505387",
"0.53384584",
"0.5265782",
"0.519072",
"0.51459587",
"0.512661",
"0.51040226",
"0.5103516",
"0.5087984",
"0.5080438",
"0.5080438",
"0.5059701",
"0.50545794",
"0.5041337",
"0.5024155",
"0.5024155",
"0.50112885",
"0.49735287",
"0.49735287",
"0.49735287",
"0.49735287",
"0.49717894",
"0.49697465",
"0.49624452",
"0.49620983",
"0.4948617",
"0.49464205",
"0.49330056",
"0.49241793",
"0.4922295",
"0.490411",
"0.4902232",
"0.48986578",
"0.486665",
"0.48660418",
"0.48598334",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.48435774",
"0.4831055",
"0.48265752",
"0.48196006",
"0.48038837",
"0.4799029",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.4796013",
"0.47943816",
"0.47906196",
"0.47862294",
"0.47815764",
"0.47644532",
"0.47631302",
"0.47612196",
"0.47598985",
"0.47594953",
"0.47422677",
"0.4742242",
"0.47250396",
"0.47238007",
"0.47088262",
"0.47088262",
"0.4703469",
"0.46982658",
"0.46813473",
"0.46733892",
"0.46593606",
"0.46536088",
"0.4643541",
"0.46435007",
"0.46333972",
"0.4630008",
"0.46272227",
"0.4626719",
"0.4624556",
"0.4624011",
"0.4617804",
"0.46175674",
"0.46175674",
"0.46175674"
] | 0.0 | -1 |
set default for private attribute to false | def public?
!private
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n self.hidden ||= false\n end",
"def fields_are_private_by_default?\n ensure_setup!\n options[:visibility] == :private\n end",
"def by_default?\n false\n end",
"def set_defaults\n self.is_admin == false\n end",
"def set_defaults\n # By the way, this method can NEVER return false or the method will return invalid, without an error message. Yay!\n self.is_public ||= false\n self.size ||= 5\n true\n end",
"def default_values\n self.active ||= false\n end",
"def immutable=(bool)\n nil\n end",
"def attribute_accessor?\n false\n end",
"def set_defaults\n self.allow_download ||= false\n self.allow_streaming ||= false\n self.expired ||= false\n self.revoked ||= false\n end",
"def set_defaults\n if self.has_attribute?(:hidden) && self.hidden.nil?\n self.hidden = true\n end\n if self.has_attribute?(:base_price)\n self.base_price ||= 0.0\n end\n end",
"def set\n false\n end",
"def set_default\n self.member.payout_methods.active_only.each do |pm|\n pm.update_attribute(:default, false) if pm.default?\n end\n self.update_attribute(:default, true)\n end",
"def default_values\n self.isAdmin ||= false\n end",
"def attr_bool_writer *symbols\n attr_writer *symbols\n end",
"def disable_for_public\n self.update_attribute(:active, false)\n end",
"def set_default_values\n self.is_paid = false\n self.is_served = false\n self.is_preparation_started = false\n self.is_preparation_done = false\n return true\n end",
"def set_defaults\n self.active ||= false\n end",
"def not_private\n !self.private\n end",
"def set_defaults\n super\n self.indian_tribe ||= false\n end",
"def default\n @default = true\n end",
"def validation_default; false; end",
"def required_by_default?\n false\n end",
"def defaults\n self.behaviour_evaluated = false if self.behaviour_evaluated.nil?\n self.special_needs_ok = false if self.special_needs_ok.nil?\n self.long_term_resident = false if self.long_term_resident.nil?\n self.senior = false if self.senior.nil?\n end",
"def local_attr name, default_val = nil\n attr name, default_val, false\n end",
"def private?\n false\n end",
"def private=(_); end",
"def private=(val)\n ref_for(@current_user, true).private = (val != \"0\")\n end",
"def private?\n false\n end",
"def owner_class_attribute_default_matches?(state); end",
"def is_default=(value)\n @is_default = value\n end",
"def is_default=(value)\n @is_default = value\n end",
"def private=(value)\n value = value ? true : nil\n self.cache_control = cache_control.\n merge('public' => !value, 'private' => value)\n end",
"def attr_set_boolean(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def set_defaults\n self.active ||= true\n end",
"def initialize(names,options = {})\n super(names,options)\n @default_value = false\n @negatable = options[:negatable].nil? ? true : options[:negatable]\n end",
"def private_model; @private_model = true end",
"def optional\n @optional = true\n end",
"def disabled?; end",
"def disabled?; end",
"def attr_bool_accessor *symbols\n attr_accessor *symbols\n symbols.each { |sym| alias_method \"#{sym}?\", sym }\n remove_method *symbols\n end",
"def default_values\n\t\tself.status = false\n\tend",
"def is_not_editable!\n update_attribute :is_editable, false\n end",
"def hidden=(hidden)\n end",
"def hidden?; self[:hidden] ||= false; end",
"def default_values\n self.trash ||= false\n end",
"def initialize\n super\n self.class.attributes.reject { |attr| attr.default.nil? }.each do |attr|\n send(\"#{attr.method_name}=\", attr.default)\n end\n end",
"def not_admin_if_nil\n self.is_admin ||= false\n end",
"def set_defaults\n #self.required_by_manufacturer ||= true\n end",
"def defaults\n if self.name == \"Alex Ames\" || self.name == \"Ife Runsewe\"\n self.admin ||= true\n else\n self.admin ||= false\n nil #^Leaving a false value on the stack means the model will not be saved.^\n end\n end",
"def private?\n !self.public\n end",
"def is_default?\n return self.name == '_default'\n end",
"def owner_class_attribute_default; end",
"def attribute?\n false\n end",
"def all_no=(val)\n BOOL_ATTRIBUTES.each do |attr|\n self.instance_variable_set(\"@#{attr}\",val)\n end\n end",
"def default_values\n\t\tself.done ||= 'false'\n\t\tself.flag ||= 'false'\n\tend",
"def collectible_private= newval\n # Boolean may be coming in as string or integer\n cached_ref(true).private =\n case newval\n when Fixnum\n newval == 1\n when String\n newval == \"1\"\n when nil\n false\n else\n newval\n end\n end",
"def default_values\n self.organization_active = true if attributes.key?('organization_active') && organization_active.nil?\n end",
"def assign_boolean_param_if_used(attr_name, value)\n\t\tsend \"#{attr_name}=\", value.present? if value\n\tend",
"def init\n self.closed = false if (self.has_attribute? :closed) && self.closed.nil? #will set the default value only if it's nil\n self.canceled = false if (self.has_attribute? :canceled) && self.canceled.nil?\n end",
"def disabled; end",
"def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end",
"def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end",
"def private?\n self.private\n end",
"def make_public\n update_attribute( :is_public, true )\n end",
"def disabled=(_arg0); end",
"def init\n self.admin ||= false\n self.active ||= false\n end",
"def readonly?; true; end",
"def readonly?; true; end",
"def readonly?; true; end",
"def is_editable\n not is_default_cash_gift\n end",
"def default?(name)\n # FIXME: should this be in DoodleInfo or here?\n __doodle__.attributes[name.to_sym].optional? && !ivar_defined?(name)\n end",
"def make_private!\n reinitialize_rules!\n allow_if do\n false\n end\n return self\n end",
"def set_defaults\n self.copied = self.copied.nil? ? false : self.copied\n end",
"def is_house_default\n self.is_master = false\n end",
"def normalize_options\n if @opts[:disabled] == false\n super\n else\n super\n @attr[:disabled] = :disabled\n end\n end",
"def set(value)\n super(value == :true)\n end",
"def set_default(attr)\n return unless klass = self.class.attrclass(attr)\n return unless klass.method_defined?(:default)\n return if @parameters.include?(klass.name)\n\n return unless parameter = newattr(klass.name)\n\n if value = parameter.default and ! value.nil?\n parameter.value = value\n else\n @parameters.delete(parameter.name)\n end\n end",
"def set_default\n end",
"def attributes_protected_by_default\n []\n end",
"def required_by_default?; end",
"def defaults\n self.searchable ||= false\n self.displayable ||= true\n self.facetable ||= false\n self.multivalued ||= false\n self.sortable ||= false\n self.data_type ||= \"string\"\n end",
"def private?\n @attributes[\"access\"] ? @attributes[\"access\"] == \"private\" : false\n end",
"def set_defaults\n self.published ||= false\n self.archived ||= false\n self.is_default ||= false\n self.version ||= 0\n self.visibility = ((self.org.present? && self.org.funder_only?) || self.is_default?) ? Template.visibilities[:publicly_visible] : Template.visibilities[:organisationally_visible] unless self.id.present?\n self.customization_of ||= nil\n self.family_id ||= new_family_id\n self.archived ||= false\n self.links ||= { funder: [], sample_plan: [] }\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def private?\n self.private\n end",
"def initialize(value)\r\n @value = value\r\n @changeable = true\r\n default_value?\r\nend",
"def set_defaults\n self.completed ||= false\n end",
"def value_if_false=(value)\n @value_if_false = value\n end",
"def is_public=( f )\n self.update_item_flag = ( is_public != f )\n write_attribute( :is_public, f ) if self.update_item_flag\n end",
"def boolean(tag, default_value = false)\n choice(tag){|inst, val|\n if val.nil?\n default_value\n else\n STDERR.puts \"used to be #{val}, norikae #{not val}\"\n not val\n end\n }\n end",
"def set_defaults\n set_nil_default( :archived, false )\n end",
"def to_none\n self.public = true\n end",
"def default_values\n \tself.access_type = 'member'\n end",
"def reset_is_default_flags\n if self.is_default == true\n self.dataset.weights.get_all_but(self.id).update_all(is_default: false)\n end\n end",
"def validation_default; true; end",
"def validation_default; true; end",
"def default_scopable?\n default_scopable != false\n end",
"def set_defaults\n self.featured ||= 1\n end",
"def enabled=(_arg0); end",
"def enabled=(_arg0); end"
] | [
"0.7142315",
"0.71222454",
"0.690919",
"0.69055337",
"0.6838684",
"0.679225",
"0.6785153",
"0.670946",
"0.6698765",
"0.6676067",
"0.66545254",
"0.66462314",
"0.6640952",
"0.6635633",
"0.6631872",
"0.6614501",
"0.66107017",
"0.6553514",
"0.6535993",
"0.65251917",
"0.6514636",
"0.65042734",
"0.6491304",
"0.64561224",
"0.6447832",
"0.6436595",
"0.6423696",
"0.6421615",
"0.64154017",
"0.640156",
"0.640156",
"0.6379769",
"0.63678443",
"0.6357161",
"0.63269556",
"0.63240886",
"0.6315338",
"0.6298503",
"0.6298503",
"0.62940955",
"0.62815624",
"0.627823",
"0.6268641",
"0.62648714",
"0.6262486",
"0.6253442",
"0.62502533",
"0.6207838",
"0.6199986",
"0.61984944",
"0.6191778",
"0.618475",
"0.6179339",
"0.617181",
"0.61614764",
"0.6153948",
"0.61504495",
"0.61357063",
"0.6132727",
"0.6128014",
"0.6117318",
"0.6117318",
"0.61156845",
"0.6110262",
"0.61023384",
"0.6093087",
"0.60918117",
"0.60918117",
"0.60918117",
"0.60861796",
"0.60708386",
"0.6070047",
"0.60681736",
"0.60529417",
"0.6046045",
"0.6042244",
"0.6025614",
"0.60181254",
"0.6006803",
"0.59996265",
"0.5989715",
"0.59840816",
"0.5983708",
"0.5977662",
"0.5977662",
"0.5968422",
"0.5964996",
"0.5964278",
"0.5957535",
"0.595636",
"0.595543",
"0.5952011",
"0.59503627",
"0.5949267",
"0.5946845",
"0.594579",
"0.594579",
"0.59233826",
"0.5916166",
"0.59057814",
"0.59057814"
] | 0.0 | -1 |
Class to read input from user and compare again known commands some commands require two words | def handle_input
# Takes user input
input = STDIN.gets.chomp
system('clear')
# Single word commands
# QUIT
if input == 'quit'
@run_game = false
puts "Thanks for playing!"
sleep(3)
system('clear')
# BACKPACK
elsif input == 'backpack'
@player.print_backpack
# HELP
elsif input == 'help'
puts "Use the commands to move around the AirBnB and use items to help you escape."
else
# Double word commands
input_arr = input.split(" ")
# User has only entered one word
if input_arr.size > 1
command1 = input_arr[0]
command2 = input_arr[1]
# TAKE ITEM
if command1 == "take"
take_item(command2)
# USE ITEM
elsif command1 == "use"
use_item(command2)
# GO ROOM
elsif command1 == "go"
go_room(command2)
else
# User doesn't specify second command
puts "I'll need more information than that!"
end
else
# User enters invalid command word
puts "That isn't a valid command"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_input(input)\n args = input.split(' ')\n command = args.shift\n return false if command.nil?\n results = self.class.search(command, ConsoleProgram.scopes.active)\n if results.length == 1\n results.first.new(args)\n else\n multiple_commands = []\n results.each do |klass|\n multiple_commands << klass unless klass.has_alternate_commands? && klass.alternate_commands.include?(command)\n end\n result = (multiple_commands.length == 1 ? multiple_commands.first : nil)\n tell_user 'Multiple commands found, which do you mean?' if result.nil?\n while result.nil?\n output_string = []\n results.each_with_index{|r, i| output_string << \"#{i + 1}: #{r.to_s.split('::')[1..-1].join('->')}\" }\n get output_string.join(results.length > 5 ? \"\\n\" : ', ')\n result = results[input.to_i - 1]\n tell_user 'Unrecognized input' if result.nil?\n end\n result.new(*args)\n end\n end",
"def valid_input\n\t\t#adds single word commands\n\t\tvalid = ['help', 'wait', 'inventory']\n\t\tlocation = find_room_in_dungeon(@player.location)\n\t\tlocation.connections.each do |direction, destination|\n\t\t\tvalid << direction.to_s\n\t\tend\n\t\t\n\t\t#adds two word commands\n\t\[email protected] do |reference|\n\t\t\t['eat', 'throw', 'examine', 'drop'].each do |action|\n\t\t\tvalid << action + \" \" + reference.to_s\n\t\t\tend\n\t\tend\n\t\tif @player.location == @other_player.location || @player.location == :Lair\n\t\t\[email protected] do |reference|\n\t\t\t\tvalid << 'give' + \" \" + reference.to_s\n\t\t\tend\n\t\tend\n\t\tif @player.inventory.include?(:crystal) && @other_player.inventory.include?(:crystal)\n\t\t\tvalid << 'wob crystal'\n\t\tend\n\t\tcase @player.location\n\t\twhen :Laboratorium then\n\t\t\tvalid << 'look tools'\n\t\t\tvalid << 'take crystal' unless @crystal_taken > 1\n\t\twhen :garden then\n\t\t\tvalid << 'look plants'\n\t\t\tvalid << 'take beans' unless @beans_taken\n\t\twhen :Lounge then\n\t\t\tvalid << 'look chair'\n\t\t\tvalid << 'take pills' unless @pills_taken\n\t\twhen :Library then\n\t\t\tvalid << 'look pedestal'\n\t\t\tvalid << 'take box' unless @box_taken\n\t\twhen :Study then\n\t\t\tvalid << 'look papers'\n\t\t\tvalid << 'take notes' unless @notes_taken\n\t\twhen :Lair then\n\t\t\tvalid << 'wob box' if @player.inventory.include?(:box)\n\t\t\tvalid << 'look creature'\n\t\t\tvalid << 'take creature'\n\t\tend\n\t\tvalid.each do |string|\n\t\t\tputs string\n\t\tend\n\tend",
"def read_command(prompt); end",
"def input_command\n\t\tloop do\n\t\t\tputs \"\"\n\t\t\tputs \"What are your commands master #{$account}?\"\n\t\t\t# cmd = ('say \"What are your commands my master?\"')\n\t\t\t# system cmd\n\t\t\tgive_command(gets.chomp.upcase)\n\t\tend\n\tend",
"def verify_command(command)\n if [\"list\", \"l\"].include?(command)\n list_command()\n elsif [\"create\", \"c\"].include?(command)\n list_command() if create_command()\n elsif [\"delete\", \"d\"].include?(command)\n list_command() if delete_command()\n elsif [\"search\", \"s\"].include?(command)\n search_command()\n elsif [\"food\", \"f\"].include?(command)\n food_command()\n elsif [\"wash\", \"w\"].include?(command)\n wash_command()\n elsif [\"alive\", \"a\"].include?(command)\n alive_command()\n elsif [\"help\", \"h\"].include?(command)\n help()\n else\n help()\n end\n end",
"def user_commands\n puts sep = \"------------------------------------------------------\".colorize(:yellow)\n prompt = TTY::Prompt.new\n commands = [\n {name: 'Place', value: 1},\n {name: 'Move', value: 2},\n {name: 'Left', value: 3},\n {name: 'Right', value: 4},\n {name: 'Report', value: 5},\n {name: 'Execute Selected Commands', value: 6},\n ]\n players_input = prompt.select(\"Select Your Commands:\", commands) \n case players_input\n when 1\n place_command = prompt_place\n @commands_sequence.push(place_command)\n p @commands_sequence\n puts sep\n user_commands\n when 2\n move_command = validate_move\n @commands_sequence.push(move_command)\n p @commands_sequence\n puts sep\n user_commands\n when 3\n left_command = validate_left\n @commands_sequence.push(left_command)\n p @commands_sequence\n puts sep\n user_commands\n when 4\n right_command = validate_right\n @commands_sequence.push(right_command)\n p @commands_sequence\n puts sep\n user_commands\n when 5\n report_command = validate_report\n @commands_sequence.push(report_command)\n p @commands_sequence\n puts sep\n user_commands\n when 6\n legal_commands = valid_commands(@commands_sequence)\n if legal_commands.length == 0\n puts \"Command sequence must begin with a Place Command\".colorize(:red)\n user_commands\n else \n return legal_commands\n end\n end \n end",
"def get_command(can_double_down, can_split)\n self.print_msg('hit_or_stay')\n \n if can_double_down\n self.print_msg('can_double_down')\n end\n \n if can_split\n self.print_msg('can_split')\n end\n \n valid_input = false\n \n until valid_input do\n input = gets.chomp\n if input == \"h\" || input ==\"s\" || (input == \"d\" && can_double_down) || (input == \"x\" && can_split) \n valid_input = true\n else\n self.print_msg('invalid_command')\n end\n end\n return input\n end",
"def command_processor(user_input)\r\n case user_input.downcase\r\n when \"help\"\r\n list_available_commands\r\n when \"create\"\r\n ui_create_event\r\n when \"view-day\"\r\n ui_view_by_day\r\n when \"view-month\"\r\n ui_view_by_month\r\n when \"delete\"\r\n ui_delete_event\r\n when \"modify\"\r\n ui_modify_event\r\n else\r\n puts \"#{user_input} is not a command. type 'help' to see a list of commands\"\r\n end\r\nend",
"def check\n case $input\n when 'inv'\n list\n when 'get'\n get\n add\n when 'n', 'north'\n $player.go($player.location.n)\n when 's', 'south'\n $player.go($player.location.s)\n when 'e', 'east'\n $player.location.go('e')\n when 'w', 'west'\n $player.location.go('w')\n when 'search'\n $player.location.search\n when 'buy'\n buy\n when 'l', 'look'\n $player.location.look\n when 'help'\n help\n when 'info'\n info\n when 'stats'\n $player.stats\n else puts 'That is not a valid command.' \n end\n end",
"def read_and_execute(inp)\n args = inp.split(' ') # Split the input by space\n cmd_name = args[0] # First argument of the command name\n cmd_args = args[1..inp.length] # Second argument is the argument of the commands\n @commands_available[cmd_name].execute(cmd_args)\n end",
"def read_command\n @std_output.print COMMAND_PROMPT\n @std_input.gets.chomp\n end",
"def handle_commands(command) # rubocop:todo Metrics/CyclomaticComplexity\n case command\n when '/start'\n greet_user\n when '/stop'\n send_message \"Bye, #{message.from.first_name}\"\n when '/help'\n send_message \"Please enter any of the following commands: #{@commands}\"\n when '/news'\n handle_news\n when '/subscribe'\n handle_subscribe command\n when '/update'\n handle_update\n when '/add_birthday'\n @name = message.text if @name_set and @name.empty?\n prompt_user command\n when '/add_my_birthday'\n prompt_user command\n when '/add_anniversary'\n @name = message.text if @name_set and @name.empty?\n prompt_user command\n\n end\n end",
"def command_line_input_logic(passby)\n\tcase passby\n\t\twhen 1\n\t\t\tputs `man mv`\n\t\twhen 2\n\t\t\tputs `man cp`\n\t\twhen 3\n\t\t\tputs `man mkdir`\n\t\twhen 4\n\t\t\tputs `man ls`\n\t\twhen 5\n\t\t\tputs `man rm`\n\t\twhen 6\n\t\t\tmenu\n\t\telse\n\t\t\tputs \"Please make a selection between 1 - 6!\"\n\tend\n\tcommand_line_menu\nend",
"def prompt_input\n class_invariant\n print ps1\n command = gets.chomp\n class_invariant\n return command\n end",
"def one_word_command\n switch = cmd.switch ? cmd.switch.downcase : nil\n switch == \"pass\" || switch == \"reload\" || switch == \"evade\"\n end",
"def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend",
"def read_command\n input = STDIN.read\n input.strip!\n if /(.*?)[ \\t]/ =~ input\n command = $1\n else\n command = input\n end\n return [input, command]\nend",
"def check(command)\n if !(command =~ /\\n/) && (command =~ /^git/)\n self.kind = \"git\"\n self.aqlog(\"Git command\")\n reads = [\"git-upload-pack\", \"git upload-pack\"]\n writes = [\"git-receive-pack\", \"git receive-pack\"]\n sh_command = command.split(\" \")\n if sh_command.size == 3\n self.cmd_cmd = sh_command[0] + \" \" + sh_command[1]\n self.cmd_opt = sh_command[2]\n elsif sh_command.size == 2\n self.cmd_cmd = sh_command[0]\n self.cmd_opt = sh_command[1]\n else\n return false\n end\n\n # check the command for type\n if reads.include?(self.cmd_cmd)\n self.read = true\n self.aqlog(\"Read command\")\n end\n if writes.include?(self.cmd_cmd)\n self.write = true\n self.aqlog(\"Write command\")\n end\n return true\n elsif !(command =~ /\\n/) && (command =~ /^hg/)\n # something fails in here\n self.kind = \"hg\"\n self.aqlog(\"Hg command\")\n reads = [\"-R\"]\n writes = []\n sh_command = command.split(\" \")\n hg_command = { :cmd => sh_command[0],\n :cmdopt => sh_command[1],\n :fake_path => sh_command[2],\n :cmd2 => sh_command[3],\n :cmd3 => sh_command[4] }\n # probably those lines\n self.cmd_cmd = \"hg #{hg_command[:cmd]}\"\n self.cmd_opt = \"#{hg_command[:cmdopt]} #{hg_command[:fake_path]} #{hg_command[:cmd2]} #{hg_command[:cmd3]}\"\n self.aqlog(cmd_opt)\n if reads.include?(self.cmd_cmd)\n self.read = true\n self.aqlog(\"Read command\")\n end\n if writes.include?(self.cmd_cmd)\n self.write = true\n self.aqlog(\"Write command\")\n end\n return true\n else\n return false\n end\n end",
"def get_menu_choice\n\n valid_cmds = [ # array of valid commands we will accept\n \"exit\",\n \"0\", \"00\",\n \"1\",\"2\",\"3\",\"4\",\"5\",\n \"show recent\",\n \"scrape more\",\n \"search\",\n \"search by pay\",\n \"results\"\n ]\n\n response = \"\"\n until valid_cmds.include?(response)\n print \"Please Enter a Command or Number: \".blue\n response = gets.chomp.downcase\n end\n\n clear_screen\n response\n end",
"def input_commands\n @new_prompt.command_selection\n command = gets.chomp.upcase\n while command != 'EXIT GAME'\n @player_command = command\n handle_commands(@player_command)\n @new_prompt.command_selection\n command = gets.chomp.upcase\n end\n @new_prompt.exit_screen\n end",
"def command(command)\n output = \"\"\n\n # LETTER: equivalent to +LETTER\n if (command.match(\"^([A-Z])$\")) then\n command = \"+#{$1}\"\n end\n\n # +WORD : add words to table\n if (command.match(\"^\\\\+([A-Z ]+)$\"))\n new_words = $1.split(\" \").delete_if{|word|word.empty?}\n @words += new_words\n output += \"Added #{new_words.inspect} to table.\\n\"\n output += format_words\n\n # -WORD : remove words from table\n elsif (command.match(\"^-([A-Z ]+)$\"))\n remove_words = $1.split(\" \").delete_if{|word|word.empty?}\n words_copy = @words.dup\n valid = true\n remove_words.each do |word|\n index = words_copy.index(word)\n if index then\n words_copy.delete_at(index)\n else\n output += \"Invalid removal: Not enough #{word.inspect}s on the table.\\n\"\n valid = false\n end\n end\n if valid then\n @words = words_copy\n output += \"Removed #{remove_words.inspect} from table.\\n\"\n end\n output += format_words\n\n elsif ([\"@\",\"/WORDS\"].include?(command))\n output += format_words\n\n # # : number of moves\n elsif ([\"#\",\"/num\"].include?(command))\n output += \"Number of possible moves: #{moves.size}\"\n\n # ? : what moves can we make\n elsif ([\"?\",\"/moves\"].include?(command))\n output += \"Possible moves:\\n\"[email protected]_moves(moves)\n\n # number : make that move\n elsif (command.match(\"^([0-9]+)$\"))\n move = moves[$1.to_i]\n if (move) then\n result = move(move)\n if result==true then\n output += \"Made move: #{dictionary.format_move(move)}\\n\"+format_words\n else\n output += result\n end\n else\n output += \"Unrecognized move #{$1.inspect}. Enter '?' for a list of valid moves.\" \n end\n\n else\n output += \"Unrecognized command #{command.inspect}\"\n end\n\n return output\n end",
"def validate_command\n\t \tcommand_types = ['get_authorization_url','update_site_registration', 'get_tokens_by_code','get_user_info', 'register_site', 'get_logout_uri','get_authorization_code','uma_rs_protect','uma_rs_check_access','uma_rp_get_rpt','uma_rp_authorize_rpt','uma_rp_get_gat']\n\t \tif (!command_types.include?(@command))\n\t\t\t\tlogger(:log_msg => \"Command: #{@command} does not exist! Exiting process.\")\n \tend\n\t end",
"def match?(input)\n input.casecmp(command_text).zero?\n end",
"def match_command(input)\n @commands.each do |command|\n return command if command.match?(input[0])\n end\n nil\n end",
"def commands_valid?\n # Loops through entire commands.txt, if there is a bad input, returns false with the index of the bad input and the entire input of that command.\n # Regex passes with only commands with F,B,L,R and positive whole numbers\n @commands.each_with_index do |command, index|\n unless command.match(/[FBLR]\\d+$/)\n return [false, index, command]\n end\n end\n return [true]\n end",
"def search_input(passthrough)\t\t\n\tcase passthrough\n\t\twhen \"mv\"\n\t\t\tputs `man mv`\n\t\twhen \"cp\"\n\t\t\tputs `man cp`\n\t\twhen \"mkdir\"\n\t\t\tputs `man mkdir`\n\t\twhen \"ls\"\n\t\t\tputs `man ls`\n\t\twhen \"rm\"\n\t\t\tputs `man rm`\n\t\telse\t\n\t\t\tputs \"Not a valid search term. Common search terms are: 'mv', 'cp', 'mkdir', 'ls', 'rm'.\"\n\t\tsearch\n\tend\n\tmenu\nend",
"def command_handler(input) \n list = input.split(\",\")\n list.each do |instruction| \n instruction = instruction.upcase.gsub(/\\s+/, \"\")\n if !(/^([a-zA-Z]+)([0-9]+)$/.match?(instruction))\n puts \"\\nInvalid input command. Please type `i` to refer to the instructions\"\n return\n end \n command = instruction[0..(instruction.index(/\\d/)-1)].upcase\n if COMMANDS.include? command \n unit = instruction[(instruction.index(/\\d/))..(instruction.length-1)].to_i\n (MOVEMENT_COMMANDS.include? command)? move_robot(command, unit) : rotate_robot(command, (unit % 4))\n else\n puts \"\\nInvalid input command. Please type `i` to refer to the instructions\"\n return\n end \n end\n puts \"\\n[------ Minimum distance to origin is `#{$x.abs() + $y.abs()}` ------]\"\n $x = 0\n $y = 0\n $current_direction = 0\nend",
"def get_input\n puts \"Input [L] to turn Left, [R] to turn right and [M] to move your Mars rover forward. Type [Q] to leave. See you, Space Cowboy\"\n @input = gets.chomp.downcase\n # Loops through the array of inputs to specify commands for each specific instruction with a case statement\n @input.each_char do |i|\n case i\n # If l is inputted, make the Rover face left\n when \"l\"\n turn_left\n # If r is inputted, make the Rover face right\n when \"r\"\n turn_right\n # Get the rover to move forward in the direction it's facing.\n when \"m\"\n move\n # Exit the game when q is typed\n when \"q\"\n exit\n end\n # Convert the results to a string\n to_s\n end\n end",
"def get_command\r\n\r\n print \"\\nType a Command to get to work (e.g. make-list to start a new list of todo´s)\r\n \\n( type <show-commands> to see your options)\r\n \\n\"\r\n\r\n cmd, target, *args = gets.chomp.downcase.split(' ')\r\n\r\n \r\n case cmd\r\n when 'up'\r\n @lists[target].up(*args.map(&:to_i))\r\n\r\n when 'down'\r\n @lists[target].down(*args.map(&:to_i))\r\n\r\n when 'swap'\r\n @lists[target].swap(*args.map(&:to_i))\r\n\r\n when 'sort'\r\n @lists[target].sort_by_date!\r\n\r\n when 'priority'\r\n if @lists[target].items.empty?\r\n puts \"\\nList #{target} does not contain any Todos yet! You can add some next.\r\n \\nWould you like to do that now?\r\n \\n[y] to create new Todo in #{target}\r\n \\n[n] to go back home.\r\n \\n\"\r\n what = gets.chomp.downcase\r\n\r\n if what == \"y\"\r\n @lists[target].add_item(*TodoBoard.todo_configurator(target))\r\n puts \"\\nYay, you created a new Todo! \\n\"\r\n @lists[target].print_priority\r\n else\r\n return true\r\n end\r\n\r\n else\r\n @lists[target].print_priority\r\n end\r\n\r\n when 'print'\r\n if args.empty?\r\n @lists[target].print\r\n else\r\n @lists[target].print_full_item(*args.first.to_i)\r\n end\r\n\r\n when 'make-list'\r\n @lists[target] = List.new(target.to_s)\r\n puts \"\\nList '#{target}' was successfully created!\\n\"\r\n\r\n when 'ls'\r\n @lists.each_key do |key|\r\n puts key\r\n end\r\n\r\n when 'showall'\r\n @lists.each do |k, v|\r\n v.print\r\n end\r\n\r\n when 'all-priorities'\r\n @lists.each do |k, v|\r\n v.print_priority\r\n end\r\n\r\n when 'make-todo'\r\n @lists[target].add_item(*TodoBoard.todo_configurator(target)) # make-todo calls self.todo_configurator to get arguments for add_item\r\n puts \"\\nYay, you created a new Todo! \\n\"\r\n\r\n when 'remove'\r\n self.remove_todo(*args.first.to_i, target)\r\n\r\n when 'delete-list'\r\n @lists.delete(target)\r\n\r\n when 'quit'\r\n return false\r\n\r\n when 'check'\r\n @lists[target].toggle_item(*args.first.to_i)\r\n\r\n when 'purge'\r\n @lists[target].purge\r\n\r\n when 'show-commands' || '<show-commands>' || 'show commands'\r\n puts \"--COMMANDS--\"\r\n p \"You can type the following commands, followed by the parameters (all seperated by \" \" and withouth the <>)\"\r\n puts \"---\"\r\n puts \"CREATE LISTS AND TODO-ITEMS\"\r\n p \"make-list <list name>\"\r\n p \"=> (Create a new list)\"\r\n p \"make-todo <list name>\"\r\n p \"=> (Create a new todo)\"\r\n p \"---\"\r\n p \"DISPLAY LISTS AND TODO ITEMS\"\r\n p \"print <list name>\"\r\n p \"=> (Print a specific list)\"\r\n p \"print <list name> <item-index>\"\r\n p \"=> (shows more detail on specific item on list)\" \r\n p \"ls\" \r\n p \"=> (shows all lists)\"\r\n p \"priority <list name>\"\r\n p \"=> (shows top item on list)\"\r\n p \"all-priorities\"\r\n p \"=> (displays all priority items from all lists)\"\r\n p \"---\"\r\n p \"MANAGE LISTS AND TODO ITEMS\"\r\n p \"sort <list name>\"\r\n p \"=> (sorts list by deadline)\"\r\n p \"swap <list name> <index1> <index2>\"\r\n p \"=> (swaps items with the indexes on list)\"\r\n p \"up <list name> <index> <optional amount of ups>\"\r\n p \"=> (moves item with index UP on list. If no amout is put, item is moved up once. If amount is put, item is moved up amount times.\"\r\n p \"down <index> <optional amount of downs>\"\r\n p \"=> (moves item with index DOWN on list. If no amout is put, item is moved down once. If amount is put, item is moved down amount times.\"\r\n p \"remove <list name> <item-index>\"\r\n p \"=> (Removes item with index on list)\"\r\n p \"check < list name> <item-index>\"\r\n p \"=> (Checks off/marks as done item index on list)\"\r\n p \"---\"\r\n p \"END THE PROGRAM\"\r\n p \"quit\"\r\n p \"=> (ends program)\"\r\n\r\n else\r\n print \"Sorry, that command is not recognized.\"\r\n end\r\n\r\n true\r\n end",
"def search_function\n puts \"Please search command line prompts only\"\n puts \"Search:\"\n puts `man #{gets.strip}`\n\nend",
"def get_user_input\n print \">> \"\n input = gets.chomp\n begin\n parse_user_input(input)\n rescue StandardError\n invalid_command\n end\n end",
"def execute(input)\n messages = Messages.new\n secret = \"BBGB\"\n if input == \"i\" || input == \"instructions\"\n Response.new(:message => messages.instructions, :status => :continue)\n elsif input == \"p\" || input == \"play\"\n Response.new(:message => messages.play, :status => :continue)\n # play\n elsif input == \"q\" || input == \"quit\"\n Response.new(:message => messages.quit, :status => :stop)\n elsif input == \"c\" || input == \"cheat\"\n Response.new(:message => \"The secret sequence is: #{secret}\", :status => :continue)\n elsif input.length < 4\n Response.new(:message => \"Are you paying attention?? You need to guess four colors. If you need instructions, enter 'i'.\", :status => :continue)\n elsif input.length > 4\n Response.new(:message => \"You are making this too complicated. Guess four colors only. If you need instructions, enter 'i'.\", :status => :continue)\n elsif input == secret.downcase\n Response.new(:message => \"Congratulations! You guessed the sequence '#{secret}' in #{@number_of_guesses} guess(es) in just #{Time.new}.\\nWould you like to (p)lay again or (q)uit?\", :status => :won)\n else\n @number_of_guesses += 1\n Response.new(:message => \"Guess again!\", :status => :continue)\n end\n end",
"def get_command\n print \"\\nEnter a command: \"\n cmd, *args = gets.chomp.split(' ')\n label = args[0]\n case cmd\n when 'mklist'\n # mklist Grocery\n # key = label\n # value = items which is an array\n @lists[label] = List.new(label)\n when 'ls'\n @lists.each {|k, v| puts k}\n when 'showall'\n @lists.each {|k, v| v.print}\n when 'mktodo'\n @lists[label].add_item(*args[1..-1])\n when 'up'\n @lists[label].up(*args[1..-1].map(&:to_i))\n when 'down'\n @lists[label].down(*args[1..-1].map(&:to_i))\n when 'swap'\n @lists[label].swap(*args[1..-1].map(&:to_i))\n when 'sort'\n @lists[label].sort_by_date!\n when 'priority'\n @lists[label].priority\n when 'print'\n if args[1..-1].empty?\n @lists[label].print\n else\n @lists[label].print_full_item(*args[1..-1].join(\"\").to_i)\n end\n when 'toggle'\n @lists[label].toggle_item(args[1].to_i) # maybe change label to args[1]?\n when 'rm'\n @lists[label].remove_item(args[1].to_i)\n when 'purge'\n @lists[label].purge\n when 'quit'\n return false\n else\n print \"Sorry, that command is not recognized.\"\n end\n\n true\n end",
"def validate!\n if not respond_to?(\"perform_#{command}!\")\n type = self.class.to_s.split(\"::\").last.downcase\n error \"Unknown #{y(type)} command: <#{r(command)}>\"\n error \"Run #{y(\"gitpusshuten help #{type}\")} for a list #{y(type)} commands.\"\n exit\n end\n end",
"def dispatch(input)\n continue = true\n commands = input.split(\" \")\n case commands[0].downcase\n when \"store\"\n continue = process_store(commands[1..-1])\n when \"factory\"\n continue = process_factory(commands[1..-1])\n when \"quit\"\n continue = process_quit\n when \"resources\"\n continue = process_resources\n when \"project\"\n continue = process_projects(commands[1..-1])\n when \"produce\"\n continue = process_production(commands[1..-1])\n when \"pick\"\n continue = process_pick(commands[1..-1])\n when \"next\"\n continue = process_next\n when \"save\"\n continue = process_save\n when \"scheduling\"\n continue = process_scheduling\n else\n puts \"unknown command: #{input}\"\n end\n return continue\n end",
"def command_list\n # system(\"clear\")\n puts \"Welcome to the Google Books CLI! Please choose from the following options: \"\n\n puts \" s: Search for a book\"\n puts \" v: View Reading List\"\n puts \" q: Exit Program\"\n puts \"\"\n input = gets.chomp.downcase\n # controls user input\n case input\n when \"s\"\n safe_search\n when \"v\"\n view_reading_list\n when \"q\"\n quit_program\n else\n system(\"clear\")\n puts \"It looks like you have entered an invalid command. Lets try again.\"\n puts \"\"\n puts \"\"\n end\n command_list\n end",
"def execute(input)\n puts_and_say(input)\n time_s = nil\n word = nil\n failed_attempts = 0\n start = Time.zone.now\n until !word.nil? && @hinter.good_word?(input, word)\n if !word.nil? && COMMANDS.exclude?(word)\n failed_attempts += 1\n if input.matches_word?(word)\n puts_and_say('Incorrect!', 'en')\n else\n puts_and_say('Bad word!', 'en')\n end\n end\n word = gets.chomp.downcase\n time_s = Time.zone.now - start\n case word\n when 'hint'\n # Brutal punishment for failed attempts\n # TODO: Use num_hints\n failed_attempts += 100\n hints = @hinter.hints(input.case_key)\n display_hints(hints)\n when 'delete'\n puts 'Deleting results for the last 30 seconds and exiting.'\n @results_model.delete_after_time(Time.zone.now - 30)\n exit\n when 'quit'\n exit\n end\n end\n puts \"Time: #{format_time(time_s)}; Failed attempts: #{failed_attempts}; Word: #{word}\"\n PartialResult.new(time_s: time_s, failed_attempts: failed_attempts, word: word)\n end",
"def raw_input(msg)\n puts msg\n print \">> \"\n input = gets.chomp\n if input.downcase == \"q\"\n return input, true\n else\n return input, false\n end\nend",
"def process(input)\n if input == \"q\"\n puts \"Goodbye\"\n elsif input == \"tweet\"\n puts \"tweeting\"\n elsif input == \"dm\"\n puts \"direct messaging\"\n elsif input == \"help\"\n puts \"helping\"\n end\nend",
"def command\n command = []\n i = 0\n until command[i - 1] == 'REPORT'\n get_input_for('Enter Commands (ex. Move)') do |input|\n command[i] = input.upcase\n i += 1\n !command.nil?\n end\n end\n command\n end",
"def ask (command_nb)\n puts \"vous voulez contruire #{\n command_nb==0 ? #si c'est la premiere commande\n \"quelquechose\" : #on demande quelque chose\n \"autre chose\" #sinon on demande autre chose\n } ?\"; #j'aime les ternaires =)\n stop = false\n while stop == false\n print \">>\"\n response = gets.chomp\n if response == \"oui\"\n stop == true #juste au cas ou\n return \"oui\"\n elsif response == \"non\"\n stop == true #juste au cas ou\n return \"STOP\"\n else\n puts \"pardon ? je n'ai pas compris ... (oui ou non)\"\n end\n end\nend",
"def one_cmd(commands, context, input)\n if cmd = commands.find{ |c| c.match(input) }\n if context.dead? && cmd.class.need_context\n print \"Command is unavailable\\n\"\n else\n cmd.execute\n end\n else\n unknown_cmd = commands.find{ |c| c.class.unknown }\n if unknown_cmd\n unknown_cmd.execute\n else\n errmsg \"Unknown command: \\\"#{input}\\\". Try \\\"help\\\".\\n\"\n end\n end\n end",
"def process\n \n # Check for commands\n @command = self.check_commands\n \n # Begin switch if command is found\n # Registration\n if @command == \"reg\"\n unless self.process_registration_information\n @response = false\n end\n \n # Sell command\n elsif @command == \"sell\"\n unless self.process_sell\n @response = false\n end\n \n # Buy command\n elsif @command == \"buy\"\n unless self.process_buy\n @response = false\n end\n \n # Find command \n elsif @command == \"find\"\n unless self.process_find\n @response = false\n end \n \n #Failover \n else \n @response = false\n end \n end",
"def read_commands_from_file commands_from_file\r\n\t#number of commands present in the file\r\n\tcount = commands_from_file.gets.chomp.to_i\r\n\ti=0\r\n\trobot_on_table = false\r\n\t\r\n\t#check for the first valid place command\r\n\twhile(!robot_on_table and i<count)\r\n\t\tcommand = commands_from_file.gets.chomp.upcase\r\n\t\tif ($is_valid_valueset)\r\n\t\t\trobot_on_table = true\r\n\t\t\t$is_valid_valueset = false\r\n\t\telse\r\n\t\t\tdetails = place_robot_on_table(command)\r\n\t\t\ti+=1\r\n\t\tend\r\n\tend\r\n\t\r\n\t#execute rest of the commands till a report command is encountered or end of file is reached.\r\n\t#Note that the robot details are displayed only if a report command is encountered.\r\n\twhile (i<count)\r\n\t\ti+=1\r\n\t\tcase command\r\n\t\twhen \"MOVE\"\r\n\t\t\tmove_robot_forward(details)\r\n\t\twhen \"RIGHT\"\r\n\t\t\tturn_robot_right(details)\r\n\t\twhen \"LEFT\"\r\n\t\t\tturn_robot_left(details)\r\n\t\twhen \"REPORT\"\r\n\t\t\treport_robot_details(details)\r\n\t\t\tprint(\"\\nEND OF PROGRAM\")\r\n\t\t\tcontinue = 'n'\t\t\t\r\n\t\telse\r\n\t\t\t#move the robot to a new place if and only if a valid place command is entered. Else, the previous values are retained.\r\n\t\t\ttemp_details = place_robot_on_table(command)\r\n\t\t\tif($is_valid_valueset)\r\n\t\t\t\tdetails = temp_details\r\n\t\t\tend\r\n\t\tend\r\n\t\tif(continue!='n')\r\n\t\t\tcommand = commands_from_file.gets.chomp.upcase\r\n\t\tend\r\n\tend\r\nend",
"def invalid_command\n puts \"Please enter a valid command\"\nend",
"def phase3_basic_command_input\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Branch by actor command window cursor position\r\n case @actor_command_window.command\r\n when SDK::Scene_Commands::Scene_Battle::Attack # attack\r\n phase3_command_attack\r\n when SDK::Scene_Commands::Scene_Battle::Skill # skill\r\n phase3_command_skill\r\n when SDK::Scene_Commands::Scene_Battle::Guard # guard\r\n phase3_command_guard\r\n when SDK::Scene_Commands::Scene_Battle::Item # item\r\n phase3_command_item\r\n end\r\n end",
"def get_user_command(game_started)\n\tprint \"What do you want to do? \"\n\tif !game_started\n\t\t# The game hasn't started\n\t\twhile true\n\t\t\tcommand = gets.chomp[0].upcase\n\t\t\tif ['D','M','Q'].include?(command)\n\t\t\t\treturn command\n\t\t\telse\n\t\t\t\tputs \"Invalid command. Valid options are: [D]eal,[M]oney,[Q]uit\"\n\t\t\tend\n\t\tend\n\telse\n\t\twhile true\n\t\t\t# The game has started\n\t\t\tcommand = gets.chomp[0].upcase\n\t\t\tif ['Q','H','S'].include?(command)\n\t\t\t\treturn command\n\t\t\telse \n\t\t\t\tputs \"Invalid command. Valid options are: [H]it,[S],[Q]uit\"\n\t\t\tend\t\t\t\t\n\t\tend\n\tend\nend",
"def parse_command(text)\n words = wordify preprocess_input text\n \n key = nil\n args = []\n \n while 0 < words.count\n key = words.join('_').intern\n \n return key, args if @actions.has_action? key\n \n args.unshift words.pop\n end # while\n \n return nil, args\n end",
"def invalid_command\n puts \"Please enter a valid command\"\nend",
"def invalid_command\n puts \"Please enter a valid command\"\nend",
"def get_command\n\t\ttext = read.chomp\n\t\tcommand = {}\n\t\tif text =~ /PASS/i\n\t\t\tcommand[:pass] = true\n\t\telsif text =~ /ADD\\W+(\\d+)\\W+\\((.*?)\\),?\\W+\\((.*?)\\)/i\n\t\t\tcommand[:action] = :add\n\t\t\tcommand[:id] = $1.to_i # FUTURE spec says it is 4 digits max\n\t\t\tcommand[:points] = [$2,$3].collect do |p|\n\t\t\t\tx,y = p.split(\",\")\n\t\t\t\t{:x => x.to_i, :y => y.to_i}\n\t\t\tend\n\t\telsif text =~ /REMOVE\\W+(\\d+)/\n\t\t\tcommand[:action] = :remove\n\t\t\tcommand[:id] = $1.to_i # FUTURE spec says it is 4 digits max\n\t\tend\n\t\tcommand\n\tend",
"def check_command(command)\n @command_array.each do |method| # For every item inside the command_array (from require function)\n if command == method # If we get a match for a command\n if @locked == true and @full_user != @admin\n chan_send(\"Sorry, #{@user_name_first}, I am currently locked (Probably for maintenance)\")\n else\n if check_ban == true # If the user is banned\n chan_send(\"Sorry, #{@user_name_first} I don't listen to idiots.\") # Give an error message, and don't execute the command\n else # If the user is not banned\n command.gsub!(/[:()]/, '') #command.slice!(0..1).chomp # Remove the :! from the command variable \n send(command) # Call command variable as a function\n end\n end\n end\n end\n \n @mod_command_array.each do |method|\n if command == method\n if @locked == true and @full_user != @admin\n chan_send(\"Sorry, #{@user_name_first}, I am currently locked (Probably for maintenance)\")\n else\n if check_ban == true\n chan_send(\"Sorry, #{@user_name_first} I don't listen to idiots.\")\n else\n mod = check_mod\n if @full_user == @admin or mod == true\n command.gsub!(/[:.\\/]/,'') #command.slice!(0..1)\n send(command)\n else\n chan_send(\"Sorry, #{@user_name_first} you are not authorized to use this command.\")\n end\n end\n end\n end\n end\n \n @admin_command_array.each do |method|\n if command == method\n if @locked == true and @full_user != @admin\n chan_send(\"Sorry, #{@user_name_first}, I am currently locked (Probably for maintenance)\")\n else\n if check_ban == true\n chan_send(\"Sorry, #{@user_name_first}, I don't listen to idiots.\")\n else\n if @full_user == @admin\n command.gsub!(/[:.\\/]/,'') #command.slice!(0..1)\n send(command)\n else\n chan_send(\"Sorry, #{@user_name_first} only the administrator is authorized for this command.\")\n end\n end\n end\n end\n end\nend",
"def getcommand(msg)\n msg.message =~ /#{$COMMAND}(\\w+)/\n commandused = $1\n case commandused\n when 'roll', 'nobotch', 'special'\n if msg.message =~ /#{commandused}\\s*help\\s*$/\n # show command help\n \"#{HELP_TEXT(commandused)}\"\n elsif msg.message =~ /#{commandused}\\s+(.*)\\s*$/\n begin\n \"<b>#{$names[msg.actor]}: </b>#{substitute($1,commandused)}\"\n rescue ArgumentError => e\n \"\\\"<b>Error</b>: #{e}</b>\\\",#{[msg.actor]}\"\n end\n end\n \n when 'help'\n \"<br>I'm here to make your V20 playing much more pleasureable!<br><br>\n Commands:<br>\n <b>#{$COMMAND}roll</b> <input> - Regular ol' dice rollin!<br>\n <b>#{$COMMAND}nobotch</b> <input> - Roll dice where 1s don't botch!<br>\n <b>#{$COMMAND}special</b> <input> - Make those 10s count DOUBLE!<br><br>\n\n use '<b>help</b>' as the input for more information on any command!\"\n else\n #wat r u doin dolan pls\n \"wat r u doin stahp\"\n end\nend",
"def search_selection\n puts SEARCH\n @query = STDIN.gets.chomp\n\n case @query\n when EXIT_COMMAND\n @loop = false\n when HELP_COMMAND\n show_help\n when FILE_COMMAND\n specify_files_to_search\n else\n system 'clear'\n process_search\n end\n end",
"def run_cmd(input); end",
"def begin\n puts instruction\n\n while read_command(gets.chomp)\n end\n end",
"def enter_command\n while true\n print \"Enter command: Left, Right, or Forward: \"\n command = gets.strip\n command.downcase!\n if command == \"left\" || command == \"right\" || command == \"forward\"\n break\n end\n end\n return command\nend",
"def checkCommand(command)\n if $commands.include? command\n return :cmd\n elsif command.partition(' ').first == 'PLACE'\n return :placecmd\n else\n return false\n end\n end",
"def try_turn\n print \"\\nPlayer #{@player.to_s.capitalize}'s command: \"\n input = gets.chomp\n outcome = if is_raw_command?(input) then try_command(input) # Returns :(no_)load, :(no_)save, :(no_)draw, :quit\n elsif is_raw_move?(input) then try_move(input) # Returns :(no_)move, :check(mate), :stalemate, :draw\n else :unknown_input end\n end",
"def method_that_calls_the_other_methods\n puts \"Do you Want to run the keyboard_line method(use y for yes or n for no)\"\n input = gets.chop\n if (input == 'y') \n keyboard_line\n else\n puts \"No method was ran\"\n end\n\n puts \"Do you Want to run the rest of the methods\"\n input = gets.chop\n if (input == 'y')\n is_it_a_big_number\n hello_there\n get_info_from_user\n\n else\n puts \"the other methods were not ran\"\n end\nend",
"def proccess_command(command)\n # branch based on command type\n case command[0]\n when COMScript # script [code]\n # evaluate script\n result = eval(command[1])\n when COMWait # wait [int]\n # decrease wait counter by 1\n command[1] -= 1\n # proceed if wait time is up\n return command[1] <= 0\n when COMMove # move [int, int]\n # add to move commands\n @moves.push(command)\n when COMTurn # turn [int]\n # add to move commands\n @moves.push(command)\n when COMJump # jump [int, int]\n # add to move commands\n @moves.push(command)\n when COMAttack # attack\n # use attack\n @ch.use_attack\n when COMSkill # skill [int]\n # use skill\n @ch.use_skill($data_skills[command[1]])\n when COMItem # item [int]\n # use item\n @ch.use_item($data_items[command[1]])\n when COMDefend # defend [int]\n # decrease time\n time = command[1] - 1\n # use defend\n @ch.use_defend\n # set penalty\n @ch.set_action(1)\n # if not done with command\n if time > 0\n # update the command counter\n command[1] = time\n # do not proceed\n return false\n end\n when COMCharacter # character [CH, value]\n # handle based on sub-command\n case command[1]\n when CHSpeed # move speed\n # set movement speed\n @ch.move_speed = command[2]\n when CHFrequency # move frequency\n # set movement frequency\n @ch.move_frequency = command[2]\n when CHSprite # change sprite\n # set sprite\n @ch.character_name = command[2]\n when CHAnimation # play animation\n # set animation\n @ch.animation_id = command[2]\n when CHFix # direction fix\n # set direction fix flag\n @ch.direction_fix = command[2]\n when CHThrough # through\n # set through flag\n @ch.through = command[2]\n when CHOnTop # always on top\n # set always on top flag\n @ch.always_on_top = command[2]\n when CHOpacity # opacity\n # set opacity\n @ch.opacity = command[2] \n end\n when COMInput # create input window [int, [keys], IN, int]\n # create new input window\n @inputs[command[1]] = [command[2], command[3], command[4], false]\n when COMVariable # variable [VAR, value1, '=', VAR, value2]\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '+=' then val2 = val1 + val2 # add\n when '-=' then val2 = val1 - val2 # subtract\n when '*=' then val2 = val1 * val2 # multiply\n when '/=' then val2 = val1 / val2 # divide\n when '%=' then val2 = val1 % val2 # modulo\n end\n # set the variable\n set_variable(command[1], command[2], val2)\n when COMCondition # condition [VAR, value1, '==', VAR, value2]\n # initialize result\n result = false\n # initialize values\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '==' # equal to\n # result is value 1 equal to value 2\n result = val1 == val2\n when '!=' # not equal to\n # result is value 1 not equal to value 2\n result = val1 != val2\n when '>' # greater than\n # result is value 1 equal to value 2\n result = val1 > val2\n when '>=' # greater than or equal to\n # result is value 1 not equal to value 2\n result = val1 >= val2\n when '<=' # less than\n # result is value 1 equal to value 2\n result = val1 < val2\n when '<=' # less than or equal to\n # result is value 1 not equal to value 2\n result = val1 <= val2\n end \n # if input or script\n if command[1] == VARInput || command[1] == VARScript\n # value 1 contains the result\n result = val1\n # do not proceed if waiting on an input window\n if command[1] == VARInput && @inputs[command[2]][2] > 0 && !result\n return false\n end\n end\n # skip next command if exists and condition not met\n @commands.delete_at(1) if !result && @commands.size > 1\n when COMFreeze # freeze input [bool]\n # set freeze input flag\n @freeze_character = command[1]\n when COMCompletion # wait for move completion\n # proceed if no more moves and character no longer moving\n return @moves.size == 0 && [email protected]?\n when COMGoTo # go to action [int]\n raise 'ERROR: Invalid action' if !is_valid_action?(command[1])\n # setup the action\n setup_action(command[1])\n # do not proceed - new set of commands\n return false\n when COMAbort # abort\n # set ended flag\n @ended = true\n end\n return true\n end",
"def get_rover_instruction\n @input = STDIN.gets.chomp.split('')\n\n while !valid_instruction\n puts \"Incorrect instructions entered. Enter rover instruction:\"\n @input = STDIN.gets.chomp.split('')\n end\n end",
"def run!\n puts \"Type 'help' to view commands\"\n run = true\n while run\n print \">> \"\n input = gets.split[0].to_sym\n output = handle_input input\n puts output\n run = false if output == \"Goodbye! Thanks for playing!\"\n end\n end",
"def read_instructions\n #Ask the user for new coordinates for where they want to go\n puts \"Give the coordinates for how you want the rover to move: \"\n @instructions = gets.chomp\n @instructions_array = @instructions.split(\" \")\n # instructions_array = @instructions\n @instructions_array.each do |command|\n if command == \"R\" || command == \"L\"\n turn(command)\n elsif command == \"M\"\n puts \"moveeeee\"\n move\n else\n puts \"Error\"\n end\n\n end\n\n end",
"def ask(message, valid_options)\n if valid_options\n answer = get_stdin(\"#{message} #{valid_options.to_s.gsub(/\"/, '').gsub(/, /,'/')} \") while !valid_options.include?(answer)\n else\n answer = get_stdin(message)\n end\n answer\nend",
"def find_command(input)\n available_accessors = @modes.current_accessors.find_all { |accessor| accessor.signature.matches? input }\n (@modes.active_modes.map { |mode| mode.find_command(input) } + available_accessors).find { |command| !command.nil? }\n end",
"def execute(command)\n case command.split.first\n when \"list\"\n list(@command)\n when \"play\"\n # if @library.empty? || @library.length.even?\n # puts \"that doesn't make any sense\"\n # prompt\n # else\n play(@command)\n # end\n when \"select\"\n if @library.empty? \n # || @library.length.even?\n puts \"that doesn't make any sense\"\n prompt\n else\n select(@command, @library)\n end\n when \"clear\"\n clear\n else\n puts \"The commands are: play, select, etc\"\n prompt\n end\n end",
"def testRegExp(command, input)\n\treturn case command\n\twhen \"a\"\n\t\tssn(input)\n\twhen \"b\"\n\t\tphoneNumber(input)\n\twhen \"c\"\n\t\temail(input)\n\twhen \"d\"\n\t\tname(input)\n\twhen \"e\"\n\t\tdate(input)\n\twhen \"f\"\n\t\taddress(input)\n\twhen \"g\"\n\t\tletter(input)\n\twhen \"h\"\n\t\tmilitaryTime(input)\n\twhen \"i\"\n\t\tcurrency(input)\n\twhen \"j\"\n\t\twebsite(input)\n\twhen \"k\"\n\t\tpassword(input)\n\twhen \"l\"\n\t\tion(input)\n\telse \n\t\t\"Invalid input... try again.\"\n\tend\nend",
"def menu\n puts '|____________________________________________________________|'\n puts '| |'\n puts '| -- M E N U : |'\n puts '| |'\n puts \"| * Show : 's' |\"\n puts \"| * Quit : 'q' |\"\n puts '|____________________________________________________________|'\n\n input = ''\n loop do\n puts ''\n input = ask ' >> '\n puts ''\n if ['q', 's'].include? input\n break\n else\n puts ' ____________________________________________________________ '\n puts '| |'\n puts '| Invalid input, please try again... |'\n puts '|____________________________________________________________|'\n end\n end\n input\nend",
"def do_special_input_stuff(input)\n case input\n when \"save\"\n save\n []\n when \"reset\"\n puts \"Choose different piece:\"\n \"reset\"\n when \"quit\"\n puts \"QUITTING\"\n exit\n else\n false\n end\n end",
"def get_user_input\n user_input_valid gets.chomp\n end",
"def get_command_from_string(command_string)\n #Split the command based on the equal '=' sign.\n remove = \"\"\n keyword=\"\"\n value=\"\"\n\n if (command_string != \"\")\n #Get command and u-value\n if ( command_string.match(/(^\\s*(\\\".*?\\\")\\s*\\=\\s*(\\S+)\\s*)/) )\n @commandName=$3.strip\n @utype = $2.strip\n remove = Regexp.escape($1)\n\n else\n # if no u-value, get just the command.\n command_string.match(/(^\\s*(\\S*)\\s)/ )\n remove = Regexp.escape($1)\n @commandName=$2.strip\n end\n #Remove command from string.\n\n command_string.sub!(/#{remove}/,\"\")\n command_string.strip!\n\n\n #Loop throught the keyword values.\n while ( command_string.length > 0 )\n #DOEMaterial, or SCHEDULES\n if ( command_string.match(/(^\\s*(MATERIAL|DAY-SCHEDULES|WEEK-SCHEDULES)\\s*(\\=?)\\s*(.*)\\s*)/))\n #puts \"Bracket\"\n keyword = $2.strip\n value = $4.strip\n remove = Regexp.escape($1)\n #Stars\n elsif ( command_string.match(/(^\\s*(\\S*)\\s*(\\=?)\\s*(\\*.*?\\*)\\s*)/))\n #puts \"Bracket\"\n keyword = $2.strip\n value = $4.strip\n remove = Regexp.escape($1)\n\n #Brackets\n elsif ( command_string.match(/(^\\s*(\\S*)\\s*(\\=?)\\s*(\\(.*?\\))\\s*)/))\n #puts \"Bracket\"\n keyword = $2.strip\n value = $4.strip\n remove = Regexp.escape($1)\n #Quotes\n elsif ( command_string.match(/(^\\s*(\\S*)\\s*(\\=?)\\s*(\".*?\")\\s*)/) )\n #puts \"Quotes\"\n keyword = $2\n value = $4.strip\n remove = Regexp.escape($1)\n #single command\n elsif command_string.match(/(^\\s*(\\S*)\\s*(\\=?)\\s*(\\S+)\\s*)/)\n #puts \"Other\"\n keyword = $2\n value = $4.strip\n remove = Regexp.escape($1)\n end\n #puts \"DOE22::DOECommand: #{command_string}\"\n #puts \"K = #{keyword} V = #{value}\\n\"\n if (keyword != \"\")\n set_keyword_value(keyword,value)\n end\n command_string.sub!(/#{remove}/,\"\")\n end\n #puts \"Keyword\"\n #puts keywordPairs\n end\n end",
"def process\n command = get_command()\n\n if command\n verify_command(command)\n else\n help\n end\n end",
"def invalid_command\n # code invalid_command here\n puts \"Please enter a valid command\"\nend",
"def mad_lib\n user_inputs = []\n required_data = %w(noun verb adjective adverb)\n required_data.each do |question|\n puts \"Enter a #{question}:\"\n user_inputs << gets.chomp\n end\n puts \"Do you #{user_inputs[1]} your #{user_inputs[2]} #{user_inputs[0]} #{user_inputs[3]}? That's hilarious!\"\nend",
"def process_command(inp)\n @commands.each do |cmd|\n if inp =~ cmd.command_regexp\n begin\n output = cmd.execute self, $~\n puts output if output\n rescue StandardError => e\n handle_exception e\n end\n break\n end\n end\n end",
"def new_hand_check\n puts 'Are you ready to play? Enter ' + '(Y)es'.light_green + ' to proceed or ' + '(N)o'.light_red + ' to return to the main menu.'\n @input = STDIN.gets.chomp\n if @input.downcase == 'y' || @input.downcase == 'yes'\n @game_running = true\n elsif @input.downcase == 'n' || @input.downcase == 'no'\n @game_running = false\n else\n puts 'Please enter a valid input.'\n new_hand_check\n end\nend",
"def continue\n puts \"Do you wish to add more? Y/N\".center(70)\n result = STDIN.gets.chomp.downcase\n if result == \"n\"\n return false\n end\nend",
"def read_command(prompt)\n return command_queue.shift unless command_queue.empty?\n\n read_input(prompt)\n end",
"def phase2_command_input \r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Branch by party command window cursor position\r\n case @party_command_window.command\r\n when SDK::Scene_Commands::Scene_Battle::Fight # fight\r\n phase2_command_fight\r\n when SDK::Scene_Commands::Scene_Battle::Escape # escape\r\n phase2_command_escape\r\n end\r\n end",
"def requestCommands\n # Request input in a loop until QUIT is read\n quit = false\n until quit do\n input = @view.captureInput\n # Check if input is QUIT\n quit = input =~ /^#{Command::Q}$/i\n unless quit\n processCommand(input)\n end\n end\n end",
"def process_command command\n\n # The decision maker will validate the command\n # and get rid of the commands that is invalid\n # and make the right order of commands and notify different observers.\n\n # Notify the observers that a new valid command comes.\n command\n end",
"def set_command_objects\n puts \"@input before set_command_object: #{@input}\"\n command_objects = []\n \n @input.each do |name|\n if command_objects.length < 1 || @command_word == \"combine\" && command_objects.length < 2\n if name_is_valid_object_name?(name)\n command_objects << $game.get_object_by_name(name)\n \n end\n end\n end \n\n \n @command_object_1, @command_object_2 = command_objects\n puts \"@input after set_command_object: #{@input}\"\n puts \"@object_1 and @object_2: #{@command_object_1.to_s + \", \" + @command_object_2.to_s}.\"\n end",
"def inputLoop\r\n defaultInfo\r\n printCommands\r\n puts 'Your input:'\r\n input = gets.chomp\r\n while input != 'q'\r\n\r\n if input == 's'\r\n # puts 's selected.'\r\n resolveS\r\n elsif input[0] == 'u'\r\n resolveU(input)\r\n\r\n elsif input == 'v'\r\n resolveV\r\n\r\n elsif input[0] == 'c'\r\n #puts 'c selected.'\r\n resolveC(input)\r\n\r\n\r\n elsif input == 'b'\r\n #puts 'b selected.'\r\n resolveB\r\n elsif input == 'f'\r\n #puts 'f selected.'\r\n resolveF\r\n\r\n elsif input == 'q'\r\n #puts 'q selected. exiting program.'\r\n exit\r\n elsif input == 'z'\r\n defaultInfo\r\n else\r\n puts 'input unknown. try again.'\r\n end\r\n printCommands\r\n puts 'Your input:'\r\n input = gets.chomp\r\n end\r\n\r\n end",
"def get_input\n begin\n inp = gets.chomp\n raise Error unless %w{s h d}.include?(inp)\n rescue\n retry\n end\n inp\n end",
"def get_command_from_user choices=[\"quit\",\"help\", \"suspend\", \"shell_output\"]\n @_command_history ||= Array.new\n str = rb_gets(\"Cmd: \", choices) { |q| q.default = @_previous_command; q.history = @_command_history }\n @_command_history << str unless @_command_history.include? str\n # shell the command\n if str =~ /^!/\n str = str[1..-1]\n suspend(false) { \n #system(str); \n $log.debug \"XXX STR #{str} \" if $log.debug? \n\n output=`#{str}`\n system(\"echo ' ' \");\n $log.debug \"XXX output #{output} \" if $log.debug? \n system(\"echo '#{output}' \");\n system(\"echo Press Enter to continue.\");\n system(\"read\"); \n }\n return nil # i think\n else\n # TODO\n # here's where we can take internal commands\n #alert \"[#{str}] string did not match :!\"\n str = str.to_s #= str[1..-1]\n cmdline = str.split\n cmd = cmdline.shift #.to_sym\n return unless cmd # added 2011-09-11 FFI\n f = @form.get_current_field\n if respond_to?(cmd, true)\n if cmd == \"close\"\n throw :close # other seg faults in del_panel window.destroy executes 2x\n else\n res = send cmd, *cmdline\n end\n elsif f.respond_to?(cmd, true)\n res = f.send(cmd, *cmdline)\n else\n alert \"App: #{self.class} does not respond to #{cmd} \"\n ret = false\n # what is this execute_this: some kind of general routine for all apps ?\n ret = execute_this(cmd, *cmdline) if respond_to?(:execute_this, true)\n rb_puts(\"#{self.class} does not respond to #{cmd} \", :color_pair => $promptcolor) unless ret\n # should be able to say in red as error\n end\n end\n end",
"def input_2\n input = gets.chomp\n if \n input == \"list\"\n Character.all.clear\n call\n elsif\n input == \"exit\"\n clear\n puts \"Goodbye!\".colorize(:green).colorize(:background => :black)\n exit!\n else \n clear \n puts \"Try Again\".colorize(:red).colorize(:background => :black)\n\n puts \"\\nType list to search for another character or exit to quit.\".colorize(:blue).colorize(:background => :black)\n input_2\n end \n end",
"def commandInterface\n\t\tisfinished = false\n\t\tcmd = \"\" \n\n\t\twhile !isfinished do\n\t\t\tprint \"min::\"\n\t\t\tcmd = $stdin.gets.chomp!\n\t\t\tcase cmd\n\t\t\t\twhen /end|exit|quit/i then isfinished = true \n\t\t\tend\n\t\tend\n\tend",
"def validate(command)\n args = command.split(' ')\n\n case args[0]\n when 'C', 'S'\n raise ArgumentError, \"#{WRONG_NUM}: #{command}\" unless args.length == 1\n when 'I'\n raise ArgumentError, \"#{WRONG_NUM}: #{command}\" unless args.length == 3\n\n int1 = integer?(args[1])\n int2 = integer?(args[2])\n raise ArgumentError, \"#{WRONG_TYPE}: #{command}\" unless int1 && int2\n when 'L'\n raise ArgumentError, \"#{WRONG_NUM}: #{command}\" unless args.length == 4\n\n int1 = integer?(args[1])\n int2 = integer?(args[2])\n color = valid_color?(args[3])\n correct_types = int1 && int2 && color\n raise ArgumentError, \"#{WRONG_TYPE}: #{command}\" unless correct_types\n when 'V', 'H'\n raise ArgumentError, \"#{WRONG_NUM}: #{command}\" unless args.length == 5\n\n int1 = integer?(args[1])\n int2 = integer?(args[2])\n int3 = integer?(args[3])\n color = valid_color?(args[4])\n correct_types = int1 && int2 && int3 && color\n raise ArgumentError, \"#{WRONG_TYPE}: #{command}\" unless correct_types\n else\n raise ArgumentError, \"unrecognised command :( : #{command}\"\n end\n end",
"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 input\n\t\tprint_word\n\t\tprint \"\\n>> \"\n\t\tinput = gets.chomp\n\t\tif @player.word_to_guess.include? input\n\t\t\[email protected]_letters << input\n\t\telsif input == \"save game\"\n\t\t\toutput = File.new('save.yml', 'w')\n\t\t\toutput.puts YAML.dump(@player)\n\t\t\toutput.close\n\t\t\tputs \">game saved<\"\n\t\t\tgame_loop\n\t\telsif input == \"exit\"\n\t\t\texit\n\t\telse\n\t\t\[email protected] += 1\n\t\tend\n\tend",
"def check_first_command(command)\n arr_1 = command.split(' ') #only one space\n return false if arr_1.length != 2\n return false if arr_1[0] != 'PLACE'\n command_arr = command.split(' ').join(',').split(',')\n directions = [\"NORTH\", \"EAST\", \"SOUTH\", \"WEST\"]\n coords = ['0', '1','2','3','4'] # using strings because to_i converts non numerics to 0\n return false if command_arr.length != 4\n return false if !directions.include?(command_arr[3])\n return false if !coords.include?(command_arr[1])\n return false if !coords.include?(command_arr[2])\n return true\nend",
"def human_vs_comp\n puts \"Player One choose X or O\"\n\n input = gets.strip\n\n player_one = Players::Human.new(input)\n\n if player_one.token == \"X\"\n player_two = Players::Computer.new(\"O\")\n else\n player_two = Players::Computer.new(\"X\")\n end\n\n return player_one, player_two\nend",
"def check(command)\n self.kind = \"git\" # that's for sure\n reads = [\"git-upload-pack\", \"git upload-pack\"]\n writes = [\"git-receive-pack\", \"git receive-pack\"]\n sh_command = command.split(\" \")\n if sh_command.size == 3\n self.cmd_cmd = sh_command[0] + \" \" + sh_command[1]\n self.cmd_opt = sh_command[2]\n elsif sh_command.size == 2\n self.cmd_cmd = sh_command[0]\n self.cmd_opt = sh_command[1]\n else\n return false\n end\n\n # check the command for type, not really used but hey, always good to have\n if reads.include?(self.cmd_cmd)\n self.read = true\n logger.info(\"Read command\")\n end\n if writes.include?(self.cmd_cmd)\n self.write = true\n logger.info(\"Write command\")\n end\n return true\n end",
"def new_search\n puts \"Would you like to see other types of artists? If not, type 'exit' to exit or hit any key to see more careers.\"\n @input = gets.strip\n end",
"def generateXMLInput\n\n\t# keep generating commands until user specifies\n\tcommand = \"\"\n\txml_full_results = \"\"\n\twhile (command != \"done\" && command != \"stop\")\n\n\t\t# specifying the command to add\n\t\tprint(\"\\nInput command to test (mapRoad, etc.): \")\n\t\tcommand = $stdin.readline.chomp\n\t\twhile (command !~ /^[a-zA-Z]+$/)\n\t\t\tprint(\"\\nInput a valid command to test (mapRoad, etc.): \")\n\t\t\tcommand = $stdin.readline.chomp\n\t\tend\n\n\t\t# specify how many tests to generate\n\t\tif (command != \"done\" && command != \"stop\" && command != \"comment\" && command != \"help\")\n\t\t\tprint(\"\\nHow many tests to generate: \")\n\t\t\ttest_amount = $stdin.readline.chomp\n\t\t\twhile (test_amount !~ /^[0-9]+$/)\n\t\t\t\tprint(\"Enter a valid number of tests to generate: \")\n\t\t\t\ttest_amount = $stdin.readline.chomp\n\t\t\tend\n\t\tend\n\n\t\t# determine whether to generate parameters randomly or custom\n\t\tif (command != \"done\" && command != \"stop\" && command != \"clearAll\" && command != \"listCities\" && command != \"printAvlTree\" && command != \"comment\" && command != \"help\")\n\t\t\tprint(\"\\nEnter how to generate parameters (random or custom): \")\n\t\t\tparamGen = $stdin.readline.chomp\n\t\t\twhile ((paramGen != \"random\" && paramGen != \"custom\" && paramGen.length > 1) || (paramGen.length == 1 && paramGen[0] != 'r' && paramGen[0] != 'c'))\n\t\t\t\tprint(\"\\nEnter a valid way to generate parameters (random or custom): \")\n\t\t\t\tparamGen = $stdin.readline.chomp\n\t\t\tend\n\t\tend\n\n\t\t# determining which tags to create\n\t\tif (command == \"mapAirport\")\n\t\t\txml_full_results += \"\\n\" + generateMapAirport(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"createCity\")\n\t\t\txml_full_results += \"\\n\" + generateCreateCity(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"deleteCity\")\n\t\t\txml_full_results += \"\\n\" + generateDeleteCity(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"clearAll\")\n\t\t\txml_full_results += \"\\n\" + generateClearAll(test_amount.to_i)\n\t\telsif (command == \"listCities\")\n\t\t\txml_full_results += \"\\n\" + generateListCities(test_amount.to_i)\n\t\telsif (command == \"printAvlTree\")\n\t\t\txml_full_results += \"\\n\" + generatePrintAvlTree(test_amount.to_i)\n\t\telsif (command == \"mapRoad\")\n\t\t\txml_full_results += \"\\n\" + generateMapRoad(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"unmapRoad\")\n\t\t\txml_full_results += \"\\n\" + generateUnmapRoad(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"unmapAirport\")\n\t\t\txml_full_results += \"\\n\" + generateUnmapAirport(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"printPMQuadtree\")\n\t\t\txml_full_results += \"\\n\" + generatePrintPMQuadtree(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"saveMap\")\n\t\t\txml_full_results += \"\\n\" + generateSaveMap(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"globalRangeCities\")\n\t\t\txml_full_results += \"\\n\" + generateGlobalRangeCities(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"nearestCity\")\n\t\t\txml_full_results += \"\\n\" + generateNearestCity(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"nearestAirport\")\n\t\t\txml_full_results += \"\\n\" + generateNearestAirport(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"shortestPath\")\n\t\t\txml_full_results += \"\\n\" + generateShortestPath(test_amount.to_i, paramGen[0] == 'r')\n\t\telsif (command == \"comment\")\n\t\t\txml_full_results += \"\\n\" + generateComment\n\t\telsif (command == \"help\")\n\t\t\tprintHelpScreen\n\t\telsif (command != \"done\" && command != \"stop\")\n\t\t\tputs(\"Invalid command was provided.\")\n\t\tend\n\n\tend\n\n\treturn xml_full_results\n\nend",
"def search_menu\n puts\n prompt = \"(dork3r)> \"\n while line = Readline.readline(\"#{prompt}\", true)\n cmd = line.chomp\n case cmd\n when /^!(.+)/\n # Execute system commands in terminal\n cmd=$1.strip.chomp\n res = commandz(cmd)\n print_line(\"\\n#{res.join().chomp}\")\n search_menu\n when /^c$|^clear$|^cls$/i\n cls\n banner\n search_menu\n when /^h$|^help$|^ls$/i\n puts\n search_menu_help\n search_menu\n when /^exit$|^quit$|^back$/i\n puts\n print_error(\"Returning to Main Menu....\")\n main_menu\n when /^ip$/i\n ip_info\n search_menu\n when /^ip2host$|^host2ip$/i\n host = Readline.readline(\" Target IP or Domain: \", true)\n dnsenum = DNSEnum.new(host.strip.chomp)\n ip, domain, hostname = dnsenum.host_info\n puts\n print_status(\"IP: #{ip}\")\n print_status(\"Domain: #{domain}\") unless domain == ip\n print_status(\"Hostname: #{hostname}\\n\\n\")\n search_menu\n when /^list$/i\n file = Readline.readline(\" Path to Links File: \", true)\n if File.exists?(file.strip.chomp)\n print_status(\"Performing quick vuln test with user provided links....\")\n links=File.open(file.strip.chomp).readlines\n print_status(\"Loaded #{links.size} links from #{file}....\")\n testing_links = link_prep(links)\n print_status(\"#{testing_links.size} links prepped for testing....\")\n send_and_check(testing_links)\n else\n puts\n print_error(\"Unable to load URL list!\")\n print_error(\"Check path or permissions and try again....\\n\")\n end\n search_menu\n when /^ask$|^bing$|^yahoo$|^google|^all$/i\n print_status(\"Need some info for search....\")\n squery = Readline.readline(\" Enter Search Term: \", true)\n eanswer = Readline.readline(\" Enable TLD Expansion Search (Y/N)? \", true)\n if eanswer.strip.chomp.upcase == 'N' or eanswer.strip.chomp.upcase == 'NO'\n tld_expansion = false\n else\n tld_expansion = true\n line = Readline.readline(\" Enter CSV list of TLD's to Expand Search:\", true)\n if line =~ /.+,.+/\n tld_expansion_array = line.split(',')\n else\n tld_expansion_array = [ 'COM', 'EDU', 'NET', 'ORG' ]\n end\n end\n answer = Readline.readline(\" Enable Vuln Checks w/Search (Y/N)? \", true)\n if answer.strip.chomp.upcase == 'N' or answer.strip.chomp.upcase == 'NO'\n dorking=false\n else\n dorking=true\n end\n puts\n links=[]\n search = SearchEngine.new\n case cmd\n when /ask/i\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.ask_search(dork, false)\n print_status(\"Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.ask_search(squery.strip.chomp)\n end\n when /bing/i\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.bing_search(dork, false)\n print_status(\"Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.bing_search(squery.strip.chomp)\n end\n when /google/i\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.google_search(dork, false)\n print_status(\"Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.google_search(squery.strip.chomp)\n end\n when /excite/i\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.excite_search(dork, false)\n print_status(\"Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.excite_search(squery.strip.chomp)\n end\n when /hotbot/i\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.hotbot_search(dork, false)\n print_status(\"Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.hotbot_search(squery.strip.chomp)\n end\n when /yahoo/i\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.hotbot_search(dork, false)\n print_status(\"Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.yahoo_search(squery.strip.chomp)\n end\n else # All\n if tld_expansion\n tld_expansion_array.each do |t|\n count=links.size\n print_status(\"Searching with Dork against #{t}....\")\n dork = squery.strip.chomp + \"%20site%3A#{t}\"\n links += search.ask_search(dork, false)\n print_status(\"Ask Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n count=links.size\n links += search.bing_search(dork, false)\n print_status(\"Bing Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n count=links.size\n links += search.google_search(dork, false)\n print_status(\"Google Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n count=links.size\n links += search.yahoo_search(dork, false)\n print_status(\"Yahoo Found #{links.size - count.to_i} Links....\") unless (links.size - count.to_i) == 0\n end\n else\n links += search.ask_search(squery.strip.chomp)\n links += search.bing_search(squery.strip.chomp)\n links += search.google_search(squery.strip.chomp)\n links += search.yahoo_search(squery.strip.chomp)\n end\n end\n if not links.nil? and links.size > 0\n links.uniq!\n if dorking\n test_links = link_prep(links)\n print_good(\"#{test_links.size} links prepped for testing....\")\n send_and_check(test_links)\n else\n print_good(\"Search Results: \")\n links.each {|link| puts link.to_s.white }\n end\n puts\n else\n puts\n print_error(\"No links returned from searches!\")\n print_error(\"Can't do anything without links....\\n\\n\")\n end\n search_menu\n when /^local$|^OS$/i\n local_shell\n search_menu\n else\n puts\n print_error(\"Oops, Didn't quite understand that one!\")\n print_error(\"Please try again...\\n\\n\")\n search_menu\n end\n end\nend",
"def process_simple_command(command, board)\n\n case command\n when \"help\"\n puts command_list\n return true\n when \"display\"\n board.display\n return true\n when \"exit\"\n abort\n end\n\n false\nend",
"def question\n puts <<EOT\nEnter search, like : #{@defaultsearch} or just hit enter to start player! \nt search -> track search\nu search -> user search\nq -> exit! :)\nEOT\n search = STDIN.gets.strip\n if search.empty?\n @defaultsearch\n else\n search\n end\n end",
"def get_input input\n\n case input\n\n # avancar\n when 'a'\n case menu\n when 'do_inicio',\n 'continuar' then line_forth\n when 'escrevendo' then next_char\n when 'ler' then @filelist.rotate!\n else next_option\n end\n\n # voltar\n when 'v'\n case menu\n when 'do_inicio',\n 'continuar' then line_back\n when 'escrevendo' then last_char\n when 'ler' then @filelist.rotate! -1\n else last_option\n end\n\n # fim\n when 'f'\n case menu\n when 'escrevendo' then end_of_text\n end\n\n # enter\n when 'e'\n case menu\n\n when 'ler'\n @filename = @filelist.first[:file]\n seleciona_ler_modo\n\n when 'principal',\n 'ler_modo'\n self.send \"seleciona_#{@options.first.gsub(\" \",\"_\")}\"\n\n when 'escrever'\n @writer = Writer.new('nota')\n @options = ['nota']\n seleciona_escrevendo\n\n when 'escrevendo' then end_of_line\n\n when 'salvar' then save_action\n\n end\n\n # backspace\n when 'b'\n case menu\n when 'escrevendo' then delete_char\n end\n\n # esc\n when 's'\n case menu\n when 'ler','escrever' then seleciona_principal\n when 'ler_modo',\n 'do_inicio',\n 'continuar' then seleciona_ler\n when 'escrevendo'\n save_options\n seleciona_salvar\n end\n\n # inputs de dados\n else\n case menu\n when 'escrevendo' then insert_char(input)\n end\n end\n\n end"
] | [
"0.72747916",
"0.67126584",
"0.6711882",
"0.66055363",
"0.65910697",
"0.6519679",
"0.6517951",
"0.642518",
"0.6409627",
"0.6408113",
"0.6400838",
"0.63081086",
"0.6274884",
"0.6272199",
"0.6240104",
"0.62262005",
"0.62257683",
"0.6216708",
"0.61950654",
"0.619037",
"0.6183787",
"0.6173359",
"0.61721045",
"0.61279476",
"0.61264765",
"0.61261183",
"0.612126",
"0.61168927",
"0.6116007",
"0.60971147",
"0.60805815",
"0.6077034",
"0.60763025",
"0.605288",
"0.60499257",
"0.6045237",
"0.60368454",
"0.6015119",
"0.5987086",
"0.59812075",
"0.5978545",
"0.5976426",
"0.59718996",
"0.5967006",
"0.5962829",
"0.5951313",
"0.5947348",
"0.59355885",
"0.59327215",
"0.59327215",
"0.59224427",
"0.5922146",
"0.5901239",
"0.5893245",
"0.58906496",
"0.5890449",
"0.5889618",
"0.5883089",
"0.58790046",
"0.5873025",
"0.5867606",
"0.58656836",
"0.5837703",
"0.5836096",
"0.5835277",
"0.5826063",
"0.58228475",
"0.5818737",
"0.5818534",
"0.58169115",
"0.58141464",
"0.58139634",
"0.580241",
"0.57983685",
"0.5790851",
"0.57838637",
"0.5781612",
"0.577105",
"0.5766943",
"0.5758925",
"0.57575995",
"0.5756964",
"0.57568353",
"0.57552624",
"0.57537436",
"0.5744786",
"0.5736342",
"0.5735776",
"0.57352865",
"0.572766",
"0.5727602",
"0.57273245",
"0.572305",
"0.5714088",
"0.57022876",
"0.5699718",
"0.5698839",
"0.56875813",
"0.56829894",
"0.5678608"
] | 0.64604276 | 7 |
Initialises all game objects and their attributes | def initialize_environment
# Create items
@key = Item.new("key", "Head to the livingroom and use it before the ghost finds you!", "d", true)
@phone = ScoreItem.new("phone", "This works better with charge", "You've used the phone to leave a good review and the ghost loved it! Your score has improved by one star.", false, 1)
@charger = ScoreItem.new("charger", "You could use this to charge up your phone!", "You've charged the phone.", false, 1)
@juice = ScoreItem.new("juice", "I'm sure the host won't mind if you finish it off.", "You've just drank all the ghost's favourite juice :( Your AirBnB score has dropped one star.", false, -1)
@toothbrush = ScoreItem.new("toothbrush", "You sure could use some fresh breath", "Ew! You've grossed out the ghost and lost a star.", false, -1)
# Store star characters used to print score
@star1 = "\u2b50"
## Create rooms and store items
# livingroom
@lroom_items = ["charger"]
@lroom_exits = {:west => "bedroom"}
@lroom = Room.new("livingroom", @lroom_items, @lroom_exits)
# bedroom
@broom_items = ["phone", "toothbrush"]
@broom_exits = {:east => "livingroom", :south => "kitchen"}
@broom = Room.new("bedroom", @broom_items, @broom_exits)
# kitchen
@kitchen_items = ["juice", "key"]
@kitchen_exits = {:north => "bedroom"}
@kitchen = Room.new("kitchen", @kitchen_items, @kitchen_exits)
# Store items together for validation
@game_items = [@key, @phone, @charger, @juice, @toothbrush]
# Store rooms together for validation
@game_rooms = [@kitchen, @broom, @lroom]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_game_objects\n rm_extender_create_game_objects\n $game_self_vars = Hash.new\n $game_labels = Hash.new\n $game_self_labels = Hash.new\n end",
"def init_game\n @io.welcome_msg\n @num_decks = @io.get_num_decks \n @player_cnt = @io.get_player_cnt(@max_players)\n players_names = @io.get_players_names\n\n # Initialize player objects\n 0.upto(players_names.length - 1) do |x|\n @players[x] = Player.new(players_names[x], @bankroll)\n end\n\n # Create the dealer and add as a player\n @dealer = Dealer.new\n @dealer.hit_soft_17 = @hit_soft_17\n @players[@players.length] = @dealer\n end",
"def initialize()\n @tileset = Gosu::Image.load_tiles(\"media/tileset.png\", TILE_WIDTH, TILE_HEIGHT, tileable: true)\n\n # Load images here so they will only be loaded once per game\n @enemyAnimation = *Gosu::Image.load_tiles(\"media/enemy_char.png\", Enemy::WIDTH, Enemy::HEIGHT)\n @portalAnimation = *Gosu::Image.load_tiles(\"media/portal.png\", Portal::WIDTH, Portal::HEIGHT)\n @diamondImg = Gosu::Image.new(\"media/diamond.png\")\n\n # Load all the stages in to an array\n @stages = Dir.glob('stages/*').select { |e| File.file? e }\n @finalStage = false\n end",
"def game_init\r\n state(0)\r\n @game_deck.create_new_deck\r\n @player_deck = {}\r\n @dealer_deck = {}\r\n @player.points = 0\r\n @dealer.points = 0\r\n end",
"def init_players\n\t\t@human = Human.new(\"Jack\", Field.new)\n\t\t@computer = Computer.new(Field.new)\n\t\tinit_fields\n\tend",
"def init args\n\n # Create the various objects\n args.state.world = World.new args\n args.state.player = Player.new args\n args.state.turrets = Array.new\n args.state.bullets = Array.new\n\nend",
"def initialize(objects = nil)\n Aethyr::Extend::HandlerRegistry.handle(self)\n\n @soft_restart = false\n @storage = StorageMachine.new\n @uptime = Time.new.to_i\n @future_actions = PriorityQueue.new\n @pending_actions = PriorityQueue.new\n\n unless objects\n @cancelled_events = Set.new\n\n log \"Loading objects from storage...\"\n @game_objects = @storage.load_all(false, CacheGary.new(@storage, self))\n log \"#{@game_objects.length} objects have been loaded.\"\n\n @calendar = Calendar.new\n\n @event_handler = EventHandler.new(@game_objects)\n\n @running = true\n else\n @game_objects = objects\n end\n end",
"def initalize\n @deck = Deck.new\n @player = Player.new\n @dealer = Dealer.new\n end",
"def initialize\n @screen = Game_Screen.new\n @interpreter = Game_Interpreter.new(0, true)\n @map_id = 0\n @display_x = 0\n @display_y = 0\n create_vehicles\n end",
"def initialize\n greeting\n init_players\n end",
"def initialize_game\n setup_boards\n end",
"def init\n\t\t@state = NewGame.new(self)\n\t\t# Deck.create({:game => self})\n\tend",
"def initialize_players\n\n end",
"def initialize()\n original_dir = Dir.pwd\n Dir.chdir(__dir__)\n\n classes_before = ObjectSpace.each_object(Class).to_a\n Dir[\"../model/game/*\"].each {|file|\n require_relative file\n }\n Dir.chdir(original_dir)\n\n classes_after = ObjectSpace.each_object(Class).to_a\n @modes_loaded = classes_after - classes_before\n\n @game_started = false\n @observer_views = []\n @players = []\n @clients_players = Hash.new\n @board = nil\n @clients_board = nil\n @player_playing = nil\n @clients_player_playing_index = nil\n @AI_players = 0\n # http://docs.ruby-lang.org/en/2.0.0/Hash.html\n @game_history = Hash.new(-1)\n @turn = 1\n @online_mode = false\n @player_name = nil\n @player_id = 1\n @save_requests_received = Hash.new(0)\n @turn_which_save_was_requested = -1\n @continuing_game = false\n end",
"def initialize(self)\n self.objects = []\n self.agents = []\n end",
"def initialize_classes_and_modules\n @classes = {}\n @modules = {}\n end",
"def game_setup\n end",
"def initialize \n # Keep track of hooks and what object owns what\n @hooks = {}\n @cmds = {}\n @modules = {}\n\n # Prevent access to hooks when other things are\n # editing or using them.\n @hooks_mutex = Mutex.new\n end",
"def defaults\n state.flash_at ||= 0\n state.zombie_min_spawn_rate ||= 60\n state.zombie_spawn_countdown ||= random_spawn_countdown state.zombie_min_spawn_rate\n state.zombies ||= []\n state.killed_zombies ||= []\n\n # Declares player as a new entity and sets its properties.\n # The player begins the game in the center of the screen, not moving in any direction.\n state.player ||= state.new_entity(:player, { x: 640,\n y: 360,\n attack_angle: 0,\n dx: 0,\n dy: 0 })\n end",
"def initialize()\n # Cards table, containing cards hashes\n setAllCards()\n end",
"def initialize\n @game_settings = GameSettings.new\n super 920, 480\n self.caption = GAME_TITLE\n @settings_hovered = Options::START_SCREEN[0]\n @title_font, @subtitle_font = Gosu::Font.new(50), Gosu::Font.new(20)\n @background_image = Gosu::Image.new(\"media/background1.jpg\", :tileable => true)\n @blank_card = Gosu::Image.new(\"media/card.png\", :tileable => true)\n @button_option = Gosu::Image.new(\"media/button.png\", :tileable => true)\n @deck = Deck.new\n @playing_cards = Array.new\n @computer_signal = ComputerTimer.new\n @players_created, @mes, @false_mes, @true_mes, @trying_mes = false, false, false, false, false\n @hint = []\n #players\n @pressed, @p1, @p2 = nil, nil, nil\n @game_timer = Timers.new\n end",
"def init_public_members\r\n @id = 0\r\n @x = 0\r\n @y = 0\r\n @real_x = 0\r\n @real_y = 0\r\n @tile_id = 0\r\n @character_name = \"\"\r\n @character_index = 0\r\n @move_speed = 4\r\n @move_frequency = 6\r\n @walk_anime = true\r\n @step_anime = false\r\n @direction_fix = false\r\n @opacity = 255\r\n @blend_type = 0\r\n @direction = 2\r\n @pattern = 1\r\n @priority_type = 1\r\n @through = false\r\n @bush_depth = 0\r\n @animation_id = 0\r\n @balloon_id = 0\r\n @transparent = false\r\n end",
"def initialize\n @imgs = {}\n @global_imgs = {}\n @tilesets = {}\n @global_tilesets = {}\n @sounds = {}\n @global_sounds = {}\n @songs = {}\n @global_songs = {}\n @fonts = {}\n @global_fonts = {}\n\n @prefix = File.expand_path(File.dirname($0)) + '/data/'\n @img_dir = 'img/'\n @tileset_dir = 'tileset/'\n @sound_dir = 'sound/'\n @song_dir = 'song/'\n @font_dir = 'font/'\n @separator = '_'\n @retro_images = false\n end",
"def initialize\n team_objects\n end",
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_name = $game_player.character_name\n @character_index = $game_player.character_index\n $game_player.set_graphic('', 0)\n\n $game_system.menu_disabled = true\n Graphics.frame_count = 0\n\n super\n create_foreground\n create_background\n create_command_window\n play_title_music\n end",
"def initialize\n self.class.traits.each do |k,v| # passing the values to each new instance of \n instance_variable_set \"@#{k}\",v # Creature and its subclasses\n end\n end",
"def initialize\n create_boss_hp_bar \n bosses_initialize \n end",
"def initialize fps, title\n # The sprite and sound managers.\n @spriteManager = SpriteManager.new\n @soundManager = SoundManager.new 3\n\n # Number of frames per second.\n @framesPerSecond = fps\n\n # Title in the application window.\n @windowTitle = title\n\n # create and set timeline for the game loop\n buildAndSetGameLoop\n end",
"def init_public_members\n @id = 0\n @x = 0\n @y = 0\n @real_x = 0.0\n @real_y = 0.0\n @tile_id = 0\n @character_name = \"\"\n @character_index = 0\n @move_speed = 4\n @move_frequency = 6\n @walk_anime = true\n @step_anime = false\n @direction_fix = false\n @opacity = 255\n @blend_type = 0\n @direction = 2\n @pattern = 1\n @priority_type = 1\n @through = false\n @bush_depth = 0\n @animation_id = 0\n @balloon_id = 0\n @transparent = false\n end",
"def setup_players\n @players = []\n @players << add(Spaceship, 400, 320)\n @players << add(Tank, width/2, height-100)\n end",
"def init\n\t\t## Pathfind\n\t\t#@pathfind = Pathfind.new\n\n\t\t## Add player\n\t\t@player = Player.new #spawn: @room.get_spawn\n\n\t\t## Song controller\n\t\t@song = SongController.new\n\n\t\t## Only load one level\n\t\t@level = load_level @level_name\n\n\t\t#@room = @levels[@level_name].rooms.first unless (@levels[:first].nil?)\n\t\t@room = @level.get_room @room_name\n\t\[email protected]_to_spawn @room.get_spawn\n\n\t\tputs \"Level: #{@level.name}\"\n\t\tputs \" Room: #{@room.name}\"\n\t\tputs \"INSTANCE_COUNT:\\n\\tsolid:\\t\\t#{@room.instances[:solid].size}\"\n\t\tputs \"\\tpassable:\\t#{@room.instances[:passable].size}\"\n\n\t\t## Init Pathfinder\n\t\t#@pathfind.pathfind_init\n\t\t## Add Solid blocks to pathfind grid (bootstrap it)\n\t\t#@pathfind.add_solids @room.get_instances(:solid)\n\n\t\ttracker0 = Tracker.new pos: @player.pos, track: @player\n\t\ttracker1 = Tracker.new pos: @player.pos, track: tracker0\n\t\ttracker2 = Tracker.new pos: @player.pos, track: tracker1\n\t\ttracker3 = Tracker.new pos: @player.pos, track: tracker2\n\t\ttracker4 = Tracker.new pos: @player.pos, track: tracker3\n\t\ttracker5 = Tracker.new pos: @player.pos, track: tracker4\n\n\t\t@entities = [\n\t\t\t@player,\n\t\t\tEnemy.new,\n\t\t\ttracker0, tracker1, tracker2, tracker3, tracker3, tracker4, tracker5\n\t\t]\n\n\t\t## Move camera to player\n\t\t$camera.center_on x: @player.pos(:x), y: @player.pos(:y)\n\n\t\t## Font for FPS display\n\t\t@font_fps = Gosu::Font.new 32\n\n\t\t## For consequtive updating of entities, instead of all at once\n\t\t#@update_entity_index = 0\n\tend",
"def initialize # utilise la classe player pour demander les infos aux joueurs et la classe baord pour lancer la tipar\n puts \" The Houmous Project présente Morbac\"\n @player_one = Player.new\n @player_one.informations\n @player_two = Player.new\n @player_two.informations\n @boboard = Board.new\n end",
"def initialize\n\t\t@grid = Board.new\n\t\t@player_1 = Player.new\n\t\t@player_2 = Player.new\n\t\t@game_status = true #true means game is still playing\n\t\tassign_players\n\tend",
"def initialize settings={:x => 0, :y => 0, :width => 0, :height => 0, :life => 1, :depth => 0}\n\t\t\ts = {:x => 0, :y => 0, :width => 0, :height => 0, :life => 1, :depth => 0}.merge! settings\n\t\t\tUtil.hash_to_var(s, [:x, :y, :width, :height, :life, :depth], self)\n\t\t\t@@game.add self\n\t\tend",
"def initialize\n @loot = createLoot\n @suppliesPackage = createSuppliesPackage\n @weapon = createWeapon\n @shieldBooster = createShieldBooster\n @dice = Dice.new\n @hangar = createHangar\n @damageNumeric = createDamageNumeric\n @damageSpecific = createDamageSpecific\n @enemyStarShip = createEnemyStarShip\n @spaceStation = createSpaceStation\n @spaceCity = createSpaceCity\n @betaPowerEfficient = createBetaPowerEfficient\n @powerEfficient = createPowerEfficient\n @gameUniverse = GameUniverse.new\n end",
"def my_initialize\n\t\t@classes = 1\n\t\t@toys = 0\n\t\t@books = 0\t\t\n\t\tsrand seed.to_i\n\t\t@location = nil\n\t\tnext_spot()\n\t\t@random_number = 0\n\t\ttrue\n\tend",
"def initialize\n @width = 800\n @width_tiles = @width / 32\n @height = 640\n @height_tiles = @height / 32\n @keys = []\n super(@width, @height, fullscreen = false)\n self.caption = \"Aetheris\"\n\n @spell = Gosu::Image.new(Utils.image_path_for(\"explosion\"), rect: [0, 0, 32 * 3, 32 * 3])\n @spell_cooldown = 0\n @game_name = Gosu::Image.from_text(\"Aetheris\", 100)\n @player = Player.new(self)\n @npc = NPC.new\n @player.warp(300, 200)\n @visibility = { fog: 3 }\n @map = Gosu::Image.new(\"images/map.jpg\")\n @low_grass = @map.subimage(32, 32 * 2, 22, 22)\n @camera = Camera.new(x: 0, y: 0, width: WIDTH, height: HEIGHT)\n @interacting = false\n @spell_avalanche_of_fire = nil\n end",
"def initialize\n bosses_initialize\n @bhp_frame = Cache.system(\"boss_hp_bar_borders\")\n @bhp_background = Cache.system(\"boss_hp_bar_bcg\")\n @bhp_fill = []\n 5.times { |time|\n @bhp_fill.push(Cache.system(\"boss_hp_bar#{time+1}\"))\n }\n end",
"def initialize \n super(ScreenWidth, ScreenHeight, false)\n self.caption = \"Mad Pokemon\"\n $window = self\n\n @@images = Hash.new\n @@fonts = Hash.new \n load_images\n load_fonts\n\n @@fading_off = false\n @@fading_on = false\n @@end_fade = 0\n @@start_fade = 0\n\n @@change_game_state = nil\n\n @@game_state = MenuState.new\n end",
"def initialize name, map\n #set meta data\n @name = name\n @players = Array.new\n @map = map\n\n # mode defaults to lobby\n @mode = :lobby\n @state = State.new []\n\n @finalized_players = PlayerFinalizationTracker.new\n\n @character_templates = [\n CharacterTemplate.new(\"devil\",[0,9]),\n CharacterTemplate.new(\"ghost\",[4,7])\n ]\n end",
"def initialize(*args)\n super\n @game = Game.new\n\n @changelog = self.load_changelog\n\n @mods = config[:mods]\n @channel_name = config[:channel]\n @settings_file = config[:settings]\n @games_dir = config[:games_dir]\n\n @idle_timer_length = config[:allowed_idle]\n @invite_timer_length = config[:invite_reset]\n\n @idle_timer = self.start_idle_timer\n\n @game_timer_minutes = nil\n @game_timer = nil\n end",
"def initialize(args)\n\n # Keep a handy reference to the args\n @args = args\n\n # On startup we're not running\n @args.state.vertices.running = false\n\n # Set some basic game parameters\n @args.state.vertices.play_ticks ||= 20.seconds\n @args.state.vertices.target_shapes ||= 10\n @args.state.vertices.polygons ||= []\n @polygons = []\n @stars = []\n\n # Need an audio handler\n @audio_handler = Ahnlak::ClassAudio.new\n @audio_handler.play('vertices/sounds/title.ogg')\n\n # Initialise some other bits - again, set some defaults\n @prompt = []\n @prompt << TintedLabel.new(\n visible: true,\n x: @args.grid.center_x, y: 400,\n alignment_enum: 1, size_enum: 15,\n text: 'Click on the shape with the fewest edges',\n font: 'vertices/fonts/Kenney Future Square.ttf'\n )\n @prompt << TintedLabel.new(\n visible: true,\n x: @args.grid.center_x, y: 325,\n alignment_enum: 1, size_enum: 15,\n text: \"Can you clear #{@args.state.vertices.target_shapes} shapes in time?!\",\n font: 'vertices/fonts/Kenney Future Square.ttf'\n )\n @prompt.each do |prompt|\n prompt.colourable_cycle(\n [\n [255, 255, 255, 255],\n [100, 255, 100, 255],\n [255, 100, 255, 255]\n ],\n 30\n )\n end\n @counter = Counter.new(args)\n\n # And load up our sprites\n load_sprites\n\n # The system icons are static\n args.outputs.static_sprites << @audio_sprite\n args.outputs.static_sprites << @music_sprite\n\n end",
"def initialize(name, age, style)\n # - We assign our attributes (instance variables) here!\n @name = name\n @age = age\n @style = style\n\n # - As well as pushed all instances inside of our @@all\n @@all << self\n end",
"def initialize #everytie an instance of the class is initialized, we should push it into the @@all class variable\n @@all << self\n end",
"def create_objects\n # Create objects for the user.\n @user_board = Board.new\n @user_board.cells\n @user_board.selected_rows(4)\n user_cruiser = Ship.new('Cruiser', 3)\n user_submarine = Ship.new('Submarine', 2)\n @user_ships = []\n @user_ships << user_cruiser\n @user_ships << user_submarine\n \n # Create objects for the npc, and place the ships.\n npc_cruiser = Ship.new('Cruiser', 3)\n npc_submarine = Ship.new('Submarine', 2)\n @npc_ships = []\n @npc_ships << npc_cruiser\n @npc_ships << npc_submarine\n @npc = Computer.new(@npc_ships)\n @npc.board.cells\n @npc.board.selected_rows(4)\n @npc.computer_place\n end",
"def init_fields\n\t\tinit_human_field\n\t\tinit_computer_field\n\t\tplace_ships_on_the_field(@human.ships, @human.field)\n\t\tplace_ships_on_the_field(@computer.ships, @computer.field)\n\tend",
"def initialize\n @rooms = { #defines the rooms available for use on each floor\n :upstairs => [\"Master Bedroom\", \"A Guest Room\", \"Tower\", \"Balcony\", \"Observatory\", \"The Hole Room\"],\n :main => [\"Kitchen\", \"Library\", \"Study\", \"Dining Room\", \"Living Room\", \"Vault\"],\n :downstairs => [\"Furnace Room\", \"Chapel\", \"Storage Room\", \"The Pit\"]\n }\n\n @used_rooms = []\n @omen_count = 0 #Omens are a game event that change the story line. Once the omen count reaches 10 the haunt starts\n @player = Character.new\n intro #script\n entry_hall(\"Main Hallway\")\n game\n end",
"def setup(numPlayers, myIndex, suspects, locations, weapons)\n @@numPlayers = numPlayers\n @myIndex = myIndex\n @suspects = suspects.clone\n @locations = locations.clone\n @weapons = weapons.clone\n @cards = Array.new\n @inGame = true\n end",
"def initialize_hotels\n Hotel.all.each do |hotel|\n GameHotel.create(name: hotel.name, hotel_id: hotel.id, game_id: self.id, chain_size: 0, share_price: 0)\n end\n end",
"def initialize(name) # je recrée un initialize et je fais appel aux caractéristiques de la classe mère avec super\n super(name)\n\n @life_points = 100 # j'ajoute les caractéristiques propres au joueur humain\n @weapon_level = 1\n end",
"def initialize(game_objects)\n @event_queue = Queue.new\n @running = true\n @mutex = Mutex.new\n end",
"def init_actorsprites\r\n # Make actor sprites\r\n @actor_sprites = []\r\n @actor_sprites.push(Sprite_Battler.new(@viewport2))\r\n @actor_sprites.push(Sprite_Battler.new(@viewport2))\r\n @actor_sprites.push(Sprite_Battler.new(@viewport2))\r\n @actor_sprites.push(Sprite_Battler.new(@viewport2))\r\n end",
"def init primaryStage\n # Sets the window title\n primaryStage.setTitle getWindowTitle\n\n # Create the scene\n setSceneNodes Group.new\n setGameSurface Scene.new getSceneNodes, 640, 580\n primaryStage.setScene getGameSurface\n\n generateManySpheres 150\n\n # Display the number of spheres visible.\n # Create a button to add more spheres.\n # Create a button to freeze the game loop.\n gameLoop = getGameLoop\n stats = VBoxBuilder.create\n .spacing(5)\n .translateX(10)\n .translateY(10)\n .children(HBoxBuilder.create\n .spacing(5)\n .children(\n Label.new(\"Number of Particles: \"),\n @num_sprites_field\n ).build,\n\n # button to build more spheres\n ButtonBuilder.create\n .text(\"Regenerate\")\n .onMousePressed(proc {\n generateManySpheres 150\n }).build,\n\n # button to freeze game loop\n ButtonBuilder.create\n .text(\"Freeze/Resume\")\n .onMousePressed(proc {\n case gameLoop.getStatus\n when Animation::Status::RUNNING\n gameLoop.stop\n when Animation::Status::STOPPED\n gameLoop.play\n end\n }).build\n ).build # (VBox) stats on children\n\n # lay down the controls\n getSceneNodes.getChildren.add stats\n end",
"def standard_setup\n @body = Body.new(@client)\n @entity_tracker = EntityTracker.new(@client, @body)\n @chunk_tracker = ChunkTracker.new(@client)\n @inventory = Inventory.new(@client)\n end",
"def initialize\n @mode = game_set_mode\n @turn_obj = Turn.new\n @solution_obj = Solution.new\n @human_solution_obj = HumanSolution.new\n @computer_solve_obj = ComputerSolver.new\n end",
"def initialize args\n\n # Build the scrolling backdrop - for now, the backdrop is split in half because of Reasons.\n divide = args.grid.center_x.div( BACKDROP_WIDTH ) * BACKDROP_WIDTH\n @backdropl_spr = AhnSprite.new \"backdrop\", divide, args.grid.h\n 0.step( args.grid.h, BACKDROP_HEIGHT ).each do |row|\n 0.step( ( divide ) + BACKDROP_WIDTH, BACKDROP_WIDTH ).each do |col|\n @backdropl_spr.sprites << { x: col, y: row, w: BACKDROP_WIDTH, h: BACKDROP_HEIGHT, path: \"sprites/backdrop.png\" }\n end\n end\n @backdropl_spr.x = 0\n\n @backdropr_spr = AhnSprite.new \"backdrop\", args.grid.w - divide, args.grid.h\n 0.step( args.grid.h, BACKDROP_HEIGHT ).each do |row|\n 0.step( ( args.grid.w - divide ) + BACKDROP_WIDTH, BACKDROP_WIDTH ).each do |col|\n @backdropr_spr.sprites << { x: col, y: row, w: BACKDROP_WIDTH, h: BACKDROP_HEIGHT, path: \"sprites/backdrop.png\" }\n end\n end\n @backdropr_spr.x = divide\n\n # Set up the world; leave the player empty, update will spawn him/her\n @player = nil\n @lives = 3\n @player_bullets = []\n\n # Remember the epoch we started at, to trigger enemies at the right time\n @epoch = args.state.tick_count\n @enemy_idx = 0\n @enemy = []\n @enemy_bullets = []\n\n end",
"def setup\n super\n @background = Image['Bg level1.png']\n viewport.lag = 0\n viewport.game_area = [0, 0, 3000, 1000]\n @gilbert = Gilbert.create(x: 50, y: 900, limited: viewport.game_area.width)\n @level = File.join(ROOT, 'levels', self.filename + '.yml')\n load_game_objects(file: @level)\n\n @plataformas = Plataforma2.all\n @music = Song.new('media/Songs/Music Level1.mp3')\n @loser_song = Song.new('media/Songs/gameover.ogg')\n\n @moneda = Moneda.all.first\n\n @meta_on = false\n\n @marco_name = Image['MarcoName.png']\n @marco_score = Image['MarcoPoint.png']\n\n @score = 0\n @msj_name = Chingu::Text.new(@player_name, x: 85, y: 25, size: 30, color: Gosu::Color::WHITE)\n @msj_score = Chingu::Text.new(@score.to_s, x: $window.width - 130, y: 30, size: 35)\n @mensaje = Chingu::Text.new('Has encontrado todas las monedas', x: 320, y: 20, size: 25, color: Gosu::Color::GREEN)\n @mensaje2 = Chingu::Text.new('Encuentra la Meta', x: @msj_name.x, y: 45, size: 30, color: Gosu::Color::YELLOW)\n\n @music.play(true) if @sonido\n end",
"def load_entities\r\n\r\n # Cycle thru the list of objects\r\n for i in [email protected]\r\n\r\n # Handle each type differently\r\n case @objects[i][0]\r\n\r\n # Player character, so initialize a Protagonist object\r\n when \"player\"\r\n\r\n # Generate the protagonist start location\r\n @player = Protagonist.new(@objects[i][1].to_f, @objects[i][2].to_f)\r\n\r\n # Debug mode, tell the developer what was added.\r\n if $debug_mode == 1 then\r\n print \"load_entities() --> [ player,\",\r\n @objects[i][1].to_f,\r\n \",\",\r\n @objects[i][2].to_f,\r\n \"]\\n\"\r\n end\r\n\r\n # Otherwise probably an item, so initialize an Item object\r\n when \"flop4\", \"compact_disc_01\"\r\n\r\n # Add the item to the list of entities\r\n @entities << Item.new(@objects[i][1].to_f, @objects[i][2].to_f, @objects[i][0])\r\n\r\n # Debug mode, tell the developer what was added.\r\n if $debug_mode == 1 then\r\n print \"load_entities() --> [ \",\r\n @objects[i][0],\r\n \",\",\r\n @objects[i][1].to_f,\r\n \",\",\r\n @objects[i][2].to_f,\r\n \"]\\n\"\r\n end\r\n end\r\n end\r\n end",
"def initialize\n @next_scene = nil\n @map_bgm = nil\n @map_bgs = nil\n @common_event_id = 0\n @in_battle = false\n @battle_proc = nil\n @shop_goods = nil\n @shop_purchase_only = false\n @name_actor_id = 0\n @name_max_char = 0\n @menu_beep = false\n @last_file_index = 0\n @debug_top_row = 0\n @debug_index = 0\n @background_bitmap = Bitmap.new(1, 1)\n end",
"def init\r\n @tasks = {\r\n on_update: {},\r\n on_scene_switch: {},\r\n on_dispose: {},\r\n on_init: {},\r\n on_warp_start: {},\r\n on_warp_process: {},\r\n on_warp_end: {},\r\n on_hour_update: {},\r\n on_getting_tileset_name: {},\r\n on_transition: {}\r\n }\r\n @storage = {}\r\n end",
"def initialize\r\n\t super(0,Graphics.height-WIN_HEIGHT,Graphics.width,WIN_HEIGHT)\r\n\t @x, @y, @i = 10, 50, 0\r\n\t @party_size = $game_party.all_members.size\r\n contents.font.size = FONT_SIZE\r\n\t self.back_opacity = WIN_OPACITY\r\n self.opacity = FRAME_OPACITY\r\n @actor_hp = []\r\n @actor_mp = []\r\n\t fhiz_hud\r\n\t check_visible\r\n end",
"def initialize!\n $sfxengine = SoundEngine.new\n\n GameMode.enter_name_input =\n Text.new(\n Settings.winX/2,\n Settings.winY/2,\n Settings.fontsize,\n Color.new(0, 255, 0, 0.8),\n Settings.fontfile,\n \"\")\n GameMode.enter_name_headline =\n Text.new(\n Settings.winX/2,\n Settings.winY*0.35,\n Settings.fontsize,\n Color.new(0, 255, 0, 0.8),\n Settings.fontfile,\n \"enter name\")\n\n GameMode.fader = Rect.new(0, 0, Settings.winX, Settings.winY)\n GameMode.fader.colors = ColorList.new(4) { |i| Color.new(0, 0, 0, 0.8) }\n\n @ingame_timer = Timer.new\n @external_timer = Timer.new\n @engine_running = true\n @score_object = Score.new\n\n $gfxengine.prepare # TODO put to end, remove things mouse depends on!\n @mouse = Mouse.new(100, 100, Settings.mousedef)\n @score_object.cur_level = 0\n start_level @score_object.cur_level\n @textbuffer = \"\"\n GameMode.set_mode(GameMode::NORMAL)\n end",
"def initialize # Demande les paramètres aux joueurs\n puts \"Welcome to the BDX Tic-Tac-Toe ! Have fun with our progZ !\"\n @p_one = Player.new\n @p_one.infos\n @p_two = Player.new\n @p_two.infos\n @board_game = Board.new\n end",
"def initialize\r\n init_public_members\r\n init_private_members\r\n end",
"def init_caterpillar\n # add player controlled character\n @actors = [$game_player]\n # MAX-PARTY size - 1 times create actor\n (1...Config::MAX_PARTY).each {|i| @actors.push(Map_Actor.new(i))}\n # refresh all battlers\n $game_player.refresh\n # if not very beginning of the game\n if $game_map.map_id != nil && $game_map.map_id > 0\n # move all actors to the player's position\n $game_player.moveto($game_player.x / pixel, $game_player.y / pixel)\n end\n end",
"def init(container)\n @entities = []\n @entities += Array.new(3) { Giant.new(container, self) }\n @entities += Array.new(20) { Goblin.new(container, self) }\n @entities += Array.new(20) { Human.new(container, self) }\n end",
"def initialize\n # Random number between 0 and 12\n @x = rand(12) + 1\n \n # We want vials and herbs to have higher chance to show up in rooms. \n if @x >= 8 and @x < 10\n @objX = $objs[4]\n @x = 4\n elsif @x >= 10\n @objX = $objs[7]\n @x = 7\n else\n @objX = $objs[@x]\n end\n end",
"def initialize()\n populate_squares\n @players = []\n @players << collect_player_info(\"one\")\n @players << collect_player_info(\"two\")\n @rows = [\n [0,1,2],\n [3,4,5],\n [6,7,8]\n ]\n @columns = [\n [0,3,6],\n [1,4,7],\n [2,5,8]\n ]\n @diagonals = [\n [0,4,8],\n [6,4,2]\n ]\n @win_conditions = [@rows,@columns,@diagonals]\n end",
"def initialize(name)\n super(name: name)\n self.hit_points = 10\n self.charm_points = 10\n self.house_id = House.all.sample.id\n self.wand = Character.all.select{|c| !c.wand.start_with?(\" \") }.sample.wand\n self.pet = [\"cat\", \"owl\", \"toad\", \"rat\"].sample\n self.patronus = MY_ANIMAL_FAKER.sample\n @classmates_faced = []\n self.friends = 0\n self.victories = 0\n end",
"def initialize\n\n $scene = self\n\n # Prep model\n @map = Game_Map.new\n @player = Game_Player.new\n\n # Make viewports - Also in the scene\n @vp_under = Viewport.new(0,0,$game.width,$game.height)\n @vp_under.z = 0\n @vp_main = Viewport.new(0,0,$game.width,$game.height) \n @vp_main.z = 1000\n @vp_weather = Viewport.new(0,0,$game.width,$game.height)\n @vp_weather.z = 1999\n @vp_over = Viewport.new(0,0,$game.width,$game.height)\n @vp_over.z = 2000\n @vp_ui = Viewport.new(0,0,$game.width,$game.height)\n @vp_ui.z = 3000\n \n # Make tilemap\n @panoramas = []\n @tilemap = MapWrap.new(@vp_main)\n \n @characters = [] \n @sparks = []\n @pops = []\n\n # weather in map data\n @weather = nil#Weather.new(@vp_over)\n @fogs = []\n\n # Misc Overlay\n @overlay = Sprite.new(@vp_over)\n @overlay.bitmap = Bitmap.new($game.width,$game.height)\n @overlay.bitmap.fill(Color.new(0,0,0))\n @overlay.opacity = 0\n @overlay.z = 999\n\n # Fadeout\n @black = Sprite.new(@vp_over)\n @black.bitmap = Bitmap.new($game.width,$game.height)\n @black.bitmap.fill(Color.new(0,0,0))\n @black.opacity = 0\n @black.z = 1000\n \n # UI\n @hud = nil # Define in sub\n \n end",
"def setup\n\t\tsuper\n\t\t@x = 400\n\t\t@y = 300\n\t\t#@image = Gosu::Image[\"Ship.png\"]\n\t\t self.input = {\n\t\t \tholding_left: :left,\n\t\t \tholding_right: :right,\n\t\t \tholding_up: :up,\n\t\t \tholding_down: :down,\n\t\t \tspace: :fire\n\t\t }\n\t\t@speed = 10\n\t\t@angle = 0\n\t\t@animation = Chingu::Animation.new(:file => \"flame_48x48.bmp\")\n\t\[email protected]_names = { :still =>0..1, :up =>2..5, :fire =>6..7}\n# :still =>0..1, :fire =>6..7, :up =>2..5\n\t\t@frame_name = :still\n\t\t@last_x, @last_y = @x, @y\n\tend",
"def initialize(_name, _race, _class, _abilities, _equipment, _hp, _alignment, _background, _currency: {},\n\t\t_personality_traits: \"\", _ideals: \"\", _bonds: \"\", _flaws: \"\", _height: \"\", _weight: \"\", _age: \"\", _eyes: \"\", _skin: \"\", _hair: \"\")\n\n\t\t@name = _name\n\t\t@race = _race\n\t\t@classes = []\n\t\t@classes << _class\n\t\t@abilities = _abilities\n\t\t@feats = []\n\n\t\t@currency = {}\n\t\t@currency[:copper] = _currency.fetch(:copper, 0)\n\t\t@currency[:silver] = _currency.fetch(:silver, 0)\n\t\t@currency[:gold] = _currency.fetch(:gold, 0)\n\t\t@currency[:electrum] = _currency.fetch(:electrum, 0)\n\t\t@currency[:platinum] = _currency.fetch(:platinum, 0)\n\n\t\t@equipment = _equipment\n\n\t\t@hit_points = _hp\n\t\t@current_hp = @hit_points\n\t\t@temp_hp = 0\n\t\t@experience = 0\n\n\t\t@alignment = _alignment\n\t\t@background = _background\n\t\t@personality_traits = _personality_traits\n\t\t@ideals = _ideals\n\t\t@bonds = _bonds\n\t\t@flaws = _flaws\n\t\t@height = _height\n\t\t@weight = _weight\n\t\t@age = _age\n\t\t@eyes = _eyes\n\t\t@skin = _skin\n\t\t@hair = _hair\n\n\t\t@@all << self\n\tend",
"def setup\n setup_major_pieces\n setup_pawns\n end",
"def at_init\n\n\t\tend",
"def initialize(name)\n @human_player = HumanPlayer.new(name)\n @enemies = []\n for i in 1..3\n robot_name = \"player#{i}\"\n enemies << Player.new(robot_name)\n end\n end",
"def initialize (money, life, fights, respect)\n #The health bar of the player, when the health gets down to 0 the player loses.\n @life = life\n #The wealth that the player has amassed throughout the game.\n @money = money\n #Respect that the player has earned winning fights in the game\n @respect = respect\n #Number of fight events that the player has won.\n @fights = fights\n #List of states for the game.\n @states = []\n\tend",
"def preload_all_game_attrs\n @loaded_game_attributes = Terra::DEFAULT_PLAYER_ATTRIBUTES.clone\n self.player_attributes.all.each do |q|\n @loaded_game_attributes[q.name.to_sym] = q\n end\nend",
"def initialize(game) \n @game= game\n @items=[]\n fill_items([])\n end",
"def populate_room\n unless @dungeon.first_room\n @enemy = Zarta::Enemy.new(@dungeon) if enemy_spawned\n end\n @dungeon.first_room = false\n @weapon = Zarta::Weapon.new(@dungeon) if weapon_spawned\n @stairs = stairs_spawned\n end",
"def buildObject()\n case @x\n when 0\n attrX = $doorAttr[rand(6)]\n attrSX = $doorAttrS[rand(6)]\n @obj_pickable = false\n @combat_usability = false\n when 1\n attrX = $chestAttr[rand(3)]\n attrSX = $chestAttrS[rand(3)]\n @obj_pickable = false\n @combat_usability = false\n when 2\n attrX = $knifeAttr[rand(2)] \n attrSX = $knifeAttrS[rand(2)]\n @obj_pickable = true\n @combat_usability = true\n when 3\n attrX = $bodyAttr[rand(3)]\n attrSX = $bodyAttrS[rand(3)]\n @obj_pickable = true\n @combat_usability = true\n when 4\n attrX = $vialAttr[rand(3)]\n attrSX = $vialAttrS[rand(3)] \n @obj_pickable = true\n @combat_usability = true\n when 5\n attrX = $keyAttr[rand(2)] \n attrSX = $keyAttrS[rand(2)] \n @obj_pickable = true\n @combat_usability = false\n when 6\n attrX = $windowAttr[rand(5)] \n attrSX = $windowAttrS[rand(5)] \n @obj_pickable = false\n @combat_usability = false\n when 7\n attrX = $herbAttr[rand(3)]\n attrSX = $herbAttrS[rand(3)]\n @obj_pickable = true\n @combat_usability = true\n end\n \n @obj_name = @objX\n @obj_attr = attrX\n @obj_secondattr = attrSX\n end",
"def initializePesos\r\n \[email protected] do\r\n\t patron = @patrones[rand(@patrones.count-1)]\r\n @neuronas << {:class=>rand(@cantClases), :pesos => initPesos}\r\n\tend\r\n end",
"def init_public_members\n super\n @trigger = 0\n @list = nil\n @starting = false\n if $game_map.effectus_event_starting == self\n $game_map.effectus_event_starting = nil\n end\n end",
"def initalize\n @@all << self\n end",
"def viewDidLoad \n super\n self.new_game \n self.init_views\n\n end",
"def initialize(name1)\r\n @player1=Player1.new(name1)\r\n @grid=Grid.new()\r\n @grid.pretty_print\r\n puts \"\\nYour game is ready!!!\\n\\n\"\r\n game \r\nend",
"def initialize(attrs = {})\n load_attributes(attrs)\n load_properties(attrs)\n end",
"def initializeSprites\n # initializes player sprite\n @battle.player.each_with_index do |pl, i|\n plfile = GameData::TrainerType.player_back_sprite_filename(pl.trainer_type)\n pbAddSprite(\"player_#{i}\", 0, 0, plfile, @viewport)\n if @sprites[\"player_#{i}\"].bitmap.nil?\n @sprites[\"player_#{i}\"].bitmap = tempMissingBackSprite\n end\n @sprites[\"player_#{i}\"].x = 40 + i*100\n @sprites[\"player_#{i}\"].y = Graphics.height - @sprites[\"player_#{i}\"].bitmap.height\n @sprites[\"player_#{i}\"].z = 50\n @sprites[\"player_#{i}\"].opacity = 0\n @sprites[\"player_#{i}\"].src_rect.width /= 5\n end\n # initializes trainer sprite\n if @battle.opponent\n @battle.opponent.each_with_index do |t, i|\n @sprites[\"trainer_#{i}\"] = DynamicTrainerSprite.new(@battle.doublebattle?, -1, @viewport, @battle.opponent.length > 1, t)\n @sprites[\"trainer_#{i}\"].setTrainerBitmap\n @sprites[\"trainer_#{i}\"].z = (@minorAnimation || @integratedVS) ? 100 : @sprites[\"battlebg\"].battler(i*2 + 1).z\n @sprites[\"trainer_#{i}\"].shadow.z = 98 if @minorAnimation\n @sprites[\"trainer_#{i}\"].tone = Tone.new(-255, -255, -255, -255)\n end\n end\n # initializes Pokemon sprites\n @battlers.each_with_index do |b, i|\n next if !b\n @sprites[\"pokemon_#{i}\"] = DynamicPokemonSprite.new(@battle.doublebattle?, i, @viewport, @battle)\n @sprites[\"pokemon_#{i}\"].z = @sprites[\"battlebg\"].battler(i).z\n @sprites[\"pokemon_#{i}\"].index = i\n end\n # assign bitmaps for wild battlers\n loadWildBitmaps\n end",
"def initialize(species, weight, nickname, zoo)\n @species = species\n @weight = weight\n @nickname = nickname\n @zoo = zoo\n @@all << self\n\n #everytime a new animal object is created, its shoveled into the Animal class\n\nend",
"def initialize(settings={:width => 640, :height => 480, :flags => [Rubygame::HWSURFACE, Rubygame::DOUBLEBUF], :title => \"Game Engine Window\", :fps => 30})\n\t\t\ts = {:width => 640, :height => 480, :flags => [Rubygame::HWSURFACE, Rubygame::DOUBLEBUF], :title => \"Game Engine Window\", :fps => 30}.merge(settings)\n\t\t\t@fps = s[:fps]\n\t\t\t@screen = Rubygame::Screen.new [s[:width], s[:height]], 0, s[:flags]\r\n\t\t\[email protected] = s[:title]\r\n\t\t\r\n\t\t\t@queue = Rubygame::EventQueue.new\r\n\t\t\t@clock = Rubygame::Clock.new\r\n\t\t\[email protected]_framerate = s[:fps]\n\t\t\t\n\t\t\tGameObject.add_to_game self\n\t\t\tState.add_to_game self\n\t\t\t\n\t\t\t@current_state = State.new\n\t\t\t@states = []\n\t\t\t@objs2 = []\n\t\t\t@global_events = {:key_press => [], :key_release => [], :mouse_press => [], :mouse_release => [], :mouse_motion => [], :while_key_down => [], :while_key_up => []}\n\t\t\t@state_buffer = nil\n\t\tend",
"def init_player_hands\n\n @player1_hand = []\n @player2_hand = []\n @player3_hand = []\n @player4_hand = []\n\n end",
"def initialize(species) #Automatically executes the code in the method body\n @species = species #Requires Owner to define the pets' species\n @name = name #Requires Owner to define the pet's name\n @@all << self #Adds new instance of Owner to the collection @@all = []\n @pets = {:fishes => [], :dogs => [], :cats => []} #Stores all of the owner's pets\n end",
"def initialize\n super\n @gold = 0\n @steps = 0\n @last_item_id = 0\n @last_actor_index = 0\n @last_target_index = 0\n @actors = [] # Party member (actor ID)\n @items = {} # Inventory item hash (item ID)\n @weapons = {} # Inventory item hash (weapon ID)\n @armors = {} # Inventory item hash (armor ID)\n end",
"def create_actors\n @actor_sprites = []\n @actor_sprites.push(Sprite_Battler.new(@viewport1))\n @actor_sprites.push(Sprite_Battler.new(@viewport1))\n @actor_sprites.push(Sprite_Battler.new(@viewport1))\n @actor_sprites.push(Sprite_Battler.new(@viewport1))\n end",
"def initialize(weapons,megazord,color,age,name,skill,gender)\n @weapons = weapons\n @color = color\n @megazord = megazord\n @age = age\n @gender = gender\n @ethnicity = ethnicity\n @skill = skill\n end",
"def new_game_for players\r\n players.each do |player|\r\n player[:state] = 'normal'\r\n\tplayer[:cards] = []\r\n\tplayer[:points] = 0\r\n\tplayer[:bet] = 0\r\n end\r\nend",
"def setup(actor_id)\n actor = $data_actors[actor_id]\n @actor_id = actor_id\n @name = actor.name\n @character_name = actor.character_name\n @character_hue = actor.character_hue\n @battler_name = actor.battler_name\n @battler_hue = actor.battler_hue\n @class_id = actor.class_id\n @weapon_id = actor.weapon_id\n @armor1_id = actor.armor1_id\n @armor2_id = actor.armor2_id\n @armor3_id = actor.armor3_id\n @armor4_id = actor.armor4_id\n @pierce1_id = 0\n @pierce2_id = 0\n @pierce3_id = 0\n @pierce4_id = 0\n @pierce5_id = 0\n @pierce6_id = 0\n @pierce7_id = 0\n @level = actor.initial_level\n @exp_list = Array.new(101)\n make_exp_list\n @exp = @exp_list[@level]\n @skills = []\n @hp = maxhp\n @sp = maxsp\n @states = []\n @states_turn = {}\n @maxhp_plus = 0\n @maxsp_plus = 0\n @str_plus = 0\n @dex_plus = 0\n @agi_plus = 0\n @int_plus = 0\n # Learn skill\n for i in 1..@level\n for j in $data_classes[@class_id].learnings\n if j.level == i\n learn_skill(j.skill_id)\n end\n end\n end\n # Update auto state\n update_auto_state(nil, $data_armors[@armor1_id])\n update_auto_state(nil, $data_armors[@armor2_id])\n update_auto_state(nil, $data_armors[@armor3_id])\n update_auto_state(nil, $data_armors[@armor4_id])\n end",
"def create_graphics\n create_viewport\n create_background\n create_pokemon_sprite\n create_egg_sprite\n end",
"def initialize(attrs)\n @name = attrs.fetch(:name)\n @engine = Engine.new(attrs.fetch(:max_speed), attrs.fetch(:max_jump_length), attrs.fetch(:max_fuel_amount))\n @navigator = Navigator.new(self, attrs.fetch(:map), attrs.fetch(:current_star_system))\n @cargo_bay = CargoBay.new\n end",
"def setup\n self.parse() # load file\n puts(\"+Constructing a total of (#{@groups.keys.size}) Groups:\") if @verbose\n @groups.each_value do |grp|\n grp.displaylist = glGenLists( 1 )\n glNewList(grp.displaylist, GL_COMPILE )\n puts(\" * \\\"#{grp.name}\\\" : Faces(#{grp.faces.size}) openGL draw list cached.\") if @verbose\n grp.gl_draw_list(self) # create precahced draw operation\n glEndList()\n end\n puts(\"+Total Count of Faces: [ #{self.get_face_count} ]\") if @verbose\n # display materials information\n puts(\"+Material Lib: \\\"#{material_lib}\\\" with (#{@current_materials.size}) Name Refrences.\") if @verbose\n end",
"def data_load\r\n unless $data_actors\r\n $data_actors = _clean_name_utf8(load_data(\"Data/Actors.rxdata\"))\r\n $data_classes = _clean_name_utf8(load_data(\"Data/Classes.rxdata\"))\r\n $data_enemies = _clean_name_utf8(load_data(\"Data/Enemies.rxdata\"))\r\n $data_troops = _clean_name_utf8(load_data(\"Data/Troops.rxdata\"))\r\n $data_tilesets = _clean_name_utf8(load_data(\"Data/Tilesets.rxdata\"))\r\n $data_common_events = _clean_name_utf8(load_data(\"Data/CommonEvents.rxdata\"))\r\n $data_system = load_data_utf8(\"Data/System.rxdata\")\r\n end\r\n $game_system = Game_System.new\r\n $game_temp = Game_Temp.new\r\n end"
] | [
"0.73748857",
"0.6818352",
"0.6765243",
"0.65569055",
"0.65507984",
"0.65133375",
"0.64690095",
"0.6439903",
"0.640616",
"0.6393699",
"0.6378587",
"0.63523334",
"0.63146687",
"0.63107437",
"0.6303703",
"0.6258151",
"0.624342",
"0.62359524",
"0.6231693",
"0.62161237",
"0.6206773",
"0.6183993",
"0.61839074",
"0.6180994",
"0.6175307",
"0.6174755",
"0.6163957",
"0.61605436",
"0.61425316",
"0.611644",
"0.6115294",
"0.6111125",
"0.611013",
"0.6104451",
"0.60629374",
"0.60516125",
"0.59909153",
"0.5990785",
"0.59837383",
"0.59798205",
"0.59669244",
"0.59440404",
"0.59426665",
"0.59280044",
"0.5925935",
"0.5924171",
"0.59215426",
"0.5921257",
"0.5915185",
"0.59139496",
"0.5905473",
"0.5893415",
"0.58873355",
"0.5886803",
"0.5885666",
"0.58804476",
"0.58765566",
"0.5873021",
"0.5868981",
"0.5868548",
"0.5858949",
"0.5850516",
"0.58333755",
"0.5817203",
"0.58149916",
"0.58005416",
"0.57697546",
"0.5769589",
"0.5763741",
"0.57611424",
"0.57605",
"0.5754671",
"0.5750613",
"0.5750186",
"0.57458",
"0.5744919",
"0.5737598",
"0.57366085",
"0.5736213",
"0.5731865",
"0.5727863",
"0.5725035",
"0.5721275",
"0.57177705",
"0.5715058",
"0.5714002",
"0.5712185",
"0.57108974",
"0.5702924",
"0.5697176",
"0.5695733",
"0.5693863",
"0.5687272",
"0.568617",
"0.5682186",
"0.5679218",
"0.5678658",
"0.56774145",
"0.56752473",
"0.5670502"
] | 0.5770501 | 66 |
Validates item is in room Removes item from room and adds to players backpack | def take_item(command)
if @current_room.has_item?(command) # item isn't in current room
self.new_current_item(command)
# Remove from room and add to backpack
@current_room.remove_item(command)
@player.pick_up(command)
puts "\nYou have picked up a #{@current_item.name}"
puts @current_item.collect_description + "\n\n"
else
puts "This item isn't here\n"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_item(item)\n #this will take an item from the hero's inventory and place it in the current room\n end",
"def remove_from_gamespace\n # remove it from the room it's in.\n self.from_room \n self.recycle \n # Possibly in the future return all switches. I.e. an admin taking over an NPC body.\n end",
"def pick_up(item_name)\n if current_room.has_item(item_name)\n item = current_room.items.find { |thing| thing.name == item_name }\n @player.add_to_inventory(item)\n current_room.remove_one(item)\n else\n puts \"Sorry, that item is not in this room. Try again.\"\n end\n end",
"def remove(item)\n pos = position_of(item)\n if pos\n @inventory.remove(item)\n @equipment[pos][item.layer] = nil\n item.info.delete_field :equipment_of\n item.container = @player\n true\n else\n false\n end\n end",
"def update_rooms\n Room.find_or_create_by(name: @moving_item.room)\n end",
"def find_and_delete_items_for_room\n Item.where({\"room_id\" => self.id}).delete_all\n end",
"def remove_item(item)\n if !@item\n log(\"Nothing is equipped in that EquipSlot.\")\n return\n end\n if @item != item\n log(\"Item being removed from EquipSlot is not the same as already equipped item.\")\n return\n end\n @item = nil if @item == item\n return\n end",
"def take(item_name)\n if current_room.npc && current_room.npc.has_item(item_name)\n npc_item = item_to_take(item_name)\n @player.add_to_inventory(npc_item)\n # this just doesn't seem to remove the item from NPC inventory no matter what I do :(\n current_room.npc.remove_from_inventory(npc_item)\n else\n puts \"Sorry, that item isn't here.\"\n end\n end",
"def unequip_item\n\t\tself.equiped = false\n\t\tself.save\n\tend",
"def remove(item, position = nil)\n result = @equipment.remove(item)\n\n if result\n @inventory.add(item)\n true\n else\n false\n end\n end",
"def dispose_item(item)\n if self == item.owner\n equipments.delete(item.in_slot) if EquipmentSlots.include? item.in_slot\n item.destroy\n # TODO: notify\n end\n end",
"def unlock_armoire\n if @house.find_room(:bedroom).inventory.include?(\"key\") && (@level == 1)\n @house.delete_item(\"armoire\")\n @house.create_item(\"armoire\", \"This armoire is unlocked. Hey, when you look inside it, you see a secret room extending to the west. Spooky.\", 30)\n @house.find_room(:bedroom).links[:west] = :secret_room\n @house.last_move_message = \"You took the key out of your pack and it fit the armoire!\"\n @level+=1\n end\n end",
"def on_item_ok\n return back_to_items if (item = @item_window.item).nil?\n $game_party.lose_item(item, 1)\n @unit_item_list.tb_unit.gain_item(item, 1)\n TactBattleManager.store_unit_item(@actor.id, item)\n back_to_items\n end",
"def wear(item, position = nil)\n if position\n position = sym(position)\n else\n position = item.position\n end\n\n position = find_empty_position(item, position)\n\n return nil if position.nil?\n\n container = $manager.get_object(item.container)\n\n if container and not container.is_a? Player\n container.remove(item)\n end\n\n item.container = nil\n\n @equipment[position] ||= []\n @equipment[position][item.layer] = item.goid\n @inventory << item\n item.info.equipment_of = @player\n end",
"def unit_item_ok\n return refresh_items if @unit_item_list.tb_unit.nil?\n @unit_item_list.activate\n return if (item = @unit_item_list.item).nil?\n @unit_item_list.tb_unit.lose_item(item, 1) \n TactBattleManager.rm_unit_item(@actor.id, item)\n $game_party.gain_item(item, 1)\n refresh_items\n end",
"def valid_item\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n @active_battler.current_action.clear\n @active_battler.current_action.set_item(@item.id)\n if @item.for_dead_friend? and !$game_system.actors_bodies? \n if $game_map.passable?(@cursor.x, @cursor.y, 0) and\n (occupied_by?(@cursor.x, @cursor.y) == nil)\n open_revive_window\n end\n else\n @active_battler.current_action.set_item(@item.id)\n @targets = get_targets\n if @targets.empty?\n Sound.play_buzzer\n else\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Item) \n @windows[Win_Status].dmg_preview(3, @active_battler, @item, @targets)\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n end\n end\n end",
"def unequip_item(item)\n pair = @outfit.detect { |type, value| value.name.casecmp(item.to_s).zero? }\n if pair\n # On a successful find, the \"detect\" method always returns\n # an array of length 2; thus, the following line should not fail.\n item = pair[1]\n item.unequip(self)\n add_item(item)\n else\n print NOT_EQUIPPED_ERROR\n end\n end",
"def get_item\n \n if active_character\n item = Item.find(params[:item][:id])\n position = params[:item][:container_position]\n \n # swap any existing item in same position\n prev_item = active_character.inventory.find(:first, :conditions => {:container_position => position})\n \n if item.owner == active_character\n if prev_item\n prev_item.container_position = item.container_position\n prev_item.save\n end\n \n item.container_position = position\n item.save\n elsif item.owner == active_character.area\n area = active_character.area\n \n if prev_item\n prev_item.owner = area\n prev_item.save\n \n render_to_area area do |page|\n page.call :addEvent, \"#{h current_user} has dropped #{h prev_item.name}!\"\n page.call 'game.updateDisplayable', prev_item.css_id, prev_item.left, prev_item.top\n end\n end\n \n item.owner = active_character\n item.container_position = position\n item.save\n # Update all clients in area\n render_to_area area do |page|\n page.call :addEvent, \"#{h active_character.name} has picked up #{h item.name}!\"\n page.call :got_item, item.css_id, active_character.id\n end\n end\n end\n \n render :nothing => true\n end",
"def remove_item\n\n end",
"def remove_item\n if [email protected]_answers && @item.ok && @question.items.count > 1\n # No more good answer\n # We put one in random to true\n @item.destroy\n @item2 = @question.items.last\n @item2.ok = true\n @item2.save\n flash[:info] = \"Vous avez supprimé une réponse correcte : une autre a été mise correcte à la place par défaut.\"\n else\n @item.destroy\n end\n redirect_to question_manage_items_path(params[:question_id])\n end",
"def validate \r\n self.room.strip!\r\n self.room = nil if self.room !~ /\\S/\r\n end",
"def pbWithdrawItemScreen\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n @scene.pbStartScene(storage)\n loop do\n item = @scene.pbChooseItem\n break if item==0\n commands = [_INTL(\"Withdraw\"),_INTL(\"Give\"),_INTL(\"Cancel\")]\n itemname = PBItems.getName(item)\n command = @scene.pbShowCommands(_INTL(\"{1} is selected.\",itemname),commands)\n if command==0 # Withdraw\n qty = storage.pbQuantity(item)\n if qty>1 && !pbIsImportantItem?(item)\n qty = @scene.pbChooseNumber(_INTL(\"How many do you want to withdraw?\"),qty)\n end\n if qty>0\n if [email protected]?(item,qty)\n pbDisplay(_INTL(\"There's no more room in the Bag.\"))\n else\n dispqty = (pbIsImportantItem?(item)) ? 1 : qty\n itemname = PBItems.getNamePlural(item) if dispqty>1\n pbDisplay(_INTL(\"Withdrew {1} {2}.\",dispqty,itemname))\n if !storage.pbDeleteItem(item,qty)\n raise \"Can't delete items from storage\"\n end\n if [email protected](item,qty)\n raise \"Can't withdraw items from storage\"\n end\n end\n end\n elsif command==1 # Give\n if $Trainer.pokemonCount==0\n @scene.pbDisplay(_INTL(\"There is no Jermon.\"))\n return 0\n elsif pbIsImportantItem?(item)\n @scene.pbDisplay(_INTL(\"The {1} can't be held.\",itemname))\n else\n pbFadeOutIn(99999){\n sscene = PokemonParty_Scene.new\n sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)\n if sscreen.pbPokemonGiveScreen(item)\n # If the item was held, delete the item from storage\n if !storage.pbDeleteItem(item,1)\n raise \"Can't delete item from storage\"\n end\n end\n @scene.pbRefresh\n }\n end\n end\n end\n @scene.pbEndScene\n end",
"def destroy\n super\n @area.rooms.delete self\n if @exits\n @exits.dup.each do |exit|\n exit.destroy\n end\n end\n if @entrances\n @entrances.dup.each do |entrance|\n entrance.destroy\n end\n end\n @inventory.items.dup.each do |item|\n item.destroy\n end\n if @mobiles\n @mobiles.dup.each do |mob|\n mob.destroy\n end\n end\n if @players\n @players.dup.each do |player|\n player.move_to_room(Game.instance.starting_room)\n end\n end\n @area = nil\n @exits = nil\n @inventory = nil\n @mobiles = nil\n @players = nil\n Game.instance.remove_room(self)\n end",
"def check_out(room_number, hotel)\n room = @rooms.delete(room_number)\n hotel.add_room(room)\n end",
"def use_item(command)\n if @player.has_item?(command)\n # Player is carrying item\n self.new_current_item(command)\n if @current_item.is_key? \n if @current_room == @lroom \n puts \"Congratulations! You escaped the AirBnB\"\n puts \"You escaped with a rating of: \\n\"\n puts @star1.encode('utf-8') * @score\n puts \"\\n\\n\\nThanks for playing!\\n\"\n # Write score to player scores file\n write_to_file(\"#{@score} #{@username}\",\"player_scores.txt\")\n sleep(3)\n system('clear')\n @run_game = false\n else \n puts \"You are not using this item in the correct room!\"\n end\n elsif @current_item.is_a? ScoreItem\n # Item adjusts score\n @score += @current_item.score\n if @score == 1\n # Score reaches 0\n puts \"\\nYour guest rating dropped too low.\"\n puts \"\\nThe gHost has killed you.\".colorize(:color => :white, :background => :red)\n sleep(2.5)\n system('clear')\n @run_game = false\n else\n puts \"\\n#{@current_item.use_description}\\n\\n\"\n puts \"You now have a guest rating of #{@score}\".colorize(:blue)\n puts @star1.encode('utf-8') * @score # print star rating\n @player.remove_item(command)\n end\n else \n puts \"You aren't carrying this item.\\n\"\n end\n end\n end",
"def remove_item(item)\r\n items.delete(item)\r\n item.owner = nil\r\n end",
"def remove_item\n\tsaved = current_user.saved\n\titem = saved.items.find(params[:item])\n saved.items.delete(item)\n redirect_to :back\n\tend",
"def retractItem\n if !session[:user_id]\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n end\n\n roomname = params[:retractitem][\"roomname\"]\n collectionname = params[:retractitem][\"collectionname\"]\n nodename = params[:retractitem][\"nodename\"]\n itemid = params[:retractitem][\"itemid\"]\n\n begin\n am = session[:am]\n acc = Account.find_by_username(session[:user_id])\n if(acc.nil?)\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n return\n end\n am.keepalive(acc.username, acc.password)\n\n myroominfo = am.getRoomInfo(roomname)\n if(!myroominfo.nil? and myroominfo.isConnected == true)\n result = am.retractItem(roomname, collectionname, nodename, itemid)\n flash[:result] = \"retractItem result success: \" + result + \" \" + acc.roomURL + \" \" + collectionname + \" \" + nodename + \" \" + itemid\n else\n result = \"Room is shutdown, this feature only available when room is started.\"\n flash[:notice] = result\n end\n \n redirect_to :action => 'accountManager'\n rescue Exception => msg\n flash[:notice] = msg\n end\n\n end",
"def useItem?\n # to make sure duplicates are not registered at the beginning\n Input.update\n # render bitmap for item use confirmation\n bitmap = @sprites[\"confirm\"].bitmap\n bitmap.clear; bmp = pbBitmap(@path + @confirmImg)\n bitmap.blt(0, 0, bmp, bmp.rect)\n icon = pbBitmap(GameData::Item.icon_filename(@ret))\n bitmap.blt(20, 30, icon, icon.rect)\n # draw text\n drawTextEx(bitmap, 80, 12, 364, 3, GameData::Item.get(@ret).description, @baseColor, Color.new(0, 0, 0, 32))\n # select confirm message as target\n @sprites[\"sel\"].target(@sprites[\"confirm\"])\n # animate in\n 8.times do\n # slide panels into screen\n @sprites[\"confirm\"].x += @viewport.width/8\n @sprites[\"cancel\"].x += @viewport.width/8\n if @pocket\n # fade out panels\n for i in [email protected]\n @items[\"#{i}\"].opacity -= 32\n end\n end\n for i in 0...4\n @sprites[\"pocket#{i}\"].opacity -= 64 if @sprites[\"pocket#{i}\"].opacity > 0\n end\n # animate bottom items moving off screen\n @sprites[\"pocket4\"].y += 10 if @sprites[\"pocket4\"].y < @sprites[\"pocket4\"].ey + 80\n @sprites[\"pocket5\"].y += 10 if @sprites[\"pocket5\"].y < @sprites[\"pocket5\"].ey + 80\n @sprites[\"name\"].x -= @sprites[\"name\"].width/8\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # ensure pocket name is off screen\n @sprites[\"name\"].x = -@sprites[\"name\"].width\n index = 0; oldindex = 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n # start the main input loop\n loop do\n @sprites[\"#{choice}\"].src_rect.y += 1 if @sprites[\"#{choice}\"].src_rect.y < 0\n # process directional input\n if Input.trigger?(Input::UP)\n index -= 1\n index = 1 if index < 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n elsif Input.trigger?(Input::DOWN)\n index += 1\n index = 0 if index > 1\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n end\n # process change in index\n if index != oldindex\n oldindex = index\n pbSEPlay(\"EBDX/SE_Select1\")\n @sprites[\"#{choice}\"].src_rect.y -= 6\n @sprites[\"sel\"].target(@sprites[\"#{choice}\"])\n end\n # confirmation and cancellation input\n if Input.trigger?(Input::C)\n pbSEPlay(\"EBDX/SE_Select2\")\n break\n elsif Input.trigger?(Input::B)\n @scene.pbPlayCancelSE()\n index = 1\n break\n end\n Input.update\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # animate exit\n 8.times do\n @sprites[\"confirm\"].x -= @viewport.width/8\n @sprites[\"cancel\"].x -= @viewport.width/8\n @sprites[\"pocket5\"].y -= 10 if index > 0\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # refresh old UI (swap cursor to target)\n self.refresh\n # return output\n if index > 0\n @ret = nil\n return false\n else\n @index = 0 if @index == 4 && GameData::Item.get(@lastUsed).id_number == 0\n return true\n end\n end",
"def delete_object(game_object)\n leave_in_room = nil\n\n #See if we need to drop anything the object is holding\n unless game_object.container.nil?\n container = @game_objects.find_by_id(game_object.container)\n unless container.nil?\n if container.is_a? Container\n container.remove game_object\n else\n container.inventory.remove(game_object)\n end\n if container.can? :equipment\n container.equipment.delete game_object\n end\n if container.is_a? Room\n container.remove(game_object)\n leave_in_room = container\n end\n end\n end\n\n if game_object.info.equipment_of\n container = @game_objects.find_by_id(game_object.info.equipment_of)\n container.equipment.delete game_object.goid unless container.nil?\n end\n\n if leave_in_room.nil?\n leave_in_room = @game_objects.find('Garbage Dump', Room)\n end\n\n if game_object.can? :inventory\n game_object.inventory.each do |o|\n if leave_in_room\n leave_in_room.add(o)\n o.container = leave_in_room.goid\n end\n end\n end\n\n if game_object.can? :equipment\n game_object.equipment.each do |o|\n game_object.equipment.remove o\n if leave_in_room\n leave_in_room.add o\n o.container = leave_in_room.goid\n end\n end\n end\n\n @game_objects.remove(game_object)\n\n @storage.delete_object(game_object)\n game_object = nil\n end",
"def remove_guest_from_room()\n @room.remove_guest_from_room\n assert_equal(2, @room.count_occupants)\n end",
"def unequip_slot(slot)\n if(equipped_item = equipped_items.first(:conditions => {:slot => slot}))\n equipped_item.unequip!\n else\n true\n end\n end",
"def vacate_room(room)\n room.occupied = 0\n end",
"def set_room_item\n @room_item = RoomItem.find(params[:id])\n end",
"def remove_item_verify\n\n\t\twait_for_animate\n\t\tvalue3= query(\"* marked:'quantityText'\", :text)[0]\n\t\tguide_price3 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity Before remove Item : : #{value3}\"\n\t\ttouch(\"* id:'remove_btn'\")\n\t\twait_for_animate\n\t\tsleep 4\n\t\t#wait_for_elements_exist( [\"button marked:'Open basket'\"], :timeout => 40)\n\t\tvalue4 = query(\"* marked:'quantityText'\", :text)[0]\n\t\tguide_price4 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Values guide price & Quantity(remove :After) : #{guide_price4} #{value4}\"\n\t\tputs \"Count guide price #{guide_price4}\"\n\t\tputs \"Quantity campare\"\n\t\tcampare_values(value3, value4)\n\t\t# puts \"guideprice campare\"\n\t\t# campare_values(guide_price3,guide_price4)\n\t\t#puts \"Item added successfully\"\n\tend",
"def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end",
"def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end",
"def free item\n item.order_book.remove item if item.order_book\n end",
"def discard_equip(item)\n slot_id = equips.index(item)\n @equips[slot_id].object = nil if slot_id\n end",
"def remove_guest_from_room(guest)\n @guest_list.delete(guest)\nend",
"def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end",
"def server_leave(client, body)\n return nil unless @rooms[body]\n return nil unless @rooms[body].include?(client.name)\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"presence leave #{client.name}#{body}\")\n ) { |x| @rooms[body].include?(x.name) }\n @rooms[body].delete client.name\n if @rooms[body].empty?\n @rooms.delete body\n @motd.delete body\n end\nend",
"def release_item(item)\r\n if self.items.include?(item)\r\n item.owner = nil\r\n self.items.delete(item)\r\n end\r\n end",
"def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n $game_temp.select_data == nil\n # play buzzer, can't use\n $game_system.se_play($data_system.buzzer_se)\n end\n # stop input update\n return true\n end",
"def reserve_room\n unless rooms_available?\n raise NoRoomsError.new(\"All rooms are reserved.\")\n end\n room = @available_rooms.pop\n @reserved_rooms << room\n return room\n end",
"def pickUp( char, map )\n addToInventory( char )\n if map then\n map.removeItem( self )\n end\n end",
"def remove item\n @components.remove item\n end",
"def fix_items\n valid_items = EquipmentModel.where(id: items.keys).collect(&:id)\n self.items = items.select { |em, _count| valid_items.include? em }\n end",
"def lose_template_item(item, include_equip)\n container_list = item_container_list(item)\n item_lost = container_list.find {|obj| obj.template_id == item.template_id }\n if item_lost\n container = item_container(item.class)\n container[item.template_id] ||= 0\n container[item.template_id] -= 1\n container_list.delete(item_lost)\n elsif include_equip\n discard_members_template_equip(item, 1)\n end\n return item_lost\n end",
"def destroy\n @room_item.destroy\n respond_to do |format|\n format.html { redirect_to room_items_url, notice: \"Room item was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def addItem\n begin\n ProgrammeItem.transaction do\n @assignment = nil\n if !params[:cancel]\n item = ProgrammeItem.find(params[:itemid])\n room = Room.find(params[:roomid])\n day = params[:day]\n time = params[:time].to_time # The start time\n\n @assignment = addItemToRoomAndTime(item, room, day, time)\n end\n\n render :layout => 'content'\n end\n rescue => ex\n render status: :bad_request, text: ex.message\n end\n end",
"def reset_game\n @current_room_id = 9\n find_room_by_id(9).isLocked = true\n find_item_by_id(8).show_item = false\n @inventory.delete(8)\n @talk_id = 18\n end",
"def remove_from\n begin\n study = Study.find(params[:study_id])\n unless study.user_id != session[:user_id] || study.active\n params[:items].each do |i|\n item = Item.find(i)\n unless item.study_id != params[:study_id].to_i\n item.destroy\n end\n end\n end\n rescue\n \n ensure\n redirect_to(edit_study_path(params[:study_id]))\n end\n end",
"def cleanRoom\n session[:room] = nil\n end",
"def add_item_to_the_room\n @item = Item.find(params[:id])\n @room = Room.find(params[:room_id])\n \n @item.rooms << @room\n \n render json: @item, include: :rooms\n\n end",
"def inventory_item_is_available\n \tif self.inventory_item.present? && self.inventory_item.is_available?(project.rental_delivery, project.rental_pickup) == false\n \t\terrors.add(:inventory_item, \"is not available within this project's duration\")\n \telsif self.inventory_item.blank?\n \t\tself.inventory_item = inventory_style.find_available(project.rental_delivery, project.rental_pickup)\n \t\terrors.add(:inventory_style, \"has no available items within this project's duration\") if self.inventory_item.blank?\n \tend\n end",
"def remove_region_item(opts)\n opts = check_params(opts,[:items])\n super(opts)\n end",
"def use(item_name)\n # TODO: figure out how to pass around entire item object to access effects anywhere\n if @player.has_item(item_name) && current_room.npc && current_room.npc.has_item(item_name)\n effect = current_room.npc.inventory.select { |i| i.name == item_name }.first.effects\n puts effect\n @player.remove_from_inventory(item_name)\n # TODO: eventually remove from NPC inventory & change ownership of item\n elsif @player.has_item(item_name) && current_room.has_item(item_name)\n effect = current_room.items.find { |i| i.name == item_name }.effects\n puts effect\n @player.remove_from_inventory(item_name)\n # TODO: eventually remove from Room inventory & change ownership of item\n else\n puts \"Sorry, that item is not in your inventory. Did you pick it up or try taking it from someone?\"\n end\n end",
"def update_item\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to menu screen\n $scene = Scene_Menu.new(1)\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the item window\n @item = @item_window.item\n # If not a use item\n unless @item.is_a?(RPG::Item)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # If it can't be used\n unless $game_party.item_can_use?(@item.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # If effect scope is an ally\n if @item.scope >= 3\n use_item\n # If effect scope is other than an ally\n else\n # If command event ID is valid\n if @item.common_event_id > 0\n # Command event call reservation\n $game_temp.common_event_id = @item.common_event_id\n # Play item use SE\n $game_system.se_play(@item.menu_se)\n # If consumable\n if @item.consumable\n # Decrease used items by 1\n $game_party.lose_item(@item.id, 1)\n # Draw item window item\n @item_window.draw_item(@item_window.index)\n end\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n end\n return\n end\n end",
"def room4\n #state 1 = new\n #state 2 = axe not taken\n #state 3 = axe taken\n if @room4 == 1\n @room4 = 2\n end\n\n puts 'You are in a small round room, with lots of rock and debris. There is an open doorway to the east'\n\n while true\n\n cmd = take_input\n\n if cmd.include? 'help'\n help\n elsif cmd.include? 'exit'\n exit_game\n elsif cmd.include? 'inventory'\n list_inventory\n elsif cmd.include? 'look'\n puts 'You are in a small circular room full of dirt and debris. There is a passageway to the east.'\n if @room4_items.include? 'pickaxe'\n puts 'You see something shiny among the debris.'\n end \n elsif cmd.include? 'rock' or cmd.include? 'debris'\n if @room4_items.include? 'pickaxe'\n puts 'You kick the debris around with your feet and reveal a pickaxe on the ground.'\n else\n puts 'You kick around the debris but can\\'t find anything else.'\n end\n elsif cmd.include? 'use'\n puts 'You can\\'t use that here.'\n elsif cmd.include? 'axe'\n if @room4_items.include? 'pickaxe'\n puts 'You take the pickaxe'\n @inventory.push('pickaxe')\n @room4_items.delete('pickaxe')\n @room4 = 3\n else\n puts 'You already took the pickaxe'\n end\n elsif cmd.include? 'east'\n room3\n else\n invalid_action\n end\n end\nend",
"def release_item(item)\n if self.items.include?(item)\n item.owner = nil\n self.items.delete(item)\n end\n end",
"def set_room_is_clean(room)\n room.clean = 1\n end",
"def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end",
"def remove_item_from_order(id)\n return unless @items[id] <= 0\n\n get_order(GameData::Item[id].socket).delete(id)\n end",
"def usable?(item)\n return false if item.nil?\n tb = battler\n return tb.usable?(item) # tb.is_a?(Game_Actor) ? <- : false\n end",
"def remove\n if @item.quantity == 1\n @item.destroy!\n else\n @item.decrement(:quantity)\n @item.save!\n end\n\n refresh\n end",
"def unequip(item_name)\n\t\tif item_name == \"weapon\"\n\t\t\[email protected] = nil\n\t\telsif @player.weapon && item_name.downcase == @player.weapon.name.downcase\n\t\t\[email protected] = nil\n\t\telsif @player.armour.keys.include?(item_name.to_sym)\n\t\t\[email protected][item_name.to_sym] = nil\n\t\telse\n\t\t\tputs \"usage: unequip (weapon or piece of armour)\"\n\t\tend\n\tend",
"def consume_item(item)\n if item.is_a?(RPG::Item) and item.consumable\n lose_item(item, 1)\n end\n end",
"def pbTossItemScreen\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n @scene.pbStartScene(storage)\n loop do\n item = @scene.pbChooseItem\n break if item==0\n if pbIsImportantItem?(item)\n @scene.pbDisplay(_INTL(\"That's too important to toss out!\"))\n next\n end\n qty = storage.pbQuantity(item)\n itemname = PBItems.getName(item)\n itemnameplural = PBItems.getNamePlural(item)\n if qty>1\n [email protected](_INTL(\"Toss out how many {1}?\",itemnameplural),qty)\n end\n if qty>0\n itemname = itemnameplural if qty>1\n if pbConfirm(_INTL(\"Is it OK to throw away {1} {2}?\",qty,itemname))\n if !storage.pbDeleteItem(item,qty)\n raise \"Can't delete items from storage\"\n end\n pbDisplay(_INTL(\"Threw away {1} {2}.\",qty,itemname))\n end\n end\n end\n @scene.pbEndScene\n end",
"def remove_have\n if params[:id].present? and params[:remove_have].present?\n if params[:from_haves_tab] == 'true'\n @user = current_user\n # @have_items = @user.items\n item = Item.find_by_id_and_user_id(params[:id],current_user.id)\n if item.present?\n # item.destroy\n item.update_attribute(\"status\",\"DELETED\")\n end\n flash[:info] = \"Item has been removed from your Haves Board .\"\n redirect_to haves_user_path(@user, :delete => item.id)\n # elsif params[:from_my_offers_tab] == 'true'\n # @user = current_user\n # @have_items = @user.have_items\n # item = Item.find_by_id_and_user_id(params[:id],current_user.id)\n # item.destroy\n # params[:id] = params[:original_id]\n # @item = Item.find_by_id(params[:id])\n # @offer_ids = @item.current_offers.pluck(:offer_id)\n # @useritems = @user.items\n # @useritem_ids = @useritems.pluck(:id)\n # elsif params[:from_items_index] == 'true'\n # # item = Item.find_by_id(params[:id])\n # # item.destroy\n # respond_to do |format|\n # format.js\n # format.html { redirect_to items_path}\n # end\n end\n end\n end",
"def item_usable?\n return false unless @item\n return @actor ? @actor.usable?(@item) : $game_player.usable?(@item)\n end",
"def remove_from_playlist\n errors.clear\n if self.new_record?\n errors.add(:base, :problem_removing_from_playlist)\n return false\n end\n return true if !self.in_playlist?\n resp = false\n my_position = self.position\n ActiveRecord::Base.transaction do\n self.position = nil\n if !self.save\n errors.add(:base, :problem_removing_from_playlist)\n raise ActiveRecord::Rollback\n end\n VirtualClassroomLesson.where('user_id = ? AND position > ?', self.user_id, my_position).order(:position).each do |vcl|\n vcl.position -= 1\n if !vcl.save\n errors.add(:base, :problem_removing_from_playlist)\n raise ActiveRecord::Rollback\n end\n end\n resp = true\n end\n resp\n end",
"def remove!\n self.class.removed(item)\n end",
"def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end",
"def garbage_check(id)\n\t return room == id || inv.include?(id)\n\tend",
"def remover_item\n # Remove um item do final do buffer\n BUFFER.pop\n end",
"def remove_item\n part = Part.find(params[:part_id])\n order = Order.find(params[:order_id])\n respond_to do |format|\n if part && order\n list_item = PartsInOrder.find_by({part_id: part.id, order_id: order.id})\n if list_item\n list_item.destroy!\n msg = { :status => \"ok\", :message => \"Success!\"}\n format.json { render json: msg }\n else\n msg = { :status => \"error\", :message => \"This Part is not in this order!\"}\n format.json { render json: msg }\n end\n else\n msg = { :status => \"error\", :message => \"Missing Part or Order in the DB!\"}\n format.json { render json: msg }\n end\n end\n end",
"def leave_unoccupied\n vehicle = self.vehicle\n if mark_free(-1)\n if vehicle.present?\n vehicle.update_attributes!(slot_id: nil)\n end\n end\n end",
"def release_room(type, number)\n select_room_flag = false\n @rooms.each_with_index do |room, i|\n if room[:type].downcase == type.downcase\n select_room_flag = true\n if room[:booked].to_i < number.to_i\n puts \"Sorry Wrong Input\"\n else\n puts \"Congratulation you have sccesfully checked out #{number} #{room[:type]}\"\n @rooms[i][:booked] = room[:booked].to_i - number.to_i\n end\n end\n end\n puts \"Sorry Please enter the correct room type\" if select_room_flag === false\n end",
"def clear_dead_pokemon\n dead_condition = proc { |pokemon| pokemon.hp <= 0 }\n # List all the items from dead Pokemon\n item_ids = $actors.select(&dead_condition).map(&:item_hold)\n # Add items back to the bag\n item_ids.each { |item_id| $bag.add_item(item_id, 1) if item_id >= 0 }\n # Storing Pokemon that are dead\n graveyard.concat($actors.select(&dead_condition))\n # Remove Pokemon from the party\n $actors.delete_if(&dead_condition)\n end",
"def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n\r\n puts \"User chose item #{ItemService.item_sym_of(id)}\"\r\n @pedestal.pedestal_item_id = id\r\n\t\t\t$game_party.gain_item(rmxp_item_id, -1)\r\n\r\n SetupEventService.new.setup!\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end",
"def remove(type, thing, quantity=0)\n\n missing_type_error = \"We could not find #{type} as a type! Please try again.\"\n missing_item_error = \"#{thing} does not exist in your list under #{type}.\"\n wrong_quantity_error = \"You tried to delete more #{thing} than you have. #{thing} has been removed from the list.\"\n\n # Checks if type exists in list\n puts missing_type_error if [email protected]_key?(type)\n return false if [email protected]_key?(type)\n\n\n list = @items[type]\n\n # Removes the item by quantity depending on Array or Hash type\n if list.is_a? Array then\n if list.include?(thing) then\n list.delete(thing)\n return true\n else\n puts missing_item_error\n return false\n end\n elsif list.has_key?(thing) then\n if list[thing] < quantity then\n list.delete(thing)\n puts wrong_quantity_error\n return false\n else\n list[thing] -= quantity\n return true\n end\n else\n puts missing_item_error\n return false\n end\n end",
"def cleanup_empty_room(room)\n # dump_round_vars 'Entering cleanup_empty_room()'\n # if !@@prev_round[room].nil?\n # finalize_round(@@prev_round[room]) # ...finalize any previous round\n # @@prev_round[room] = nil\n # end\n # if !@@curr_round[room].nil?\n # finalize_round(@@curr_round[room]) # ...finalize any in-progress round\n # # @@curr_round[room] = nil\n # end\n # dump_round_vars '', 'Exiting cleanup_empty_room()'\n end",
"def someone_left_room(&block)\n presence(:from => Regexp.new(\"^\"+Blather::JID.new(room_jid).to_s+\".*\"), :type => :unavailable, &block)\n end",
"def remove_mtg_cards\n reservation = Mtg::Reservation.find(params[:id])\n unless current_cart.remove_mtg_listing(reservation, params[:quantity].to_i) # remove this listing from cart\n flash[:error] = \"there was a problem processing your request\"\n redirect_to back_path\n return\n end\n redirect_to back_path, :notice => \"Item(s) removed!\"\n return #stop method, don't display a view\n end",
"def release_unequippable_items(item_gain = true)\n loop do\n last_equips = equips.dup\n @equips.each_with_index do |item, i|\n if !equippable?(item.object) || !etype_can_equip?(i, item.object)\n trade_item_with_party(nil, item.object) if item_gain\n item.object = nil\n end\n end\n return if equips == last_equips\n end\n end",
"def dressing_room_item_id=(value)\n self[:dressing_room_item_id] = value\n @dressing_room_item = nil\n end",
"def remove_item(items, groceries_list)\n groceries_list.delete(items)\nend",
"def room_item_params\n params.fetch(:room_item, {})\n end",
"def drop(object)\n\t\t\traise GreyGoo::Error, \"You don't have that object\" if !has?(object)\n\t\t\tcurrent_room.take(object)\n\t\t\tself.reload # because the object's parent has lost the object, not us\n\t\tend",
"def destroy\n @user = User.find(params[:id])\n\n if !session[:user_id]\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n end\n\n item = Item.find_by_id(@user.item_id)\n node = Node.find_by_id(item.node_id)\n collection = Collectionnode.find_by_id(node.collectionnode_id)\n room = Room.find_by_id(collection.room_id)\n roomname = room.roomName\n collectionname = collection.sharedID\n nodename = node.name\n itemid = item.itemID\n\n begin\n am = session[:am]\n acc = Account.find_by_username(session[:user_id])\n if(acc.nil?)\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n return\n end\n am.keepalive(acc.username, acc.password)\n\n myroominfo = am.getRoomInfo(roomname)\n if(!myroominfo.nil? and myroominfo.isConnected == true)\n result = am.retractItem(roomname, collectionname, nodename, itemid)\n flash[:result] = \"retractItem result success: \" + result + \" \" + acc.roomURL + \" \" + collectionname + \" \" + nodename + \" \" + itemid\n else\n result = \"Room is shutdown, this feature only available when room is started.\"\n flash[:notice] = result\n end\n\n \n rescue Exception => msg\n flash[:notice] = msg\n end\n\n\n @user.destroy\n\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end",
"def remove_item(item)\n @items.delete(item)\n end",
"def remove_item(grocery_list, item)\r\n\tgrocery_list.delete(item)\r\n\tgrocery_list\r\nend",
"def updateRoom\n @room = Room.find(params[:id])\n @battle = Battle.where(id: @room.battle_id)\n @user = current_user\n \n if params[:invested]\n @room.invested = BigDecimal(params[:invested])\n @room.total = @room.bank + @room.invested\n \n \n respond_to do |format|\n format.json {render :json => @room.total}\n end\n return\n \n end\n\n if params[:enemy_invested]\n \n @battle[0].users.each do |u|\n if u.id != @user.id\n @enemy = u\n @enemyRoom = Room.where(user_id: @enemy, battle_id: @battle[0].id)\n end\n end\n\n \n @room.enemy_invested = BigDecimal(params[:enemy_invested])\n @room.enemy_bank = @enemyRoom[0].bank\n @room.enemy_total = @room.enemy_bank + @room.enemy_invested\n\n respond_to do |format|\n format.json {render :json => @room.enemy_total}\n end\n return\n \n end\n\n if @room.save\n #session[:room] = @room.id\n #get all names in wallet then remove duplicates\n redirect_to(battle_path(@room.battle_id))\n \n end\n end",
"def add(item)\n item.available? ? items.create(cartable: item) : false\n release\n end",
"def wear(item, position = nil)\n result = @equipment.check_position(item, position)\n\n if result\n self.output(result)\n return false\n end\n\n result = @equipment.wear(item, position)\n\n if result\n @inventory.remove(item)\n true\n else\n false\n end\n end",
"def pick_up(item)\n expected_weight = items_weight + item.weight\n if expected_weight <= 250\n item.is_a?(Weapon) ? @equipped_weapon = item : items << item \n else\n return false\nend\nend",
"def add_item(item)\n if @item\n log(\"Item is already equipped in EquipSlot.\")\n return\n end\n @item = item\n return\n end",
"def set_room_is_dirty(room)\n room.clean = 0\n end",
"def remove_item(item)\n\t$grocery_list.delete(item)\n\tp \"You crossed off #{item} from your list.\"\nend"
] | [
"0.69065285",
"0.6767096",
"0.67458135",
"0.6603359",
"0.6277711",
"0.6174731",
"0.6172688",
"0.6087252",
"0.6060096",
"0.6024024",
"0.60207987",
"0.59822786",
"0.5825139",
"0.5798893",
"0.5798189",
"0.57874787",
"0.5768507",
"0.57216734",
"0.5717968",
"0.57084304",
"0.5702674",
"0.56909364",
"0.5690726",
"0.5634693",
"0.5622153",
"0.5604028",
"0.55772203",
"0.55768156",
"0.5563497",
"0.5559306",
"0.5549367",
"0.55317557",
"0.55302143",
"0.5512104",
"0.5511035",
"0.5492815",
"0.54911804",
"0.54826695",
"0.54763484",
"0.54763",
"0.5472038",
"0.5463417",
"0.5459429",
"0.54554033",
"0.544972",
"0.54433745",
"0.5442391",
"0.544031",
"0.5432498",
"0.54324496",
"0.5431309",
"0.54212826",
"0.5407873",
"0.5393592",
"0.53895193",
"0.53842336",
"0.53762114",
"0.53682834",
"0.5361288",
"0.53443825",
"0.53442854",
"0.533989",
"0.53371346",
"0.53251445",
"0.53247505",
"0.5324617",
"0.5322747",
"0.53162104",
"0.53114694",
"0.53090954",
"0.5299373",
"0.5288444",
"0.5282365",
"0.52812386",
"0.52811605",
"0.52806556",
"0.5274798",
"0.5274724",
"0.5264748",
"0.526463",
"0.52634495",
"0.5258294",
"0.52555025",
"0.5244241",
"0.5243518",
"0.5243122",
"0.5242459",
"0.52415496",
"0.5240655",
"0.5238895",
"0.5237385",
"0.5236761",
"0.5228521",
"0.521907",
"0.5217683",
"0.5217508",
"0.52093786",
"0.51990473",
"0.5198969",
"0.5193922"
] | 0.6196508 | 5 |
Validates item is in backpack and depending on item type either adjusts score or finishes game | def use_item(command)
if @player.has_item?(command)
# Player is carrying item
self.new_current_item(command)
if @current_item.is_key?
if @current_room == @lroom
puts "Congratulations! You escaped the AirBnB"
puts "You escaped with a rating of: \n"
puts @star1.encode('utf-8') * @score
puts "\n\n\nThanks for playing!\n"
# Write score to player scores file
write_to_file("#{@score} #{@username}","player_scores.txt")
sleep(3)
system('clear')
@run_game = false
else
puts "You are not using this item in the correct room!"
end
elsif @current_item.is_a? ScoreItem
# Item adjusts score
@score += @current_item.score
if @score == 1
# Score reaches 0
puts "\nYour guest rating dropped too low."
puts "\nThe gHost has killed you.".colorize(:color => :white, :background => :red)
sleep(2.5)
system('clear')
@run_game = false
else
puts "\n#{@current_item.use_description}\n\n"
puts "You now have a guest rating of #{@score}".colorize(:blue)
puts @star1.encode('utf-8') * @score # print star rating
@player.remove_item(command)
end
else
puts "You aren't carrying this item.\n"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n $game_temp.select_data == nil\n # play buzzer, can't use\n $game_system.se_play($data_system.buzzer_se)\n end\n # stop input update\n return true\n end",
"def useItem?\n # to make sure duplicates are not registered at the beginning\n Input.update\n # render bitmap for item use confirmation\n bitmap = @sprites[\"confirm\"].bitmap\n bitmap.clear; bmp = pbBitmap(@path + @confirmImg)\n bitmap.blt(0, 0, bmp, bmp.rect)\n icon = pbBitmap(GameData::Item.icon_filename(@ret))\n bitmap.blt(20, 30, icon, icon.rect)\n # draw text\n drawTextEx(bitmap, 80, 12, 364, 3, GameData::Item.get(@ret).description, @baseColor, Color.new(0, 0, 0, 32))\n # select confirm message as target\n @sprites[\"sel\"].target(@sprites[\"confirm\"])\n # animate in\n 8.times do\n # slide panels into screen\n @sprites[\"confirm\"].x += @viewport.width/8\n @sprites[\"cancel\"].x += @viewport.width/8\n if @pocket\n # fade out panels\n for i in [email protected]\n @items[\"#{i}\"].opacity -= 32\n end\n end\n for i in 0...4\n @sprites[\"pocket#{i}\"].opacity -= 64 if @sprites[\"pocket#{i}\"].opacity > 0\n end\n # animate bottom items moving off screen\n @sprites[\"pocket4\"].y += 10 if @sprites[\"pocket4\"].y < @sprites[\"pocket4\"].ey + 80\n @sprites[\"pocket5\"].y += 10 if @sprites[\"pocket5\"].y < @sprites[\"pocket5\"].ey + 80\n @sprites[\"name\"].x -= @sprites[\"name\"].width/8\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # ensure pocket name is off screen\n @sprites[\"name\"].x = -@sprites[\"name\"].width\n index = 0; oldindex = 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n # start the main input loop\n loop do\n @sprites[\"#{choice}\"].src_rect.y += 1 if @sprites[\"#{choice}\"].src_rect.y < 0\n # process directional input\n if Input.trigger?(Input::UP)\n index -= 1\n index = 1 if index < 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n elsif Input.trigger?(Input::DOWN)\n index += 1\n index = 0 if index > 1\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n end\n # process change in index\n if index != oldindex\n oldindex = index\n pbSEPlay(\"EBDX/SE_Select1\")\n @sprites[\"#{choice}\"].src_rect.y -= 6\n @sprites[\"sel\"].target(@sprites[\"#{choice}\"])\n end\n # confirmation and cancellation input\n if Input.trigger?(Input::C)\n pbSEPlay(\"EBDX/SE_Select2\")\n break\n elsif Input.trigger?(Input::B)\n @scene.pbPlayCancelSE()\n index = 1\n break\n end\n Input.update\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # animate exit\n 8.times do\n @sprites[\"confirm\"].x -= @viewport.width/8\n @sprites[\"cancel\"].x -= @viewport.width/8\n @sprites[\"pocket5\"].y -= 10 if index > 0\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # refresh old UI (swap cursor to target)\n self.refresh\n # return output\n if index > 0\n @ret = nil\n return false\n else\n @index = 0 if @index == 4 && GameData::Item.get(@lastUsed).id_number == 0\n return true\n end\n end",
"def update_backstage (item)\n if item.sell_in < 11 && item.sell_in > 5\n update_quality_value(item, 2)\n elsif item.sell_in < 6 && item.sell_in > 0\n update_quality_value(item, 3)\n elsif item.sell_in > 0\n update_quality_value(item, 1)\n end\n end",
"def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end",
"def on_item_ok\n return back_to_items if (item = @item_window.item).nil?\n $game_party.lose_item(item, 1)\n @unit_item_list.tb_unit.gain_item(item, 1)\n TactBattleManager.store_unit_item(@actor.id, item)\n back_to_items\n end",
"def valid_type? item_type\n [BATTLE_ITEMS, KEY_ITEMS, INGREDIENTS, TREASURES, CAR_PARTS, LEISURE].include?(item_type)\n end",
"def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end",
"def pbItemMenu(idxBattler,_firstAction)\r\n # Fade out and hide all sprites\r\n visibleSprites = pbFadeOutAndHide(@sprites)\r\n # Set Bag starting positions\r\n oldLastPocket = $PokemonBag.lastpocket\r\n oldChoices = $PokemonBag.getAllChoices\r\n $PokemonBag.lastpocket = @bagLastPocket if @bagLastPocket!=nil\r\n $PokemonBag.setAllChoices(@bagChoices) if @bagChoices!=nil\r\n # Start Bag screen\r\n itemScene = PokemonBag_Scene.new\r\n itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|\r\n useType = GameData::Item.get(item).battle_use\r\n next useType && useType>0\r\n },false)\r\n # Loop while in Bag screen\r\n wasTargeting = false\r\n loop do\r\n # Select an item\r\n item = itemScene.pbChooseItem\r\n break if !item\r\n # Choose a command for the selected item\r\n item = GameData::Item.get(item)\r\n itemName = item.name\r\n useType = item.battle_use\r\n cmdUse = -1\r\n commands = []\r\n commands[cmdUse = commands.length] = _INTL(\"Use\") if useType && useType!=0\r\n commands[commands.length] = _INTL(\"Cancel\")\r\n command = itemScene.pbShowCommands(_INTL(\"{1} is selected.\",itemName),commands)\r\n next unless cmdUse>=0 && command==cmdUse # Use\r\n # Use types:\r\n # 0 = not usable in battle\r\n # 1 = use on Pokémon (lots of items), consumed\r\n # 2 = use on Pokémon's move (Ethers), consumed\r\n # 3 = use on battler (X items, Persim Berry), consumed\r\n # 4 = use on opposing battler (Poké Balls), consumed\r\n # 5 = use no target (Poké Doll, Guard Spec., Launcher items), consumed\r\n # 6 = use on Pokémon (Blue Flute), not consumed\r\n # 7 = use on Pokémon's move, not consumed\r\n # 8 = use on battler (Red/Yellow Flutes), not consumed\r\n # 9 = use on opposing battler, not consumed\r\n # 10 = use no target (Poké Flute), not consumed\r\n case useType\r\n when 1, 2, 3, 6, 7, 8 # Use on Pokémon/Pokémon's move/battler\r\n # Auto-choose the Pokémon/battler whose action is being decided if they\r\n # are the only available Pokémon/battler to use the item on\r\n case useType\r\n when 1, 6 # Use on Pokémon\r\n if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1\r\n break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene\r\n end\r\n when 3, 8 # Use on battler\r\n if @battle.pbPlayerBattlerCount==1\r\n break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene\r\n end\r\n end\r\n # Fade out and hide Bag screen\r\n itemScene.pbFadeOutScene\r\n # Get player's party\r\n party = @battle.pbParty(idxBattler)\r\n partyPos = @battle.pbPartyOrder(idxBattler)\r\n partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)\r\n modParty = @battle.pbPlayerDisplayParty(idxBattler)\r\n # Start party screen\r\n pkmnScene = PokemonParty_Scene.new\r\n pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty)\r\n pkmnScreen.pbStartScene(_INTL(\"Use on which Pokémon?\"),@battle.pbNumPositions(0,0))\r\n idxParty = -1\r\n # Loop while in party screen\r\n loop do\r\n # Select a Pokémon\r\n pkmnScene.pbSetHelpText(_INTL(\"Use on which Pokémon?\"))\r\n idxParty = pkmnScreen.pbChoosePokemon\r\n break if idxParty<0\r\n idxPartyRet = -1\r\n partyPos.each_with_index do |pos,i|\r\n next if pos!=idxParty+partyStart\r\n idxPartyRet = i\r\n break\r\n end\r\n next if idxPartyRet<0\r\n pkmn = party[idxPartyRet]\r\n next if !pkmn || pkmn.egg?\r\n idxMove = -1\r\n if useType==2 || useType==7 # Use on Pokémon's move\r\n idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL(\"Restore which move?\"))\r\n next if idxMove<0\r\n end\r\n break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene\r\n end\r\n pkmnScene.pbEndScene\r\n break if idxParty>=0\r\n # Cancelled choosing a Pokémon; show the Bag screen again\r\n itemScene.pbFadeInScene\r\n when 4, 9 # Use on opposing battler (Poké Balls)\r\n idxTarget = -1\r\n if @battle.pbOpposingBattlerCount(idxBattler)==1\r\n @battle.eachOtherSideBattler(idxBattler) { |b| idxTarget = b.index }\r\n break if yield item.id, useType, idxTarget, -1, itemScene\r\n else\r\n wasTargeting = true\r\n # Fade out and hide Bag screen\r\n itemScene.pbFadeOutScene\r\n # Fade in and show the battle screen, choosing a target\r\n tempVisibleSprites = visibleSprites.clone\r\n tempVisibleSprites[\"commandWindow\"] = false\r\n tempVisibleSprites[\"targetWindow\"] = true\r\n idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites)\r\n if idxTarget>=0\r\n break if yield item.id, useType, idxTarget, -1, self\r\n end\r\n # Target invalid/cancelled choosing a target; show the Bag screen again\r\n wasTargeting = false\r\n pbFadeOutAndHide(@sprites)\r\n itemScene.pbFadeInScene\r\n end\r\n when 5, 10 # Use with no target\r\n break if yield item.id, useType, idxBattler, -1, itemScene\r\n end\r\n end\r\n @bagLastPocket = $PokemonBag.lastpocket\r\n @bagChoices = $PokemonBag.getAllChoices\r\n $PokemonBag.lastpocket = oldLastPocket\r\n $PokemonBag.setAllChoices(oldChoices)\r\n # Close Bag screen\r\n itemScene.pbEndScene\r\n # Fade back into battle screen (if not already showing it)\r\n pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting\r\n end",
"def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end",
"def pbWithdrawItemScreen\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n @scene.pbStartScene(storage)\n loop do\n item = @scene.pbChooseItem\n break if item==0\n commands = [_INTL(\"Withdraw\"),_INTL(\"Give\"),_INTL(\"Cancel\")]\n itemname = PBItems.getName(item)\n command = @scene.pbShowCommands(_INTL(\"{1} is selected.\",itemname),commands)\n if command==0 # Withdraw\n qty = storage.pbQuantity(item)\n if qty>1 && !pbIsImportantItem?(item)\n qty = @scene.pbChooseNumber(_INTL(\"How many do you want to withdraw?\"),qty)\n end\n if qty>0\n if [email protected]?(item,qty)\n pbDisplay(_INTL(\"There's no more room in the Bag.\"))\n else\n dispqty = (pbIsImportantItem?(item)) ? 1 : qty\n itemname = PBItems.getNamePlural(item) if dispqty>1\n pbDisplay(_INTL(\"Withdrew {1} {2}.\",dispqty,itemname))\n if !storage.pbDeleteItem(item,qty)\n raise \"Can't delete items from storage\"\n end\n if [email protected](item,qty)\n raise \"Can't withdraw items from storage\"\n end\n end\n end\n elsif command==1 # Give\n if $Trainer.pokemonCount==0\n @scene.pbDisplay(_INTL(\"There is no Jermon.\"))\n return 0\n elsif pbIsImportantItem?(item)\n @scene.pbDisplay(_INTL(\"The {1} can't be held.\",itemname))\n else\n pbFadeOutIn(99999){\n sscene = PokemonParty_Scene.new\n sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)\n if sscreen.pbPokemonGiveScreen(item)\n # If the item was held, delete the item from storage\n if !storage.pbDeleteItem(item,1)\n raise \"Can't delete item from storage\"\n end\n end\n @scene.pbRefresh\n }\n end\n end\n end\n @scene.pbEndScene\n end",
"def pick_up_checks(input)\n \n if find_item_by_id(input).pick_up_dependency_met\n put_item_in_inventory(input)\n\n else\n @pick_up_rules.each do |rule|\n slow_type(\"#{rule[:message]}\") if rule[:item_id] == input\n reset_game if input == 7 \n end\n end\n\n end",
"def pick_up(item)\n expected_weight = items_weight + item.weight\n if expected_weight <= 250\n item.is_a?(Weapon) ? @equipped_weapon = item : items << item \n else\n return false\nend\nend",
"def valid_item\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n @active_battler.current_action.clear\n @active_battler.current_action.set_item(@item.id)\n if @item.for_dead_friend? and !$game_system.actors_bodies? \n if $game_map.passable?(@cursor.x, @cursor.y, 0) and\n (occupied_by?(@cursor.x, @cursor.y) == nil)\n open_revive_window\n end\n else\n @active_battler.current_action.set_item(@item.id)\n @targets = get_targets\n if @targets.empty?\n Sound.play_buzzer\n else\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Item) \n @windows[Win_Status].dmg_preview(3, @active_battler, @item, @targets)\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n end\n end\n end",
"def update_item\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to menu screen\n $scene = Scene_Menu.new(1)\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the item window\n @item = @item_window.item\n # If not a use item\n unless @item.is_a?(RPG::Item)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # If it can't be used\n unless $game_party.item_can_use?(@item.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # If effect scope is an ally\n if @item.scope >= 3\n use_item\n # If effect scope is other than an ally\n else\n # If command event ID is valid\n if @item.common_event_id > 0\n # Command event call reservation\n $game_temp.common_event_id = @item.common_event_id\n # Play item use SE\n $game_system.se_play(@item.menu_se)\n # If consumable\n if @item.consumable\n # Decrease used items by 1\n $game_party.lose_item(@item.id, 1)\n # Draw item window item\n @item_window.draw_item(@item_window.index)\n end\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n end\n return\n end\n end",
"def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end",
"def occasion_ok?(item)\r\n $game_party.in_battle ? item.battle_ok? : item.menu_ok?\r\n end",
"def pass\n @score = @rubric_item.max_score\n end",
"def item_apply(user, item)\n super\n if item.damage.element_id < 0\n user.atk_elements.each do |e|\n $game_party.add_bestiary_data(@enemy_id, :ele, e)\n end\n else\n $game_party.add_bestiary_data(@enemy_id, :ele, item.damage.element_id)\n end\n end",
"def occasion_ok?(item)\n SceneManager.scene_is?(Scene_Map) ? item.battle_ok? : item.menu_ok?\n end",
"def item_conditions_met?(item)\r\n usable_item_conditions_met?(item) && $game_party.has_item?(item)\r\n end",
"def process_tool_action(item)\n PearlKernel.load_item(item)\n return if !battler.tool_ready?(item)\n \n unless PearlKernel.has_data?\n if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n msgbox('Tool data missing') if $DEBUG\n return\n end\n if item.scope.between?(1, 6)\n msgbox('Tool data missing') if $DEBUG\n return\n elsif item.scope == 0\n return\n \n elsif !battler.usable?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return \n end\n end\n \n if PearlKernel.has_data? and not usable_test_passed?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return\n end\n \n @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?\n if @user_casting[0] > 0\n @animation_id = 0\n @animation_id = PearlKernel.tool_castanimation\n else\n load_abs_tool(item)\n end\n end",
"def check_item_needed(type, id)\n action = eval(type + '_Need_Items.dup')\n equipment = eval(type + '_Need_Equiped.dup')\n if action.include?(id)\n for need in action[id]\n next if need[0] == 'i' and $game_party.item_number(need[1]) >= need[2]\n next if need[0] == 'a' and $game_party.armor_number(need[1]) >= need[2]\n next if need[0] == 'w' and $game_party.weapon_number(need[1]) >= need[2]\n return false\n end\n end\n if equipment.include?(id)\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for equip in equipments\n if action_id(equip) == need[1] and (need[0] == 'a' and \n $game_party.armor_number(need[1]) >= [need[2] - 1, 0].max) or\n (need[0] == 'w' and $game_party.weapon_number(need[1]) >= [need[2] - 1, 0].max)\n return true \n end\n end\n end\n return false\n end\n return true\n end",
"def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n\r\n puts \"User chose item #{ItemService.item_sym_of(id)}\"\r\n @pedestal.pedestal_item_id = id\r\n\t\t\t$game_party.gain_item(rmxp_item_id, -1)\r\n\r\n SetupEventService.new.setup!\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end",
"def check_item_heal(pokemon)\n return false unless $game_temp.trainer_battle\n is_last = (@enemies.count { |pkmn| !pkmn.dead? }) == 1\n max_hp = pokemon.max_hp\n dhp = max_hp - pokemon.hp\n bag = get_bag(pokemon)\n has_full_restore = bag.contain_item?(:full_restore)\n has_full_restore = false unless is_last or bag.item_quantity(:full_restore) > 1\n has_full_restore = false if dhp < 60 # Don't use the fullrestore at this point\n #> Soin status\n if pokemon.status != 0 and pokemon.hp_rate > 0.5\n if pokemon.poisoned?\n return true if perform_status_heal(bag, has_full_restore, *PoisonHealItems)\n elsif pokemon.burnt?\n return true if perform_status_heal(bag, has_full_restore, *BurnHealItems)\n elsif pokemon.paralyzed?\n return true if perform_status_heal(bag, has_full_restore, *ParalyzeHealItems)\n elsif pokemon.frozen?\n return true if perform_status_heal(bag, has_full_restore, *FreezeHealItems)\n elsif pokemon.asleep?\n return true if perform_status_heal(bag, has_full_restore, *WakeUpItems)\n end\n end\n #> Soin HP\n if pokemon.hp_rate < 0.25\n if dhp > 120 and has_full_restore\n return _stack_add_item(pokemon: pokemon, item_id: :full_restore, bag: bag)\n elsif dhp > 120 and bag.contain_item?(:max_potion)\n return _stack_add_item(pokemon: pokemon, item_id: :max_potion, bag: bag)\n end\n # Test items healing more than 60 HP\n if dhp > 60\n ItemHealingMoreThan60.each do |sym|\n return _stack_add_item(pokemon: pokemon, item_id: sym, bag: bag) if bag.contain_item?(sym)\n end\n end\n # Itest items healing more than 20 HP\n if dhp > 20\n ItemHealingMoreThan20.each do |sym|\n return _stack_add_item(pokemon: pokemon, item_id: sym, bag: bag) if bag.contain_item?(sym)\n end\n end\n ItemHealingHP.each do |sym|\n return _stack_add_item(pokemon: pokemon, item_id: sym, bag: bag) if bag.contain_item?(sym)\n end\n end\n return false\n end",
"def check_item_condition?\n # disallow usage if item button disabled\n return false if !$game_system.item_button\n # disallow usage\n item_condition = false\n # if using direct hotkeys\n if BlizzABS::Config::DIRECT_HOTKEYS\n # check direct hotkeys\n item_condition = self.item_hotkeys?\n # if item button pressed\n elsif Input.trigger?(Input::Item)\n # allow usage\n item_condition = true\n end\n # return result\n return item_condition\n end",
"def pbTossItemScreen\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n @scene.pbStartScene(storage)\n loop do\n item = @scene.pbChooseItem\n break if item==0\n if pbIsImportantItem?(item)\n @scene.pbDisplay(_INTL(\"That's too important to toss out!\"))\n next\n end\n qty = storage.pbQuantity(item)\n itemname = PBItems.getName(item)\n itemnameplural = PBItems.getNamePlural(item)\n if qty>1\n [email protected](_INTL(\"Toss out how many {1}?\",itemnameplural),qty)\n end\n if qty>0\n itemname = itemnameplural if qty>1\n if pbConfirm(_INTL(\"Is it OK to throw away {1} {2}?\",qty,itemname))\n if !storage.pbDeleteItem(item,qty)\n raise \"Can't delete items from storage\"\n end\n pbDisplay(_INTL(\"Threw away {1} {2}.\",qty,itemname))\n end\n end\n end\n @scene.pbEndScene\n end",
"def choice_a_battle\n use_item_in_battle\n end",
"def pbUseKeyItem\n # TODO: Remember move order\n moves = [:CUT,:DEFOG,:DIG,:DIVE,:FLASH,:FLY,:HEADBUTT,:ROCKCLIMB,:ROCKSMASH,\n :SECRETPOWER,:STRENGTH,:SURF,:SWEETSCENT,:TELEPORT,:WATERFALL,\n :WHIRLPOOL]\n realmoves = []\n for i in moves\n move = getID(PBMoves,i)\n next if move==0\n for j in 0...$Trainer.party.length\n next if $Trainer.party[j].egg?\n if $Trainer.party[j].hasMove?(move)\n realmoves.push([move,j]) if Kernel.pbCanUseHiddenMove?($Trainer.party[j],move,false)\n break\n end\n end\n end\n realitems = []\n for i in $PokemonBag.registeredItems\n realitems.push(i) if $PokemonBag.pbHasItem?(i)\n end\n if realitems.length==0 && realmoves.length==0\n Kernel.pbMessage(_INTL(\"An item in the Bag can be registered to this key for instant use.\"))\n else\n $game_temp.in_menu = true\n $game_map.update\n sscene = PokemonReadyMenu_Scene.new\n sscreen = PokemonReadyMenu.new(sscene) \n sscreen.pbStartReadyMenu(realmoves,realitems)\n $game_temp.in_menu = false\n end\nend",
"def pbIsMedicine?(item)\n return [1, 2, 6, 7].include?(GameData::Item.get(item).battle_use) && !GameData::Item.get(item).is_berry?\nend",
"def equippable?(item)\n # If weapon\n if item.is_a?(RPG::Weapon)\n style = get_style(0, item.id)\n # If included among equippable weapons in current class\n if $data_classes[@class_id].weapon_set.include?(item.id)\n if style == nil or @job_current == Unemployed\n return true\n else\n #check if they have the style\n job = get_job\n for i in 1...3\n key = 'style' + i.to_s\n if job[key] == style\n return true\n end\n end\n if (first_command == 'Equip ' + style) or (second_command == 'Equip ' + style)\n return true\n end\n end\n end\n end\n # If armor\n if item.is_a?(RPG::Armor)\n style = get_style(1, item.id)\n # If included among equippable armor in current class\n if $data_classes[@class_id].armor_set.include?(item.id)\n if style == nil or @job_current == Unemployed\n return true\n else\n #check if they have the style\n job = get_job\n for i in 1...3\n key = 'style' + i.to_s\n if job[key] == style\n return true\n end\n end\n if (first_command == 'Equip ' + style) or (second_command == 'Equip ' + style)\n return true\n end\n end\n end\n end\n return false\n end",
"def inventory_item_is_available\n \tif self.inventory_item.present? && self.inventory_item.is_available?(project.rental_delivery, project.rental_pickup) == false\n \t\terrors.add(:inventory_item, \"is not available within this project's duration\")\n \telsif self.inventory_item.blank?\n \t\tself.inventory_item = inventory_style.find_available(project.rental_delivery, project.rental_pickup)\n \t\terrors.add(:inventory_style, \"has no available items within this project's duration\") if self.inventory_item.blank?\n \tend\n end",
"def unit_item_ok\n return refresh_items if @unit_item_list.tb_unit.nil?\n @unit_item_list.activate\n return if (item = @unit_item_list.item).nil?\n @unit_item_list.tb_unit.lose_item(item, 1) \n TactBattleManager.rm_unit_item(@actor.id, item)\n $game_party.gain_item(item, 1)\n refresh_items\n end",
"def check_bag(lost_item)\n @items.each do |type,list|\n contains_lost_item = list.any? {|item,empty| item == lost_item}\n return \"No worries, you already packed #{lost_item}.\" if contains_lost_item\n end\n return \"Your bag is missing #{lost_item}!\"\n end",
"def check_if_right_game_slot\n if self.game.nil? || self.game.slot != self.slot\n self.game = Game.latest.with_slot(self.slot).first\n #self.game.iball += 1\n end\n end",
"def requirement_met?(equip)\n return false if $game_party.item_number(@item) < @number\n return false if $game_party.gold < required_gold(equip)\n true\n end",
"def use_item(item_name)\n item = self.items.find_by(name: item_name)\n if item.item_type == \"Healing Potion\"\n if self.hp += 10 < self.base_hp\n puts \"You drank the entire bottle. You feel energized! (+10 HP)\"\n puts \"You HP is now #{self.hp}\"\n #removes Item from inventory \n Item.destroy(item)\n else\n #if HP goes ove the base_health, it automatically caps at base_hp aka your max hp\n self.hp = self.base_hp\n puts \"You drank the entire bottle. You are at full health!\"\n puts \"Your HP is now #{self.base_hp}\"\n Item.destroy(item)\n end \n elsif item.item_type == \"Weapon\"\n #weapons will boost the characters attack points by a random number?\n if self.current_weapon == nil \n random_attack_boost = [2,3,5].sample\n self.attack_power += random_attk_boost\n puts \"You've equipped #{item.name}. (+#{random_attk_boost})\"\n else \n equipped_weapon = self.items.find_by(current_weapon)\n Item.destroy(equppied_weapon)\n self.attack_power = self.base_attk\n random_attack_boost = [5,6,10].sample\n self.attack_power += random_attack_boost\n puts \"You have replaced your weapon with #{item.name}. (+#{random_attk_boost})\"\n end \n else \n puts \"You can't use/equip this!\"\n end \n end",
"def usable_item_conditions_met?(item)\r\n movable? && occasion_ok?(item)\r\n end",
"def pbChooseItem\n @sprites[\"helpwindow\"].visible = false\n itemwindow = @sprites[\"itemlist\"]\n thispocket = @bag.pockets[itemwindow.pocket]\n swapinitialpos = -1\n pbActivateWindow(@sprites,\"itemlist\"){\n loop do\n oldindex = itemwindow.index\n Graphics.update\n Input.update\n pbUpdate\n if itemwindow.sorting && itemwindow.index>=thispocket.length\n itemwindow.index = (oldindex==thispocket.length-1) ? 0 : thispocket.length-1\n end\n if itemwindow.index!=oldindex\n # Move the item being switched\n if itemwindow.sorting\n thispocket.insert(itemwindow.index,thispocket.delete_at(oldindex))\n end\n # Update selected item for current pocket\n @bag.setChoice(itemwindow.pocket,itemwindow.index)\n pbRefresh\n end\n if itemwindow.sorting\n if Input.trigger?(Input::A) ||\n Input.trigger?(Input::C)\n itemwindow.sorting = false\n pbPlayDecisionSE\n pbRefresh\n elsif Input.trigger?(Input::B)\n curindex = itemwindow.index\n thispocket.insert(swapinitialpos,thispocket.delete_at(itemwindow.index))\n itemwindow.index = swapinitialpos\n itemwindow.sorting = false\n pbPlayCancelSE\n pbRefresh\n end\n else\n # Change pockets\n if Input.trigger?(Input::LEFT)\n newpocket = itemwindow.pocket\n loop do\n newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1\n break if !@choosing || newpocket==itemwindow.pocket\n if @filterlist; break if @filterlist[newpocket].length>0\n else; break if @bag.pockets[newpocket].length>0\n end\n end\n if itemwindow.pocket!=newpocket\n itemwindow.pocket = newpocket\n @bag.lastpocket = itemwindow.pocket\n thispocket = @bag.pockets[itemwindow.pocket]\n pbPlayCursorSE\n pbRefresh\n end\n elsif Input.trigger?(Input::RIGHT)\n newpocket = itemwindow.pocket\n loop do\n newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1\n break if !@choosing || newpocket==itemwindow.pocket\n if @filterlist; break if @filterlist[newpocket].length>0\n else; break if @bag.pockets[newpocket].length>0\n end\n end\n if itemwindow.pocket!=newpocket\n itemwindow.pocket = newpocket\n @bag.lastpocket = itemwindow.pocket\n thispocket = @bag.pockets[itemwindow.pocket]\n pbPlayCursorSE\n pbRefresh\n end\n# elsif Input.trigger?(Input::F5) # Register/unregister selected item\n# if !@choosing && itemwindow.index<thispocket.length\n# if @bag.pbIsRegistered?(itemwindow.item)\n# @bag.pbUnregisterItem(itemwindow.item)\n# elsif pbCanRegisterItem?(itemwindow.item)\n# @bag.pbRegisterItem(itemwindow.item)\n# end\n# pbPlayDecisionSE\n# pbRefresh\n# end\n elsif Input.trigger?(Input::A) # Start switching the selected item\n if !@choosing\n if thispocket.length>1 && itemwindow.index<thispocket.length &&\n !POCKETAUTOSORT[itemwindow.pocket]\n itemwindow.sorting = true\n swapinitialpos = itemwindow.index\n pbPlayDecisionSE\n pbRefresh\n end\n end\n elsif Input.trigger?(Input::B) # Cancel the item screen\n pbPlayCancelSE\n return 0\n elsif Input.trigger?(Input::C) # Choose selected item\n pbPlayDecisionSE\n return itemwindow.item\n end\n end\n end\n }\n end",
"def item_hotkeys?\n # find all triggered keys\n triggered = BlizzABS::Cache::Keys.find_all {|i|\n Input.trigger?(Input::Key[i.to_s]) &&\n $game_player.item_hotkeys[i] != 0}\n # no usage if usage invalid\n return false if triggered.size == 0\n # set as usable item\n $game_player.battler.item = $game_player.item_hotkeys[triggered[0]]\n # allow usage\n return true\n end",
"def usable?(item)\n return false if item.nil?\n tb = battler\n return tb.usable?(item) # tb.is_a?(Game_Actor) ? <- : false\n end",
"def make_item_action_result\n \n # sorry i didnt work on this...\n # couse i dont have a sprite that uses items....\n # so i just added the standby sprite here...\n # when i get more time for this i'll try what i can do for this one... ^-^\n # its the same as the ones above...\n if @active_battler.is_a?(Game_Actor)\n @spriteset.actor_sprites[@active_battler.index].pose(1)\n else\n @spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)\n end\n \n @item = $data_items[@active_battler.current_action.item_id]\n unless $game_party.item_can_use?(@item.id)\n @phase4_step = 1\n return\n end\n if @item.consumable\n $game_party.lose_item(@item.id, 1)\n end\n @help_window.set_text(@item.name, 1)\n @animation1_id = @item.animation1_id\n @animation2_id = @item.animation2_id\n @common_event_id = @item.common_event_id\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n set_target_battlers(@item.scope)\n for target in @target_battlers\n target.item_effect(@item)\n end\n end",
"def process_ok\n if current_item_enabled?\n Input.update\n deactivate\n call_ok_handler\n else\n Sound.play_buzzer\n end\n end",
"def add_item(item)\n item.item_number = @@item_number\n @@item_number += 1\n @grocery_item << item\n\n # starting the logic for finding out what type of item it is and if it will be\n # allowed to be taxed. < -- Continue here\n if @grocery_item.item_type == \"books\"\n\n end\n\n\n\nend",
"def item_ok?\n return true if MAP_ITEM_ID == 0\n $game_party.has_item?($data_items[MAP_ITEM_ID])\n end",
"def busted?(total)\n total > GAME_HIGH\nend",
"def valid_bid?\n unless Auction.find(Item.find(self.item_id).auction_id).end_date > (DateTime.now.to_time - 7.hours).to_datetime\n errors[:base] = \"It is now past the auction time and no more bids are allowed online.\"\n return false\n end\n # Check if there are any bids for this item yet.\n if !Bid.where(:item_id => self.item_id).empty?\n # Checks if there was an unsuccessful bid that is waiting but it's the first one\n if Bid.where(:item_id => self.item_id).count == 1 && Bid.where(:item_id => self.item_id).first.user_id.nil?\n if self.bid_amount >= Item.find(self.item_id).min_bid\n return true\n else \n errors[:base] = \"Invalid bid amount! Please make sure that your bid is at \n least as high as the starting bid.\"\n return false\n end\n end\n # Check that this bidder is not the one who made the highest bid, first\n if Bid.where(:item_id => self.item_id, :bid_amount => Item.find(self.item_id).min_bid).first.user_id==self.user_id\n \terrors[:base] = \"You are already the highest bidder!\"\n return false\n else\n # Now check that this bid amount is higher than the highest bid amount\n if self.bid_amount < Item.find(self.item_id).min_bid + Item.find(self.item_id).min_increase\n errors[:base] = \"Invalid bid amount! Please make sure that your bid is at \n least as high as the highest bid plus the minimum increase.\"\n return false\n else\n # If the bidder isn't already the highest bidder, the bid amount is not empty,\n # and the bid is more than the highest bid, return true because it's valid\n return true\n end\n end\n # there are no bids for the item, check that the bid is at least as much as the min bid\n else\n if self.bid_amount >= Item.find(self.item_id).min_bid\n return true\n else \n errors[:base] = \"Invalid bid amount! Please make sure that your bid is at \n least as high as the starting bid.\"\n return false\n end\n end\n end",
"def newly_craftable?(item)\n !item.nil? && item.synthesis_level == @level\n end",
"def consume_item(type, id)\n action = eval(type + '_Need_Items.dup')\n equipment = eval(type + '_Need_Equiped.dup')\n if action.include?(id)\n for need in action[id]\n $game_party.lose_item(need[1], need[2]) if need[0] == 'i' \n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a' \n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w' \n end\n end\n if equipment.include?(id)\n if $atoa_script['Atoa Multi Slot']\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for i in 0...equips.size\n if action_id(equip[i]) == need[1]\n equip(i, 0)\n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a'\n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w'\n equip(i, equip[i].id)\n end\n end\n end\n else\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for equip in equipments\n if equip.type_name == 'Weapon'\n type = 0\n else\n type = 1 if equip.id == @armor1_id\n type = 2 if equip.id == @armor2_id\n type = 3 if equip.id == @armor3_id\n type = 4 if equip.id == @armor4_id\n end\n if action_id(equip) == need[1]\n equip(type, 0)\n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a'\n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w'\n equip(type, equip.id)\n end\n end\n end\n end\n end\n end",
"def check_if_new_game\n if self.game.score > self.score\n # TODO write test only if game 1\n Game.not_finished.map &:finish! if game.slot == 1\n self.game = Game.create!(:player => self.game.player, :slot => self.game.slot)\n end\n end",
"def game_bomb_action\n if tool_canuse?(BweaponId) and not @showing_bomb\n if $game_party.has_item?($data_items[BcostItemId]) \n $game_party.consume_item($data_items[BcostItemId])\n @gamebomb.direction = @direction\n @gamebomb.moveto(@x, @y)\n @gamebomb.jump_passable?(1)[email protected]_jump(1) :@gamebomb.jump(0,0)\n @gamebomb.action_time = BombDuration * 60\n @showing_bomb = true\n @gamebomb.through = false\n RPG::SE.new(BombActionSe,90).play\n @tool_anime = 20\n else\n Sound.play_buzzer\n end\n end\n end",
"def play\n self.check \n while (\"unfinished\" == @hands_status[@cur])\n choice = 0\n \n if 2 == @hands[@cur].length # handle a hand first time\n if (num_to_value(@hands[@cur][0]) == num_to_value(@hands[@cur][1])) && (@balance >= @bets[@cur])\n # can split and double\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand; 3--double; 4--split\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..4)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand; 3--double; 4--split\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n elsif (@balance >= @bets[@cur])\n # can double\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand; 3--double\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..3)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand; 3--double\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n else\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..2)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n end\n choice = Integer(get_input)\n end\n else\n # can only hit or stand\n puts \"please input INTEGER for your choice:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n while (!is_int? get_input) || ((is_int? get_input) && !((1..2)===Integer(get_input)))\n puts \"invalid input, please re-input:\\n1--hit; 2--stand\"\n get_input = gets.chomp\n end \n choice = Integer(get_input)\n end\n\n case choice\n when 1\n self.hit\n when 2\n self.stand\n when 3\n self.double\n when 4\n self.split\n end\n\n self.check\n \n end\n end",
"def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Menu.new(0)\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If it can't be used\r\n unless $game_party.item_can_use?(@item.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n if @item.scope >= 3\r\n # Activate target window\r\n @item_window.active = false\r\n @target_window.x = (@item_window.index + 1) % 2 * 304\r\n @target_window.visible = true\r\n @target_window.active = true\r\n # Set cursor position to effect scope (single / all)\r\n if @item.scope == 4 || @item.scope == 6\r\n @target_window.index = -1\r\n else\r\n @target_window.index = 0\r\n end\r\n # If effect scope is other than an ally\r\n else\r\n # If command event ID is valid\r\n if @item.common_event_id > 0\r\n # Command event call reservation\r\n $game_temp.common_event_id = @item.common_event_id\r\n # Play item use SE\r\n $game_system.se_play(@item.menu_se)\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used items by 1\r\n $game_party.lose_item(@item.id, 1)\r\n # Draw item window item\r\n @item_window.draw_item(@item_window.index)\r\n end\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n return\r\n end\r\n end",
"def verify!\n wrong = @children.find do |i|\n Interscript::Node::Item::Stage === i ||\n ! (Interscript::Node::Item === i) ||\n i.class == Interscript::Node::Item\n end\n\n if wrong\n raise TypeError, \"An I::Node::Item::Group can't contain an #{wrong.class} item.\"\n end\n end",
"def make_item_action_result\n # Get item\n @item = $data_items[@active_battler.current_action.item_id]\n # If unable to use due to items running out\n unless $game_party.item_can_use?(@item.id)\n # Shift to step 1\n @phase4_step = 1\n return\n end\n # If consumable\n if @item.consumable\n # Decrease used item by 1\n $game_party.lose_item(@item.id, 1)\n end\n # Display item name on help window\n @help_window.set_text(@item.name, 1)\n # Set animation ID\n @animation1_id = @item.animation1_id\n @animation2_id = @item.animation2_id\n # Set common event ID\n @common_event_id = @item.common_event_id\n # Decide on target\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n # Set targeted battlers\n set_target_battlers(@item.scope)\n # Apply item effect\n for target in @target_battlers\n target.item_effect(@item)\n end\n end",
"def action(type, amount, player)\n @player = Player.find(player.to_i)\n amount = amount.to_i\n case type\n when 'fold'\n @player.in_hand = false\n when 'bet'\n if amount > @player.money\n amount = @player.money\n end\n if amount + @player.in_pot_current < self.high_bet\n p 'invalid bet'\n else\n put_money(amount, @player)\n end\n when 'raise'\n # If player doesn't have enough money or trying to not raise enough and can't bet enough\n if amount > @player.money || (amount + @player.in_pot_current < 2*self.high_bet && 2*self.high_bet - @player.in_pot_current > @player.money)\n amount = @player.money\n elsif amount + @player.in_pot_current < self.high_bet\n amount = 2*self.high_bet - @player.in_pot_current\n else\n amount = amount + self.high_bet - @player.in_pot_current\n end\n put_money(amount, @player)\n when 'check'\n # do nothing; high better already set to be player after dealer inside of deal()\n when 'call'\n amount = self.high_bet - @player.in_pot_current\n put_money(amount, @player)\n else\n p 'invalid action'\n end\n self.current_player = self.get_next_player(@player.location) # Set next player to current\n\n @player.save\n self.save\n if self.high_better == self.current_player #progress round if you've gone back around to the high better\n # unless no one raises and it's back to big blind, bb should be able to go\n if self.high_bet <= self.big_blind && self.round == 0 && self.high_better == get_next_player(get_next_player(self.dealer))\n self.high_better = get_next_player(get_next_player(get_next_player(self.dealer)))\n else\n set_round((self.round + 1))\n deal(self.round)\n end\n end\n if self.players.where(:in_hand => true).length <= 1\n set_round(4)\n end\n\n @player.save\n self.save\n end",
"def consume_item(item)\n if item.is_a?(RPG::Item) and item.consumable\n lose_item(item, 1)\n end\n end",
"def make_item_action_result\r\n # Get item\r\n @item = $data_items[@active_battler.current_action.item_id]\r\n # If unable to use due to items running out\r\n unless $game_party.item_can_use?(@item.id)\r\n # Shift to step 1\r\n @phase4_step = 1\r\n return\r\n end\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used item by 1\r\n $game_party.lose_item(@item.id, 1)\r\n end\r\n # Display item name on help window\r\n @help_window.set_text(@item.name, 1)\r\n # Set animation ID\r\n @animation1_id = @item.animation1_id\r\n @animation2_id = @item.animation2_id\r\n # Set common event ID\r\n @common_event_id = @item.common_event_id\r\n # Decide on target\r\n index = @active_battler.current_action.target_index\r\n target = $game_party.smooth_target_actor(index)\r\n # Set targeted battlers\r\n set_target_battlers(@item.scope)\r\n # Apply item effect\r\n for target in @target_battlers\r\n target.item_effect(@item)\r\n end\r\n end",
"def did_block?(item, is_crit = false,user)\r\r\n return false unless item.for_opponent?\r\r\n return false if @base_attack_roll == 20\r\r\n return false if item.magical?\r\r\n \r\r\n @base_attack_roll += user.attack_roll(item).to_i\r\r\n \r\r\n rate = 0\r\r\n result = false\r\r\n real_ac = self.armor_class\r\r\n \r\r\n @states.each do |state|\r\r\n real_ac += $data_states[state].armor_class\r\r\n end\r\r\n \r\r\n \r\r\n if actor?\r\r\n for equip in equips\r\r\n next if equip.nil?\r\r\n next if is_crit && !equip.does_block_crit\r\r\n next if !does_block?(equip, item)\r\r\n break if result == true\r\r\n \r\r\n result = true if (real_ac + adjusted_block_rate(equip, item)) > @base_attack_roll\r\r\n end\r\r\n end\r\r\n \r\r\n if !result\r\r\n real_ac = self.armor_class + calc_block_rate(item)\r\r\n end\r\r\n \r\r\n #puts \"THAC0:#{@real_thac0} AC:#{real_ac}\"\r\r\n result = @base_attack_roll + @real_thac0 < real_ac\r\r\n \r\r\n if real_ac > 0 && ($game_system.show_roll_result? || $force_show_roll_result)\r\r\n $game_message.battle_log_add(sprintf(\"** Block Result: **\"))\r\r\n $game_message.battle_log_add(sprintf(\"** %s's %20s\",self.name , \"AC:\" + real_ac.to_s))\r\r\n $game_message.battle_log_add(sprintf(\"** %s's %20s\",user.name , \"Attack Roll(adjusted):\" + (@base_attack_roll + @real_thac0).to_s))\r\r\n end\r\r\n \r\r\n return result\r\r\n end",
"def is_a_bust?\n score > 21\n end",
"def item_ok?\n check_ok?(:item) || all_ok?\n end",
"def choice_a_hold\n item_id = @item_list[@index]\n return action_b if item_id.nil?\n return play_buzzer_se if item_id == 0 || !GameData::Item[item_id].holdable\n\n play_decision_se\n @running = false\n @return_data = @item_list[@index]\n end",
"def validate_object(item_hash)\n not_nil = [\"name\", \"item_type\", \"element\", \"register\", \"sell\", \"buy\", \"invent1\", \"invent2\"]\n stats = [\"atk\", \"def\", \"hit\", \"avd\", \"mag\", \"str\", \"vit\", \"agl\", \"int\", \"luk\", \"cost\", \"ap\"]\n stats.each do |stat|\n not_nil += (1..5).map {|x| \"#{stat}#{x}\"}\n end\n not_nil.delete(\"cost1\") #no cost for level 1.\n \n conditional_nil = []\n valid = true\n case item_hash[\"item_type\"]\n when \"Armour\", \"Ring\"\n not_nil += [\"absorb\", \"autoskill\", \"autoskill_slot_count\"]\n else\n not_nil += [\"range\", \"height\"]\n (1..4).each do |x|\n not_nil << \"weapon#{x}\"\n conditional_nil << \"weapon#{x}_level\"\n end\n end\n \n \n not_nil.each do |x|\n if item_hash[x].nil?\n valid = false\n puts \"Couldn't find #{x} in #{item_hash}\"\n end\n end\n conditional_nil.each do |x|\n if match = (/([\\w ]+)_level/.match(x)[1])\n if item_hash[match] != \"(nothing)\" and item_hash[x].nil?\n valid = false \n \"Couldn't find #{x} in #{item_hash}, but expected it\"\n end \n end\n end\n return valid\nend",
"def shipped\n corresponding_item = self.item.take\n current_inventory = corresponding_item.inventory_level\n corresponding_item.update_attribute(:inventory_level, (self.quantity + current_inventory)) unless previous.nil?\n self.update_attribute(:shipped_on, date.current.to_date)\n\n def item_exists_and_active?\n all_active_items = Item.active.all.map(&:id)\n if all_active_items.include?(self.item_id)\n return true\n end\n errors.add(:item_id, \"is not an active item at the chess store\")\n return false\n end\n\n def subtotal(date = nil)\n end\n\n def valid_quantity?\n if self.quantity >= 0\n return true\n end\n stock_quantity = self.item.inventory_level\n if (self.quantity* -1) > stock_quantity\n errors.add(:quantity, \"too much purchase quantity\")\n return false\n end\n return true\n end\nend",
"def game_barrel_action\n if tool_canuse?(BAweaponId) and not @showing_barrel\n if $game_party.has_item?($data_items[BarrelItemCost]) \n $game_party.consume_item($data_items[BarrelItemCost])\n @gamebarrel.direction = @direction\n @gamebarrel.moveto(@x, @y)\n @gamebarrel.jump_passable?(1) ? @gamebarrel.start_jump(1) :\n @gamebarrel.jump(0, 0)\n @showing_barrel = true\n @tool_anime = 20\n RPG::SE.new(BarrelActionSe,80).play\n else\n Sound.play_buzzer\n end\n end\n end",
"def validate_item( x )\n fail 'not implemented!'\n end",
"def finished\n @quick_fire.finished\n winner = @quick_fire.to_hash[:winner]\n rebuy_added = false\n rebuy_used = false\n top_score_achieved = false\n previous_score = @game.score\n if winner[:id] == 1\n @game.score = @game.score * 2\n @game.high_score = @game.score if @game.score > @game.high_score\n rmq(:play).style {|st| st.text = \"Next Hand\" }\n if winner[:rank] == \"Straight Flush\" || winner[:rank] == \"Royal Flush\"\n rebuy_added = true\n add_rebuy(@game.score)\n end\n if @game.score == 64 && [email protected]_rebuy && @game.difficulty == 0\n add_rebuy(64)\n rebuy_added = true\n @game.easy_rebuy = true\n end\n if @game.score == 1024 && [email protected]_obtained\n add_rebuy(1024)\n rebuy_added = true\n @game.rebuy_obtained = true\n end\n if @game.score == 1048576 && !game.million_rebuy\n applause_sound\n add_rebuy(1048576)\n rebuy_added = true\n @game.million_rebuy = true\n end\n if @game.score >= 274877906944\n applause_sound\n @game.open = false\n top_score_achieved = true\n rmq(:play).style {|st| st.text = \"Game Over\"}\n end\n elsif winner[:id] == 2\n if @game.rebuys.empty?\n @game.open = false\n rmq(:play).style {|st| st.text = \"Play Again?\" }\n else\n rebuy_used = true\n @game.score = @game.rebuys.shift\n end\n end\n opts_hash = {rebuy_added: rebuy_added, rebuy_used: rebuy_used, previous_score: previous_score, top_score_achieved: top_score_achieved}\n OverlayController.new(self, @game, @quick_fire, opts_hash).show\n end",
"def bust\n if player.score > 21 || dealer.score > 21\n puts \"---------------BUST!---------------\"\n show_hand\n play_again\n end\n end",
"def pbDepositItemScreen\n @scene.pbStartScene(@bag)\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n item = 0\n loop do\n item = @scene.pbChooseItem\n break if item==0\n qty = @bag.pbQuantity(item)\n if qty>1 && !pbIsImportantItem?(item)\n qty = @scene.pbChooseNumber(_INTL(\"How many do you want to deposit?\"),qty)\n end\n if qty>0\n if !storage.pbCanStore?(item,qty)\n pbDisplay(_INTL(\"There's no room to store items.\"))\n else\n dispqty = (pbIsImportantItem?(item)) ? 1 : qty\n itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)\n pbDisplay(_INTL(\"Deposited {1} {2}.\",dispqty,itemname))\n if [email protected](item,qty)\n raise \"Can't delete items from bag\"\n end\n if !storage.pbStoreItem(item,qty)\n raise \"Can't deposit items to storage\"\n end\n end\n end\n end\n @scene.pbEndScene\n end",
"def ty_execute_action_skill\n # Check to see if the current attacker is the actor and is using a weapon that needs ammo\n if @active_battler.is_a?(Game_Actor) && TysAmmoRequirements::Skill_ammo_cost[@active_battler.action.skill_id]\n if TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id].is_a?(Array)\n # Check passed, so now we store the array items\n array_items = TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]\n # Now we check each ID in array_items and compare to see if we have enough ammo\n for index in array_items\n # Check to see if the actor has enough ammo\n if $game_party.item_number($data_items[index]) >= gather_ammo_cost\n # Check cleared, gather item ID and terminate check loop\n gather_ammo_item = $data_items[index]\n break\n end\n end\n else\n gather_ammo_item = $data_items[TysAmmoRequirements::Weapons_ammo_id[@active_battler.skill_id]]\n end\n # Both checks clear, so perform Ammo adjustments\n # First we collect some end-user options, like ammo cost and ammo ID.\n gather_ammo_cost = TysAmmoRequirements::Skill_ammo_cost[@active_battler.action.skill_id]\n id = @active_battler.action.skill_id\n gather_ammo_item = $data_items[TysAmmoRequirements::Skill_ammo_id[id]]\n if $game_party.item_number(gather_ammo_item) >= gather_ammo_cost\n # The check cleared, so perform ammo adjustments\n # Consume Ammunition\n $game_party.lose_item(gather_ammo_item, gather_ammo_cost)\n # Display text\n text = sprintf(Vocab::ConsumeAmmo, @active_battler.name, gather_ammo_cost, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n else\n # Failed check, go into defense mode\n text = sprintf(Vocab::NoAmmo, @active_battler.name, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 0\n execute_action_guard\n end\n # Perform a check to see if Active_Battler is a enemy and has ammo\n elsif @active_battler.is_a?(Game_Enemy) && $data_enemies[@active_battler.enemy_id].note.include?(TysAmmoRequirements::Enemy_ammo_activate_string) && TysAmmoRequirements::Enemy_skill_cost[@active_battler.action.skill_id]\n # Now we have to isolate the interger in the 'Note' string of the enemies\n # and then store the interger in a new local value for future use.\n enemy_ammo_cost = TysAmmoRequirements::Enemy_skill_cost[@active_battler.action.skill_id]\n enemy_ammo_name = TysAmmoRequirements::Enemy_ammo_name[@active_battler.enemy_id]\n # Check to see if the enemy has enough ammo to attack\n if @enemy_ammo[@enemy_attack] >= enemy_ammo_cost\n # Check cleared, remove enemy ammo.\n text = sprintf(Vocab::EnemyUsedAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @enemy_ammo[@enemy_attack] -= enemy_ammo_cost\n else\n # Check failed, put enemy in guard mode \n text = sprintf(Vocab::EnemyNoAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 0\n execute_action_guard\n end\n end\n end",
"def process_ok\n if current_item_enabled?\n Sound.play_ok \n Input.update\n deactivate unless @symbol.nil?\n call_ok_handler\n else\n Sound.play_buzzer\n end\n end",
"def choice_a_menu\n item_id = @item_list[@index]\n return action_b if item_id.nil?\n return play_buzzer_se if item_id == 0\n play_decision_se\n show_shadow_frame\n # Prepare the choice info\n # Use option\n map_usable = proc { !GameData::Item[item_id].map_usable }\n # Give option\n giv_check = proc { $pokemon_party.pokemon_alive <= 0 || !GameData::Item[item_id].holdable }\n # Unregister / register\n if $bag.shortcuts.include?(item_id)\n reg_id = 14\n reg_meth = method(:unregister_item)\n else\n reg_id = 2\n reg_meth = method(:register_item)\n reg_check = map_usable\n end\n # Throw option\n thr_check = proc { !GameData::Item[item_id].limited }\n # Create the choice\n choices = PFM::Choice_Helper.new(Yuki::ChoiceWindow::But, true, 999)\n choices.register_choice(text_get(22, 0), on_validate: method(:use_item), disable_detect: map_usable)\n .register_choice(text_get(22, 3), on_validate: method(:give_item), disable_detect: giv_check)\n .register_choice(text_get(22, reg_id), on_validate: reg_meth, disable_detect: reg_check)\n .register_choice(text_get(22, 1), on_validate: method(:throw_item), disable_detect: thr_check)\n .register_choice(text_get(22, 7))\n # Show selection : item_name\n @base_ui.show_win_text(parse_text(22, 35, PFM::Text::ITEM2[0] => GameData::Item[item_id].exact_name))\n # Process the actual choice\n y = 200 - 16 * choices.size\n choices.display_choice(@viewport, 306, y, nil, on_update: method(:update_graphics), align_right: true)\n @base_ui.hide_win_text\n hide_shadow_frame\n end",
"def load_abs_tool(item)\n return if @knockdown_data[0] > 0\n PearlKernel.load_item(item)\n \n return if self.is_a?(Game_Follower) and @targeted_character.nil?\n \n if !@targeting[0] and self.battler.is_a?(Game_Actor)\n if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)\n # apply target to skills items \n if PearlKernel.tool_target == \"true\" || item.scope == 7 ||\n item.scope == 9\n load_target_selection(item)\n return\n end\n else\n # apply target parsing the invoked skill to weapons and armors\n invoke = PearlKernel.tool_invoke\n if invoke != nil && invoke > 0 && invoke != 1 && invoke != 2\n invokeskill = $data_skills[invoke]\n if PearlKernel.tool_target == \"true\" || invokeskill.scope == 7 ||\n invokeskill.scope == 9\n load_target_selection(item)\n return\n end\n # apply target to normal weapon and armor without invoking\n else\n if PearlKernel.tool_target == \"true\"\n load_target_selection(item)\n return\n end\n end\n end\n end\n if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)\n battler.use_item(item) \n else\n if PearlKernel.tool_invoke != 0\n battler.use_item($data_skills[PearlKernel.tool_invoke])\n end\n end\n \n # if the tool has data continue\n if PearlKernel.has_data?\n consume_ammo_item(item) if battler.is_a?(Game_Actor) and\n PearlKernel.tool_itemcost != 0\n @anime_speed = PearlKernel.user_animespeed\n battler.apply_cooldown(item, PearlKernel.tool_cooldown)\n end\n create_projectile_object(item)\n create_anime_sprite_object(item)\n end",
"def pbTypeImmunityByAbility(type,attacker,opponent)\n return false if attacker.index==opponent.index\n return false if attacker.hasMoldBreaker\n if opponent.hasWorkingAbility(:SAPSIPPER) && isConst?(type,PBTypes,:GRASS)\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s Sap Sipper (made #{@name} ineffective)\")\n if opponent.pbCanIncreaseStatStage?(PBStats::ATTACK,opponent)\n opponent.pbIncreaseStatWithCause(PBStats::ATTACK,1,opponent,PBAbilities.getName(opponent.ability))\n else\n @battle.pbDisplay(_INTL(\"{1}'s {2} made {3} ineffective!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))\n end\n return true\n end\n if (opponent.hasWorkingAbility(:STORMDRAIN) && isConst?(type,PBTypes,:WATER)) ||\n (opponent.hasWorkingAbility(:LIGHTNINGROD) && isConst?(type,PBTypes,:ELECTRIC))\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s #{PBAbilities.getName(opponent.ability)} (made #{@name} ineffective)\")\n if opponent.pbCanIncreaseStatStage?(PBStats::SPATK,opponent)\n opponent.pbIncreaseStatWithCause(PBStats::SPATK,1,opponent,PBAbilities.getName(opponent.ability))\n else\n @battle.pbDisplay(_INTL(\"{1}'s {2} made {3} ineffective!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))\n end\n return true\n end\n if opponent.hasWorkingAbility(:MOTORDRIVE) && isConst?(type,PBTypes,:ELECTRIC)\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s Motor Drive (made #{@name} ineffective)\")\n if opponent.pbCanIncreaseStatStage?(PBStats::SPEED,opponent)\n opponent.pbIncreaseStatWithCause(PBStats::SPEED,1,opponent,PBAbilities.getName(opponent.ability))\n else\n @battle.pbDisplay(_INTL(\"{1}'s {2} made {3} ineffective!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))\n end\n return true\n end\n if (opponent.hasWorkingAbility(:DRYSKIN) && isConst?(type,PBTypes,:WATER)) ||\n (opponent.hasWorkingAbility(:VOLTABSORB) && isConst?(type,PBTypes,:ELECTRIC)) ||\n (opponent.hasWorkingAbility(:WATERABSORB) && isConst?(type,PBTypes,:WATER))\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s #{PBAbilities.getName(opponent.ability)} (made #{@name} ineffective)\")\n healed=false\n if opponent.effects[PBEffects::HealBlock]==0\n if opponent.pbRecoverHP((opponent.totalhp/4).floor,true)>0\n @battle.pbDisplay(_INTL(\"{1}'s {2} restored its HP!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability)))\n end\n end\n if !healed\n @battle.pbDisplay(_INTL(\"{1}'s {2} made {3} useless!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability),@name))\n end\n return true\n end\n if opponent.hasWorkingAbility(:FLASHFIRE) && isConst?(type,PBTypes,:FIRE)\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s Flash Fire (made #{@name} ineffective)\")\n if !opponent.effects[PBEffects::FlashFire]\n opponent.effects[PBEffects::FlashFire]=true\n @battle.pbDisplay(_INTL(\"{1}'s {2} raised its Fire power!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability)))\n else\n @battle.pbDisplay(_INTL(\"{1}'s {2} made {3} ineffective!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))\n end\n return true\n end\n if opponent.hasWorkingAbility(:TELEPATHY) && pbIsDamaging? &&\n !opponent.pbIsOpposing?(attacker.index)\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s Telepathy (made #{@name} ineffective)\")\n @battle.pbDisplay(_INTL(\"{1} avoids attacks by its ally Jermon!\",opponent.pbThis))\n return true\n end\n if opponent.hasWorkingAbility(:BULLETPROOF) && isBombMove?\n PBDebug.log(\"[Ability triggered] #{opponent.pbThis}'s Bulletproof (made #{@name} ineffective)\")\n @battle.pbDisplay(_INTL(\"{1}'s {2} made {3} ineffective!\",\n opponent.pbThis,PBAbilities.getName(opponent.ability),self.name))\n return true\n end\n return false\n end",
"def calc_block_rate(item)\r\r\n block_rate_plus = 0\r\r\n\r\r\n for skill in $data_notetagged_items\r\r\n next if skill.nil? || !skill.is_a?(RPG::Skill)\r\r\n next unless self.skills.include?(skill) && skill_equip_ready?(skill)\r\r\n \r\r\n bonus = skill.block_adjust_set ? skill.block_adjust_set : 0 rescue nil\r\r\n bonus += skill.missile_block_rate if item.is_missile rescue nil\r\r\n bonus = 0 if bonus.nil?\r\r\n block_rate_plus += bonus\r\r\n \r\r\n end\r\r\n \r\r\n for state in self.states\r\r\n next if state.nil?\r\r\n \r\r\n bonus = state.block_adjust_set ? state.block_adjust_set : 0 rescue nil\r\r\n if item.is_missile \r\r\n bonus += state.missile_block_rate ? state.missile_block_rate : 0 rescue nil\r\r\n end\r\r\n bonus = 0 if bonus.nil?\r\r\n block_rate_plus += bonus\r\r\n end\r\r\n \r\r\n return block_rate_plus\r\r\n end",
"def valid_item?\n # PCP Items can only be created by Commenting Group\n return 1 if pcp_step.in_presenting_group?\n\n # scenario without comments; note that I can safely assume that there are at\n # least two steps ... because it is not allowed to add PCP Items to the first\n # PCP Step (0), hence the current step is at least PCP Step (1).\n ps = pcp_subject.current_steps\n if pcp_comments.count == 0 then\n if pcp_step == ps[ 0 ] # newly created?\n return ( pub_assmt.nil? && new_assmt == assessment ) ? 0 : 2\n elsif pcp_step == ps[ 1 ] # new item released\n return ( pub_assmt == new_assmt && new_assmt == assessment ) ? 0 : 3\n else\n # inconsistent: there should be comments in the previous step\n return 4\n end\n end\n # we have comments here ( pcp_comments.count > 0 )\n \n # if PCP Item was newly created for step, last public comment -\n # if existing - determines current assessment, else assessment\n if pcp_step == ps[ 0 ]\n return 5 unless pub_assmt.nil?\n na = assessment\n pcp_comments.each do | c |\n return 6 unless c.pcp_step == pcp_step\n na = c.assessment if c.is_public\n end\n return ( new_assmt == na ) ? 0 : 7\n end\n\n # PCP Item was created for earlier step, determine current assessment\n # from current comments: default is last, most recent comment, look\n # for any public comments which then override new_assmt\n pc = pcp_comments.for_step( ps[ 0 ])\n if pc.count == 0 \n # no comments for current step (yet - or if closed)\n return 8 unless ( pub_assmt == new_assmt )\n elsif ps[ 0 ].in_commenting_group?\n na = pc.last.assessment\n pc.each do | c |\n na = c.assessment if c.is_public\n end\n return 9 unless ( new_assmt == na )\n else\n # no assessment changes allowed by presenting group\n pc.each do | c |\n return 10 if assessment_changed?( c.assessment )\n end\n end\n\n # now check if pub_assmt is correctly computed from previous step:\n # determine last released assessment, if any\n\n if ps[ 1 ].in_presenting_group?\n # there should be no changes at all\n pc = pcp_comments.for_step( ps[ 1 ])\n pc.each do | c |\n return 11 unless ( pub_assmt == c.assessment )\n # note: new_assmt could be different now due to new comments\n # in current step ...\n end\n else # in_commenting_group?\n pc = pcp_comments.is_public.for_step( ps[ 1 ])\n if pc.count > 0\n return 12 unless ( pub_assmt == pc.last.assessment )\n else # no public comments, assessment comes from item\n return 13 unless ( pub_assmt == new_assmt && new_assmt == assessment )\n end\n end\n\n return 0\n end",
"def use_item(item)\n battler.use_item(item)\n end",
"def next_item\n if (player.location.inventory.length > @index)\n @item = player.location.inventory[@index]\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n else\n game.change_state(Map.new)\n end\n end",
"def tbs_use_item_era(item)\n \n tb = TactBattleManager.tact_battle?\n ch_tar = tb && TactBattleManager.selecting_target? # remove\n \n # Case during a tact battle, and not selecting a target\n if tb && !ch_tar\n return if (tb_event = $game_temp.tb_event).nil?\n dir = tb_event.dir_to_sym_era\n r1,r2 = item.tbs_spec_range, item.tbs_simple_range\n \n range = r1.nil? ? r2 : r1[dir]\n return no_range_set_tb(item) if r1.nil? && r2.nil?\n \n if r1.nil?\n if self.is_a?(Game_Actor)\n \n n,m = item.tb_range_min-1, item.tb_range_max-1\n range=Unit_Range.points(0,0,eqp_r_min(item) + n,eqp_r_max(item)+m)\n else; range = r2; end\n else; range = r1[dir]; end\n \n if !range.nil?\n range = relative_range_era(range)\n $game_map.next_att_highlights(range, item.tbs_hl_color)\n end\n \n # instead of doing this here, alias use_item inside game_battler, and call\n # it twice. Once when using the item initially, and then again after the\n # target has been selected.\n TactBattleManager.set_selecting_target(true)\n $game_temp.tb_item = item\n \n if !SceneManager.scene.is_a?(Scene_Map) && SceneManager.get_stack.size > 0\n SceneManager.return \n end\n # SceneManager.return # <= this fucking line of code... omfg wow.. fucking noob shit\n # was causing SceneManager to pop off last scene from stack\n # and seemingly exit strangely. Scariest error of my life,\n # had no call stack to debug with\n end\n end",
"def handle_menu(menu_item,battleship)\n\n case menu_item.to_i\n\n when 1\n # view_all_apts(apartments)\n menu_item=0\n battleship=start_game\n battleship.build_ship\n battleship.build_ship\n return false\n when 2\n battleship.showship = !battleship.showship\n return false\n when 3\n battleship.build_ship\n battleship.show_board\n return false\n\n when 99\n return true\n else\n puts(\"Please type a Valid Menu Item\")\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n end #case\n end",
"def on_item_ok\n @item = @item_window.item\n BattleManager.actor.input.set_item(@item.id)\n action = BattleManager.actor.input\n case @item.target_type[0]\n when :one\n select_target_selection\n when :all\n BattleManager.actor.input.set = SES::TargetManager.make_targets(action)\n when :rand\n targets, set = [], SES::TargetManager.make_targets(action)\n (@item.target_type[1][0] + rand(@item.target_type[1][1])).times do\n targets << set[rand(set.size)]\n end\n BattleManager.actor.input.set = set\n else\n @item_window.hide\n next_command\n end\n $game_party.last_item.object = @item\n end",
"def slot_contain_pokemon?(index)\n return @boxes[@current_box][index].class == ::PFM::Pokemon\n end",
"def perform_status_heal(bag, has_full_restore, *item_ids)\n if has_full_restore\n return _stack_add_item(pokemon: pokemon, item_id: :full_restore, bag: bag)\n else\n item_ids.each do |id|\n if bag.contain_item?(id)\n return _stack_add_item(pokemon: pokemon, item_id: id, bag: bag)\n end\n end\n end\n return false\n end",
"def add_item_verify\n\t\twait_for_animate\n\t\tvalue1= query(\"* marked:'quantityText'\", :text)[0]\n\t\tguide_price1 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity Before Add Item : : #{value1}\"\n\t\ttouch(\"* id:'add_btn'\")\n\t\twait_for_animate\n\t\tsleep 4\n\t\t#wait_for_elements_exist( [\"button marked:'Open basket'\"], :timeout => 40)\n\t\tvalue2 = query(\"* marked:'quantityText'\", :text)[0]\n\t\tif (value2 == \"0\")\n\t\t\tvalue2 = query(\"* marked:'quantityText'\", :text)[3]\n\t\tend\n\t\tguide_price2 = query(\"* marked:'basket_action_bar_up'\", :text)[0]\n\t\tputs \"Quantity After Add Item: : #{value2}\"\n\t\t#campare_values(value1,value2)\n\t\t#campare_values(guide_price1,guide_price2)\n\t\t#puts \"Item added successfully\"\n\n\tend",
"def use_item\n\n if @inventory.empty?\n slow_type(\"\\nYou don't have anything in your inventory\")\n\n else\n print_inventory_items\n\n use_item = TTY::Prompt.new\n\n choices = []\n @options = []\n @inventory.each do |item_id|\n inventory_item = find_item_by_id(item_id)\n choices << { name: inventory_item.name, value: inventory_item.item_id }\n end\n\n item_id = use_item.select(slow_type(\"\\nWhat would you like to use?\"), choices)\n \n selected_item = find_item_by_id(item_id)\n \n use_on = TTY::Prompt.new\n\n choices = []\n @options = []\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n choices << { name: item.name, value: item.item_id } unless @inventory.include?(item.item_id) || item.show_item == false\n end\n\n target_item = use_on.select(slow_type(\"\\nWhat would you like to use the #{selected_item.name} on?\"), choices)\n\n combo = @use_combos.find { |combo| combo[:item_id] == item_id && combo[:usage_location] == @current_room_id && combo[:target_id] == target_item}\n \n if combo.nil?\n slow_type(\"\\nYou cannot use these two items together\") \n \n else \n use_item_dependency(item_id)\n slow_type(combo[:message])\n\n if combo[:cell_to_unlock]\n find_room_by_id(combo[:cell_to_unlock]).isLocked = false\n game_complete if combo[:game_complete]\n\n elsif\n combo[:knocked_out]\n @guard_is_knocked_out = true\n end\n\n end\n end\n end",
"def item_apply(user, item)\n @result.clear\n @result.used = item_test(user, item)\n @result.missed = (@result.used && rand >= item_hit(user, item))\n @result.evaded = ([email protected] && rand < item_eva(user, item))\n if @result.hit?\n unless item.damage.none?\n @result.critical = (rand < item_cri(user, item))\n make_damage_value(user, item)\n execute_damage(user)\n end\n item.effects.each {|effect| item_effect_apply(user, item, effect) }\n item_user_effect(user, item)\n end\n end",
"def on_item_ok2; item_ok(@item_window2, @trade_win2, @tb_unit2); end",
"def enable?(item)\n return false if item.nil?\n return false unless has_recipebook?\n return false if item.tocrafting_gold_fee > $game_party.gold\n return false if $game_party.item_max?(item)\n return false unless have_tools?(item)\n return false unless have_actors?(item)\n return true if item.ingredient_list.empty?\n return have_ingredients?(item)\n end",
"def pass_if(b)\n @score = b ? @rubric_item.max_score : 0.0\n end",
"def add_item\n @item = Item.new(:question_id => params[:question_id],\n :ok => params[:item][:ok],\n :ans => params[:item][:ans])\n last_pos = 0\n last_item = @question.items.order(:position).last\n if !last_item.nil?\n last_pos = last_item.position\n end\n @item.position = last_pos+1\n if [email protected]_answers && @item.ok && @question.items.count > 0\n flash[:info] = \"La réponse correcte a maintenant changé (une seule réponse est possible pour cet exercice).\"\n # Two good answer\n # We put the other one to false\n @question.items.each do |f|\n if f.ok\n f.ok = false\n f.save\n end\n end\n end\n if [email protected]_answers && [email protected] && @question.items.count == 0\n flash[:info] = \"Cette réponse est mise correcte par défaut. Celle-ci redeviendra erronée lorsque vous rajouterez la réponse correcte.\"\n @item.ok = true\n end\n unless @item.save\n flash.clear # Remove other flash info\n flash[:danger] = error_list_for(@item)\n end\n redirect_to question_manage_items_path(@question)\n end",
"def has_item?(item)\n return true if drops_item?(item)\n return true if can_steal_item?(item)\n false\n end",
"def process_after_save\n \t# QualityLotGaugeResult.skip_callback(\"save\", :after, :process_after_save)\n \tpos_tolerance = self.item_part_dimension.item_part_dimension.to_f + self.item_part_dimension.item_part_pos_tolerance.to_f\n \tneg_tolerance = self.item_part_dimension.item_part_dimension.to_f - self.item_part_dimension.item_part_neg_tolerance.to_f\n \tdimension_max = self.all_lot_gauges.maximum(:lot_gauge_result_value).to_f\n \tdimension_min = self.all_lot_gauges.minimum(:lot_gauge_result_value).to_f\n\n \tif dimension_max.between?(neg_tolerance, pos_tolerance) && dimension_min.between?(neg_tolerance, pos_tolerance)\n \t \tself.all_lot_gauges.update_all(:lot_gauge_result_status => \"accepted\")\n \telse\n \t \tself.all_lot_gauges.update_all(:lot_gauge_result_status => \"rejected\")\n \tend\n \t# QualityLotGaugeResult.set_callback(\"save\", :after, :process_after_save)\n end",
"def damage(item_damaged) #allow the item class to be use through the parameter\n until @current_time == @time || item_damaged.item_health == 0 || @tool_health == 0\n item_damaged.item_health -= 5\n @tool_health -= 10\n @current_time += 1\n end\n end",
"def bust_or_win?\n if player.total == BLACKJACK\n puts \"#{player.name} hit backjack!! #{player.name} lost, dealer lost.\"\n play_again?\n elsif player.total > BLACKJACK\n puts \"#{player.name} busted! #{player.name} lost, dealer won.\"\n play_again?\n elsif dealer.total == BLACKJACK\n puts \"Dealer hit blackjack!! #{player.name} lost.\" \n play_again?\n elsif dealer.total > BLACKJACK\n puts \"Dealer busted! #{player.name} won.\"\n play_again?\n else\n \"continue\"\n end\n end",
"def item_usable?\n return false unless @item\n return @actor ? @actor.usable?(@item) : $game_player.usable?(@item)\n end",
"def validate\n @result = POSSIBLE_RESULT[@index]\n $game_system.se_play($data_system.decision_se)\n end",
"def pbBikeCheck\n if $PokemonGlobal.surfing ||\n (!$PokemonGlobal.bicycle && pbGetTerrainTag==PBTerrain::TallGrass)\n Kernel.pbMessage(_INTL(\"Can't use that here.\"))\n return false\n end\n# if $game_player.pbHasDependentEvents?\n# Kernel.pbMessage(_INTL(\"It can't be used when you have someone with you.\"))\n# return false\n# end\n if $PokemonGlobal.bicycle\n if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)\n Kernel.pbMessage(_INTL(\"You can't dismount your Bike here.\"))\n return false\n end\n return true\n else\n val=pbGetMetadata($game_map.map_id,MetadataBicycle)\n val=pbGetMetadata($game_map.map_id,MetadataOutdoor) if val==nil\n if !val\n Kernel.pbMessage(_INTL(\"Can't use that here.\"))\n return false\n end\n return true\n end\nend",
"def validate_refill(items)\n raise App::InvalidParameter, 'incorrect input provided, expects Hash' if items.class != Hash\n items.each do |key, value|\n raise App::InvalidParameter, \"invalid refill item '#{key}' provided\" unless value.to_f && @inventory[key.to_s]\n raise App::InvalidParameter, \"negative amount provided for #{key}\" if value && value.to_f < 0\n left_space = @capacity[key.to_s] - @inventory[key.to_s]\n raise App::InvalidParameter, \"#{key} overflow, left space is #{left_space} ml\" if left_space < value.to_f\n end\n end",
"def backer?\n bounties.count > 0\n end",
"def take_item(command)\n if @current_room.has_item?(command) # item isn't in current room\n self.new_current_item(command)\n # Remove from room and add to backpack\n @current_room.remove_item(command)\n @player.pick_up(command)\n puts \"\\nYou have picked up a #{@current_item.name}\"\n puts @current_item.collect_description + \"\\n\\n\"\n else\n puts \"This item isn't here\\n\"\n end\n end",
"def item_growth_effect( user, item )\n if item.parameter_type > 0 and item.parameter_points != 0\n case item.parameter_type\n when 1 # Maximum HP\n @maxhp_plus += item.parameter_points\n @cached_maxhp = nil\n when 2 # Maximum MP\n @maxmp_plus += item.parameter_points\n @cached_maxmp = nil\n when 3 # Attack\n @atk_plus += item.parameter_points\n @cached_atk = nil\n when 4 # Defense\n @def_plus += item.parameter_points\n @cached_def = nil\n when 5 # Spirit\n @spi_plus += item.parameter_points\n @cached_spi = nil\n when 6 # Agility\n @agi_plus += item.parameter_points\n @cached_agi = nil\n end\n end\n end"
] | [
"0.6544835",
"0.6384428",
"0.63258195",
"0.6312675",
"0.6167244",
"0.6150383",
"0.6149054",
"0.6097104",
"0.60433525",
"0.6040932",
"0.6009231",
"0.6005586",
"0.59727484",
"0.59668845",
"0.5927016",
"0.5894959",
"0.5849974",
"0.584237",
"0.5819108",
"0.58133554",
"0.58028847",
"0.5800143",
"0.57853705",
"0.5764321",
"0.5747916",
"0.5738252",
"0.5731018",
"0.57292473",
"0.57167447",
"0.5705856",
"0.57037354",
"0.5696906",
"0.56881106",
"0.56505835",
"0.5638175",
"0.56315154",
"0.5623639",
"0.5617518",
"0.56166464",
"0.56031513",
"0.5603053",
"0.55855244",
"0.5569447",
"0.5569432",
"0.55635035",
"0.5563035",
"0.55557007",
"0.5549053",
"0.5539128",
"0.5531742",
"0.5513244",
"0.5492421",
"0.54830366",
"0.54524416",
"0.5445976",
"0.54169774",
"0.5414133",
"0.5406169",
"0.5403362",
"0.54015154",
"0.53970057",
"0.53876734",
"0.5379477",
"0.53788155",
"0.537174",
"0.53536856",
"0.53530216",
"0.5344643",
"0.5338565",
"0.5336813",
"0.53295875",
"0.5314745",
"0.53143865",
"0.531418",
"0.5312349",
"0.5305997",
"0.5299189",
"0.529702",
"0.5291331",
"0.5288151",
"0.52699184",
"0.5267133",
"0.526081",
"0.52561444",
"0.52550685",
"0.52481306",
"0.5232521",
"0.5231877",
"0.5229481",
"0.5229201",
"0.52265537",
"0.5226046",
"0.5226045",
"0.52249235",
"0.5221356",
"0.5216998",
"0.52148646",
"0.52111936",
"0.5208272",
"0.52058905"
] | 0.5872931 | 16 |
Validates direction inputted leads to a room Updates current room | def go_room(command)
if @current_room.has_exit?(command)
# current room has this exit
exit_room = @current_room.get_exit(command) # return string of room name
# Search for instance of this room
# update current room
@game_rooms.each do |room|
if room.is_room?(exit_room)
@current_room = room # update current room
end
end
puts "\nYou have entered the #{@current_room.print_name}!\n"
else
puts "That is not a direction you can travel.\n"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @room = Room.update(params.require(:id), room_attributes)\n if @room.valid?\n success\n else\n validation_errors(@room)\n end\n end",
"def update\n if @moving.update(moving_params)\n unless @moving.save_rooms(params[:moving][:rooms])\n flash[:warning] = \"Couldn't save rooms\"\n end\n flash[:success] = \"Moving updated\"\n redirect_to moving_url(@moving)\n else\n render 'edit'\n end\n end",
"def move(direction)\n movements = @game.current_room_model.movement\n monster = @game.current_room_model.monster\n\n if direction == :north and not movements.north\n return \"No exit that way\"\n elsif direction == :south and not movements.south\n return \"There is no exit south\"\n elsif direction == :east and not movements.east\n return \"You cannot go in that direction\"\n elsif direction == :west and not movements.west\n return \"You cannot move through solid stone\"\n elsif direction == :up and not movements.up\n return \"You cannot go up this floor\"\n elsif direction == :down and not movements.down\n return \"You cannot go down this floor\"\n end\n\n return \"Monster shouts: YOU SHALL NOT PASS!!\" if monster && rand < 0.1\n\n @game.current_room = movements.send(direction)\n @game.player.tally += 1\n @game.player.strength -= 5\n\n if @game.player.strength < 1\n @game.state = DeadState.new @game\n else\n @game.state = WinnerState.new(@game) if @game.current_room == \"Exit\"\n end\n\n \"You moved to another room...\"\n end",
"def update_direction!\n direction.place!(command.arguments[:direction])\n end",
"def update\n if @direction.created_by != current_user\n flash[:alert]=\"You cannot modify another user direction\"\n redirect_to users_directions_url\n else\n respond_to do |format|\n if @direction.update(direction_params)\n format.html { redirect_to users_directions_url, notice: 'direction was successfully updated.' }\n format.json { render :show, status: :ok, location: [:service, @direction] }\n else\n format.html { render :edit }\n format.json { render json: @direction.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n if @room.update(room_params)\n redirect_to @room\n else\n render 'edit'\n end\n end",
"def update\n if @room.update(room_params)\n redirect_to admin_rooms_path, notice: 'Room was successfully updated.'\n else\n render :edit\n end\n end",
"def move(direction)\n if not @location.exits.include? direction\n return nil\n end\n destination = @location.exits[direction]\n if not @rooms.include? destination \n raise \"%s was not a known room name.\" % destination\n end\n @location = @rooms[destination]\n return @location\n end",
"def update\n if params[:move_up] || params[:move_down]\n update_move\n else\n update_all\n end\n end",
"def update\n if params[:move_up] || params[:move_down]\n update_move\n else\n update_all\n end\n end",
"def update\n if params[:move_up] || params[:move_down]\n update_move\n else\n update_all\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: t('flash.room.upadate') }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_in_direction dir\n new_room = Room.create({:created_at=>Time.now, :x=>self.x, :y=>self.y, :z=>self.z})\n \n case dir\n when \"north\",:north, 0\n new_room.y += 1\n when \"east\", :east, 1\n new_room.x += 1\n when \"south\",:south, 2\n new_room.y -= 1\n when \"west\",:west, 3\n new_room.x -= 1\n when \"up\",:up, 4\n new_room.y += 1\n when \"down\",:down, 5\n new_room.y -= 1\n end\n \n create_exit(dir, new_room, true) # two way exit\n return new_room\n end",
"def update\n @room = Room.find(params[:id])\n\n if @room.update_attributes(params[:room])\n head :ok\n else\n render :json => @room.errors, :status => :unprocessable_entity \n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @room.update(room_params)\n\t\t\t\tformat.html { redirect_to @room, notice: 'Room was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @room }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @room.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update_position(direction)\n ox, oy = @x, @y\n nx, ny = @x, @y\n case direction\n when :left\n nx -= 1\n when :right\n nx += 1\n when :up\n return unless @current_cell.ladder? && !@current_cell.sky?\n ny -= 1\n when :down\n ny += 1\n end\n \n # If the would-be destination isn't valid, just return without doing anything\n return if @map.cells_at[nx][ny].rock\n return unless ((0..MAP_SIZE - 1).include?(nx) && (0..MAP_SIZE - 1).include?(ny))\n \n # If we've made it this far, the move is valid. Update player's cell coords now.\n @x, @y = nx, ny\n set_center\n set_current_cell\n \n # Fire some events at the map, so it knows how to redraw things the next time around\n @map.handle(CellDugEvent.new([nx, ny])) unless @map.cells_at[nx][ny].dug? or @map.cells_at[nx][ny].sky?\n @map.handle(PlayerMovedEvent.new([ox, oy]))\n\n # Decide whether this move put the player in gravitational jeopardy\n @falling = true if @map.cells_at[nx][ny + 1].dug? && [email protected]_at[nx][ny + 1].ladder?\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update_attributes(room_params)\n format.html { redirect_to room_path(@room.slug), notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to rooms_path, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_room.update(admin_room_params)\n format.html { redirect_to [:admin, @admin_room.building], notice: 'Room was successfully updated.' }\n # format.json { render :show, status: :ok, location: @admin_room }\n else\n format.html { render :edit }\n # format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def move\n @dungeon.set_next_room( params[:direction].to_sym)\n if @dungeon_instance.update(dungeon_data: @dungeon.to_json)\n redirect_to dungeon_instance_play_path( @dungeon_instance )\n end\n end",
"def update_rooms\n Room.find_or_create_by(name: @moving_item.room)\n end",
"def update\n \n if @meeting_room.update(room_params)\n redirect_to meeting_rooms_path\n else\n render 'edit'\n end\n end",
"def move(direction)\n\t\tnorth = [\"n\", \"up\", \"north\"]\n\t\teast = [\"e\", \"right\", \"east\"]\n\t\twest = [\"w\", \"left\", \"west\"]\n\t\tsouth = [\"s\", \"down\", \"south\"]\n\t\tif north.include?(direction)\n\t\t\tdirection == \"north\"\n\t\telsif east.include?(direction)\n\t\t\tdirection == \"east\"\n\t\telsif west.include?(direction)\n\t\t\tdirection == \"west\"\n\t\telsif south.include?(direction)\n\t\t\tdirection == south\n\t\tend\n\t\tif $hero.location.exits.has_key?(direction)\n\t\t\tnewroom = $hero.location.exits[direction]\n\t\t\t$hero.location = newroom\n\t\t\t$hero.xy = newroom.xy\n\t\telse\n\t\t\tputs \"You cannot travel #{direction}. The path does not lead there.\"\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: \"Room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_room_status\n room.update(:is_available => false)\n end",
"def update\n @direction = Direction.find(params[:id])\n\n respond_to do |format|\n if @direction.update_attributes(params[:direction])\n format.html { redirect_to(admin_direction_path(@direction), :notice => 'Direction was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @direction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @room.update(room_params)\n render json: @room, status: :ok, serializer: RoomSerializer\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to rooms_path, notice: \"Sala '\" + @room.name + \"' atualizada com sucesso!\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, alert: 'Что-то пошло не так' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: t('default.room.updated') }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @error, status: :unprocessable_entity }\n end\n end\n end",
"def can_change_direction_to?(new_direction)\n case @direction\n when 'up' then new_direction != 'down'\n when 'down' then new_direction != 'up'\n when 'left' then new_direction != 'right'\n when 'right' then new_direction != 'left'\n end\n end",
"def update\n\n respond_to do |format|\n if @room.update(room_params_update)\n format.html { redirect_to @room, :flash => { success: 'Room was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def direction_parser(word)\n if (word == \"north\" or word == \"n\") and hero.location.north_room\n hero.location = hero.location.north_room\n elsif (word == \"south\" or word == \"s\") and hero.location.south_room\n hero.location = hero.location.south_room\n elsif (word == \"east\" or word == \"e\") and hero.location.east_room\n hero.location = hero.location.east_room\n elsif (word == \"west\" or word == \"w\") and hero.location.west_room\n hero.location = hero.location.west_room\n elsif (word == \"up\" or word == \"u\") and hero.location.up_room\n hero.location = hero.location.up_room\n elsif (word == \"down\" or word == \"d\") and hero.location.down_room\n hero.location = hero.location.down_room\n else\n invalid_direction\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to(@room, :notice => 'Room was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cleaning_room.update(cleaning_room_params)\n format.html { redirect_to @cleaning_room, notice: 'Cleaning room was successfully updated.' }\n format.json { render :show, status: :ok, location: @cleaning_room }\n else\n format.html { render :edit }\n format.json { render json: @cleaning_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def transfer(new_room)\n raise HmsErrors::Bed::CannotMoveOffWard unless self.room.ward == new_room.ward\n \n self.room = new_room\n self.save!\n true\n end",
"def update\n if @room.update(room_params)\n head :no_content\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'La Sala ha sido actualizada correctamente!' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @empty_room.update(empty_room_params)\n format.html { redirect_to @empty_room, notice: 'Empty room was successfully updated.' }\n format.json { render :show, status: :ok, location: @empty_room }\n else\n format.html { render :edit }\n format.json { render json: @empty_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to staff_path(@room.id), notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: staff_path(@room.id).errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @request_room.update(request_room_params)\n format.html { redirect_to @request_room, notice: 'Request room was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_room }\n else\n format.html { render :edit }\n format.json { render json: @request_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_room.update(admin_room_params)\n format.html { redirect_to admin_rooms_path, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @rooms = Room.all\n @groups = Group.all\n @passenger = Passenger.new\n @passengers = Passenger.all\n @enterprise = Enterprise.new\n @enterprises = Enterprise.all\n @room_types = RoomType.all\n\n @reservation.update_attributes( reservation_params )\n\n respond_to do |format|\n if @reservation.guardar( new_reservation_rooms )\n format.html { redirect_to @reservation, notice: 'Los datos de la reserva ha sido modificados correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_direction\n direction = params.try(:[], 2)\n unless Robot::Engine::DIRECTIONS.include?(direction)\n errors[:params] << \"[PLACE] Not valid 3 param. Expected #{Robot::Engine::DIRECTIONS.join(', ')}. Got #{direction}\"\n end\n end",
"def update\n\n filteredParams = params.require(:room).permit(:name, :privacy, :password, :id)\n @room = Room.find(filteredParams[\"id\"]) rescue nil\n\n if filteredParams[\"privacy\"] && filteredParams[\"privacy\"] == \"on\"\n filteredParams[\"privacy\"] = \"private\"\n else\n filteredParams[\"privacy\"] = \"public\"\n end \n\n # if ![\"\", \"public\", \"private\"].include?(filteredParams[\"privacy\"])\n # res_with_error(\"Privacy field must be either empty, public or private\", :bad_request)\n # return (false)\n # end\n\n if filteredParams[\"privacy\"] == \"private\"\n if filteredParams[\"password\"].empty?\n res_with_error(\"None empty password required if the room is private\", :bad_request)\n return (false)\n else\n roomPassword = BCrypt::Password.create filteredParams[\"password\"]\n filteredParams[\"password\"] = roomPassword\n end\n end\n\n if filteredParams[\"privacy\"] == \"public\"\n filteredParams[\"password\"] = \"\"\n end\n\n filteredParams.each do |key, value|\n if (value == \"\" && (filteredParams[\"privacy\"] != \"public\" && key != \"password\"))\n filteredParams.delete(key)\n end\n end\n\n if !filteredParams[\"name\"] || filteredParams[\"name\"].length == 0 || filteredParams[\"name\"].blank?\n res_with_error(\"Empty Room Name\", :bad_request)\n return (false)\n end\n\n if @room == nil\n res_with_error(\"Unknown Room\", :bad_request)\n return (false)\n end\n \n respond_to do |format|\n if @room.update(filteredParams)\n\n ActionCable.server.broadcast \"room_channel\", type: \"rooms\", description: \"update\", user: current_user\n format.html { redirect_to :index, notice: 'Room was successfully updated.' }\n format.json { render :index, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room}\n flash[:success] ='Room was successfully updated.'\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to hotel_path(@room.hotel_id), notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n \n @room.criterias.delete_all\n params[:criteria].each_pair do |k,v|\n @room.criterias << Criteria.find(k.to_i) if v == \"1\"\n end\n\n @room.not_criterias.delete_all \n params[:not_criteria].each_pair do |k,v|\n @room.not_criterias << Criteria.find(k.to_i) if v == \"1\"\n end\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n flash[:notice] = 'Room was successfully updated.'\n format.html { redirect_to agency_site_room_path(params[:agency_id], params[:site_id], @room.id) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @direction = args[:direction] if args.key?(:direction)\n @span = args[:span] if args.key?(:span)\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to school_room_path(@room.school,@room), notice: 'Room update successful.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @check = RoomManagement.find(params[:id])\n @room_management.user = current_user\n if params[:room_management][:status] == \"Available\" then\n puts params[:room_management][:arrival_date]\n @room_management.student_id = nil\n @room_management.arrival_date = nil\n if [email protected]_id.nil?\n @room_history = RoomHistory.new\n @room_history.category_no = params[:room_management][:category_no]\n @room_history.dorm = params[:room_management][:dorm]\n @room_history.student_id = @check.student_id\n @room_history.arrival_date = @check.arrival_date\n @room_history.leave_date = DateTime.civil(params[:room_management][\"arrival_date(1i)\"].to_f,params[:room_management][\"arrival_date(2i)\"].to_f,params[:room_management][\"arrival_date(3i)\"].to_f,params[:room_management][\"arrival_date(4i)\"].to_f,params[:room_management][\"arrival_date(5i)\"].to_f, 0, 0)\n @room_history.allocated_user_id = @check.user_id\n @room_history.deallocated_user_id = current_user.id\n @room_history.room_management = @check\n @room_history.save\n\n @room_management.status = \"Available\"\n params[:room_management].delete_if{ |key, value| key.match(/^arrival_date/) }\n end\n end\n respond_to do |format|\n if @room_management.update(room_management_params)\n format.html { redirect_to @room_management, notice: 'Room management was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_management }\n # else\n # format.html { render :edit }\n # format.json { render json: @room_management.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reserved_room.update(reserved_room_params)\n format.html { redirect_to @reserved_room, notice: 'Reserved room was successfully updated.' }\n format.json { render :show, status: :ok, location: @reserved_room }\n else\n format.html { render :edit }\n format.json { render json: @reserved_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @meetingroom.update(meetingroom_params)\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully updated.' }\n format.json { render :show, status: :ok, location: [@space, @meetingroom] }\n else\n format.html { render :edit }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n room = Room.find(params[:id])\n\n if room.update(room_params)\n response_data = {\n room: room,\n txt: ['更新しました!'],\n }\n render json: response_data, status: :ok\n else\n response_data = {\n txt: room.errors.full_messages,\n }\n render json: response_data, status: :unprocessable_entity\n end\n end",
"def assign_room\n\t\tTeam.update_all({room_1: params[:room_1]}, {number: params[:number]}) unless params[:room_1].blank?\n\t\tTeam.update_all({room_2: params[:room_2]}, {number: params[:number]}) unless params[:room_2].blank?\n\t\tTeam.update_all({room_3: params[:room_3]}, {number: params[:number]}) unless params[:room_3].blank?\n\t\tTeam.update_all({room_4: params[:room_4]}, {number: params[:number]}) unless params[:room_4].blank?\n\t\tredirect_to teams_path, notice: \"Rooms Updated\"\n\tend",
"def edit\n if @direction.created_by != current_user\n flash[:alert]=\"You cannot modify another user direction\"\n redirect_to users_directions_url\n end\n end",
"def update\n param=room_params\n actype=param[:AC]\n bedcount=param[:beds]\n param.delete(\"AC\")\n param.delete(\"beds\")\n @room=Room.find_by(roomid:param[:roomid])\n respond_to do |format|\n if @room.update(param)\n [email protected]\n roomtype.update(AC:actype,beds:bedcount)\n format.html { redirect_to @room, notice: \"Room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(last_move_params)\n\t\t\tplayer = last_move_params[0]\n\t\t\tposition = last_move_params[1]\n\n\t\t\tis_move_valid = false\n\n\t\t\t# si la case n'est pas déjà occupée par un autre joueur\n\t\t\t# on set le joueur courant comme owner de la case\n\t\t\tif get_map[position].get_owner == nil\n\t\t\t\tis_move_valid = true\n\t\t\t\tget_map[position].set_owner(player)\n\t\t\telse\n\t\t\t\tputs \"This Case is already taken by another player !\"\n\t\t\t\tputs \"Try again !\"\n\t\t\tend\n\n\t\t\treturn self, is_move_valid\n\t\tend",
"def update\n # Filter only those valid to be updated\n updated_attributes = {}\n updated_attributes[:name] = params[:room][:name]\n updated_attributes[:max_user] = params[:room][:max_user]\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(updated_attributes)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reservation2_room.update(reservation2_room_params)\n format.html { redirect_to @reservation2_room, notice: 'Reservation2 room was successfully updated.' }\n format.json { render :show, status: :ok, location: @reservation2_room }\n else\n format.html { render :edit }\n format.json { render json: @reservation2_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@reservation = Reservation.new(reservation_params)\n #Same date constraints\n if @[email protected]_time.to_date\n redirect_to rooms_path, notice:'Dates should match' and return\n end\n #duration constraint=>automatically assigned\n if params[:duration].to_i==0\n @[email protected]_time+60.minutes\n else \n @[email protected]_time+params[:duration].to_i.minutes\n end\n #Date Constraints\n if (@reservation.date < Date.current() || @reservation.date - Date.current() >7)\n redirect_to rooms_path, notice:'Failed due to date constraints' and return\n end\n #Time Constraints\n if (@reservation.start_time<Time.now)\n redirect_to rooms_path, notice: 'Failed due to time constraints' and return\n end\n #Member Overlap\n @reservations = Reservation.where(\"member_id=? AND date=? AND (start_time, end_time) overlaps (?,?) AND id <> ?\", @reservation.member_id, @reservation.date, @reservation.start_time, @reservation.end_time,@reservation.id)\n if !(is_admin?)\n if !(@reservations.empty?)\n redirect_to rooms_path, notice: 'Failed due to member constraint' and return\n end\n end\n #Room Overlap\n @reservations = Reservation.where(\"room_id=? AND date=? AND (start_time, end_time) overlaps (?,?) AND id<> ?\", @reservation.room_id, @reservation.date, @reservation.start_time, @reservation.end_time,@reservation.id)\n if !(@reservations.empty?)\n redirect_to rooms_path, notice: 'Failed due to room overlap' and return\n end\n respond_to do |format|\n if @reservation.update(reservation_params)\n format.html { redirect_to @reservation, notice: \"Success\"}\n format.json { render :show, status: :created, location: @reservation }\n else\n format.html { render :new }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @occupied_room.update(occupied_room_params)\n format.html { redirect_to @occupied_room, notice: 'Occupied room was successfully updated.' }\n format.json { render :show, status: :ok, location: @occupied_room }\n else\n format.html { render :edit }\n format.json { render json: @occupied_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @roomtype = DetailRoom.all_types\n @time = Room.all_times\n @day_list = Room.all_days\n @rooms = Room.all\n @rooms.each do |room|\n r={}\n r[\"roomname\"] = room.roomname\n r[\"first\"] = \"free\"\n r[\"second\"] = \"free\"\n r[\"third\"] = \"free\"\n r[\"fourth\"] = \"free\"\n r[\"fifth\"] = \"free\"\n r[\"sixth\"] = \"free\"\n r[\"seventh\"] = \"free\"\n r[\"eighth\"] = \"free\"\n r[\"day\"] = room.day\n room.update_attributes!(r)\n end\n redirect_to staffs_path\n \n end",
"def update\n respond_to do |format|\n if @dte_direction.update(dte_direction_params)\n format.html { redirect_to @dte_direction, notice: 'Dte direction was successfully updated.' }\n format.json { render :show, status: :ok, location: @dte_direction }\n else\n format.html { render :edit }\n format.json { render json: @dte_direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def direction?(new_direction)\n case @direction\n when direction = 'up' then new_direction != 'down'\n when direction = 'down' then new_direction != 'up'\n when direction = 'left' then new_direction != 'right'\n when direction = 'right' then new_direction != 'left'\n end\n end",
"def update\n respond_to do |format|\n @route.attributes = route_params\n @route.validate\n if (@route.errors.keys - [:start_station_id, :end_station_id]).size == 0\n @route.save(validate: false)\n end\n if @route.save\n format.html { redirect_to @route, notice: 'Маршрут обновлён.' }\n format.json { render :show, status: :ok, location: @route }\n else\n format.html { render :edit }\n format.json { render json: @route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def check_move(direction)\n\n if direction == 0 #up\n if @y < 1\n \n return false\n end\n elsif direction == 1 #down\n if @y > @boundry\n \n return false\n end\n elsif direction == 2 #left\n if @x < 1\n \n return false\n end\n else #right\n\n if @x > @boundry\n \n return false\n end\n\n end\n\n return true\n end",
"def update\n authorize @direction.recipe\n respond_to do |format|\n if @direction.update(direction_params)\n format.html { redirect_to @direction }\n format.json { render :show, status: :ok, location: @direction }\n else\n format.html { render :edit }\n format.json { render json: @direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def move # takes (x, y, direction) from Rover\n\t\tif direction == \"N\"\n\t\t\t@y += 1\n\t\telsif direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif direction == \"S\"\n\t\t\t@y -= 1\n\t\telsif direction == \"E\"\n\t\t\t@x += 1\n\t\telse \n\t\t\treturn \"The input direction enterned is wrong\"\n\t\tend\n\tend",
"def update\n # Get the chat room\n @chat_room = ChatRoom.find(params[:id])\n\n # Save the changes\n @chat_room.update_attributes(params[:chat_room])\n\n # Update the flash based on whether we locked or unlocked the room\n if @chat_room.locked?\n flash[:notice] = 'Chat room now locked. No one else can join.'\n else\n flash[:notice] = 'Chat room now unlocked. Anyone can join.'\n end\n\n # Send the user back to the page they came from\n redirect_to(:back)\n end",
"def update\n respond_to do |format|\n if @roomlist.update(roomlist_params)\n #format.html { redirect_to @roomlist, notice: 'Roomlist was successfully updated.' }\n format.html { redirect_to @roomlist, notice: 'Room was successfully Allocated.' }\n format.json { render :show, status: :ok, location: @roomlist }\n else\n format.html { render :edit }\n format.json { render json: @roomlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @screeningroom = Screeningroom.find(params[:id])\n\n respond_to do |format|\n if @screeningroom.update_attributes(params[:screeningroom])\n format.html { redirect_to @screeningroom, notice: 'Screeningroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @screeningroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def move()\n if @direction == \"up\"\n move_up()\n elsif @direction == \"down\"\n move_down()\n else\n #check if anyone is on current floor- which way do majority want to go from here?\n @direction = people_on_current_floor()\n if @direction == \"up\" #were more ppl on this floor wanting to go up\n move_up()\n elsif @direction == \"down\"\n move_down()\n else #no one on this floor, decide direction based on pending rqsts above and below...\n decide_direction()\n end\n end\n end",
"def update_old_room_status_if_room_changed\n Room.find_by(:id => room_id_was).update(:is_available => true)\n room.update(:is_available => false)\n end",
"def update(params)\n params[:player][:id].to_i == player1.id ? player = player1 : player = player2 # identify player\n space = params[:space]\n\n if self.game_type == 'hvh'\n self.make_human_move(player, space)\n self.switch_player(player) # sends next 'current player' to front end\n elsif self.game_type == 'hvc'\n if player == player1\n # This will be true every time except for when player2 (computer), starts the game\n self.make_human_move(player, space)\n end\n unless self.game_is_over(self.board)\n # in hvc gameplay, unless human move ends the game:\n # computer move is made every time human player makes a move\n self.make_computer_move(player2)\n self.switch_player(player2) # switch back to player 1\n end\n elsif self.game_type == 'cvc'\n self.make_computer_move(player)\n self.switch_player(player) # sends next 'current player' to front end\n end\n end",
"def valid_room\n return unless room.try(:venue).try(:conference) && program.try(:conference)\n\n errors.add(:room, \"must be a room of #{program.conference.venue.name}\") unless room.venue.conference == program.conference\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def update\n respond_to do |format|\n if @bus_line_direction.update(bus_line_direction_params)\n format.html { redirect_to @bus_line_direction, notice: 'Bus line direction was successfully updated.' }\n format.json { render :show, status: :ok, location: @bus_line_direction }\n else\n format.html { render :edit }\n format.json { render json: @bus_line_direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tddbc_room = Tddbc::Room.find(params[:id])\n\n respond_to do |format|\n if @tddbc_room.update_attributes(params[:tddbc_room])\n format.html { redirect_to @tddbc_room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tddbc_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @telecom_room = TelecomRoom.find(params[:id])\n\n respond_to do |format|\n if @telecom_room.update_attributes(params[:telecom_room])\n format.html { redirect_to(@telecom_room, :notice => 'TelecomRoom was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @telecom_room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_player_movement\r\n # Move player in the direction the directional button is being pressed\r\n case Input.dir4\r\n when 2\r\n move_down\r\n when 4\r\n move_left\r\n when 6\r\n move_right\r\n when 8\r\n move_up\r\n end\r\n end",
"def update_movement\n #p \"Unit Z = #{self.z}\"\n # Skip if the unit is carrying out movement\n if !@running\n # If there is a hidden unit at the next spot, prompt TRAP and stop processing\n if @move_route.size > 0\n case @directions[0]\n when 2 #down\n @h_unit = $game_map.get_unit(@unit.x, @unit.y+1) if ($game_map.get_unit(@unit.x, @unit.y+1).is_a?(Unit) and $game_map.get_unit(@unit.x, @unit.y+1).army != @unit.army)\n when 4 #left\n @h_unit = $game_map.get_unit(@unit.x-1, @unit.y) if ($game_map.get_unit(@unit.x-1, @unit.y).is_a?(Unit) and $game_map.get_unit(@unit.x-1, @unit.y).army != @unit.army)\n when 6 #right\n @h_unit = $game_map.get_unit(@unit.x+1, @unit.y) if ($game_map.get_unit(@unit.x+1, @unit.y).is_a?(Unit) and $game_map.get_unit(@unit.x+1, @unit.y).army != @unit.army)\n when 8 #up\n @h_unit = $game_map.get_unit(@unit.x, @unit.y-1) if ($game_map.get_unit(@unit.x, @unit.y-1).is_a?(Unit) and $game_map.get_unit(@unit.x, @unit.y-1).army != @unit.army)\n end\n end\n # The unit's direction unless there is a hidden unit at the next spot\n @dir = (@h_unit.nil? and !@move_route[0].nil? ? @directions.shift : 0)\n # Reduce unit's fuel based on terrain cost unless it encountered hidden unit\n # OR if route is a series of integers\n if @dir != 0 && @move_route[0].is_a?(MoveTile)\n @unit.fuel -= @move_route.shift.cost\n end\n \n @counter = 1\n case @dir\n when 2 then @real_y += 16\n when 4 then @real_x -= 16\n when 6 then @real_x += 16\n when 8 then @real_y -= 16\n else # when zero (TRAP or not moving)\n @counter = 7\n end\n @running = true\n else\n # Move the sprite to its destination slowly (4 frames per tile)\n @counter += 1\n case @dir\n when 2 then @real_y += 16\n when 4 then @real_x -= 16\n when 6 then @real_x += 16\n when 8 then @real_y -= 16\n end\n # Change the unit's (x,y) values since it reached the tile\n if @counter == 8\n @running = false\n case @dir\n when 2 then @unit.y+=1\n when 4 then @unit.x-=1\n when 6 then @unit.x+=1\n when 8 then @unit.y-=1\n end\n # Slide the cursor with the unit\n unless @unit.loaded or (@dir == 0 and @h_unit.nil?)\n #$game_player.slide_to(@unit.x, @unit.y)\n $game_player.add_move_action(@unit.x, @unit.y, nil,0,nil,true)\n #$game_player.x = @unit.x\n #$game_player.y = @unit.y\n #$game_player.real_x = @unit.x * 128\n #$game_player.real_y = @unit.y * 128\n end\n \n # When done moving the unit or encounter hidden unit\n if @move_route.size == 0 or !@h_unit.nil?\n # Play TRAP animation if hidden unit\n @h_unit.sprite.play_animation('trap') unless @h_unit.nil?\n @unit.trap = (!@h_unit.nil?)\n # Fade the movement SE\n #Audio.bgs_fade(300)\n Audio.bgs_stop\n # Turn off flags\n @is_moving = false\n $spriteset.unit_moving = false\n # Unload the unit\n @unit.loaded = false if @unit.loaded\n # Update the FOW\n $spriteset.update_fow\n end\n end # if @counter != 4\n end # end of if !@running\n end",
"def update\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n if @hotel_room.update_attributes(params[:hotel_room])\n format.html { redirect_to @hotel_room, notice: 'Hotel room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hotel_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @message_room.update(message_room_params)\n format.html { redirect_to @message_room, notice: 'Message room was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_room }\n else\n format.html { render :edit }\n format.json { render json: @message_room.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.64552754",
"0.64520425",
"0.6423017",
"0.626482",
"0.6104987",
"0.60988015",
"0.6079913",
"0.60535735",
"0.6041613",
"0.6041613",
"0.6041613",
"0.6038573",
"0.6012011",
"0.5983828",
"0.5973101",
"0.59718484",
"0.5955458",
"0.59512436",
"0.5949693",
"0.5948011",
"0.5947553",
"0.5946329",
"0.5943727",
"0.59371316",
"0.5934688",
"0.5921585",
"0.5912284",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59046257",
"0.59015214",
"0.58984995",
"0.5890864",
"0.58679295",
"0.58583754",
"0.58564204",
"0.58530307",
"0.58467615",
"0.5841884",
"0.58383405",
"0.5832195",
"0.5831906",
"0.58290684",
"0.58182555",
"0.58077025",
"0.57735115",
"0.5767916",
"0.5755597",
"0.5747379",
"0.5745836",
"0.57432747",
"0.5732029",
"0.5731656",
"0.572306",
"0.57183766",
"0.57050055",
"0.56898516",
"0.5684521",
"0.5664779",
"0.5658779",
"0.5658643",
"0.5650447",
"0.56328875",
"0.56318516",
"0.5609535",
"0.56086975",
"0.56073725",
"0.5592286",
"0.5587805",
"0.556577",
"0.5562078",
"0.5554173",
"0.55414903",
"0.55394244",
"0.5539366",
"0.55324584",
"0.5519271",
"0.5506089",
"0.5478656",
"0.54725873",
"0.54635805",
"0.546357",
"0.5458244",
"0.5456596",
"0.5454698",
"0.54401255",
"0.54289263",
"0.54274404",
"0.5424351",
"0.5419258",
"0.5418869",
"0.5411398",
"0.5402433"
] | 0.61764306 | 4 |
Print available commands, directions, rooms & items | def print_commands
puts "Your available commands are: ".green
puts "go take use help backpack quit\n\n"
puts "Directions:".green
@current_room.print_exits
if @current_room.has_items?
# Room has items in it
puts "\nItems available: ".colorize(:green)
@current_room.print_items
puts "\n"
else
puts "\nThere are no items in this room".green
puts "\n"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_commands\n puts UI_ARROW.light_yellow + \" \" + \"'fight', 'f', or 'battle' to view enemies and fight.\"\n puts UI_ARROW.light_yellow + \" \" + \"'armoury' or 'a' to go to the armoury.\"\n puts UI_ARROW.light_yellow + \" \" + \"'stats' to view your current status.\"\n puts UI_ARROW.light_yellow + \" \" + \"'clear' or 'cls' to clear the screen.\"\n puts UI_ARROW.light_yellow + \" \" + \"'quit', 'q', or 'exit' to abandon your journey.\"\nend",
"def list_commands\n puts UI_ARROW.light_yellow + \" \" + \"'fight', 'f', or 'battle' to view enemies and fight.\"\n puts UI_ARROW.light_yellow + \" \" + \"'armoury' or 'a' to go to the armoury.\"\n puts UI_ARROW.light_yellow + \" \" + \"'stats' to view your current status.\"\n puts UI_ARROW.light_yellow + \" \" + \"'clear' or 'cls' to clear the screen.\"\n puts UI_ARROW.light_yellow + \" \" + \"'quit', 'q', or 'exit' to abandon your journey.\"\n puts\nend",
"def print_list_of_commands\n puts \"Available commands are\"\n puts \"getinfo [CITY_CODE] - Provides all information about that city\"\n puts \"getshortest - Shortest flight\"\n puts \"getlongest - Longest flight\"\n puts \"maproutes - All the CSAir routes on a map in your browser\"\n puts \"getaveragedistance - Average Distance of all flights\"\n puts \"getbiggest - Biggest population city\"\n puts \"getsmallest - Smallest population city\"\n puts \"getaveragepop - Average population of all cities\"\n puts \"getcontinents - List of Cities in each Continent\"\n puts \"gethubs - List of all hub cities\"\n puts \"removecity [CITY_CODE] - Removes city from network\"\n puts \"removeroute [CITY_CODE_1] [CITY_CODE_2] [DIRECTION] - Removes a route from the network based on direction\"\n puts \"[DIRECTION] can take values - \\\"FORWARD\\\" \\\"BACKWARD\\\" \\\"BOTH\\\"\"\n puts \"addcity [CITY_CODE] - Adds a city to the CSAir network\"\n puts \"addroute [CITY_CODE_1] [CITY_CODE_2] [DIRECTION] - Adds a route to the network based on direction\"\n puts \"writetojson - Writes the CSAir network to new json file\"\n puts \"journey [CITY_CODES OF ROUTE] - Creates a journey through CSAir routes.\"\n puts \"findjourney [CITY_CODE_1] [CITY_CODE_2] - Find shortest route between 2 cities\"\n puts \"addjson [FILE_NAME] - Adds a new json file to the CSAir network.\"\nend",
"def print_items\n @items.each { |item| print \"#{item} \"}\n puts \"\\n\"\n end",
"def view_all_locations\n print_all_locations\n puts \"\\n\"\n location_menu\nend",
"def command_printAll\n words = @database.basicFoods\n print = \"\"\n words.each { |name|\n print += \"#{name.to_s} \\n\"\n }\n\n words = @database.recipes\n words.each { |name|\n print += \"\\n #{name.to_s}\"\n }\n\n puts print\n \n end",
"def print_menu\n puts \"1. List patients\"\n # ....\n end",
"def print_battle_commands(header = 'Battle Commands:')\n puts header\n battle_commands.each do |command|\n print \"❊ #{command.name}\\n\"\n end\n print \"\\n\"\n end",
"def print_items\n puts print_line\n puts print_date\n puts print_title\n puts print_line\n puts print_header\n puts print_line\n items.each_with_index do |item, index_no|\n puts item.print_item_details(index_no)\n end\n puts print_line\n end",
"def print_battle_commands(header = \"Battle Commands:\")\n puts header\n battle_commands.each do |command|\n print \"❊ #{command.name}\\n\"\n end\n print \"\\n\"\n end",
"def help()\n\tputs \"Hier is een lijst handige commando's die je gaan helpen met je quest:\"\n\tputs \"ga (richting): Ga in de gespecificeerde richting\"\n\tputs \"open: open deuren, kisten, je hart, etc\"\n\tputs \"kijk: Krijg een beschrijving van de kamer waar je nu bent\"\n\tputs \"neem: Neem een item en stop het in je inventory\"\n\tputs \"gebruik X op X: Gebruik een item uit je inventory op een object\"\n\tputs \"inventory: Bekijk je inventory\"\n\tputs \"stop: Stop de game\"\nend",
"def help\n\t\tputs \"Commands: pick up (weapons/items) , move to, drop, examine myself, describe me, look at me, inventory, look\"\n\t\tputs \"Commands: grab (food items), examine food (details about your food), eat (food), drink (beverages)\" \n\tend",
"def print_menu\n output.puts \"Madden's Car Selection Tool-\"\n \n # Print Current Model Info\n print_model_info\n\n # Print Menu Choices\n print_menu_choices\n\n # Get User Choice\n output.print \"Enter choice: \"\n end",
"def print_help\n puts 'Here is a list of available commands:'\n puts '- new - Create a new contact'\n puts '- list - List all contacts'\n puts '- show - Show a contact'\n puts '- find - Find a contact'\n end",
"def print_menu\n #print menu message\n border = @menu[:message].gsub(/\\s|\\S/, '*')\n puts border\n puts @menu[:message]\n puts border\n\n #print dishes This is very convoluted but using nested loops i can \n #print the menu and keep it organized the way i want it\n @menu[:options].each do |item| #this grabs all the items in the options hash\n item[:dish].each_with_index do |item2, index| #this grabs the dish array within the option hash\n puts \"#{index+1}. #{item2} - $#{(item[:price][index])}\"#the item[:price][index] grabs all the prices associated with each menu item\n end \n end\n end",
"def list_rooms\n @rooms.each do |room_name, cap| \n puts \"#{room_name} #{cap.available_space()}\"\n end\n end",
"def printable_commands(*)\n item = []\n item << banner\n item << (desc ? \"# #{desc.gsub(/\\s+/m, ' ')}\" : \"\")\n [item]\n end",
"def print_vending_menu(vending_mapping)\n vending_mapping.each do |location, name|\n puts \"Location: #{location}, Name: #{name}\"\n end\nend",
"def printable_commands(all = true, subcommand = false)\n (all ? all_commands : commands).map do |_, command|\n next if command.hidden?\n item = []\n item << banner(command, false, subcommand)\n item << (command.description ? \"# #{command.description.gsub(/\\s+/m, ' ')}\" : \"\")\n item\n end.compact\n end",
"def printCommands\r\n puts 's: Display the superclass information.'\r\n puts 'u: (n) n-th subclass'\r\n puts 'v: list of instance variables'\r\n puts 'c: (string) Class name input'\r\n puts 'b: return to the previous class'\r\n puts 'f: return forward, after b is used'\r\n puts 'z: repeat information'\r\n puts 'q: quit'\r\n end",
"def help\n puts \"_____________________________________\",\n \"Available commands:\",\n \" m <message> - chat with all players\",\n # \" m /t <player_name> <message> - chat with specified player\" #currently not supported\n \" u list - print all users in game with their states (busy or not)\",\n \" u game <username> - ask for game session with user <username>\",\n \"In game mode:\", #i'll write them later\n \" my hand - gets cards list (in hand)\",\n \" show board - shows my board and opponent's board\",\n \" move <card number> - puts card to board\"\n \"------------------------------------\"\n end",
"def print_menu\n isFinished = true\n while (isFinished)\n puts @menu_description\n @menu_items.each_pair { |key, value|\n puts \"(#{key}) #{value}\"\n }\n\n isFinished = determine_action(get_entry(\"Select option: \"))\n end\n end",
"def displayWalks\n\t\ti = 0\n\t\twhile i < @@walks\n\t\t\tputs \"Woof\"\n\t\t\tputs \"On the #{@time.strftime(\"%d-%m-%Y at %H:%M\")} #{@name} walked #{@@distance[i]}kms in #{@@location[i]}, coordinates: #{@@coordinates[i]}. \"\n\t\ti += 1\n\t\tend\n\tend",
"def print_status\n super\n print_battle_commands unless battle_commands.empty?\n end",
"def print_status\n super\n print_battle_commands unless battle_commands.empty?\n end",
"def print_instructions\n puts \"Type 'find 1' to display candidate with id 1.\"\n puts \"Type 'all' to see all candidates.\"\n puts \"Type 'qualified' to print only qualified candidates.\"\n puts \"Type 'quit' to exit.\"\n puts \"Type 'help' to see these instructions again.\"\nend",
"def display_room\n puts \"Room Type: #{@type}\"\n puts \"Price: $#{@price} per night\"\n end",
"def print_menu\n\t\tsystem ('cls') or system ('clear')\n\t\t@todo_list.print_list\n\t\tprint_menu_options\n\tend",
"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\n puts \">> Command to be executed: #{command}\"\n end",
"def list_commands\n puts template(:all, {\n app: File.basename(@app),\n\n cmds: ::WeatherSage::CLI::Help::COMMANDS.values.map { |cmd|\n template(:cmd, cmd)\n }.join(\"\\n\"),\n\n envs: ::WeatherSage::CLI::Env::VARS.map { |row|\n template(:env, row)\n }.join(\"\\n\\n\"),\n })\n end",
"def print_items\n if @past_menu.nil?\n term.erase_body\n @items.each_with_index do |item, i|\n print_item(item, i, reverse: i == @cur_menu)\n end\n else\n print_item(@items[@past_menu], @past_menu)\n print_item(@items[@cur_menu], @cur_menu, reverse: true)\n end\n end",
"def main_options\n commands = {\"1\" => \"See all buildings\" ,\n \"2\" => \"Set a unit as rented/avalilable\" ,\n \"3\" => \"Create new Building\",\n \"4\" => \"Exit program\"}\n\n commands.each do |option, description |\n puts \"#{option} - #{description} \"\n end\n print \"\\n:>\"\n gets_chomp(commands)\n end",
"def print(io)\n tree.each_with_index do |(command, event_called_handlerss), index|\n io.puts '+++++++++++++++++++++++++++++++++++' if index == 0\n io.puts \"Command: #{command.class} resulted in #{event_called_handlerss.length} events\"\n event_called_handlerss.each_with_index do |event_called_handlers, i|\n io.puts '' if i > 0\n io.puts \"-- Event #{event_called_handlers.event.class} was handled by:\"\n io.puts \"-- Projectors: [#{event_called_handlers.projectors.join(', ')}]\"\n io.puts \"-- Workflows: [#{event_called_handlers.workflows.join(', ')}]\"\n end\n\n io.puts '+++++++++++++++++++++++++++++++++++'\n end\n end",
"def printItem\n print @category,\", \"\n print @batteryLife,\", \"\n print @modelNum,\", \"\n print @color,\", \"\n print @manufacturer,\", \"\n print @status,\", \"\n print @yearBuilt,\", \"\n print @price,\", \"\n print @features\n end",
"def print_items\n if @items.empty?\n print NO_ITEMS_MESSAGE\n else\n print WARES_MESSAGE\n @items.each { |item| puts \"#{item.name} (#{item.price} gold)\" }\n print \"\\n\"\n end\n end",
"def print_menu\n MENU.each do |i| \n # in general, avoid printing things.\n # Return them instead and let the code that called it\n # to return it\n puts \"#{i[:name]} costs #{i[:price]}\"\n end\n end",
"def print_help\n\n puts\n puts \"You can type a direction to move: 'north', 'south', 'east' and 'west'.\".colorize(:red).indent(10)\n puts\n puts \"You can type 'exits' to see which way you can go.\".colorize(:red).indent(10)\n puts\n puts \"You can type 'quit' to save your character and quit.\".colorize(:red).indent(10)\n puts\n\nend",
"def print\n puts SEPARATOR\n puts @name\n puts SEPARATOR\n puts @desc\n if(@diagram)\n puts\n puts \"Diagram:\"\n puts\n puts @diagram\n end\n end",
"def printer(guests)\n batch_badge_creator(guests).map{|greeting| puts greeting}\n assign_rooms(guests).map{|room_assignment| puts room_assignment}\nend",
"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 main_menu\n puts \"Here is a list of available commands:\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - Show a contact\"\n puts \" search - Search contacts\"\n puts \" delete - Deletes a contact\"\n end",
"def display_main_menu\n puts '################################'\n puts '# {N}- Network Stuff #'\n puts '# {RF}- Read File #'\n # puts '# {GF}- Generate File #'\n # puts '# {D}- Run as Daemon #'\n # puts '# {TD}- Run as Trigger Daemon #'\n puts '# {Q}- Quit #'\n puts '################################'\nend",
"def print_menu\n self.menu_items.each do |item|\n p \"#{item.dish_name.upcase} 😋 $#{item.price}\"\n end\n end",
"def printOptions\n puts \"\\nSelect one of the following options.\\n\"\n puts \"\n [0] Print All\n [1] Print Name\n [2] Find Prefix\n [3] New Food\n [4] New Recipe\n [5] Show Log\n [6] Show Today\n [7] Show Date\n [8] Log Today\n [9] Log Date\n [10] Log Delete\n [11] Save\n [12] Quit\\n\"\nend",
"def show_details(args)\n # get a list of unknown commands\n unknown_cmds = args.select do |arg|\n !WeatherSage::CLI::Help::COMMANDS.key?(arg)\n end\n\n if unknown_cmds.size > 0\n # print list of unknown commands and exit\n puts 'Unknown commands: %s' % [unknown_cmds.join(', ')]\n exit -1\n end\n\n # print detailed help for each argument\n puts args.map { |arg| template(:one, commands[arg]) }\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 list_commands(character, input=nil)\n \t\tcommands = COMMANDS.keys\n \t\t\n\t\tprint_line commands.join(?\\s)\n\t\tprint_line\n\tend",
"def print\n added .sort.each { |pod| UI.message('A'.green + \" #{pod}\", '', 2) }\n deleted .sort.each { |pod| UI.message('R'.red + \" #{pod}\", '', 2) }\n changed .sort.each { |pod| UI.message('M'.yellow + \" #{pod}\", '', 2) }\n unchanged.sort.each { |pod| UI.message('-' + \" #{pod}\", '', 2) }\n end",
"def show_help\n\tputs \"These are the following commands that this application accepts:\"\n\tputs \"\\t 'add' (child name) (toy name) - gives a child a new toy\"\n\tputs \"\\t 'remove' (toy name) (child name) - takes away the child's toy\"\n\tputs \"\\t 'ls' - lists all children and the toys they are receiving\"\n\tputs \"\\t 'ls' (child name) - lists all the toys that one child is receiving\"\n\tputs \"\\t 'delivered' (child name) - marks that the toys have been delivered to the child\"\n\tputs \"\\t 'help' - shows all of the available commands that this application accepts\"\n\n\nend",
"def print_help()\n puts \"--------------------------------------\"\n puts \"Use the following commands\"\n puts \"--------------------------------------\"\n puts \"HELP\\t\\tDisplays this message\"\n puts \"CLEAR\\t\\tClears the console\"\n puts \"DISPLAY\\t\\tClears the console and shows all Turns\"\n puts \"SURRENDER\\tSurrender the game\"\n puts \"RULES\\t\\tDisplay current Rules\"\n puts \"CHEAT\\t\\tDisplays a code with blackhit\"\n puts \"EXIT\\t\\tBack to main menu\"\n\n puts \"\\nCurrent status: #{@game.next_action} a code. Just press Enter to get prompted\"\n return self\n end",
"def menu\n puts \"- Type in a #{\"Nintendo Character\".colorize(:red)} | #{\"Game Series\".colorize(:blue)} | #{\"Amiibo Series\".colorize(:green)}\\n\\n\"\n puts \"- Type #{'1'.colorize(:yellow)} for a list of all the Game Series included in the Amiibo collection\"\n puts \"- Type #{'2'.colorize(:yellow)} for a list of all the Amiibo Series included in the Amiibo collection\"\n puts \"- Type #{'3'.colorize(:yellow)} for a list of all the Characters included in Amiibo collection\"\n puts \"- Type #{'4'.colorize(:yellow)} for a list of ALL Amiibos collection\\n\\n\"\n puts \"- Type #{'exit'.colorize(:yellow)} to exit the CLI\\n\\n\"\n puts \"--------------------------------------------------------------------------------\\n\\n\"\n sleep(2)\n end",
"def print_items\n @items.each do |item|\n puts item.name + \" (#{item.price} gold)\"\n end\n print \"\\n\"\n end",
"def show_inventory\n puts \"we have:\"\n puts \"douwe egberts\"\n puts \"nespresso\"\n puts \"senseo\"\n puts \"Choose a product\"\nend",
"def action\n puts \"\\nHelp menu\"\n puts '=' * 'Help menu'.length + \"\\n\\n\"\n puts \" Command \\t Description\"\n puts \" \" + '-' * 'Command'.length + \" \\t \" + '-' * 'Description'.length\n commands.map {|cmd , desc| puts \" #{cmd} \\t #{desc}\"}\n puts \"\\n\\n\"\n end",
"def all\n puts header\n puts output_for @items\n end",
"def list(command)\n case command.split.at(1)\n when \"artists\" || \"artist\" || \"Artists\" || \"Artist\"\n navigate(Artist)\n when \"songs\" || \"song\" || \"Songs\" || \"Song\"\n navigate(Song)\n when \"genres\" || \"genre\" || \"Genre\" || \"Genres\"\n navigate(Genre)\n else\n puts \"The commands are:\" + Commands::list\n end\n @library.each_with_index {|member, index| puts index.to_s + \".\" + member.name}\n prompt(\"list\")\n end",
"def display_game_menu\n @output.puts '-----------------------'.center(WIDTH)\n @output.puts '| 1) Blackjack |'.center(WIDTH)\n @output.puts '| 2) Stud Poker |'.center(WIDTH)\n @output.puts \"| 3) Texas Hold 'em |\".center(WIDTH)\n @output.puts '| A) Add AI Player |'.center(WIDTH)\n @output.puts '| D) Debug Console |'.center(WIDTH)\n @output.puts '| P) Setup Player |'.center(WIDTH)\n @output.puts '| Q) Quit |'.center(WIDTH)\n @output.puts '-----------------------'.center(WIDTH)\n @output.puts # spacer\n @output.print 'Command: '\n end",
"def cmd_ids\n print_tree(Editor, 0, true)\n end",
"def print_menu\n puts \"Which action [list|add|delete|mark|idea|quit]?\"\nend",
"def display_menu\n puts \"Choose from the following options: \\n\n to find a candidate, type 'find id' (ex. find 1)\n to view all candidates, type 'all'\n to view all qualified candidates, type 'qualified'\n to exit, type 'quit' \n to view menu, type 'menu' \\n\\n\"\nend",
"def print_details\n puts \"#{@dog_walker.name} walked #{@dog.name} for #{length_in_minutes} minutes.\"\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 describe\n puts \"name: #{self.name}\"\n puts \"commands (#{self.commands.count}):\"\n\n self.commands.asc(:ordering_number).each do |command|\n puts \" ordering_number: #{command.ordering_number}\"\n puts \" job_name: #{command.job_name}\"\n puts \" input_from_command_with_number: #{command.input_from_command_with_number}\"\n puts \" create_media: #{command.create_media}\"\n command.options.each do |option|\n puts \"\\t key: #{option.key}\"\n puts \"\\t value: #{option.value}\"\n puts \"\\t param_key_name: #{option.params_key_name}\"\n end\n end\n nil\n end",
"def print\n blank = \"#{Tty.yellow}[no description]#{Tty.reset}\"\n @descriptions.keys.sort.each do |name|\n description = @descriptions[name] || blank\n puts \"#{Tty.white}#{name}:#{Tty.reset} #{description}\"\n end\n end",
"def show\n\t puts \"\t#{@spaces[0]} #{@spaces[1]} #{@spaces[2]}\"\n\t puts \"\t#{@spaces[3]} #{@spaces[4]} #{@spaces[5]}\"\n\t puts \"\t#{@spaces[6]} #{@spaces[7]} #{@spaces[8]}\"\n\tend",
"def show\n show_basic\n puts\n show_messages\n puts\n show_peers\n end",
"def printWaypoints\n puts \"\\nWaypoints for route: #{name}\"\n waypoints.each do |waypoint|\n puts \"waypoint_id #{waypoint.id}, local_index: #{waypoint.local_index}, parent_index: #{waypoint.parent_index}\"\n puts \"latitude: #{waypoint.latitude}, longitude: #{waypoint.longitude}, height: #{waypoint.height}\"\n end\n puts \"\\n\\nWaypoints minus removed for route: #{name}\"\n waypoints_minus_removed.each do |waypoint|\n puts \"waypoint_id #{waypoint.id}, local_index: #{waypoint.local_index}, parent_index: #{waypoint.parent_index}\"\n puts \"latitude: #{waypoint.latitude}, longitude: #{waypoint.longitude}, height: #{waypoint.height}\"\n end\n puts \"\\n\"\n end",
"def print_menu(options)\n i = 0\n options.each do |attribute|\n puts \"[#{i}] #{attribute}\"\n i += 1\n end\n end",
"def help\n\tputs \"Things a baby adventurer needs to know : \"\n\tputs \"(g)o (direction): (n,w,e,s) move that direction\"\n\tputs \"(o)pen: open doors, chests, your eyes, etc\"\n\tputs \"(l)ook: examine the room your in\"\n\tputs \"(t)ake: add an item to your inventory\"\n\tputs \"(u)se: use an item in your inventory\"\n\tputs \"(i)nventory: see what items you have\"\n\tputs \"(q)uit: quit the game, as a coward would.\"\nend",
"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 print\n next_codes = get_next_moves.map {|c| c.code}\n puts \"Code: #{@code}\\t Next Moves: #{next_codes.inspect}\"\n end",
"def list_reserved_rooms\n unless @rooms.empty?\n @rooms.each do |key, room|\n puts room.report_lister\n end\n end\n end",
"def about\n cmds = String.new \"\"\n @cmds.each_pair {|k,v| (cmds << \" #{k}\") if not @my_cmds.include? k }\n self.say \"These are the current recognized commands: \\0037 #{cmds}\"\n #greets = @greetings.collect {|x| ' '+x}\n self.say \"I also respond to the following greetings (and my name): \\0036 Hi, Hello, Hey, Hay, Hola, Sup, Whats up, Yo\"\n self.say \"What do I do? What don't I do is more like it. I keep logs of the IRC channel, I ask trivia questions, I search for php functions, and I can even say things if you know the right command. Heck, I am so stuck up, I can't stop saying I!\"\n end",
"def print_reservations\n puts \"We do not share our clients info!\"\n puts \"At least for free....\"\n end",
"def display_nearby_room_messages\n puts @game.nearby_room_messages\n end",
"def help\n @@commands.each do |command| \n puts command[0]\n puts \" `#{command[1]}\"\n end \n end",
"def inspect\n string_buff = [\"\\n------ Remote Control -------\\n\"]\n @on_commands.zip(@off_commands) \\\n .each_with_index do |commands, i|\n on_command, off_command = commands\n string_buff << \\\n \"[slot #{i}] #{on_command.class} \" \\\n \"#{off_command.class}\\n\"\n end\n string_buff << \"[undo] #{@undo_command.class}\\n\"\n string_buff.join\n end",
"def inspect\n string_buff = [\"\\n------ Remote Control -------\\n\"]\n @on_commands.zip(@off_commands) \\\n .each_with_index do |commands, i|\n on_command, off_command = commands\n string_buff << \\\n \"[slot #{i}] #{on_command.class} \" \\\n \"#{off_command.class}\\n\"\n end\n string_buff << \"[undo] #{@undo_command.class}\\n\"\n string_buff.join\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 print_item_list\n @current_items.each_with_index do |item, item_no|\n puts \"Item #{item_no+1}\"\n puts \"----------------\"\n puts \"Item Name: #{item.name}\"\n puts \"----------------\"\n end\n end",
"def pleasure_reading_menu_instructions\n puts pleasure_reading_header\n\n puts \"How would you like to find poems to read?\"\n puts \"To see a list of poems, type 'poems', and press enter.\"\n puts \"To see a list of poets, type 'poets', and press enter.\"\n puts \"To end the program, type 'exit', and press enter.\"\n puts \"\"\n end",
"def look()\n puts \"A%s [Door] lies north of you leading to %s,\" % [@door_status, @door_leads]\n puts \"A%s [Fireplace] is along the west wall\" % [@fireplace_status]\n puts \"A [Table] is in the center of the room%s\" % [@table_stuff] \n puts \"A%s grandfather styled [Clock]%s is in the north-east corner of the room\" % [@clock_status, @clock_hands]\n puts \"A%s [Trapdoor] is against the south wall\" % [@trapdoor_status]\n puts \"A pile of wooden [Logs] is in the south-east corner of the room\" #put logs in firepalce evry so often or bad things happen\nend",
"def look\n puts \"*#{@short_description}*\"\n puts \"#{@long_description}\"\n puts\n to_show = contents.reject{|o| o.name == 'self'}\n room_descr_items = to_show.select{|o| o.room_description} #items that have a special room_description value, which is prose overriding \n #the simple behavior of just listing the name of an item during room description.\n to_show.reject! {|x| room_descr_items.include?(x) }\n room_descr_items.each do |item|\n puts item.room_description\n end\n if not to_show.empty?\n print \"You can see \"\n to_show.each do |obj|\n print \"and \" if obj == to_show.last && obj != to_show.first\n print \"#{obj.name} \"\n end\n puts \"here.\"\n end\n end",
"def print_options\n puts '1. Start a new game [new]'\n puts '2. Load a saved game [load]'\n puts '3. Quit the game [quit]'\nend",
"def show_all_weapons\n if self.weapons.size == 0\n puts \"\"\n puts \"You have no weapons, try completing some quests first :)\"\n else\n puts \"\"\n puts \"Here Are Your Weapons:\".bold.white.on_light_black\n puts \" \"\n self.weapons.each do |weapon|\n puts \"**** #{weapon.name} **** Weapon Power: #{weapon.attack_power} ****\".italic\n end\n end\n end",
"def print_iteration via_road, to_move\r\n\t\tprev_location = \"\"\r\n\t\tif to_move == 0\r\n\t\t\tprev_location = driver.location.east_location\r\n\t\telsif to_move == 1\r\n\t\t\tprev_location = driver.location.south_location\r\n\t\telsif to_move == 2\r\n\t\t\tprev_location = driver.location.west_location\r\n\t\telsif to_move == 3\r\n\t\t\tprev_location = driver.location.north_location\r\n\t\tend\r\n\t\tputs \"#{driver.name} heading from #{prev_location.name} to #{driver.location.name} via #{via_road}.\"\r\n\tend",
"def list\n Airplay.devices.each do |device|\n puts <<-EOS.gsub(/^\\s{12}/,'')\n * #{device.name} (#{device.info.model} running #{device.info.os_version})\n ip: #{device.ip}\n mac: #{device.id}\n password?: #{device.password? ? \"yes\" : \"no\"}\n type: #{device.type}\n resolution: #{device.info.resolution}\n\n EOS\n end\n end",
"def display_order_contents\n\t\[email protected] {|item| print item, \" -- \"}\n\tend",
"def print\n\t\tputs name + ' ' + className + \" just \" + move + \" and said \" + call\n\tend",
"def print_all\n # Print all BasicFoods\n @basic_foods.each do |name, basic_food|\n print(name)\n end\n # Print all Recipes\n @recipes.each do |name, recipe|\n print(name)\n end\n end",
"def report_print_items\n $report_file.puts print_line\n $report_file.puts print_date\n $report_file.puts print_title\n $report_file.puts print_line\n $report_file.puts print_header\n $report_file.puts print_line\n items.each_with_index do |item, index_no|\n $report_file.puts item.print_item_details(index_no)\n end\n $report_file.puts print_line\n end",
"def printer(names)\n batch_badge_creator(names).each { |name| puts name };\n assign_rooms(names).each {|name| puts name};\nend",
"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 print_inventory\n @player.print_inventory\n end",
"def run(args)\n if args.size > 0\n # show details of given commands\n show_details(args)\n else\n # print full list of commands\n list_commands\n end\n end",
"def command_print(name)\n food = @database.get(name)\n if food.is_a?(BasicFood) || food.is_a?(Recipe)\n puts food.to_s\n else\n puts \"Error in pinting the specified food.\"\n end\n end",
"def print_api_call_menus\n name = convert_name_for_api(get_recipe_name_from_user)\n recipes_array = API.call_by_recipe_name(name)\n API.recipes_titles_array.each_with_index do |title, i|\n puts \"#{i + 1}. #{title.capitalize}\"\n puts \"-------------------------------------------------------\".colorize(:cyan).bold\n end\n end",
"def display_menu\n puts \"1. Scrapp townhalls' emails from web\"\n puts \"2. Send massive emails to townhalls\"\n puts \"3. Follow towhalls on Twitter\"\n puts \"4. Print me the JSON\"\n puts \"5. Exit program\"\n end",
"def print_deal_cards\n puts \"-----------\"\n puts \"Cards Dealt\"\n puts \"-----------\"\n end"
] | [
"0.71835214",
"0.70898813",
"0.68807715",
"0.65819234",
"0.645604",
"0.64390475",
"0.6406011",
"0.6381512",
"0.63746774",
"0.63736993",
"0.6351202",
"0.6326877",
"0.6311376",
"0.6264881",
"0.61981565",
"0.6196223",
"0.6152291",
"0.61484236",
"0.6144797",
"0.6130418",
"0.6124161",
"0.61062366",
"0.61015016",
"0.61014456",
"0.61014456",
"0.60995513",
"0.6069076",
"0.6064921",
"0.60624325",
"0.6061698",
"0.6040296",
"0.60330427",
"0.60262406",
"0.6015478",
"0.6014665",
"0.5997452",
"0.59902763",
"0.5985378",
"0.59844536",
"0.5973332",
"0.59718525",
"0.5971668",
"0.59604406",
"0.59479254",
"0.593939",
"0.593732",
"0.59360105",
"0.59330934",
"0.59273475",
"0.5906393",
"0.5884806",
"0.58845806",
"0.5874981",
"0.5871131",
"0.58635515",
"0.5861702",
"0.5860403",
"0.58518225",
"0.5848022",
"0.58453417",
"0.5841704",
"0.58333",
"0.5832189",
"0.5827422",
"0.5823721",
"0.5822226",
"0.58196527",
"0.5814663",
"0.5808814",
"0.5807834",
"0.580037",
"0.57994944",
"0.5789957",
"0.5789558",
"0.57793915",
"0.57767564",
"0.5776669",
"0.5775709",
"0.5775709",
"0.57735974",
"0.5768485",
"0.5767997",
"0.57648426",
"0.57521987",
"0.57477534",
"0.57400364",
"0.57393855",
"0.57326823",
"0.5732104",
"0.572937",
"0.5727718",
"0.5727406",
"0.5723573",
"0.57234365",
"0.5712427",
"0.5708983",
"0.5707438",
"0.57041085",
"0.5701539",
"0.5700781"
] | 0.85641176 | 0 |
Print welcome message to user formatted in a red bo with a border | def print_welcome
box = TTY::Box.frame(width: 90, height: 17, align: :center, style: {bg: :red}) do
"\nWelcome to the AirBnB escape game!\n
You have rented an AirBnB for the night and during your stay\n
have realised that your super host might be supernatural.\n
In order to survive, you must interact with the apartment and try to escape.\n
Each interaction will bring you a hint or a step closer to your freedom.\n
Be careful though, as some items can damage your guest rating.\n
If you reach a rating of 0, the g-host will kill you."
end
print box
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def welcome_message\n puts \"\n ┏━━━┓━━━━┏┓━━━━━━━┏┓━━━━━━━━┏┓━\n ┃┏━┓┃━━━━┃┃━━━━━━━┃┃━━━━━━━┏┛┗┓\n ┃┗━┛┃┏┓┏┓┃┗━┓┏┓━┏┓┃┃━┏┓┏━━┓┗┓┏┛\n ┃┏┓┏┛┃┃┃┃┃┏┓┃┃┃━┃┃┃┃━┣┫┃━━┫━┃┃━\n ┃┃┃┗┓┃┗┛┃┃┗┛┃┃┗━┛┃┃┗┓┃┃┣━━┃━┃┗┓\n ┗┛┗━┛┗━━┛┗━━┛┗━┓┏┛┗━┛┗┛┗━━┛━┗━┛\n ━━━━━━━━━━━━━┏━┛┃━━━━━━━━━━━━━━\n ━━━━━━━━━━━━━┗━━┛━━━━━━━━━━━━━━\n\n \".center(100).colorize(:cyan)\n sleep 2\n end",
"def welcome_message\n puts \"\\n\"\n puts \"Welcome to Rock Paper Scissors\"\n end",
"def welcome_message\n system('clear')\n puts \" _ _ _ _ \"\n sleep 0.1\n puts \"| | | | ___| | | ___ \"\n sleep 0.1\n puts \"| |_| |/ _ | |/ _ \\ \"\n sleep 0.1\n puts \"| _ | __/ | | (_) |\"\n sleep 0.1\n puts \"|_| |_| ___|_|_| ___/ \"\n sleep 0.1\n puts \"\" \n puts \"bienvenue dans mon jeu du morpion\"\n puts \"\\nAvant de commencer entre le nom des deux joueurs qui vont s'affronter\"\n end",
"def display_user_goodbye\n display_name = User[id_active_user].full_name\n goodbye_msg = \"It Was Very Nice Getting To Know You, Good Luck With All Your Future Endeavors And If We Cross Paths Again, We Will Be Very Pleased To Hear About Your Exploits, #{display_name}!\"\n puts \"\" \n puts \" -- #{ goodbye_msg } -- \".colorize(:color => :blue, :background => :white)\n puts \"\" \nend",
"def welcome(salon)\n puts\n puts HEADER_LINE\n puts \"WELCOME TO \".center(HEADER_LENGTH)\n puts \"#{salon.name} Dog Grooming !\".center(HEADER_LENGTH).colorize(:light_blue)\n puts HEADER_LINE\n puts\nend",
"def welcome\n puts Rainbow(\"Welcome to Github Jobs\").indianred.bright.underline\n end",
"def print_welcome_message\n puts \"\\nThank you for using this amazing command line bowling scorecard, good luck!\\n\"\n end",
"def welcome_msg\n puts\n puts \"Welcome to BlackJack (by Luis Perez)!\"\n puts \"For instructions, press i.\"\n puts \"To quit, press q.\"\n puts\n end",
"def farewell_message\n puts \"Program Exiting...\".red\n puts \"Goodbye #{@username}!\".blue\n end",
"def welcome\n clear\n output \"Welcome to Hangman\"\n output \"==================\"\n blank_line\n end",
"def print_status_message text=$status_message\n r = $status_message_row || Ncurses.LINES-1\n clear_error r, $datacolor\n # print it in centre\n printstring r, (Ncurses.COLS-text.length)/2, text, color = $promptcolor\n end",
"def welcome_message\r\n system(\"clear\")\r\n a = Artii::Base.new :font => 'slant'\r\n puts a.asciify('Make 10').colorize(:white).on_green\r\n puts (\"This app can find solutions for the game Make 10.\")\r\n end",
"def welcome\n system \"clear\" or system \"cls\"\n puts \"\\n____________________________________________________________________________\\n\"\n puts \" __ __ _ _ _ _ _____ __ ______ \\n\"\n puts \" / ) / ) /| / /| / / ' / ) / / / \\n\"\n puts \"---/--------/----/---/-| -/----/-| -/----/__------/--------/--------/____/--\\n\"\n puts \" / / / / | / / | / / / / / \\n\"\n puts \"_(____/___(____/___/___|/____/___|/____/____ ___(____/___/_____________/____\\n\"\nend",
"def welcome_header\n system 'clear'\n puts @header.light_blue\n puts \"Lets find something to do in Melbourne!\".center(@header_length)\n puts @header.light_blue\n end",
"def display_welcome\n\t\tputs \"\\t**************************\"\n\t\tputs \"\\t*** Welcome To Hangman ***\"\n\t\tputs \"\\t**************************\"\n\tend",
"def output(message, type)\n puts \"\\e[31m[ ✘ ]\\e[0m #{message}\" if type == 'error'\n puts \"\\e[32m[ ✔︎ ]\\e[0m #{message}\" if type == 'success'\n puts \"\\e[33m[ ✻ ]\\e[0m #{message}\" if type == 'info'\nend",
"def print_welcome_message\n puts \"Welcome to Movie Bookings\"\n puts \"------------------------\"\n end",
"def welcome_user\n puts \"Welcome to #{pastel.bright_cyan('Groupie')}.\"\n puts \"Keep up with your favorite bands, never miss a show!\"\n puts \"Type #{pastel.bright_cyan('exit')} at any time to quit the app.\"\n puts \"Type #{pastel.bright_cyan('concerts')} to get started.\"\n end",
"def print_intro\n border\n print_image\n puts \"\n Welcome to Mastermind, Shitty.0!\\n\".red\n border_bottom\n end",
"def welcome\n puts <<~DOC\n _____ _ _ _ _ _\n / ____| | | | | (_) | {_}\n| | ___ ___| | _| |_ __ _ _| | |(|\n| | / _ \\\\ / __| |/ / __/ _` | | | |=|\n| |___| (_) | (__| <| || (_| | | | / \\\\\n \\\\_____\\\\___/ \\\\___|_|\\\\_\\\\\\\\__\\\\__,_|_|_| |.--| \\\\~~~/\n| | (_) | | (_) || | \\\\_/\n| | _ ___| |_ _ _ __ __ _ || | Y\n| | | / __| __| | '_ \\\\ / _` | |'--| _|_\n| |____| \\\\__ \\\\ |_| | | | | (_| | '-=-'\n|______|_|___/\\\\__|_|_| |_|\\\\__, |\n __/ |\n |___/\nWelcome to the Cocktail Listing!\nWe are going to gets some drinks going so please select from\nthe options available below to get started...\n.......\n DOC\nend",
"def print_login_message(**params)\n result = case params[:result]\n when :success then 'Successfully logged in as '\n when :error then 'There was an error trying to login as '\n end\n print_time_stamp\n puts result.colorize(:red) + params[:username]\n end",
"def info(message)\n puts \"\\e[35m#{message}\\e[0m\"\n end",
"def display_info_about_app\n info_msg = \"Look Dude or Dudette ! All You Need To Know Is That This Is A Great App And You Should Be Very Happy It Fell Into Your Lap. It Will Help You Navigate The World Of Pharmacies, Especially If You Are An Orc Or A Kobolt Or One Of Those UnderWorld Creatures! And If You Happen To Be A DarkElf, Know That Drizzt D'Urden Is A Good Friend Of This ... WhatEver This Is!\"\n puts \"\" \n puts \" -- #{ info_msg } -- \".colorize(:color => :light_blue, :background => :white)\n puts \"\" \nend",
"def welcome_message\n puts \"Welcome to Shiqing's Secret Number Game! \\nShiqing created this game.\"\nend",
"def welcome(wins)\n <<-MSG\n\n***** #{colorize('Welcome to Rock, Paper, Scissors, Spock, Lizard!', 'white', 'bg-blue')} *****\n***** #{colorize('Current Score:', 'white')} #{colorize('YOU', 'white', 'bg-magenta', 1)} vs #{colorize('COMPUTER', 'white', 'bg-magenta', 1)} *******************\n***** #{colorize(\" #{wins[:User]} \", 'white', 'bg-cyan', 1)} #{colorize(\" #{wins[:Computer]} \", 'white', 'bg-cyan')}\n***** Game on! Make your selection now *******************\n\nMSG\nend",
"def shout(message)\n output.puts Paint[message, :bold, :red ]\n end",
"def display_error(message)\n puts \"\\e[31;1m[ERROR]\\e[0m #{message}\"\n end",
"def print_error(msg)\n puts \" #{color(\"!\", 33)} #{color(msg, 31)}\"\n end",
"def welcome\n puts \"\\nHello, welcome to DayTrader. Please sign in with your name (first + last): \"\n end",
"def welcome_screen\n puts \"\"\n puts \"Bienvenu sur votre espace TOP SECRET !\"\n puts \"Info : Aujourd'hui il fait beau (a ne pas divulguer)\" \nend",
"def bye_message\n message = \"Panacea's work is done, enjoy!\"\n say \"\\n\\n\\e[34m#{message}\\e[0m\"\n end",
"def welcome_message\n puts \"Welcome to Everything but the Kitchen Sink!\"\n end",
"def welcome\n puts 'Welcome to mastermind, the classic code-breaking game.'\n puts \"Possible peg colors are (R)ed, (O)range, (Y)ellow, (B)lue,\" +\n \" (G)reen, and (P)urple\"\n puts 'Enter \"q\" to quit at any time.'\n end",
"def welcome\n clear\n ascii_heading(\"The Bakers Box\")\n box_margin = ((TTY::Screen.width)-(\"Welcome to The Bakers Box\".length)-6)/2\n box = TTY::Box.frame padding: 3, align: :center, left: box_margin, top: 6 do\n \"Welcome to The Bakers Box\\n\\nThe percentage based\\nRecipe management app\"\n end\n print box\n space\nend",
"def print_final_message(name_player, win)\n if win\n puts \" #{name_player} you won\".colorize(:cyan)\n else\n puts \" #{name_player} you lost\".colorize(:light_red)\n end\n puts\nend",
"def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end",
"def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end",
"def display_exiting!(text)\n # create goodbye message\n # display welformatted conclusion message\n system \"clear\"\n msg = colorize(\" #{text.upcase} \", $font_colors[:cyan])\n puts \"\\n#{msg.center(77)}\\n\\n\"\n end",
"def display_welcome_message\r\n prompt \"Welcome to Tic Tac Toe!\"\r\n end",
"def welcome_screen\n\n\nputs \"\"\nputs \"**************************************************************************\"\nputs \"Bienvenue dans la zone secrète, je vais te révéler tous les messages de Flo...\"\nputs \"Réhausse ton slip et mets tes lunettes !\"\nputs \"**************************************************************************\"\nputs \"\"\nputs \"**************************************************************************\"\nputs \"1er secret : Pour accentuer l'opportunité solutionnelle, chaque entité doit anticiper les cibles vente.\"\nputs \"2ème secret : Pour accentuer la mondialisation situationnelle, il faut rapidement chiffrer les référents qualité.\"\nputs \"3ème secret : Face à l'adaptabilité quantitative, mieux vaut optimiser les intervenants organisation.\"\nputs \"**************************************************************************\"\nputs \"\"\nputs \"Fais en bon usage !\"\nputs \"\"\n\n\nend",
"def show_header()\n print_message (SPACE_SEPARATOR)\n print_message 'Welcome to Ruby Calculator'\n print_message (SPACE_SEPARATOR) \n end",
"def welcome_message\n 'Benvenuto'\nend",
"def html_out(msg, color_name=\"black\")\n\t\t\trgb = Color::RGB::by_name color_name\n\t\t\tputs \"<span style='color:#{rgb.css_rgb};'>#{msg}</span>\"\n\t\tend",
"def welcome\n puts \"\\nWelcome user! We have created a guessing game for you.\"\n puts \"Try your best to guess the word or else the bouquet of \"\n puts \"roses will die.\"\n puts \"Hint: colors make things happy\\n\\n\"\nend",
"def printWelcome \n\tsystem \"clear\"\n\tputs '\n __ ________ _ _____ ____ __ __ ______ \n \\ \\ / | ____| | / ____/ __ \\| \\/ | ____|\n \\ \\ /\\ / /| |__ | | | | | | | | \\ / | |__ \n \\ \\/ \\/ / | __| | | | | | | | | |\\/| | __| \n \\ /\\ / | |____| |___| |___| |__| | | | | |____ \n \\/ \\/ |______|______\\_____\\____/|_| |_|______|\n |__ __| \n | | ___ \n | |/ _ \\ \n | | (_) | \n |_|\\___/_ ______ _______ _ \n / ____| ____|__ __| | \n | (___ | |__ | | | | \n \\___ \\| __| | | | | \n ____) | |____ | | |_| \n |_____/|______| |_| (_) \n '\nend",
"def welcome_message\n puts \"=\" * 80\n puts \"\\t\\t\\tHello and Welcome to THE MAGIC SCHOOL BUS!\"\n puts \"\\tOn today's adventure, we will be exploring the Solar System of Anirtak...\"\n puts \"=\" * 80\n puts \"Let's choose from our options below! \"\n puts \"|| A || : Explore a list of all the planets\"\n puts \"|| B || : Discover all the details about a planet\"\n puts \"|| C || : Add your own planet\"\n puts \"|| D || : Find the distance between two planets\"\n puts \"|| Q || : Hop off the bus, and exit!\"\n\n main\nend",
"def welcome\t\n\t\tputs \"Enjoy the Game #{$person.show_name}\"\n\t\tputs \"This game is about guessing a '\\Secret Number'\\ between 1-10. You have 3 attempts to identify the '\\Secret Number'\\. \n\t\t You win if you guess the '\\Secret Number'\\ withing the 3 attempts, otherwise you lose the game!\"\n\tend",
"def farewell_message\n puts \"\"\n puts \"Cheers! \\u{1f37b}\" # beer emoji 🍻\n end",
"def error(msg)\n puts \"\\e[0;31m#{ msg }\\e[0m\"\n end",
"def intro(*args); say $terminal.color(format(*args), :bold); say(''); end",
"def red(msg)\n \"\\033[31m#{msg}\\033[39m\"\nend",
"def welcome\n system 'clear'\n puts header.call \"Welcome to Ruby QuickNews\"\n puts \"Please login or create a new username\"\n login_menu\n end",
"def welcome_message\n puts \"\\n\"\n puts \"The object of the game is to get three spots in a row, diagonally/horizontally/vertically\"\n puts \"Use the numbers from 1-9 to select your position:\"\n puts \"\\n\"\n (1..9).each_slice(3) {|a| puts a.join(' | ')} # sample layout of grid to show the relevant numbers matched to the cell\n puts \"\\n\"\n end",
"def welcome_message\n\t\tputs \"Welcome/Bienvenue \" + self.name\n\tend",
"def message(message, options = {})\n options[:prefix] ||= \"*** \"\n options[:color] ||= :white\n output message, options\n end",
"def print_status(msg)\n puts \"\" if verbose_mode?\n puts \"#{color('----->', 32)} #{msg}\"\n end",
"def welcome\n puts \"---------------------------------------------\".center(70).blue\n puts \"Welcome to the Makers Academy Student Database!\".center(70).green\n puts \"---------------------------------------------\".center(70).blue\n interactive_menu\nend",
"def welcome_user\n header\n puts \"\\n\\nWelcome #{self.active_user.name}, you are now logged in!\\n\"\n self.area_prompt\nend",
"def welcome_message\n message = \"Welcome to Locavore Kitchen!\"\n end",
"def welcome\n puts \"#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#\n#$#$#$#$#$#$#$ $#$#$#$#$#$#$#\n#$##$##$##$##{c('---', :blue)} Pokemon Ruby #{c('---', :blue)}#$##$##$#$#$#\n#$#$#$#$#$#$#$ $#$#$#$#$#$#$#\n#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#\\n\nHello there#{c('!', :blue)} Welcome to the world #{c('of', :magenta)} #{c('POKEMON', :light_yellow)}#{c('!', :blue)} My name is OAK#{c('!', :blue)}\nPeople call me the #{c('POKEMON PROF', :light_yellow)}#{c('!', :blue)}\\n\nThis world is inhabited by creatures called #{c('POKEMON', :light_yellow)}#{c('!', :blue)} For some\npeople, #{c('POKEMON', :light_yellow)} are pets. Others use them #{c('for', :magenta)} fights. Myself#{c('...', :blue)}\nI study #{c('POKEMON', :light_yellow)} #{c('as', :magenta)} a profession.\nFirst, what is your name#{c('?', :blue)}\"\n @player_name = gets.chomp # PLAYER \n puts \"\\nRight#{c('!', :blue)} So your name is #{c(@player_name.capitalize, :light_yellow)}#{c('!', :blue)}\nYour very own #{c('POKEMON', :light_yellow)} legend is about to unfold#{c('!', :blue)} #{c('A', :light_yellow)} world #{c('of', :magenta)}\ndreams and adventures #{c('with', :magenta)} #{c('POKEMON', :light_yellow)} awaits#{c('!', :blue)} Let's go#{c('!', :blue)}\nHere, #{@player_name.capitalize}! There are #{c('3', :green)} #{c('POKEMON', :light_yellow)} here! Haha!\nWhen #{c('I', :blue)} was young, #{c('I', :blue)} was a serious #{c('POKEMON', :light_yellow)} trainer.\nIn my old age, #{c('I', :blue)} have only #{c('3', :green)} left, but you can have one#{c('!', :blue)} Choose#{c('!', :blue)}\\n\\n\"\n puts \"#{c('1.', :green)}Bulbasaur #{c('2.', :green)}Charmander #{c('3.', :green)}Squirtle\\n\"\n @specie = gets.chomp.capitalize # POKEMON\n until check_initial_pokemon(@specie)\n puts \"#{c('1.', :green)}Bulbasaur #{c('2.', :green)}Charmander #{c('3.', :green)}Squirtle\\n\"\n @specie = gets.chomp.capitalize\n end\n puts \"\\nYou selected #{c(@specie.upcase, :light_yellow)}. Great choice#{c('!', :blue)}\nGive your pokemon a name#{c('?', :blue)}\"\n @pokemon_name = gets.chomp # POKEMON NAME\n @pokemon_name = @pokemon_name == \"\" ? @specie : @pokemon_name\n puts \"\\n#{c(@player_name.upcase, :light_yellow)}, raise your young #{c(@pokemon_name.upcase, :light_yellow)} by making it fight#{c('!', :blue)}\nWhen you feel ready you can challenge #{c('BROCK', :light_yellow)}, the #{c('PEWTER', :light_yellow)}'s #{c('GYM LEADER', :light_yellow)}\"\n end",
"def prompt_user\n \"[#{`whoami`.chomp}]\".green\nend",
"def print_error(text)\n\tif STDOUT.tty?\n\t\tputs \"\\e[31m[!]\\e[0m #{text}\"\n\telse\n\t\tputs \"[!] #{text}\"\n\tend\nend",
"def say_greeting\n\t\tgreeting = \"\\t\\t Welcome to the Virtual Crazy 8-Ball\" +\n\t\t\"game\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nPress Enter to \" +\n\t\t\"continue. \\n\\n: \"\n\t\tprint greeting\n\tend",
"def ok(message=\"\")\n\t\t\t\tputs \"[ #{green('Ok')} ] #{message}\"\n\t\t\tend",
"def congrats_msg()\r\n start = 0\r\n\r\n starstop1 = \"* * * * * * * * * * * * * * * * *\\n\\n\".cyan\r\n starsbottom1 = \"\\n* * * * * * * * * * * * * * * * \".cyan\r\n starstop2 = \" * * * * * * * * * * * * * * * * \\n\\n\".red\r\n starsbottom2 = \"\\n * * * * * * * * * * * * * * * * \".red\r\n starstop3 = \" * * * * * * * * * * * * * * * * \\n\\n\"\r\n starsbottom3 = \"\\n* * * * * * * * * * * * * * * * *\"\r\n message = \"Congratulations!\\n\\n\".center(starstop3.length).yellow\r\n\r\n while(start <= 20)\r\n messagePrint(starstop1, message, starsbottom1)\r\n messagePrint(starstop2, message, starsbottom2)\r\n messagePrint(starstop3, message, starsbottom3)\r\n start +=1\r\n end\r\nend",
"def magic_welcome(event)\n # TODO: Ditch this call to report - move to report lib if necessary\n report \"#{event.from} welcome message: #{event.message}\"\n if (event.message =~ /(\\S+)!\\S+$/)\n @me = $1\n elsif (event.message =~ /(\\S+)$/)\n @me = $1\n end\n\n @registered = true\n mode @me, 'i'\n end",
"def login_message\n \"You need to be logged in to carry this out.<br/>If you don't have an account, feel free to create one.\"\n end",
"def welcome(hotel)\n puts\n puts HEADER_LINE\n puts \"WELCOME TO THE\".center(HEADER_LENGTH)\n puts \"#{hotel.name} Cat Hotel!\".center(HEADER_LENGTH)\n puts HEADER_LINE\n puts\nend",
"def goodbye\n puts Rainbow(\"Thanks for visiting. Goodbye...\").indianred.bright.underline\n end",
"def welcome_message_for_user_as_codemaker\n puts \"OK, great! You're the codemaker.\"\n puts \"In order to play, you need to think up a secret code with 4 spots.\"\n puts \"The colors you can choose from are: red, blue, green, yellow, purple, and orange.\"\n puts \"Hit enter when you're ready for my first guess!\"\n get_input\n end",
"def print(color, message, nl = true)\n $stdout.print(\"\\e[34;1m[Level#{@level}] \\e[#{30 + color};22m#{message}\\e[0m\")\n $stdout.puts if nl\n end",
"def success_message\n puts \"Correct!\".green\nend",
"def welcome\n puts \nend",
"def error_message( msg, details='' )\n\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + ' ' + details\n\tend",
"def print_welcome\n puts \"Welcome to Hangman!\"\n puts \"Guess the word: or be hung!\"\n puts \"Remember that you after 10 letter guesses you lose.\"\n end",
"def print_header\n print \"\\e[H\\e[2J\"\n puts \"*************************\".green\n puts \"2nd step - Gameplay setup\".green\n puts \"*************************\".green\n end",
"def welcome\n puts message_list[:welcome]\n # help\n end",
"def error_message( msg, details='' )\n\t\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details\n\t\tend",
"def welcome(nick_name, name)\n puts \"Hello, my friends call me #{nick_name}, but I prefer #{name}.\"\nend",
"def puts_color( msg, color=nil )\n color_set( color ); puts msg; color_end\n end",
"def output_log(log)\n puts \"\\e[32m#{log}\\e[m\\s\"\nend",
"def welcome_message(positions)\n system 'clear'\n puts \"Let's play some poker!\".light_red\n sleep(1)\n puts 'There are ' + positions.length.to_s.yellow + ' players at the table.'\n sleep(1)\n puts 'Starting stacks are ' + '5000 chips.'.light_green\n sleep(1)\n puts 'The ' + 'small blind is 25 chips'.light_yellow + ' and the ' + 'big blind is 50 chips.'.light_red\n puts ''\n sleep(2)\nend",
"def welcome\n\t\tputs \"Welcome to Hangman!\\n\\n\"\n\t\tputs \"The computer has selected a random secret word for you to guess.\\n\"\n\t\tputs \"Be careful - you have 6 incorrect guesses before you hang the man!\"\n\tend",
"def log(bit)\n puts \"\\033[35m#{bit} \\033[0m\"\nend",
"def message_point couleur, point = '.'\n STDOUT.write \"\\e[#{couleur}m#{point}\\e[0m\"\n sleep 0.1\n end",
"def welcome_message\n self.custom_welcome_message || self.default_welcome_message\n end",
"def menu_error\n system(\"clear\")\n puts Spacer\n puts \"Sorry! I didn't understand that.\".colorize(:red)\n end",
"def output_message message, color\n case color\n when :black\n puts message.black\n when :red\n puts message.red\n when :green\n puts message.green\n when :yellow\n puts message.yellow\n when :blue\n puts message.blue\n when :magenta\n puts message.magenta\n when :cyan\n puts message.cyan\n else\n puts message\n end\n end",
"def print_codebreaker_intro_easy\n puts 'Welcome to Mastermind! You are playing the role of the codebreaker.'\n puts 'The computer will choose a 4-color code that you will try to guess.'\n puts \"The valid letters/colors are #{'R'.red}, #{'O'.light_red}, #{'Y'.yellow}, #{'G'.green}, #{'B'.blue}, #{'I'.light_blue}, and #{'V'.magenta}.\"\n puts ''\n puts 'You will get feedback from the code master after each round in the locations corresponding to your guess.'\n puts 'A \"√\" means you have the right color in the right place.'\n puts 'An \"X\" means that the color is in the code but not in that place.'\n puts 'Finally, a \".\" means that color is not part of the code.'\n puts 'You have 6 rounds to guess correctly. Good luck!'\n puts ''\n end",
"def msg(text, level = :info)\n case level\n when :warn\n puts \"\\e[31m#{text}\\e[0m\"\n else\n puts \"\\e[33m#{text}\\e[0m\"\n end\nend",
"def msg(text, level = :info)\n case level\n when :warn\n puts \"\\e[31m#{text}\\e[0m\"\n else\n puts \"\\e[33m#{text}\\e[0m\"\n end\nend",
"def shout_out(string)\n puts \"\\n\\e[7;1m#{string.center(75)}\\e[27;0m\\n\\n\"\nend",
"def welcome_screen\n puts \"Bienvenue dans la secret place !\"\nend",
"def header(message)\n return if quiet?\n say(message, [:black, :on_white])\n end",
"def print_command(msg)\n puts \" #{color(\"$\", 32)} #{color(msg, 32)}\"\n end",
"def banner(msg, color: GREEN)\n msg = \"#{msg} \".ljust(72, ' ')\n msg = \"[#{Time.new.strftime('%H:%M:%S')}] #{msg}\"\n msg = \"#{color}#{msg}#{RESET}\" if $stdout.tty?\n puts msg\n end",
"def message(string)\n puts\n puts \"[#{colorize(\"--\", \"blue\")}] #{ string }\"\nend",
"def bold_error(*args)\n color('1;31', *args)\n end",
"def congrats_message\n puts \" ___________\"\n sleep 0.1\n puts \" '._==_==_=_.'\"\n sleep 0.1\n puts \" .-\\: /-.\"\n sleep 0.1\n puts \" | (|:. |) |\"\n sleep 0.1\n puts \" '-|:. |-'\"\n sleep 0.1\n puts \" \\::. /\"\n sleep 0.1\n puts \" '::. .'\"\n sleep 0.1\n puts \" ) (\"\n sleep 0.1\n puts \" _.' '._\"\n sleep 0.1\n puts ' `\"\"\"\"\"\"\"`'\n end",
"def error(msg)\n puts red(bold(\"[!] #{msg}\"))\n end"
] | [
"0.73284364",
"0.713477",
"0.71022743",
"0.71007407",
"0.70024383",
"0.6943597",
"0.69146645",
"0.6900986",
"0.68961215",
"0.68570006",
"0.6851913",
"0.682991",
"0.67697144",
"0.67637426",
"0.6749306",
"0.67271733",
"0.6710904",
"0.6693463",
"0.6655457",
"0.66517806",
"0.66332906",
"0.6612269",
"0.6593463",
"0.65925306",
"0.65647477",
"0.6559102",
"0.6556343",
"0.6554086",
"0.65435946",
"0.654268",
"0.6540731",
"0.6540011",
"0.64991885",
"0.64925826",
"0.64691836",
"0.64605385",
"0.64605385",
"0.64354503",
"0.64174205",
"0.64035296",
"0.64018303",
"0.64016163",
"0.6392365",
"0.63889515",
"0.63879704",
"0.6384895",
"0.6376685",
"0.63487417",
"0.63385934",
"0.6325044",
"0.632446",
"0.6315627",
"0.6306776",
"0.6306199",
"0.6287294",
"0.6286943",
"0.6284476",
"0.6268132",
"0.62643045",
"0.62605304",
"0.62574226",
"0.62207925",
"0.6193486",
"0.6193222",
"0.6184309",
"0.61788404",
"0.6173198",
"0.61706275",
"0.61595595",
"0.6146384",
"0.61322755",
"0.6131081",
"0.6130352",
"0.61288536",
"0.6110433",
"0.61090285",
"0.61066043",
"0.6101139",
"0.6097811",
"0.60951775",
"0.6095123",
"0.6078528",
"0.6072026",
"0.6067383",
"0.60666734",
"0.60656196",
"0.60560864",
"0.6051762",
"0.60493803",
"0.60454625",
"0.60454625",
"0.6044973",
"0.6044688",
"0.6043347",
"0.6041614",
"0.6040033",
"0.6031009",
"0.6029464",
"0.60254306",
"0.60128367"
] | 0.7259877 | 1 |
Opens file and writes new line to it | def write_to_file(line, my_file)
# Error Handling
begin
File.open(my_file, "a") { |f| f.write "#{line}\n" }
rescue => e
raise FileNotFoundError,"Could not find file"
puts e.message
puts e.backtrace.inspect
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_line_to_file(file, line)\n File.open(file, \"a\") {|f| f.puts(\"#{line}\")}\n end",
"def newline()\n @file.write(\"\\n\")\n end",
"def append_line\n File.open(path, 'w') do |fh|\n lines.each do |l|\n fh.puts(l)\n end\n fh.puts line\n end\n end",
"def append_line_to_file(filename, line)\n FileUtils.touch(filename)\n File.open(filename, 'a') do |f|\n f.puts line\n end\nend",
"def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end",
"def write_lines file_path, new_lines\n File.open(file_path, 'w') do |file|\n new_lines.each do |new_line|\n file.puts new_line\n end\n end\n end",
"def add_line_to_file file_path,line\n return \"echo #{line} >> #{file_path}\"\n end",
"def append_mode(line)\n File.open(\"#{file}\",\"a\") {|file| file.puts line}\n end",
"def appendline(fn, s)\n File.open(fn, \"a+\").puts s\nend",
"def add_line_to_file(filename, new_value, line_number = nil)\n File.open(filename, 'r+') do |file|\n lines = file.each_line.to_a\n if line_number\n lines[line_number] = new_value + \"\\n\"\n else\n lines.push(new_value + \"\\n\")\n end\n file.rewind\n file.write(lines.join)\n file.close\n end\n end",
"def append_to_file(file, eol: $/)\n file.to_pathname.append_lines(self, eol: eol)\n self\n end",
"def change_line(file, lineno, new_line)\n lines = File.readlines(file).tap { |c| c[lineno - 1] = \"#{new_line}\\n\" }\n\n File.open(file, \"w\") { |f| f.write(lines.join) }\n end",
"def report_file_puts(line)\n\n\tFile.open(\"./todolist_save.txt\", \"a\") do |file|\n\t\tfile.puts line\n\tend\nend",
"def write(file=nil)\n file = file.nil? ? @file : file\n File.open(file, 'w+') {|f|\n @lines.each{|line|\n f.write(\"#{line}\\r\\n\")\n }\n }\n end",
"def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end",
"def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end",
"def add_lines_to_file file_name\n\n\t# Change the mode of the file in order to add a new line to the existing file\n\tfile = File.open(file_name, 'a')\n\n\t# Ask the user the amount of lines to be added\n\tputs \"How many lines would you like to add now?\"\n\tnumber_of_lines = gets.chomp\n\n\t# According to the amount of lines, ask for each line\n\tnumber_of_lines.to_i.times do |lines|\n\t\tprint \"#{lines + 1}: \"\n\t\tfile.write(gets)\n\tend\n\n\t# Close the file\n\tfile.close\nend",
"def append fi,c\n\tFile.open( fi, \"a\" ) {| f | f.puts c } \nend",
"def write_file\n\n # file_edited is false when there was no match in the whole file and thus no contents have changed.\n if file_edited\n backup_pathname = original_pathname + \".old\"\n FileUtils.cp(original_pathname, backup_pathname, :preserve => true)\n File.open(original_pathname, \"w\") do |newfile|\n contents.each do |line|\n newfile.puts(line)\n end\n newfile.flush\n end\n end\n self.file_edited = false\n end",
"def append_line_to_file(path, line)\n run \"echo '#{line}' | #{sudo} tee -a #{path}\", options\n end",
"def append_idea idea\n open(\"#{FileName}.txt\", 'a') do |file|\n file.puts idea\n end\n\n File.read(\"#{FileName}.txt\")\nend",
"def append_to_file(file, str)\n File.open(file, 'a+') { |f| f << str }\n end",
"def write_line(string, filename)\n Util::FileMutation.write_line(string, filename)\n end",
"def write file, text\n File.open file, \"w\" do |file|\n file.write text\n end\n end",
"def write_file!\n file = File.new( path, \"w\")\n \n file.write(@source)\n file.close\n end",
"def ingresar_producto(nuevo)\n file = File.open('productos.txt','a')\n file.puts nuevo\n file.close\nend",
"def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end",
"def writeToFile(target, aLine)\n target.puts(aLine)\n end",
"def append_file(fn, str)\n File.open(fn, 'a') do |f|\n f.puts str\n end\n end",
"def SimpleWriter\n def initialize(path)\n\t @file = File.open(path, 'w')\n end\n def write_line(line)\n\t @file.print(line)\n\t @file.print(\"\\n\")\n end\n def pos\n\t @file.pos\n end\n def rewind\n\t @file.rewind\n end\n def close\n\t @file.close\n end\nend",
"def write_file(path, content)\r\n f = File.new(path, \"w+\")\r\n f.puts content\r\n f.close\r\n end",
"def write_line(data); end",
"def write(data)\n File.open('text.txt') do |f2|\n f2.puts data\n end\nend",
"def file_append(f, t)\n File.open(f, \"a\") { |f| f.write t }\n end",
"def writeline(dst_path, line)\n FileUtils.mkdir_p(File.dirname(dst_path))\n File.open(dst_path, 'w') do |f|\n f.write line\n end\n end",
"def file_out(string)\nopen('myfile.json', 'a') { |f|\n f.puts string\n }\nend",
"def append_xy_file(filename, x, y)\n File.open(filename, 'a') do |xy_file|\n xy_file.puts \"#{x} #{y}\" \n end\n true\n end",
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def append(content)\n\t\t\tFile.open(path,'a'){|target| target << content}\n\t\t\tnew_file = FileAry.new(path)\n\t\t\t@read = new_file.read\n\t\t\t@head = read.lines.first\n\t\t\t@lines = read.lines\n\t\tend",
"def append_xy_file(filename, x, y)\n File.open(filename, 'a') do |xy_file|\n xy_file.puts \"#{x} #{y}\"\n end\n true\n end",
"def line_feed\n write_raw \"\\n\"\n end",
"def open_path(text, path, line = 1, column = 0)\n text.filename = path\n\n begin\n text.clear\n content = read_file(text, text.filename)\n text.encoding = content.encoding\n text.readonly = !text.filename.writable?\n text.insert(1.0, content)\n text.message \"Opened #{text.short_filename}\"\n rescue Errno::ENOENT\n text.clear\n text.message(\"Created #{text.short_filename}\")\n end\n\n after_open(text, line, column)\n end",
"def ensure_line_appended_to_file(path, line)\n remove_line_from_file(path, line)\n append_line_to_file(path, line)\n end",
"def file_write(file, contents=\"\")\n\t\tFile.open(file.to_s, 'w+') do |f|\n\t\t\tf.print contents\n\t\tend\n\t\tcontents\n\tend",
"def flush\n File.open(path,'a'){|f| f.write @file_content}\n @file_content = ''\n end",
"def append_file(file_name, data)\n if session.type == \"meterpreter\"\n fd = session.fs.file.new(file_name, \"ab\")\n fd.write(data)\n fd.close\n elsif session.respond_to? :shell_command_token\n if session.platform == 'windows'\n session.shell_command_token(\"<nul set /p=\\\"#{data}\\\" >> \\\"#{file_name}\\\"\")\n else\n _write_file_unix_shell(file_name, data, true)\n end\n end\n true\n end",
"def write_file(path)\n File.open(path, 'w') {|f| write_io(f)}\n end",
"def add_entry\n new_content = file_content MY_HOSTS_FILE\n open(HOSTS_FILE, 'a') do |f|\n f << \"\\n#{new_content}\\n\"\n end\nend",
"def >> file_name, i = index\n if ((File.writable? file_name or not File.exists? file_name) and not\n File.directory? (file = File.new(file_name, 'w')))\n buff = @form[i].update_text\n i = 1\n size = buff.length\n buff.each do |line|\n line = line.chop\n line += \"\\n\" unless i == size\n i += 1\n file.write line\n end\n end\n file.close if file\n end",
"def add_to_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n # Using technique outlined here: http://www.dzone.com/snippets/ruby-open-file-write-it-and\n\n File.open(path, 'a') {|f| f.write(\"#{contents}\\n\") }\n\n \"#{path} updated\"\n end",
"def add_to_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n # Using technique outlined here: http://www.dzone.com/snippets/ruby-open-file-write-it-and\n\n File.open(path, 'a') {|f| f.write(\"#{contents}\\n\") }\n\n \"#{path} updated\"\n end",
"def append_new_line(new_line)\n # Append 'line' into position 'line_number'\n puts ' append_new_line ...' if $verbose > 1\n @lines << new_line\n @line_count += 1\n end",
"def append_to_file(full_path, contents)\n\t\t::File.open(full_path, 'a') do |f|\n\t\t\tf.write contents\n\t\tend\n\t\ttrue\n\tend",
"def add(new_question)\n\n\n\tquestions = File.open(\"/Users/Wipf/questions.txt\", \"a\")\n\n\tquestions.puts new_question\n\n\tquestions.close\n\n\tprint \"Question '#{new_question}' has been added\"\n\nend",
"def log(line)\n\t\tfile=File.open(@output_file,\"a+\")\n\t\tfile.puts(line)\n\t\tfile.close\n\tend",
"def write_file\n \n # if dirty?\n generate\n \n delete_file\n File.open(absolute_path.gsub(/\\.txt$/, \"\"), 'w+') do |f| \n f.write(generated_header)\n f.write(generated_content)\n end\n # not_dirty\n # end\n end",
"def filewrt(file2wrt, data2wrt)\n\toutput = ::File.open(file2wrt, \"a\")\n\tdata2wrt.each_line do |d|\n\t\toutput.puts(d)\n\tend\n\toutput.close\nend",
"def filewrt(file2wrt, data2wrt)\n\toutput = ::File.open(file2wrt, \"a\")\n\tdata2wrt.each_line do |d|\n\t\toutput.puts(d)\n\tend\n\toutput.close\nend",
"def out text\n @fileBuffer << text << \"\\n\"\nend",
"def file_open_puts object, filename\n File.open(filename, 'w') do |f|\n f.puts(object)\n end\n\n end",
"def write(pathStr, lines) \n file = open(pathStr, \"w\")\n lines.each do |line|\n file.write(line)\n end\n file.close\n lines\nend",
"def append_file(fname, content)\n begin\n aFile = File.new(fname,\"a\")\n aFile.puts content\n aFile.close\n rescue Exception=>e\n # logger.error e\n p e.inspect\n end\nend",
"def write_to_file(f)\n return f.write(self.buffer)\n end",
"def file_write(file2wrt, data2wrt)\n if not ::File.exists?(file2wrt)\n ::FileUtils.touch(file2wrt)\n end\n\n output = ::File.open(file2wrt, 'a')\n data2wrt.each_line do |d|\n output.puts(d)\n end\n output.close\n end",
"def insert_row filename, lineno, text\n d = _read filename\n d.insert(lineno, text)\n _write filename, d\n 0\n end",
"def opx_file_open_write(file)\n File.open(file, \"w\")\n rescue => e\n opx_err(\"Fatal failure of File.open for writing: #{file}\", e)\n end",
"def write(message)\n f = open(@filename, 'a')\n f.puts(message)\n f.close()\n end",
"def createFile(file,time)\n\t\tFile.open(file, \"w+\") do |f|\n\t\t\tf.print time\n\t\tend\n\tend",
"def insert_after_line(file, insert, regex = /^## Next/)\n tempfile = File.open(\"#{file}.tmp\", \"w\")\n f = File.new(file)\n f.each do |line|\n tempfile << line\n next unless line =~ regex\n\n tempfile << \"\\n\"\n tempfile << insert\n tempfile << \"\\n\"\n end\n f.close\n tempfile.close\n\n FileUtils.mv(\"#{file}.tmp\", file)\nend",
"def write(new_contents)\n\t\tconnection.write_file(full_path, new_contents)\n\tend",
"def write(new_contents)\n\t\tconnection.write_file(full_path, new_contents)\n\tend",
"def insert_text_at_line_number(source, target_file, line_number)\n if line_number > 0\n line_number -= 1\n file = IO.readlines(target_file)\n file.insert((line_number), check_source_type(source))\n File.open(target_file, \"w\") do |x|\n x.puts file\n end\n else\n raise ArgumentError, \"Line number must be 1 or higher.\".red\n end\n end",
"def write_file(fname, data = nil, tocrlf = false, &block) # :yields: io\n File.open(fname, \"w\") do |output|\n if block\n block.call(output)\n else\n raise \"no data given\" unless data\n if tocrlf\n require 'strscan'\n sc = StringScanner.new data\n until sc.eos?\n if (ms = sc.scan(/[^\\r\\n]+/))\n output.write(ms)\n elsif (ms = sc.scan(/\\r?\\n/))\n output.write(\"\\r\\n\")\n else\n raise ArgumentError, sc.rest\n end\n end\n else\n output.write(data)\n end\n end\n end\n puts fname\nend",
"def new_file(new_name=false, body)\n f_name = new_name || file_name_with_path\n File.open(f_name, \"w\") { |line|\n line.write(body)\n line\n }\n end",
"def open_new_file_to_write(input, number)\n\toutfile = File.new(\"per-#{number}bp-#{input}.txt\", \"w\")\n\toutfile.puts \"position\\tnumhm\\tnumht\"\n\toutfile\nend",
"def write(mph, minutes, incline=\"\", date: Time.now)\n Dir.mkdir(File.dirname(filepath)) unless Dir.exist?(File.dirname(filepath))\n File.open(filepath, 'a+') do |file|\n unless(file.readlines.include?(header(date.month, date.day)))\n file.puts header(date.month, date.day)\n end\n file.puts query(mph, minutes, incline, date: date)\n end\n end",
"def makeFile filename, message\n making = File.open(filename, \"w\")\n making.puts(message)\n making.close\nend",
"def line_maker\n @lines = File.readlines(path, chomp: true)\n end",
"def write()\n f = File.open(\"#{@directory}/#{@filename}\", \"w\")\n f.write(@raw)\n f.close()\n end",
"def file_write(file, content)\n \n instructions = \"echo #{content.inspect} >> #{file}\"\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n puts 'r: ' + r.inspect if @debug\n \n @results[:file_write] = r\n\n end",
"def generate (path)\n File.open(path, \"w\") do |f|\n @output.each do |line|\n f.puts line\n end\n end \n end",
"def writeFile( fileName, textToWrite)\r\nopen(fileName,'w').write(textToWrite)\r\nend",
"def _increment_file_line()\n\t\t@reading_line += 1\n\tend",
"def writelinebinary(dst_path, line)\n FileUtils.mkdir_p(File.dirname(dst_path))\n File.open(dst_path, 'wb') do |f|\n f.write line\n end\n end",
"def write(file)\n self.files.each { |l| file.puts l }\n end",
"def test_file_append()\n\t\t# test the empty file\n\t\tCfruby::FileEdit.file_append(@emptyfilename, \"new line\")\n\t\tlines = File.open(@emptyfilename, File::RDONLY).readlines()\n\t\tassert_equal(1, lines.length)\n\t\tassert_equal(\"new line\", lines[-1])\n\t\t\n\t\t# test the multiline file\n\t\tCfruby::FileEdit.file_append(@multilinefilename, \"new line\")\n\t\tlines = File.open(@multilinefilename, File::RDONLY).readlines()\n\t\tassert_equal(@multilinefilecontents.split(\"\\n\").length+1, lines.length)\n\t\tassert_equal(\"new line\", lines[-1])\t\t\n\tend",
"def write_file(file, data)\n File.open(file, 'w') { |fd| fd.write(data) }\n end",
"def fwrite(file, text)\n\tf = File.open(file, \"w\")\n\tf.write(text)\n\tf.close\nend",
"def write\n File.open(path, 'w') { |file|\n file.write(FILE_HEADER + \"\\n\")\n file.write(encoded_body)\n }\n end",
"def put_a_line\n puts \"\\n\"\n puts \"/\\\\\" * 40\n puts \"\\n\"\n end",
"def insert_player(player, score)\n File.open(@file_name, 'a+') do |f|\n f.puts player + ',' + score\n end\n end",
"def write_file(newfile, instream)\n File.open(newfile, \"w\") do |f|\n f.write(instream.read)\n end\nend",
"def file(name, contents)\n @workdir.join(name).open(\"w+\") do |f|\n f.write(contents)\n end\n end",
"def edit_lines_in_file\n locked_file = \"\"\n begin\n locked_file = lock_file()\n lines = IO.read(locked_file).split(/\\n/)\n lines.map! { |s| s.rstrip }\n lines = yield lines\n # Blank lines (\"\") will always be deleted.\n lines.reject! { |line| line == '' }\n File.open(locked_file, 'w') { |f| f.write(lines.join(\"\\n\")+\"\\n\") }\n return true\n ensure\n unlock_file(locked_file)\n end\n end",
"def write_line data\n _data[:out].puts data\n _data[:out].flush\n end",
"def write_file(p, file)\n File.open(browse_file(p, file), 'w') { |fh| fh.print yield }\n end",
"def write_file(file_name)\n File.open(file_name, 'w') { |f| f.write header_build }\n File.write(file_name, @content, mode: 'a')\nend",
"def newLine()\n if $time < $lex.getLineCount()\n $lex = Lexer.new($filename,$time+=1)\n end\nend",
"def write_file(content, path)\n File.delete path if File.exists? path\n\n file = File.new path, 'w+'\n file.write content\n\n file.close\n end",
"def to_file\n file = \"\"\n @fileContent.each do |line|\n file << line\n file << \"\\n\" unless line == @fileContent.last\n end\n file\n end"
] | [
"0.74757147",
"0.73306346",
"0.7309672",
"0.73075056",
"0.7270581",
"0.7237945",
"0.72036654",
"0.7099398",
"0.6749733",
"0.6701245",
"0.6529158",
"0.6493587",
"0.6462126",
"0.64620805",
"0.6383742",
"0.6383742",
"0.6367607",
"0.6347354",
"0.63328964",
"0.632448",
"0.62951887",
"0.6279285",
"0.62745464",
"0.6271492",
"0.62592965",
"0.623291",
"0.621239",
"0.6137909",
"0.60696834",
"0.60286736",
"0.60184187",
"0.60168815",
"0.6015345",
"0.6000859",
"0.5984055",
"0.5973956",
"0.5966129",
"0.5927183",
"0.588379",
"0.5877049",
"0.5871917",
"0.5868491",
"0.5852705",
"0.5852596",
"0.5848088",
"0.5841353",
"0.58382666",
"0.58372384",
"0.5835365",
"0.58344257",
"0.58344257",
"0.58319825",
"0.58278126",
"0.58239985",
"0.5817368",
"0.5815461",
"0.5814906",
"0.5814906",
"0.5789555",
"0.57674074",
"0.5764772",
"0.5760995",
"0.57513905",
"0.57511944",
"0.5742542",
"0.570568",
"0.5695435",
"0.56899565",
"0.5686687",
"0.5681876",
"0.5681876",
"0.5670117",
"0.5667027",
"0.56469",
"0.5646107",
"0.56449527",
"0.5640945",
"0.56391674",
"0.5639105",
"0.56302154",
"0.5627761",
"0.5625803",
"0.5623138",
"0.56191677",
"0.5619092",
"0.56189793",
"0.56170404",
"0.56131625",
"0.56110984",
"0.5609489",
"0.5604046",
"0.5597114",
"0.5590437",
"0.5588659",
"0.5582256",
"0.5573986",
"0.5563282",
"0.5562887",
"0.55610037",
"0.55574036"
] | 0.6183684 | 27 |
Validates item as an item in the game and updates current item | def new_current_item(command)
@game_items.each do |item|
if item.is_item?(command)
@current_item = item
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n $game_temp.select_data == nil\n # play buzzer, can't use\n $game_system.se_play($data_system.buzzer_se)\n end\n # stop input update\n return true\n end",
"def valid_item\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n @active_battler.current_action.clear\n @active_battler.current_action.set_item(@item.id)\n if @item.for_dead_friend? and !$game_system.actors_bodies? \n if $game_map.passable?(@cursor.x, @cursor.y, 0) and\n (occupied_by?(@cursor.x, @cursor.y) == nil)\n open_revive_window\n end\n else\n @active_battler.current_action.set_item(@item.id)\n @targets = get_targets\n if @targets.empty?\n Sound.play_buzzer\n else\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Item) \n @windows[Win_Status].dmg_preview(3, @active_battler, @item, @targets)\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n end\n end\n end",
"def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n\r\n puts \"User chose item #{ItemService.item_sym_of(id)}\"\r\n @pedestal.pedestal_item_id = id\r\n\t\t\t$game_party.gain_item(rmxp_item_id, -1)\r\n\r\n SetupEventService.new.setup!\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end",
"def update_item\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to menu screen\n $scene = Scene_Menu.new(1)\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the item window\n @item = @item_window.item\n # If not a use item\n unless @item.is_a?(RPG::Item)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # If it can't be used\n unless $game_party.item_can_use?(@item.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # If effect scope is an ally\n if @item.scope >= 3\n use_item\n # If effect scope is other than an ally\n else\n # If command event ID is valid\n if @item.common_event_id > 0\n # Command event call reservation\n $game_temp.common_event_id = @item.common_event_id\n # Play item use SE\n $game_system.se_play(@item.menu_se)\n # If consumable\n if @item.consumable\n # Decrease used items by 1\n $game_party.lose_item(@item.id, 1)\n # Draw item window item\n @item_window.draw_item(@item_window.index)\n end\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n end\n return\n end\n end",
"def on_item_ok\n return back_to_items if (item = @item_window.item).nil?\n $game_party.lose_item(item, 1)\n @unit_item_list.tb_unit.gain_item(item, 1)\n TactBattleManager.store_unit_item(@actor.id, item)\n back_to_items\n end",
"def useItem?\n # to make sure duplicates are not registered at the beginning\n Input.update\n # render bitmap for item use confirmation\n bitmap = @sprites[\"confirm\"].bitmap\n bitmap.clear; bmp = pbBitmap(@path + @confirmImg)\n bitmap.blt(0, 0, bmp, bmp.rect)\n icon = pbBitmap(GameData::Item.icon_filename(@ret))\n bitmap.blt(20, 30, icon, icon.rect)\n # draw text\n drawTextEx(bitmap, 80, 12, 364, 3, GameData::Item.get(@ret).description, @baseColor, Color.new(0, 0, 0, 32))\n # select confirm message as target\n @sprites[\"sel\"].target(@sprites[\"confirm\"])\n # animate in\n 8.times do\n # slide panels into screen\n @sprites[\"confirm\"].x += @viewport.width/8\n @sprites[\"cancel\"].x += @viewport.width/8\n if @pocket\n # fade out panels\n for i in [email protected]\n @items[\"#{i}\"].opacity -= 32\n end\n end\n for i in 0...4\n @sprites[\"pocket#{i}\"].opacity -= 64 if @sprites[\"pocket#{i}\"].opacity > 0\n end\n # animate bottom items moving off screen\n @sprites[\"pocket4\"].y += 10 if @sprites[\"pocket4\"].y < @sprites[\"pocket4\"].ey + 80\n @sprites[\"pocket5\"].y += 10 if @sprites[\"pocket5\"].y < @sprites[\"pocket5\"].ey + 80\n @sprites[\"name\"].x -= @sprites[\"name\"].width/8\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # ensure pocket name is off screen\n @sprites[\"name\"].x = -@sprites[\"name\"].width\n index = 0; oldindex = 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n # start the main input loop\n loop do\n @sprites[\"#{choice}\"].src_rect.y += 1 if @sprites[\"#{choice}\"].src_rect.y < 0\n # process directional input\n if Input.trigger?(Input::UP)\n index -= 1\n index = 1 if index < 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n elsif Input.trigger?(Input::DOWN)\n index += 1\n index = 0 if index > 1\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n end\n # process change in index\n if index != oldindex\n oldindex = index\n pbSEPlay(\"EBDX/SE_Select1\")\n @sprites[\"#{choice}\"].src_rect.y -= 6\n @sprites[\"sel\"].target(@sprites[\"#{choice}\"])\n end\n # confirmation and cancellation input\n if Input.trigger?(Input::C)\n pbSEPlay(\"EBDX/SE_Select2\")\n break\n elsif Input.trigger?(Input::B)\n @scene.pbPlayCancelSE()\n index = 1\n break\n end\n Input.update\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # animate exit\n 8.times do\n @sprites[\"confirm\"].x -= @viewport.width/8\n @sprites[\"cancel\"].x -= @viewport.width/8\n @sprites[\"pocket5\"].y -= 10 if index > 0\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # refresh old UI (swap cursor to target)\n self.refresh\n # return output\n if index > 0\n @ret = nil\n return false\n else\n @index = 0 if @index == 4 && GameData::Item.get(@lastUsed).id_number == 0\n return true\n end\n end",
"def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Menu.new(0)\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If it can't be used\r\n unless $game_party.item_can_use?(@item.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n if @item.scope >= 3\r\n # Activate target window\r\n @item_window.active = false\r\n @target_window.x = (@item_window.index + 1) % 2 * 304\r\n @target_window.visible = true\r\n @target_window.active = true\r\n # Set cursor position to effect scope (single / all)\r\n if @item.scope == 4 || @item.scope == 6\r\n @target_window.index = -1\r\n else\r\n @target_window.index = 0\r\n end\r\n # If effect scope is other than an ally\r\n else\r\n # If command event ID is valid\r\n if @item.common_event_id > 0\r\n # Command event call reservation\r\n $game_temp.common_event_id = @item.common_event_id\r\n # Play item use SE\r\n $game_system.se_play(@item.menu_se)\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used items by 1\r\n $game_party.lose_item(@item.id, 1)\r\n # Draw item window item\r\n @item_window.draw_item(@item_window.index)\r\n end\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n return\r\n end\r\n end",
"def use_item(command)\n if @player.has_item?(command)\n # Player is carrying item\n self.new_current_item(command)\n if @current_item.is_key? \n if @current_room == @lroom \n puts \"Congratulations! You escaped the AirBnB\"\n puts \"You escaped with a rating of: \\n\"\n puts @star1.encode('utf-8') * @score\n puts \"\\n\\n\\nThanks for playing!\\n\"\n # Write score to player scores file\n write_to_file(\"#{@score} #{@username}\",\"player_scores.txt\")\n sleep(3)\n system('clear')\n @run_game = false\n else \n puts \"You are not using this item in the correct room!\"\n end\n elsif @current_item.is_a? ScoreItem\n # Item adjusts score\n @score += @current_item.score\n if @score == 1\n # Score reaches 0\n puts \"\\nYour guest rating dropped too low.\"\n puts \"\\nThe gHost has killed you.\".colorize(:color => :white, :background => :red)\n sleep(2.5)\n system('clear')\n @run_game = false\n else\n puts \"\\n#{@current_item.use_description}\\n\\n\"\n puts \"You now have a guest rating of #{@score}\".colorize(:blue)\n puts @star1.encode('utf-8') * @score # print star rating\n @player.remove_item(command)\n end\n else \n puts \"You aren't carrying this item.\\n\"\n end\n end\n end",
"def item_update(item)\n @item = item\n end",
"def add_item(item)\n if @item\n log(\"Item is already equipped in EquipSlot.\")\n return\n end\n @item = item\n return\n end",
"def get_item\n \n if active_character\n item = Item.find(params[:item][:id])\n position = params[:item][:container_position]\n \n # swap any existing item in same position\n prev_item = active_character.inventory.find(:first, :conditions => {:container_position => position})\n \n if item.owner == active_character\n if prev_item\n prev_item.container_position = item.container_position\n prev_item.save\n end\n \n item.container_position = position\n item.save\n elsif item.owner == active_character.area\n area = active_character.area\n \n if prev_item\n prev_item.owner = area\n prev_item.save\n \n render_to_area area do |page|\n page.call :addEvent, \"#{h current_user} has dropped #{h prev_item.name}!\"\n page.call 'game.updateDisplayable', prev_item.css_id, prev_item.left, prev_item.top\n end\n end\n \n item.owner = active_character\n item.container_position = position\n item.save\n # Update all clients in area\n render_to_area area do |page|\n page.call :addEvent, \"#{h active_character.name} has picked up #{h item.name}!\"\n page.call :got_item, item.css_id, active_character.id\n end\n end\n end\n \n render :nothing => true\n end",
"def unit_item_ok\n return refresh_items if @unit_item_list.tb_unit.nil?\n @unit_item_list.activate\n return if (item = @unit_item_list.item).nil?\n @unit_item_list.tb_unit.lose_item(item, 1) \n TactBattleManager.rm_unit_item(@actor.id, item)\n $game_party.gain_item(item, 1)\n refresh_items\n end",
"def next_item\n if (player.location.inventory.length > @index)\n @item = player.location.inventory[@index]\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n else\n game.change_state(Map.new)\n end\n end",
"def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Activate right window\r\n @right_window.active = true\r\n @item_window.active = false\r\n @item_window.index = -1\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Play equip SE\r\n $game_system.se_play($data_system.equip_se)\r\n # Get currently selected data on the item window\r\n item = @item_window.item\r\n # Change equipment\r\n @actor.equip(@right_window.index, item == nil ? 0 : item.id)\r\n # Activate right window\r\n @right_window.active = true\r\n @item_window.active = false\r\n @item_window.index = -1\r\n # Remake right window and item window contents\r\n @right_window.refresh\r\n @item_window.refresh\r\n return\r\n end\r\n end",
"def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end",
"def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end",
"def add_item\n @item = Item.new(:question_id => params[:question_id],\n :ok => params[:item][:ok],\n :ans => params[:item][:ans])\n last_pos = 0\n last_item = @question.items.order(:position).last\n if !last_item.nil?\n last_pos = last_item.position\n end\n @item.position = last_pos+1\n if [email protected]_answers && @item.ok && @question.items.count > 0\n flash[:info] = \"La réponse correcte a maintenant changé (une seule réponse est possible pour cet exercice).\"\n # Two good answer\n # We put the other one to false\n @question.items.each do |f|\n if f.ok\n f.ok = false\n f.save\n end\n end\n end\n if [email protected]_answers && [email protected] && @question.items.count == 0\n flash[:info] = \"Cette réponse est mise correcte par défaut. Celle-ci redeviendra erronée lorsque vous rajouterez la réponse correcte.\"\n @item.ok = true\n end\n unless @item.save\n flash.clear # Remove other flash info\n flash[:danger] = error_list_for(@item)\n end\n redirect_to question_manage_items_path(@question)\n end",
"def on_item_ok\n @item = @item_window.item\n BattleManager.actor.input.set_item(@item.id)\n action = BattleManager.actor.input\n case @item.target_type[0]\n when :one\n select_target_selection\n when :all\n BattleManager.actor.input.set = SES::TargetManager.make_targets(action)\n when :rand\n targets, set = [], SES::TargetManager.make_targets(action)\n (@item.target_type[1][0] + rand(@item.target_type[1][1])).times do\n targets << set[rand(set.size)]\n end\n BattleManager.actor.input.set = set\n else\n @item_window.hide\n next_command\n end\n $game_party.last_item.object = @item\n end",
"def pick_up(item_name)\n if current_room.has_item(item_name)\n item = current_room.items.find { |thing| thing.name == item_name }\n @player.add_to_inventory(item)\n current_room.remove_one(item)\n else\n puts \"Sorry, that item is not in this room. Try again.\"\n end\n end",
"def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end",
"def update_item\n self.item.update_complete\n end",
"def set_game_item\n @game_item = GameItem.find(params[:id])\n end",
"def activate\n if player.location.has_items?\n # set inventory index being considered for get\n @index = 0\n @item = player.location.inventory[@index]\n if player.inventory.can_fit?(@item)\n if player.location.inventory.size == 1 && @item.quantity == 1\n # a single item at the location so just get it\n player.get(@item)\n game.change_state(Map.new)\n else\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n end\n else\n game.messages << 'Your inventory is full.'\n game.change_state(Map.new)\n end\n else\n # no items at location\n game.change_state(Map.new)\n end\n end",
"def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end",
"def item_update(item)\n debug \"item update\"\n row = @contacts_rows[item.jid]\n unless row\n add_item_to_roster(item)\n row = @contacts_rows[item.jid]\n end\n fill_model_values_for_item item, row\n end",
"def use_item\n\n if @inventory.empty?\n slow_type(\"\\nYou don't have anything in your inventory\")\n\n else\n print_inventory_items\n\n use_item = TTY::Prompt.new\n\n choices = []\n @options = []\n @inventory.each do |item_id|\n inventory_item = find_item_by_id(item_id)\n choices << { name: inventory_item.name, value: inventory_item.item_id }\n end\n\n item_id = use_item.select(slow_type(\"\\nWhat would you like to use?\"), choices)\n \n selected_item = find_item_by_id(item_id)\n \n use_on = TTY::Prompt.new\n\n choices = []\n @options = []\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n choices << { name: item.name, value: item.item_id } unless @inventory.include?(item.item_id) || item.show_item == false\n end\n\n target_item = use_on.select(slow_type(\"\\nWhat would you like to use the #{selected_item.name} on?\"), choices)\n\n combo = @use_combos.find { |combo| combo[:item_id] == item_id && combo[:usage_location] == @current_room_id && combo[:target_id] == target_item}\n \n if combo.nil?\n slow_type(\"\\nYou cannot use these two items together\") \n \n else \n use_item_dependency(item_id)\n slow_type(combo[:message])\n\n if combo[:cell_to_unlock]\n find_room_by_id(combo[:cell_to_unlock]).isLocked = false\n game_complete if combo[:game_complete]\n\n elsif\n combo[:knocked_out]\n @guard_is_knocked_out = true\n end\n\n end\n end\n end",
"def update\n if @item.update(item_params)\n redirect_to items_path, notice: 'Item was successfully updated.'\n else\n render :edit, notice: 'Something went wrong try again.'\n end\n end",
"def set_item(item)\n return if @item == item\n @item = item\n refresh\n end",
"def set_item(item)\n return if @item == item\n @item = item\n refresh\n end",
"def use_item(item)\n battler.use_item(item)\n end",
"def use_item(item_name)\n item = self.items.find_by(name: item_name)\n if item.item_type == \"Healing Potion\"\n if self.hp += 10 < self.base_hp\n puts \"You drank the entire bottle. You feel energized! (+10 HP)\"\n puts \"You HP is now #{self.hp}\"\n #removes Item from inventory \n Item.destroy(item)\n else\n #if HP goes ove the base_health, it automatically caps at base_hp aka your max hp\n self.hp = self.base_hp\n puts \"You drank the entire bottle. You are at full health!\"\n puts \"Your HP is now #{self.base_hp}\"\n Item.destroy(item)\n end \n elsif item.item_type == \"Weapon\"\n #weapons will boost the characters attack points by a random number?\n if self.current_weapon == nil \n random_attack_boost = [2,3,5].sample\n self.attack_power += random_attk_boost\n puts \"You've equipped #{item.name}. (+#{random_attk_boost})\"\n else \n equipped_weapon = self.items.find_by(current_weapon)\n Item.destroy(equppied_weapon)\n self.attack_power = self.base_attk\n random_attack_boost = [5,6,10].sample\n self.attack_power += random_attack_boost\n puts \"You have replaced your weapon with #{item.name}. (+#{random_attk_boost})\"\n end \n else \n puts \"You can't use/equip this!\"\n end \n end",
"def item=(item)\n if @items\n raise InvalidSchemaError,\n \"cannot mix single item and multiple items validation\"\n end\n @item = item\n end",
"def update\n if @item.update(item_params)\n flash[:success] = \"Updated item\"\n redirect_to item_path(@item)\n else\n render 'items/edit'\n end\n end",
"def use_item(item, entity)\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n actual_item.use(self, entity)\n remove_item(actual_item) if actual_item.consumable\n else\n print NO_SUCH_ITEM_ERROR\n end\n end",
"def validate_item( x )\n fail 'not implemented!'\n end",
"def update\n @item = \"Vger::Resources::#{params[:item][:item_type]}\".constantize.find(params[:id])\n respond_to do |format|\n if @item.class.save_existing(params[:id], params[:item])\n format.html { redirect_to suitability_item_path(params[:id]), notice: 'Suitability Item was successfully updated.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game_item.update(game_item_params)\n format.html { redirect_to @game_item, notice: 'Game item was successfully updated.' }\n format.json { render :show, status: :ok, location: @game_item }\n else\n format.html { render :edit }\n format.json { render json: @game_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end",
"def item_inventory_update\n \n item = Item.find(params[:item_id])\n order= Order.find(params[:id])\n item_order = ItemOrder.where(item_id: item.id, order_id: order.id).first\n new_inventory = item.inventory - item_order.quantity\n item_order.update(status: \"fulfilled\")\n item.update(inventory: new_inventory)\n end",
"def set_item(new_item)\n return if @item == new_item\n @item = new_item\n refresh\n end",
"def update_item_selection\n @item_window.active = true\n @item_window.update\n @help_window.update\n #@item_back_window.update\n #@dataviews_window.update\n #@item_details_window.update\n \n if Input.trigger?(Input::B)\n Sound.play_cancel\n end_item_selection\n elsif Input.trigger?(Input::C)\n @item = @item_window.item\n if @item != nil\n $game_party.last_item_id = @item.id\n end\n if $game_party.item_can_use?(@item)\n Sound.play_decision\n determine_item\n else\n Sound.play_buzzer\n end\n #elsif (Input.repeat?(Input::Y) || Input.repeat?(Input::Z))\n # update_dataview_select(Input.press?(Input::Z), \n # Input.trigger?(Input::Y) || Input.trigger?(Input::Z))\n # @item_window.window_update(@dataviews_window.apply_dataview($game_party.items))\n # @item_window.index = 0\n end\n end",
"def update\r\n \t@cart_item.count -= CartItem.find(@cart_item.id).count\r\n\r\n if is_enough && @cart_item.update(cart_item_params)\r\n @cart_item.buy # pre-emtively \"buys\" the item to save it from other users\r\n flash[:notice] = \"Item was successfully updated!\"\r\n else\r\n flash[:danger] = \"Item could not be updated!\" + params.inspect\r\n end\r\n redirect_to edit_cart_item_path(@cart_item)\r\n end",
"def update\n if @item.update(item_params)\n render json: ItemSerializer.new(@item)\n else\n render json: @menu.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @item.update(item_params)\n return success_item_show\n else\n return error_item_save\n end\n end",
"def save_item(item)\n begin\n item.save\n rescue ActiveRecord::RecordNotUnique\n item.errors.add :base, :not_unique, message:\n \"An item with the name \\\"#{item.name}\\\" already exists \" +\n \"(in the category \\\"#{Item.find_by(name: item.name).category.name}\\\")\"\n end\n\n return item.errors.empty?\n end",
"def update\n item = current_user.item_infos(params[:id])\n item.assign_attributes(params[:item])\n response = current_user.update_item(item)\n unless response.is_a? StandardError\n redirect_to items_path, notice: \"Item mis a jour\"\n else\n redirect_to edit_item_path(item), alert: response.message\n end\n end",
"def inventory_item_is_available\n \tif self.inventory_item.present? && self.inventory_item.is_available?(project.rental_delivery, project.rental_pickup) == false\n \t\terrors.add(:inventory_item, \"is not available within this project's duration\")\n \telsif self.inventory_item.blank?\n \t\tself.inventory_item = inventory_style.find_available(project.rental_delivery, project.rental_pickup)\n \t\terrors.add(:inventory_style, \"has no available items within this project's duration\") if self.inventory_item.blank?\n \tend\n end",
"def switch_item\n if [email protected]_answers\n @question.items.each do |f|\n if f.ok\n f.ok = false\n f.save\n end\n end\n @item.ok = true\n else\n @item.ok = [email protected]\n end\n @item.save\n redirect_to question_manage_items_path(@question)\n end",
"def update\n if @item.update(item_params)\n redirect_to @item, notice: 'Item was successfully updated.'\n else\n render :edit\n end\n end",
"def consume_item(item)\n if item.is_a?(RPG::Item) and item.consumable\n lose_item(item, 1)\n end\n end",
"def unequip_item\n\t\tself.equiped = false\n\t\tself.save\n\tend",
"def update\n @item = Item.find(params[:id])\n\n if @item.user.id == current_user.id && @item.update(items_params)\n redirect_to item_path(@item)\n else\n render :edit\n end\n end",
"def equip_item(item)\n\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n\n # Checks for Equippable without importing the file.\n if (defined? actual_item.equip)\n actual_item.equip(self)\n\n # Equipping the item will always remove it from the entity's inventory.\n remove_item(actual_item)\n else\n print \"#{actual_item.name} cannot be equipped!\\n\\n\"\n end\n else\n print NO_SUCH_ITEM_ERROR\n end\n end",
"def update\n \n @quantity_diference = params[:ordered_item][:quantity_new].to_i - params[:old_quantity].to_i\n \n @item = Item.find(@ordered_item.item_id)\n if @item.quantity - @quantity_diference > 0\n @ordered_items = OrderedItem.all\n \n if @ordered_item.update(quantity: @ordered_item.quantity + @quantity_diference) && @item.update(quantity: @item.quantity - @quantity_diference)\n flash[:notice] = \"Item quantity has been updated.\"\n redirect_to items_path\n else\n flash[:alert] = \"Something went wrong! Item quantity has not been changed.\"\n redirect_to ordered_items_path\n end\n \n else\n flash[:alert] = \"Item is not available\"\n redirect_to items_path\n end\n end",
"def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end",
"def buy_item (item, character)\n \n if item.inventory == nil \n if character.gold >= item.cost\n item_transaction(item, character)\n \"you bought #{item.name}!\"\n else\n \"you don't have enough money\"\n end\n else\n \"Your character already has this item in their invetory\"\n end\n end",
"def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end",
"def use_item_nontarget\n Sound.play_use_item\n $game_party.consume_item(@item)\n @item_window.draw_item(@item_window.index)\n @target_window.window_update($game_party.members)\n if $game_party.all_dead?\n $scene = Scene_Gameover.new\n elsif @item.common_event_id > 0\n $game_temp.common_event_id = @item.common_event_id\n $scene = Scene_Map.new\n end\n end",
"def use_item_nontarget\n Sound.play_use_item\n $game_party.consume_item(@item)\n @item_window.draw_item(@item_window.index)\n @target_window.window_update($game_party.members)\n if $game_party.all_dead?\n $scene = Scene_Gameover.new\n elsif @item.common_event_id > 0\n $game_temp.common_event_id = @item.common_event_id\n $scene = Scene_Map.new\n end\n end",
"def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end",
"def remove_item(item)\n if !@item\n log(\"Nothing is equipped in that EquipSlot.\")\n return\n end\n if @item != item\n log(\"Item being removed from EquipSlot is not the same as already equipped item.\")\n return\n end\n @item = nil if @item == item\n return\n end",
"def item_usable?\n return false unless @item\n return @actor ? @actor.usable?(@item) : $game_player.usable?(@item)\n end",
"def update\n @item = Item.find(params[:id])\n already_complete = @item.completed\n respond_to do |format|\n if @item.update_attributes(params[:item])\n just_completed = @item.completed && !already_complete \n if (just_completed && @item.reschedule)\n new = Item.new()\n [email protected]\n new.completed=false\n [email protected]\n new.save!\n end\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(items_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_item_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n return_scene\n elsif Input.trigger?(Input::C)\n @item = @item_window.item\n if @item != nil\n $game_party.last_item_id = @item.id\n end\n if $game_party.item_can_use?(@item)\n Sound.play_decision\n determine_item\n else\n Sound.play_buzzer\n end\n elsif Input.repeat?(Input::DOWN) || Input.repeat?(Input::UP) ||\n Input.repeat?(Input::LEFT) || Input.repeat?(Input::RIGHT)\n update_detail_window(@item_window.selected_item)\n elsif (Input.repeat?(Input::Y) || Input.repeat?(Input::Z))\n update_dataview_select(Input.press?(Input::Z), \n Input.trigger?(Input::Y) || Input.trigger?(Input::Z))\n @item_window.window_update($game_party.items, @dataviews_window.selected_view)\n @item_window.index = 0\n update_detail_window(@item_window.selected_item)\n end\n end",
"def update_item_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n return_scene\n elsif Input.trigger?(Input::C)\n @item = @item_window.item\n if @item != nil\n $game_party.last_item_id = @item.id\n end\n if $game_party.item_can_use?(@item)\n Sound.play_decision\n determine_item\n else\n Sound.play_buzzer\n end\n elsif Input.repeat?(Input::DOWN) || Input.repeat?(Input::UP) ||\n Input.repeat?(Input::LEFT) || Input.repeat?(Input::RIGHT)\n update_detail_window(@item_window.selected_item)\n elsif (Input.repeat?(Input::Y) || Input.repeat?(Input::Z))\n update_dataview_select(Input.press?(Input::Z), \n Input.trigger?(Input::Y) || Input.trigger?(Input::Z))\n @item_window.window_update($game_party.items, @dataviews_window.selected_view)\n @item_window.index = 0\n update_detail_window(@item_window.selected_item)\n end\n end",
"def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n temp = UI_MSG::ITEM\n UI_MSG.const_set(:ITEM, false)\n $game_party.gain_item(old_item, 1)\n $game_party.lose_item(new_item, 1)\n UI_MSG.const_set(:ITEM, temp)\n return true\n end",
"def update_phase3_item_select\n # Make item window visible\n @item_window.visible = true\n # Update item window\n @item_window.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End item selection\n end_item_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the item window\n @item = @item_window.item\n # If it can't be used\n unless $game_party.item_can_use?(@item.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.item_id = @item.id\n # Make item window invisible\n @item_window.visible = false\n # If effect scope is single enemy\n if @item.scope == 1\n # Start enemy selection\n start_enemy_select\n # If effect scope is single ally\n elsif @item.scope == 3 or @item.scope == 5\n # Start actor selection\n start_actor_select\n # If effect scope is not single\n else\n # End item selection\n end_item_select\n # Go to command input for next actor\n phase3_next_actor\n end\n return\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n itemid = @item.id\n @cartitems = CartItem.where(\"item_id = #{itemid}\")\n @cartitems.each do |cartitem|\n cartitem.available = @item.quantity\n cartitem.save\n end\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def offer_an_item(item)\r\n item.status = true\r\n end",
"def item_ok?\n return true if MAP_ITEM_ID == 0\n $game_party.has_item?($data_items[MAP_ITEM_ID])\n end",
"def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end",
"def update\n item = Item.find(params[:id])\n if item.user == current_user\n if item.update(item_params)\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n else\n render json: {errors: \"you can't do it\"}, status: :unprocessable_entity\n end\n end",
"def attach_item(item)\r\n equal_item = self.check_for_equal_item(item.name,item.price,item.description)\r\n if equal_item == nil\r\n self.items << item\r\n item.owner = self\r\n item.deactivate\r\n else\r\n equal_item.quantity += item.quantity\r\n equal_item.deactivate\r\n item.delete\r\n end\r\n end",
"def use(item_name)\n # TODO: figure out how to pass around entire item object to access effects anywhere\n if @player.has_item(item_name) && current_room.npc && current_room.npc.has_item(item_name)\n effect = current_room.npc.inventory.select { |i| i.name == item_name }.first.effects\n puts effect\n @player.remove_from_inventory(item_name)\n # TODO: eventually remove from NPC inventory & change ownership of item\n elsif @player.has_item(item_name) && current_room.has_item(item_name)\n effect = current_room.items.find { |i| i.name == item_name }.effects\n puts effect\n @player.remove_from_inventory(item_name)\n # TODO: eventually remove from Room inventory & change ownership of item\n else\n puts \"Sorry, that item is not in your inventory. Did you pick it up or try taking it from someone?\"\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item ' + @item.name + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_transaction(item, character)\n \n case item.class.name\n\n when \"Weapon\"\n item.inventory = character.inventory\n character.inventory.weapons << item\n when \"Armor\"\n item.inventory = character.inventory\n character.inventory.armors << item\n when \"Potion\"\n item.character = character\n character.potions << item\n else\n \"Error\"\n end\n character.update(:gold => (character.gold - item.cost))\n end",
"def update\n respond_to do |format|\n @list = @item.auction.items.all\n temp = Item.new(item_params)\n item = Item.find_by seq: @item.seq, id: @item.id #Item sequence was changed and collides\n # logger.info {\">>>>>item #{item.id} #{item.seq} temp #{temp.seq} <<<<\"}\n @list.each do |l|\n # logger.info {\">>>>> #{item.seq} #{temp.seq} <<<<\"}\n if item.seq > temp.seq # dir = up\n if ((l.seq < item.seq) && (l.seq >= temp.seq)) \n l.seq += 1 \n l.save\n end\n else # dir = down\n if ((l.seq > item.seq) && (l.seq <= temp.seq)) \n l.seq -= 1 \n l.save\n end\n end\n end\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item.update!(item_params)\n end",
"def shipped\n corresponding_item = self.item.take\n current_inventory = corresponding_item.inventory_level\n corresponding_item.update_attribute(:inventory_level, (self.quantity + current_inventory)) unless previous.nil?\n self.update_attribute(:shipped_on, date.current.to_date)\n\n def item_exists_and_active?\n all_active_items = Item.active.all.map(&:id)\n if all_active_items.include?(self.item_id)\n return true\n end\n errors.add(:item_id, \"is not an active item at the chess store\")\n return false\n end\n\n def subtotal(date = nil)\n end\n\n def valid_quantity?\n if self.quantity >= 0\n return true\n end\n stock_quantity = self.item.inventory_level\n if (self.quantity* -1) > stock_quantity\n errors.add(:quantity, \"too much purchase quantity\")\n return false\n end\n return true\n end\nend",
"def fix_items\n valid_items = EquipmentModel.where(id: items.keys).collect(&:id)\n self.items = items.select { |em, _count| valid_items.include? em }\n end",
"def update_equip_window\n return if @equip_window.nil?\n @equip_window.set_item(item)\n end",
"def update_item_stats(item)\n @status_window.window_item_update(item)\n \n if item.is_a?(RPG::Item)\n if @buy_window.active\n @buy_window.detail_window = @item_details_window\n elsif @sell_window.active\n @sell_window.detail_window = @item_details_window\n end\n #@item_details_window.window_update(item)\n else\n if @buy_window.active\n @buy_window.detail_window = @equip_details_window\n elsif @sell_window.active\n @sell_window.detail_window = @equip_details_window\n end\n #@equip_details_window.winow_update(item)\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_url, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_phase3_item_select\r\n # Make item window visible\r\n @item_window.visible = true\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End item selection\r\n end_item_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If it can't be used\r\n unless $game_party.item_can_use?(@item.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.item_id = @item.id\r\n # Make item window invisible\r\n @item_window.visible = false\r\n @item_window.active = false\r\n # If effect scope is single enemy\r\n if @item.scope == 1\r\n # Start enemy selection\r\n start_enemy_select\r\n # If effect scope is single ally\r\n elsif @item.scope == 3 or @item.scope == 5\r\n # Start actor selection\r\n start_actor_select\r\n # If effect scope is not single\r\n else\r\n # End item selection\r\n end_item_select\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n return\r\n end\r\n end",
"def update\n authorize! :edit, @item\n if @item.update(item_params)\n redirect_to @item\n else\n render 'edit'\n end\n\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item was updated successfully' }\n format.json { render :show, status: :ok, location: items_path }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def has_item?(item)\n return true if drops_item?(item)\n return true if can_steal_item?(item)\n false\n end",
"def set_item\n @item = Item.find(params[:item_id])\n end",
"def update\n redirect_nonadmin(root_url)\n @item = Item.find(params[:id])\n orig_inventory = @item.inventory\n if @item.update(item_params)\n if orig_inventory <= 0 && @item.inventory > 0 && [email protected]\n @item.subscriber_list.users.each do |user|\n UserMailer.with(user: user, item: @item).subscribe_email.deliver_now\n end\n @item.subscriber_list.users.clear\n end\n redirect_to @item\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@item.user, @item], notice: t('.notice') }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def invalid_item(node)\n false\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def take_item(command)\n if @current_room.has_item?(command) # item isn't in current room\n self.new_current_item(command)\n # Remove from room and add to backpack\n @current_room.remove_item(command)\n @player.pick_up(command)\n puts \"\\nYou have picked up a #{@current_item.name}\"\n puts @current_item.collect_description + \"\\n\\n\"\n else\n puts \"This item isn't here\\n\"\n end\n end",
"def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\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 update\n @item = @deal.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to deal_items_url(@deal), notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_item\n @item = Item.active.find(params[:id])\n end"
] | [
"0.7698581",
"0.7389902",
"0.72924334",
"0.7193974",
"0.6940228",
"0.6888836",
"0.6828286",
"0.6714838",
"0.6701786",
"0.6676836",
"0.6666414",
"0.66294634",
"0.6620903",
"0.65999854",
"0.6526522",
"0.6517986",
"0.64891446",
"0.64812785",
"0.6467987",
"0.6456754",
"0.6456328",
"0.64365685",
"0.641392",
"0.6413481",
"0.6387656",
"0.6380884",
"0.63642824",
"0.63461643",
"0.63461643",
"0.6326288",
"0.6321051",
"0.63183594",
"0.63037294",
"0.6303704",
"0.6299617",
"0.628344",
"0.6254747",
"0.6247742",
"0.6240216",
"0.6232366",
"0.6226594",
"0.6224665",
"0.62211174",
"0.62114555",
"0.62074995",
"0.6201931",
"0.6185175",
"0.6180493",
"0.6173964",
"0.6166013",
"0.6164627",
"0.61572075",
"0.6148744",
"0.61441827",
"0.6137642",
"0.6126521",
"0.61258316",
"0.61227",
"0.61227",
"0.6117116",
"0.6113751",
"0.61094964",
"0.6108263",
"0.60960096",
"0.60960096",
"0.60770094",
"0.6076044",
"0.606906",
"0.60663676",
"0.60604846",
"0.60543174",
"0.6047667",
"0.60463494",
"0.6044593",
"0.6044346",
"0.6036102",
"0.60327625",
"0.6008919",
"0.60056037",
"0.5998963",
"0.5997068",
"0.597875",
"0.5975244",
"0.597468",
"0.59736556",
"0.59707433",
"0.5969334",
"0.5969006",
"0.5964599",
"0.59619045",
"0.59602994",
"0.59538776",
"0.59536767",
"0.59536767",
"0.59536767",
"0.59536767",
"0.59536475",
"0.5950603",
"0.59480697",
"0.5931717",
"0.59314513"
] | 0.0 | -1 |
Get the rails logger. | def rails_logger
defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logger\n if !Rails.nil?\n return Rails.logger\n else\n return Logger.new( STDOUT )\n end\n end",
"def logger\n unless @logger\n if defined?(Rails) && ::Rails.logger\n @logger = ::Rails.logger\n else\n @logger = ::Logger.new(STDERR)\n end\n end\n @logger\n end",
"def rails_logger\n if defined?(::Rails)\n ::Rails.logger\n else\n nil\n end\n end",
"def logger\n unless defined? @logger\n logger = Logging.logger[self]\n @logger = Kernel.const_defined?('Rails') ? Rails.logger : logger\n end\n @logger\n end",
"def logger\n @logger ||= defined?(Rails) ? Rails.logger || Logger.new(STDERR) : Logger.new(STDERR)\n end",
"def logger\n return @logger if @logger\n if defined?(Rails)\n Rails.logger\n else\n unless @log\n require 'logger'\n @log = Logger.new(STDOUT)\n @log.level = Logger::INFO\n end\n @log\n end\n end",
"def logger\n @logger ||= Rails.logger\n end",
"def logger\n Rails.logger ||= ::Logger.new(STDOUT)\n @logger ||= Rails.logger\n end",
"def logger\n @logger ||= Rails.logger\n end",
"def logger\n @logger ||= Rails.logger\n end",
"def logger\n \n if defined?(::Rails) && ::Rails.respond_to?(:version)\n if ::Rails.version >= \"2.1\" && !::Rails.logger.nil?\n @@logger = ::Rails.logger\n end\n end\n \n # If none of the above was able to set @@logger, create a new default logger\n @@logger ||= ::Logger.new(STDOUT)\n \n return @@logger\n end",
"def logger\n return @logger ||= default_logger\n end",
"def logger\n @logger ||= (defined?(Rails) ? Rails.logger : Logger.new('monocle.log'))\n end",
"def logger\n\n return @logger\n\n end",
"def logger\n @logger ||= options[:logger] || if defined?(Rails)\n Rails.logger\n else\n default_logger\n end\n end",
"def logger\n @logger ||= options[:logger] || if defined?(Rails)\n Rails.logger\n else\n default_logger\n end\n end",
"def logger\n reset_logger! unless defined? @@logger\n @@logger\n end",
"def logger\n @logger ||= build_logger\n end",
"def logger\n @logger ||= Logging.get_logger(self)\n end",
"def logger\n @logger ||= Logger.get_logger(config.robot.log_level, config.robot.log_formatter)\n end",
"def logger\n @logger ||= Logger.get_logger(config.robot.log_level)\n end",
"def logger\n @logger ||= default_logger\n end",
"def logger\n @logger ||= defined?(Rails) ? Rails.logger : ::Logger.new($stdout)\n end",
"def logger\n RAILS_DEFAULT_LOGGER\n end",
"def logger\n @logger ||= default_logger\n end",
"def logger\n init_logger if Log4r::Logger[STANDARD_LOGGER].nil?\n Log4r::Logger[STANDARD_LOGGER]\n end",
"def logger\n @logger || default_logger\n end",
"def logger\n @logger || default_logger\n end",
"def logger\n env.logger\n end",
"def logger\n @logger ||= Logging.logger_for(self.class.name)\n end",
"def logger\n @logger ||= _new_logger\n end",
"def logger\n @logger ||= create_logger\n end",
"def logger\n @logger ||= create_logger\n end",
"def logger\n Logging.logger\n end",
"def logger\n return @logger if @logger\n\n self.logger = Logger.new($stderr)\n end",
"def logger\n Rails.logger\n end",
"def logger\n @logger ||= NilLogger.new\n end",
"def logger\n @logger ||= self.class.logger\n end",
"def logger\n @logger ||= Logger.new(self)\n end",
"def logger\n @logger ||= case environment\n when 'development'\n Logger.new(STDERR, Logger::DEBUG)\n when 'test'\n Logger.new(STDERR, Logger::WARN)\n else\n Logger.new(STDERR, Logger::INFO)\n end\n end",
"def logger\n @logger ||= configuration.logger\n end",
"def logger\n @logger\n end",
"def logger\n @logger\n end",
"def logger\n @logger ||= Logger.new(STDOUT)\n end",
"def logger\n @__logger\n end",
"def logger\n classname = (self.is_a? Module) ? self : self.class.name\n @logger ||= Loggable.logger_for(classname)\n end",
"def logger\n @logger || Rcal::Util::Loggable.default_logger\n end",
"def logger\n if request.respond_to? :logger\n request.logger\n else\n Logger.new(STDOUT)\n end\n end",
"def logger\n\t\t\t@system_lock.synchronize {\n\t\t\t\treturn @systems[0].logger unless @systems.empty?\n\t\t\t}\n\t\t\tSystem.logger\n\t\tend",
"def logger\n @logger ||= Esi.config.logger || Logger.new(Esi.config.log_target).tap do |l|\n l.level = Logger.const_get(Esi.config.log_level.upcase)\n end\n end",
"def logger\n @logger ||= Logger.new(STDOUT)\n end",
"def logger\n @logger ||= set_logger\n end",
"def get_logger; @logger; end",
"def logger\n @logger || StartupLogger.instance\n end",
"def logger\n @logger ||= ::Logger.new(STDOUT)\n end",
"def logger\n Logging.logger\n end",
"def logger\n @loggers.first\n end",
"def logger\n @_logger ||= Logger.new(self)\n end",
"def logger\n self.class.logger\n end",
"def logger\n @log\n end",
"def logger\n @log\n end",
"def logger\n self.configuration.logger\n end",
"def log\n unless self.class._slflogger\n self.class.createlogger\n end\n return self.class._slflogger\n end",
"def logger\n @logger ||= Logger.new(File.join(Rails.root, 'log', 'meta_request.log'))\n end",
"def logger\n @logger ||=\n begin\n logger = SemanticLogger::Processor.logger.clone\n logger.name = self.class.name\n logger\n end\n end",
"def _logger\n @logger ||= Log4r::Logger.new(self.class.to_s)\n end",
"def logger\n init unless @initialized\n logger = @logger\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n self.configuration.logger\n end",
"def logger\n Rails.logger\nend",
"def logger\n Rails.logger\nend",
"def logger\n @logger\n end",
"def logger\n if defined?(BOWLINE_LOGGER)\n BOWLINE_LOGGER\n else\n nil\n end\n end",
"def logger\n if @logger.nil?\n @logger = Logger::new(STDOUT)\n \n # formatter\n default = Logger::Formatter::new\n @logger.formatter = proc do |severity, datetime, progname, msg|\n progname = @targets.from\n msg = \"##{Thread.current.object_id} \" + msg \n default.call(severity, datetime, progname, msg)\n end\n end\n \n return @logger\n end",
"def logger\n Thread.current[:merb_logger] ||= Merb::Logger.new\n end",
"def logger\n @logger ||= Logger.new($stdout).tap do |log|\n log.progname = self.class.name\n end\n end",
"def logger\n @logger ||= Doing.logger\n end",
"def logger\n LOGGER\n end",
"def logger\n @logger ||= LogAdapter.new(Stevenson.new, (ENV[\"JEKYLL_LOG_LEVEL\"] || :info).to_sym)\n end",
"def log\n Logger.instance\n end",
"def logger\n initialize_logger unless @logger\n @logger\n end",
"def logger\n\t\treturn Loggability[ self ]\n\tend",
"def logger\n @_logger ||= ::Logger.new(log_file)\n end",
"def logger\n return @logger if @logger\n\n # Figure out where the output should go to.\n output = nil\n if ENV[\"MELISSADATA_LOG\"] == \"STDOUT\"\n output = STDOUT\n elsif ENV[\"MELISSADATA_LOG\"] == \"NULL\"\n output = nil\n elsif ENV[\"MELISSADATA_LOG\"]\n output = ENV[\"MELISSADATA_LOG\"]\n else\n output = nil #log_path.join(\"#{Time.now.to_i}.log\")\n end\n\n # Create the logger and custom formatter\n @logger = Logger.new(output)\n @logger.formatter = Proc.new do |severity, datetime, progname, msg|\n \"#{datetime} - #{progname} - [#{resource}] #{msg}\\n\"\n end\n\n @logger\n end",
"def logger\r\n self.class.logger\r\n end",
"def logger\n Backburner.configuration.logger\n end",
"def logger\n if @logger.nil?\n @logger = Logger.new($stdout)\n @logger.level = Logger::WARN\n @logger.formatter = proc do |severity, datetime, m_progname, msg|\n \"[#{datetime.strftime('%F %H:%M:%S')} #{severity.red}] #{msg}\\n\"\n end\n end\n @logger\n end",
"def logger\n adapter.logger if adapter\n end",
"def default_logger\n self.logger = Logger.new(STDERR)\n\n if settings.service.debug_mode || $DEBUG\n logger.level = Logger::DEBUG\n else\n logger.level = Logger::INFO\n end\n\n logger\n end",
"def default_logger\n self.logger = Logger.new(STDERR)\n\n if settings.service.debug_mode || $DEBUG\n logger.level = Logger::DEBUG\n else\n logger.level = Logger::INFO\n end\n\n logger\n end",
"def logger\n if logger = super\n return logger\n end\n\n @__utilrb_hierarchy__default_logger =\n if kind_of?(Module)\n m = self\n while m\n if m.name && !m.spacename.empty?\n parent_module =\n begin\n constant(m.spacename)\n rescue NameError\n end\n if parent_module.respond_to?(:logger)\n break\n end\n end\n\n if m.respond_to?(:superclass)\n m = m.superclass\n if m.respond_to?(:logger)\n parent_module = m\n break\n end\n else\n m = nil; break\n end\n end\n\n if !m\n raise NoParentLogger, \"cannot find a logger for #{self}\"\n end\n if parent_module.respond_to? :register_log_child\n @parent_module = parent_module\n parent_module.register_log_child(self)\n end\n parent_module.logger\n else\n self.class.logger\n end\n end",
"def log\n @logger ||= Logger.new(nil)\n @logger\n end",
"def logger(level = Logger::WARN)\n @logger ||= ::Logger.new(STDERR).tap{ |l| l.level = level }\n end",
"def logger\n return @logger if defined?(@logger) && [email protected]?\n path = log_path\n FileUtils.mkdir_p(File.dirname(path))\n prepare_logger(path)\n rescue\n prepare_logger(STDOUT)\n end",
"def get_logger\n stream = STDOUT\n if @opts[:quiet]\n stream = '/dev/null'\n end\n logger = Logger.new(stream)\n logger.level = Logger::INFO\n logger.formatter = proc do |severity, datetime, progname, msg|\n \"#{msg}\\n\"\n end\n logger\n end",
"def logger\n instance ? instance.logger : Kitchen.logger\n end",
"def logger\n instance ? instance.logger : Kitchen.logger\n end",
"def logger \n klass = self.class\n klass.logger\n end"
] | [
"0.8582375",
"0.8527005",
"0.85252905",
"0.8474324",
"0.83409715",
"0.82954866",
"0.8262594",
"0.82197416",
"0.8206335",
"0.8206335",
"0.81383276",
"0.80863273",
"0.795165",
"0.79264176",
"0.7888504",
"0.7888504",
"0.7849386",
"0.78331345",
"0.78239095",
"0.7817571",
"0.7813175",
"0.7812419",
"0.78059244",
"0.77895766",
"0.77562034",
"0.7752898",
"0.7728863",
"0.7728863",
"0.7726819",
"0.7697525",
"0.7693416",
"0.7679549",
"0.7679549",
"0.7678298",
"0.7674358",
"0.7657073",
"0.7608022",
"0.76066655",
"0.75938636",
"0.7589326",
"0.75852203",
"0.75474834",
"0.75474834",
"0.7520654",
"0.7516523",
"0.7502861",
"0.74936444",
"0.7492329",
"0.7492056",
"0.7479289",
"0.7476788",
"0.74670506",
"0.7430037",
"0.7415318",
"0.7384393",
"0.7349169",
"0.7322942",
"0.73228467",
"0.73197246",
"0.7308321",
"0.7308321",
"0.7307578",
"0.73067975",
"0.72866696",
"0.72814",
"0.7274914",
"0.72534895",
"0.72361493",
"0.72361493",
"0.72361493",
"0.72200465",
"0.7215587",
"0.7215587",
"0.7213679",
"0.71917087",
"0.7184162",
"0.7157112",
"0.715408",
"0.7147285",
"0.71431255",
"0.71277785",
"0.71171093",
"0.7112775",
"0.7101052",
"0.70994014",
"0.7091629",
"0.7089904",
"0.70752394",
"0.7072143",
"0.7070719",
"0.70688087",
"0.70688087",
"0.70661706",
"0.70625705",
"0.70520276",
"0.7050052",
"0.70493084",
"0.7046036",
"0.7046036",
"0.7044634"
] | 0.82239556 | 7 |
Get the default logger. | def default_logger
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_logger\n Logger.new(debug? ? STDOUT : nil)\n end",
"def logger\n return @logger ||= default_logger\n end",
"def logger\n @logger ||= default_logger\n end",
"def logger\n @logger ||= default_logger\n end",
"def default_logger\n Logger.new(STDOUT)\n end",
"def logger\n @logger || default_logger\n end",
"def logger\n @logger || default_logger\n end",
"def default_logger\n log = ::Logger.new(STDOUT)\n log.level = ::Logger::INFO\n log\n end",
"def logger( name )\n return default_logger if name.nil?\n @hash.fetch(name, default_logger)\n end",
"def default_logger\n self.logger = Logger.new(STDERR)\n\n if settings.service.debug_mode || $DEBUG\n logger.level = Logger::DEBUG\n else\n logger.level = Logger::INFO\n end\n\n logger\n end",
"def default_logger\n self.logger = Logger.new(STDERR)\n\n if settings.service.debug_mode || $DEBUG\n logger.level = Logger::DEBUG\n else\n logger.level = Logger::INFO\n end\n\n logger\n end",
"def init_logger \n if not Object.const_defined?(get_rails_default_logger_name)\n Logger.new(STDOUT)\n else\n eval(get_rails_default_logger_name)\n end \n end",
"def logger\n @logger ||= _new_logger\n end",
"def logger\n @logger ||= NilLogger.new\n end",
"def logger\n init_logger if Log4r::Logger[STANDARD_LOGGER].nil?\n Log4r::Logger[STANDARD_LOGGER]\n end",
"def logger\n @logger || Rcal::Util::Loggable.default_logger\n end",
"def default_logger\n logger = Logger.new(STDERR)\n logger.level = Mongoid::Config.log_level\n logger\n end",
"def logger\n @logger ||= create_logger\n end",
"def logger\n @logger ||= create_logger\n end",
"def logger\n @logger ||= build_logger\n end",
"def logger\n unless defined? @logger\n logger = Logging.logger[self]\n @logger = Kernel.const_defined?('Rails') ? Rails.logger : logger\n end\n @logger\n end",
"def logger(logger_name = :default)\n # Coerce the logger_name if needed.\n logger_name = ::Af::Application.singleton.af_name if logger_name == :default\n # Check with Log4r to see if there is a logger by this name.\n # If Log4r doesn't have a logger by this name, make one with Af defaults.\n return Log4r::Logger[logger_name] || Log4r::Logger.new(logger_name)\n end",
"def logger(name = self.class.name)\n Logger.new(name)\n end",
"def logger\n @logger ||= options[:logger] || if defined?(Rails)\n Rails.logger\n else\n default_logger\n end\n end",
"def logger\n @logger ||= options[:logger] || if defined?(Rails)\n Rails.logger\n else\n default_logger\n end\n end",
"def logger\n RAILS_DEFAULT_LOGGER\n end",
"def logger\n @logger ||= Logger.get_logger(config.robot.log_level, config.robot.log_formatter)\n end",
"def logger\n @logger || StartupLogger.instance\n end",
"def logger\n @logger ||= Esi.config.logger || Logger.new(Esi.config.log_target).tap do |l|\n l.level = Logger.const_get(Esi.config.log_level.upcase)\n end\n end",
"def logger\n if !Rails.nil?\n return Rails.logger\n else\n return Logger.new( STDOUT )\n end\n end",
"def logger\n @logger ||= set_logger\n end",
"def logger\n @logger ||= Logging.logger_for(self.class.name)\n end",
"def logger\n @logger ||= Logger.new(\"/dev/null\")\n end",
"def logger\n @logger ||= (defined?(Rails) ? Rails.logger : Logger.new('monocle.log'))\n end",
"def logger\n @logger ||= Logger.get_logger(config.robot.log_level)\n end",
"def logger\n @logger ||= configuration.logger\n end",
"def logger\n if logger = super\n return logger\n end\n\n @__utilrb_hierarchy__default_logger =\n if kind_of?(Module)\n m = self\n while m\n if m.name && !m.spacename.empty?\n parent_module =\n begin\n constant(m.spacename)\n rescue NameError\n end\n if parent_module.respond_to?(:logger)\n break\n end\n end\n\n if m.respond_to?(:superclass)\n m = m.superclass\n if m.respond_to?(:logger)\n parent_module = m\n break\n end\n else\n m = nil; break\n end\n end\n\n if !m\n raise NoParentLogger, \"cannot find a logger for #{self}\"\n end\n if parent_module.respond_to? :register_log_child\n @parent_module = parent_module\n parent_module.register_log_child(self)\n end\n parent_module.logger\n else\n self.class.logger\n end\n end",
"def logger\n @logger ||= Logging.get_logger(self)\n end",
"def logger_for(name)\n loggers[name] ||= DefaultLogger.new(name, level)\n end",
"def logger\n reset_logger! unless defined? @@logger\n @@logger\n end",
"def logger\n settings[\"logger\"] ||= Yell.new(STDERR, :level => \"gt.fatal\") # null logger\n end",
"def logger\n settings[\"logger\"] ||= Yell.new(STDERR, :level => \"gt.fatal\") # null logger\n end",
"def logger\n @logger ||= Logger.new($stdout).tap do |log|\n log.progname = self.class.name\n end\n end",
"def logger\n @logger ||= self.class.logger\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||=\n begin\n logger = SemanticLogger::Processor.logger.clone\n logger.name = self.class.name\n logger\n end\n end",
"def logger\n classname = (self.is_a? Module) ? self : self.class.name\n @logger ||= Loggable.logger_for(classname)\n end",
"def logger\n @logger ||= Rails.logger\n end",
"def logger\n @logger ||= Rails.logger\n end",
"def logger\n \n if defined?(::Rails) && ::Rails.respond_to?(:version)\n if ::Rails.version >= \"2.1\" && !::Rails.logger.nil?\n @@logger = ::Rails.logger\n end\n end\n \n # If none of the above was able to set @@logger, create a new default logger\n @@logger ||= ::Logger.new(STDOUT)\n \n return @@logger\n end",
"def logger\n @logger ||= Rails.logger\n end",
"def logger\n initialize_logger unless @logger\n @logger\n end",
"def logger\n\t\t\tunless CLILogging.class_variable_defined?(:@@logger)\n\t\t\t\t@@logger = CLILogger.new\n\t\t\t\t@@logger.progname=$0\n\t\t\tend\n\t\t\t@@logger\n\t\tend",
"def logger\n\t\t\tunless CLILogging.class_variable_defined?(:@@logger)\n\t\t\t\t@@logger = CLILogger.new\n\t\t\t\t@@logger.progname=$0\n\t\t\tend\n\t\t\t@@logger\n\t\tend",
"def logger\n return @logger if @logger\n if defined?(Rails)\n Rails.logger\n else\n unless @log\n require 'logger'\n @log = Logger.new(STDOUT)\n @log.level = Logger::INFO\n end\n @log\n end\n end",
"def get_logger\n stream = STDOUT\n if @opts[:quiet]\n stream = '/dev/null'\n end\n logger = Logger.new(stream)\n logger.level = Logger::INFO\n logger.formatter = proc do |severity, datetime, progname, msg|\n \"#{msg}\\n\"\n end\n logger\n end",
"def logger\n @loggers.first\n end",
"def logger\n\t\t\t@system_lock.synchronize {\n\t\t\t\treturn @systems[0].logger unless @systems.empty?\n\t\t\t}\n\t\t\tSystem.logger\n\t\tend",
"def logger\n @logger ||= Logger.new(STDOUT)\n end",
"def logger\n if @logger.nil?\n @logger = Logger::new(STDOUT)\n \n # formatter\n default = Logger::Formatter::new\n @logger.formatter = proc do |severity, datetime, progname, msg|\n progname = @targets.from\n msg = \"##{Thread.current.object_id} \" + msg \n default.call(severity, datetime, progname, msg)\n end\n end\n \n return @logger\n end",
"def logger\n unless @logger\n if defined?(Rails) && ::Rails.logger\n @logger = ::Rails.logger\n else\n @logger = ::Logger.new(STDERR)\n end\n end\n @logger\n end",
"def logger\n @logger ||= Doing.logger\n end",
"def logger\n @logger ||= Logger.new(STDOUT)\n end",
"def logger\n @logger ||= ::Logger.new(STDOUT)\n end",
"def logger\n @logger ||= case environment\n when 'development'\n Logger.new(STDERR, Logger::DEBUG)\n when 'test'\n Logger.new(STDERR, Logger::WARN)\n else\n Logger.new(STDERR, Logger::INFO)\n end\n end",
"def logger\n\n return @logger\n\n end",
"def logger\n @logger ||= Logger.new(self)\n end",
"def logger\n return @logger if @logger\n\n # Figure out where the output should go to.\n output = nil\n if ENV[\"MELISSADATA_LOG\"] == \"STDOUT\"\n output = STDOUT\n elsif ENV[\"MELISSADATA_LOG\"] == \"NULL\"\n output = nil\n elsif ENV[\"MELISSADATA_LOG\"]\n output = ENV[\"MELISSADATA_LOG\"]\n else\n output = nil #log_path.join(\"#{Time.now.to_i}.log\")\n end\n\n # Create the logger and custom formatter\n @logger = Logger.new(output)\n @logger.formatter = Proc.new do |severity, datetime, progname, msg|\n \"#{datetime} - #{progname} - [#{resource}] #{msg}\\n\"\n end\n\n @logger\n end",
"def logger\n @logger ||= Logger.new(@log_file_name)\n\n @logger.formatter = proc do |severity, datetime, progname, msg|\n \"%s, [%s #%d] (%s) %5s -- %s: %s\\n\" % [severity[0..0], datetime, $$, Conf.global_conf[:hostname], severity, progname, msg]\n end\n\n if Conf.global_conf[:debug]\n @logger.level = Logger::DEBUG\n else\n @logger.level = Logger::INFO\n end\n @logger\n end",
"def logger\n return @logger if defined?(@logger) && [email protected]?\n path = log_path\n FileUtils.mkdir_p(File.dirname(path))\n prepare_logger(path)\n rescue\n prepare_logger(STDOUT)\n end",
"def logger\n init unless @initialized\n logger = @logger\n end",
"def get_logger; @logger; end",
"def logger\n @logger ||= Neo4j::Config[:logger] || default_logger\n end",
"def logger\n @logger ||= Neo4j::Config[:logger] || default_logger\n end",
"def logger\n @logger ||= defined?(Rails) ? Rails.logger || Logger.new(STDERR) : Logger.new(STDERR)\n end",
"def logger\n @_logger ||= Logger.new(self)\n end",
"def logger\n @logger ||= Logger.new($stdout).tap do |log|\n log.progname = self.name\n end\n end",
"def logger\n Logging.logger\n end",
"def logger\n @logger ||= ( pool.respond_to?(:logger) ? pool.logger : nil ) rescue nil\n end",
"def logger\n if @logger.nil?\n @logger = Logger.new($stdout)\n @logger.level = Logger::WARN\n @logger.formatter = proc do |severity, datetime, m_progname, msg|\n \"[#{datetime.strftime('%F %H:%M:%S')} #{severity.red}] #{msg}\\n\"\n end\n end\n @logger\n end",
"def defaultLogger(opts=nil, parser=nil)\n if opts && parser\n #noinspection RubyArgCount\n result = Logger.new(opts[:logFile] || 'dataMetaXtra.log', 'daily', 10*1024*1024)\n result.level = case opts[:level] ? opts[:level].downcase[0] : 'i'\n when 'd'\n Logger::DEBUG\n when 'i'\n Logger::INFO\n when 'w'\n Logger::WARN\n when 'e'\n Logger::ERROR\n else\n parser.educate\n raise \"Invalid log level #{opts[:level]}\"\n end\n result.datetime_format = '%Y-%m-%d %H:%M:%S'\n result\n else\n result = Logger.new($stdout)\n result.level = Logger::WARN\n result\n end\n end",
"def logger\n Rails.logger ||= ::Logger.new(STDOUT)\n @logger ||= Rails.logger\n end",
"def log\n @logger ||= Logger.new(nil)\n @logger\n end",
"def logger\n @_logger ||= ::Logger.new(log_file)\n end",
"def logger\n return @local_logger if @local_logger\n FileUtils.mkdir_p(File.dirname(log_path)) unless File.exists?(File.dirname(log_path))\n\n if API_KEYS[\"logentries\"]\n token = API_KEYS[\"logentries\"][Rails.env][\"nsc\"]\n @local_logger = Le.new(token, :debug => false, :local => log_path, :ssl => true, :tag => true)\n else\n @local_logger = Logger.new(log_path)\n end\n @local_logger\n end",
"def logger\n @logger ||= defined?(Rails) ? Rails.logger : ::Logger.new($stdout)\n end",
"def logger\n @logger ||= LogAdapter.new(Stevenson.new, (ENV[\"JEKYLL_LOG_LEVEL\"] || :info).to_sym)\n end",
"def logger\n return @logger if @logger\n\n self.logger = Logger.new($stderr)\n end",
"def logger\n if defined?(BOWLINE_LOGGER)\n BOWLINE_LOGGER\n else\n nil\n end\n end",
"def logger(out=STDOUT)\n @@logger ||= Logger.new(out)\n @@logger\n end",
"def logger\n @logger ||= ADAL::Logger.new(Logging.log_output, Logging.correlation_id)\n @logger.level = Logging.log_level || DEFAULT_LOG_LEVEL\n @logger\n end",
"def null_logger\n NullLoggerSingleton.instance\n end",
"def default_log_path\n if @config.log_root\n File.join(@config.log_root, default_log_file_name)\n else\n nil\n end\n end",
"def logger\n @__logger\n end",
"def logger\n @logger\n end",
"def logger\n @logger\n end",
"def log\n @log ||= Logging.logger[File.basename($0)]\n end",
"def get_logger()\n # Set up logging\n log = ::Logger.new(STDOUT)\n log.level = ::Logger::INFO\n return log\nend"
] | [
"0.84414726",
"0.83610004",
"0.82711554",
"0.8249946",
"0.81388146",
"0.8112992",
"0.8112992",
"0.79669183",
"0.7891161",
"0.7767544",
"0.7767544",
"0.7712007",
"0.76754177",
"0.7641371",
"0.76356536",
"0.7630005",
"0.76122713",
"0.7607246",
"0.7607246",
"0.76035166",
"0.7528862",
"0.7496649",
"0.74890083",
"0.7437038",
"0.7437038",
"0.7423079",
"0.74013555",
"0.73669523",
"0.7365585",
"0.73048586",
"0.73006386",
"0.72940916",
"0.7274165",
"0.7263008",
"0.72622806",
"0.7251458",
"0.72078985",
"0.7202739",
"0.72008294",
"0.7190217",
"0.71882874",
"0.71882874",
"0.7184647",
"0.71810454",
"0.7149011",
"0.7149011",
"0.7149011",
"0.7140172",
"0.7119589",
"0.70958626",
"0.70958626",
"0.7089624",
"0.7085428",
"0.70795226",
"0.7071622",
"0.7071622",
"0.70698017",
"0.70677316",
"0.70676225",
"0.7048938",
"0.7038549",
"0.70360297",
"0.7031047",
"0.70286196",
"0.7016922",
"0.70069325",
"0.699519",
"0.69887877",
"0.6983734",
"0.69666827",
"0.69608605",
"0.6924175",
"0.69217324",
"0.68820983",
"0.68769217",
"0.68769217",
"0.68661356",
"0.68517196",
"0.68494475",
"0.6820031",
"0.68169",
"0.6788584",
"0.6781741",
"0.67732084",
"0.6771457",
"0.6769416",
"0.6758355",
"0.6742212",
"0.67360556",
"0.6732536",
"0.6726089",
"0.6723462",
"0.6714566",
"0.66985536",
"0.669373",
"0.66882133",
"0.667529",
"0.667529",
"0.6670357",
"0.66602814"
] | 0.79327685 | 8 |
Gets Page object that has given url. Very inefficient O(n) solution. | def get_page_from_url(url,col)
col.each do |page|
return page if page.url == url
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_page_from_url(url)\n site.pages.each do |page|\n if page.url == url then\n return page\n end\n end\n end",
"def get_page_from_url(url)\n\t(site.pages + site.posts).each do |page|\n\t\treturn page if page.url == url\n\tend\n\n\treturn nil\nend",
"def get_page_from_url(url)\n (site.pages + site.posts).each do |page|\n return page if page.url == url\n end\nend",
"def find_or_create_page_from_url\n if self.page_id.nil? and @url.present?\n self.page_id = (Page.where(url: @url).first || Page.create!(url: @url)).id\n end\n end",
"def find_page(url)\n found = Page.find_by_url(url)\n found if found #and (found.published?)\n end",
"def page_for_url(url)\n logger.debug(\"checking if this page url \" + self.url.to_s + \" == \" + url.to_s);\n if (self.url == url)\n logger.debug(\"true, match found\");\n return self\n else\n children.each do |child|\n if (url =~ Regexp.compile( '^' + Regexp.quote(child.url)))\n found = child.page_for_url(url)\n return found if found\n end\n end\n end\n return nil;\n end",
"def get_page(url)\n\t\tbegin\n\t\t if not defined? agent\n\t\t \tagent = Mechanize.new\n\t\t end\n\n\t\t return agent.get(url)\n\n\t\trescue Mechanize::ResponseCodeError => e\n\n\t\t # if page couldn't be found, throw an error\n\t\t if e.response_code == \"404\"\n\t\t \traise ArgumentError.new(\n\t\t \t\t\"#{@url} #{NOT_FOUND_ERROR}\"\n\t\t \t\t)\n\t\t else\n\t\t \tthrow\n\t\t end \n\n\t\tend\n\tend",
"def page\n return @most_recent_page if @most_recent_page && @most_recent_page.on_page?\n\n if @browser.is_a? Watir::Browser\n url = @browser.url\n elsif @browser.is_a? Selenium::WebDriver::Driver\n url = @browser.current_url\n else\n raise SiteObject::BrowserLibraryNotSupportedError, \"Unsupported browser library: #{@browser.class}\"\n end\n\n found_page = nil\n @pages.each do |p|\n if p.url_matcher && p.url_matcher =~ url\n found_page = p\n elsif p.query_arguments && p.url_template.match(url)\n found_page = p\n elsif !p.query_arguments && p.url_template.match(url.split(/(\\?|#)/)[0])\n found_page = p\n end\n\n break if found_page\n end\n\n if found_page && !found_page.required_arguments.empty?\n if hsh = found_page.url_template.extract(url)\n return found_page.new(self, found_page.url_template.extract(url))\n else\n return found_page.new(self, found_page.url_template.extract(url.split(/(\\?|#)/)[0]))\n end\n elsif found_page\n return found_page.new(self)\n else\n return nil\n end\n end",
"def fetch_page(url, from_page = nil)\n begin\n url = URI(url) unless url.is_a?(URI)\n\n if from_page\n referer = from_page.url\n depth = from_page.depth + 1\n end\n\n response, code, location, response_time = get(url, referer)\n\n aka = nil\n if !url.eql?(location)\n aka = location\n end\n\n return Page.new(url, response.body, code, response.to_hash, aka, referer, depth, response_time)\n rescue\n return Page.new(url)\n end\n end",
"def get_page(url, prog_name = self.class)\n begin\n retries ||= 0\n page = Nokogiri::HTML(URI.open(url))\n rescue OpenURI::HTTPError => e\n retry if (retries += 1) < MAX_RETRIES\n logger.error(prog_name) { \"Could not load page '#{url}': #{e.message}\" }\n raise $!\n end\n page\n end",
"def get_page(url)\n @doc = Nokogiri::HTML(open(url))\n end",
"def get_page(url)\n @log.info(\"Loading page: #{url}\")\n try_three_times do\n page = @agent.get(url)\n page.encoding = 'utf-8' if page.is_a?(Mechanize::Page)\n return page\n end\n end",
"def page\n @page_object ||= Page.find(self.page_id)\n rescue\n nil\n end",
"def page_for_url(url)\n @mechanize_instance.get(url)\n end",
"def obj_by_url(url)\n begin\n u = URI.parse(url)\n rescue URI::InvalidURIError\n return nil\n end\n\n if match = CONTENT_MATCHES.find { |k,_| u.path =~ k }\n # build the obj_key\n key = match[1].constantize.obj_key($~[1])\n article = Outpost.obj_by_key(key)\n article && article.published? ? article : nil\n else\n nil\n end\n end",
"def find_by_url(url)\n find_by(url: convert_url(url))\n end",
"def get_page_by_path(page_path, output = :OBJECT, post_type = 'page')\n slugs = page_path.split('/')\n ancestors = []\n p_class = Railspress::WpPost.find_sti_class(post_type)\n page = nil\n begin\n post_parent = 0\n slugs.each do |slug|\n begin\n page = p_class.where(post_name: slug, post_parent: post_parent).first!\n post_parent = page.id\n ancestors << page\n rescue ActiveRecord::RecordNotFound\n page = nil\n break\n end\n end\n rescue ActiveRecord::RecordNotFound\n page = if slugs.size == 1 # retry without considering the parent\n p_class.where(post_name: params[:slug]).first\n else\n nil\n end\n end\n page\n end",
"def get_page()\n @page = Nokogiri::HTML(open(@url).read)\n end",
"def retrieve_page(url)\n begin \n page = Timeout::timeout(5) {$agent.get(url)}\n if page.is_a?(Mechanize::Page)\n return page\n else\n return nil\n end\n rescue\n return nil\n end\nend",
"def load_page\n @page ||= @mechanize.get(url)\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n DomainPage.new(@version, response, @solution)\n end",
"def set_page\n @page = Page.find_by_url(params[:url])\n end",
"def get_page(uri, conditions, use_curl = true)\n uri = uri.to_s\n \n uri = URI::join(self.source, uri) if !uri.include?(self.source)\n\n html = get_html(uri)\n\n if self.cached\n # Caching html parsing to not repeat same operations\n # with same html\n hash = Digest::SHA1.hexdigest(html + conditions.sort.to_s)\n return @cache[hash] ||= parse_html(html, conditions)\n else\n return parse_html(html, conditions)\n end\n end",
"def get_page(query)\n\t# FOR OFFLINE DEVELOPMENT\n\t# uri = BASE_URL + query + \".html\"\n\t# page = Nokogiri::HTML(open(uri))\n\t\n\turi = BASE_URL + query\n\tpage = Nokogiri::HTML(open(uri).read)\n\treturn page\nend",
"def find(page)\n Page.find(page)\n end",
"def getObjectFromUrl(url,type=nil)\n method = 'getObjectFromUrl'\n type = BaseObj if not type\n args = {:url=>url}\n return_object type,method,args,true\n end",
"def page(slug_id)\n\t\treturn self.pages.where(:slug => slug_id).first\n\tend",
"def find_page(title, options = {})\n @page_found_with_redirect = false\n title = start_page if title.blank?\n title = Wiki.titleize(title)\n page = pages.find_by(\"LOWER(title) = LOWER(?)\", title)\n if page.nil? && options[:with_redirect] != false\n # search for a redirect\n redirect = redirects.where(\"LOWER(title) = LOWER(?)\", title).first\n if redirect\n page = redirect.target_page\n @page_found_with_redirect = true\n end\n end\n page\n end",
"def page\n @page ||= retrieve_page\n end",
"def page\n @page ||= retrieve_page\n end",
"def get_page(url)\n Hpricot.buffer_size = 262144\n Hpricot(open(url, {\"User-Agent\" => \"Mozilla/5.0 Firefox/3.5\"}))\n end",
"def visit_page(url)\n logger.info { \"visit #{url}\" }\n WebPage.new(url, web[url.to_s])\n end",
"def find_nearest_page_matching(url, regex)\n raise ArgumentError,\n 'No crawl found. Set @crawl as the first thing in your Anemone.crawl block' if crawl.nil?\n\n page = @crawl.pages[url]\n return page if page.nil? || page.url.to_s =~ regex\n\n find_nearest_page_matching(page.referer, regex)\n end",
"def get_webpage(url)\n uri = URI.parse(url)\n Net::HTTP.get_response(uri)\nend",
"def get_page\n begin\n puts \"@@@@@@@@@@@@@ Visiting: #{@url} from #{@parent_page.address if @parent_page.present?}\"\n require 'nokogiri'\n require 'open-uri'\n @page = Nokogiri::HTML(open(@url))\n @page_title = (title_container = @page.css('title').first) ? title_container.content : \"Title unknown\"\n @links = @page.css(\"a\")\n\n return true\n rescue => exc\n puts \"==Problem with URL #{@url} == #{ exc.message}\"\n return false\n end\n end",
"def find_nearest_page_matching(url, regex)\n raise ArgumentError,\n 'No crawl found. Set @crawl as the first thing in your Anemone.crawl block' if crawl.nil?\n\n page = @crawl.pages[url]\n return page if page.nil? || page.url.to_s =~ regex\n\n find_nearest_page_matching(page.referer, regex)\n end",
"def url\n self.page.try(:url) || @url\n end",
"def set_page\n @page = if params[:url].present?\n Page.find_by_url params[:url]\n else\n Page.find(params[:id]) if params[:id].present?\n end\n end",
"def get(page)\n case page\n when Model\n page\n when String\n new site.get page\n when Sitepress::Resource\n new page\n else\n raise ModelNotFoundError, \"#{self.inspect} could not find #{page.inspect}\"\n end\n end",
"def retrieve_page(rurl = nil)\n durl = rurl || url\n return nil unless durl\n durl = filter_url(durl) if self.respond_to?(:filter_url)\n self.class.retrieve_session ||= WebPageParser::HTTP::Session.new\n self.class.retrieve_session.get(durl)\n end",
"def set_page\n @page = Page.find_by(url: params[:url])\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n CompositionPage.new(@version, response, @solution)\n end",
"def load_page\n page_not_found! unless Language.current\n\n @page ||= Language.current.pages.contentpages.find_by(\n urlname: params[:urlname],\n language_code: params[:locale] || Language.current.code\n )\n end",
"def crawlPage pageURL\n agent = Mechanize.new\n page = agent.get pageURL\n return page\nend",
"def find_page(title, version = nil, load_content: true)\n page_title, page_dir = page_title_and_dir(title)\n\n if page = wiki.page(title: page_title, version: version, dir: page_dir, load_content: load_content)\n WikiPage.new(self, page)\n end\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n CampaignPage.new(@version, response, @solution)\n end",
"def get_page_source(page_url)\n url = URI.parse(page_url)\n req = Net::HTTP::Get.new(url.path)\n Net::HTTP.start(url.host, url.port) do |http|\n http.request(req)\n end\nend",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n CallPage.new(@version, response, @solution)\n end",
"def url\n page && \"/#{page.urlname}\" || read_attribute(:url).presence\n end",
"def find_or_new_page(title)\n title = start_page if title.blank?\n find_page(title) || WikiPage.new(:wiki => self, :title => Wiki.titleize(title))\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n CallPage.new(@version, response, @solution)\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n TaskPage.new(@version, response, @solution)\n end",
"def fetch_page(url, options = {}, &block)\n return if url.to_s.strip.empty?\n\n options = ThreatDetector::DEFAULT_CURL_OPTIONS.merge(options)\n @page = Curl::Easy.perform(url.to_s) do |req|\n options.each do |key, val|\n req.send(\"#{key}=\", val)\n end\n\n block&.call(req)\n end\n end",
"def find_by_uri_or_empty(uri)\n find_by_uri(uri) or Page.new(uri, '')\n end",
"def find_by_title(*opts)\n find_by_titles(opts).pages.first\n end",
"def get\n page = Page.where(url: @url).first\n\n # if not crawled page, crawl it\n unless page\n uri = URI(@url)\n client = self.client(\"#{uri.scheme}://#{uri.host}\")\n\n begin\n response = client.get(uri.request_uri)\n raise unless response.success?\n rescue\n Page.create(url: @url, is_exist: false, extracted_at: Time.now)\n return render json: { message: \"Invalid Url\" }, status: :bad_request\n end\n\n page = Page.create(url: @url, is_exist: true, extracted_at: Time.now)\n extracted_ids = self.extract_ids(response.body)\n\n # crawl youtube video titles if not have complete them\n exist_videos = Video.where(youtube_id: extracted_ids)\n exist_video_ids = exist_videos.map(&:id)\n unexist_ids = extracted_ids.reject{|id| exist_video_ids.include?(id) }\n unexist_videos = unexist_ids.map {|id| crawl_youtube_video(id) }\n # XXX why cannot work????\n # unexist_videos = Parallel.map(unexist_ids) do |id|\n # ActiveRecord::Base.connection_pool.with_connection do\n # crawl_youtube_video(id)\n # end\n # end\n page.add_videos!(exist_videos + unexist_videos)\n end\n\n if page.exist?\n @videos = page.valid_videos\n @message = \"Cannot find any available videos\" if @videos.empty?\n else\n return render json: { message: \"Invalid Url\" }, status: :bad_request\n end\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n TaskPage.new(@version, response, @solution)\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n ServicePage.new(@version, response, @solution)\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n ServicePage.new(@version, response, @solution)\n end",
"def get_page(site,page)\n page.blank? ? Page.find_by_slug_and_site_id(Page::INDEX, site.id, :include => { :parts => :part_type }) : Page.find_by_slug_and_site_id(page, site.id, :include => { :parts => :part_type} )\n end",
"def page_post\n Post.find_by_permalink(params[:id])\n end",
"def page\n get_page\n nil\n end",
"def set_page\n @page = Page.find_or_create(params[:page_url])\n # Does this page exist? If not, raise 404 error.\n raise ActiveRecord::RecordNotFound unless @page\n end",
"def get_page(page_number)\n # Find URI that we can work with, if we cannot get the first or the\n # last page URI then there is only one page.\n page_uri = first_page_uri || last_page_uri\n return nil unless page_uri\n\n perform_request(page_uri, page_number)\n end",
"def get_page(url_to_scrap)\n # Ouvre l'URL souhaitée \"url_to_scrap\" sous Nokogiri et la stocke dans l'objet \"page\" qui est retourné si l'URL a pu être trouvée\n # renvoie nil sinon\n page = nil\n if !url_to_scrap.nil? && url_to_scrap.instance_of?(String) && !url_to_scrap.strip.empty?\n puts \"L'URL qui vous intéresse est : \\\"#{url_to_scrap}\\\".\"\n begin\n page = Nokogiri::HTML(URI.open(url_to_scrap))\n rescue OpenURI::HTTPError => e\n if e.message == '404 Not Found'\n puts \"Malheureusement, la page \\\"#{url_to_scrap}\\\" n'a pas été trouvée.\" # handle 404 error\n else\n raise e\n end\n rescue Errno::ENOENT => e\n puts \"Malheureusement, le fichier \\\"#{url_to_scrap}\\\" n'a pas été trouvé.\" # handle \"No such file or directory @ rb_sysopen\" error\n rescue SocketError => e # handle \"Failed to open TCP connection to ... (getaddrinfo: Name or service not known)\" error\n puts \"Malheureusement, l'URL \\\"#{url_to_scrap}\\\" est incorrecte.\" # Le domaine peut ne pas exister (DNS error)\n rescue Errno::ECONNREFUSED => e\n puts \"Malheureusement, il n'y a aucun serveur en cours d'exécution sur l'adresse IP à laquelle vous voulez vous connecter.\"\n end\n end\n page\nend",
"def find_page(title)\n title = normalize_title(title)\n \n store[title + '.md'] or Page.new(:title => title)\n end",
"def fetchPage(url)\n Nokogiri::HTML(open(url, 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19').read, nil, 'utf-8')\n end",
"def show\n @page = Page.find_by!(permalink: params[:id])\n rescue\n # This is a hack. Do not use exception handling to handle application logic. \n @page = Page.find(params[:id])\n end",
"def page\n\t\t@visited_pages = []\n\t\tlogger.debug \"retreiving page for #{name}\"\n\t\tfind_page(name, false)\n\tend",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n ApplicationPage.new(@version, response, @solution)\n end",
"def url_obj (url)\n url_1 = HTTParty.get(url)\n return Nokogiri::HTML(url_1)\nend",
"def retrieve_page\n return nil unless url\n spurl = url.gsub(/^http:/, \"https:\")\n spurl << (spurl.include?(\"?\") ? \"&\" : \"?\")\n spurl << \"pagewanted=all\"\n p = super(spurl)\n\n # If it fails, reset the session and try one more time\n unless retreive_successful?(p)\n self.class.retrieve_session ||= WebPageParser::HTTP::Session.new\n p = super(spurl)\n end\n if retreive_successful?(p)\n p\n else\n raise RetrieveError, \"Blocked by NYT paywall\"\n end\n end",
"def get_page_html(url)\n begin\n Nokogiri::HTML(open(url))\n rescue\n puts \"Can't reach the server.\"\n exit 1\n end\n end",
"def get_page(name, version='master')\n IO.read(page_path(name, version)) if cache_hit?(name, version)\n end",
"def expect_page(page_arg)\n p = page\n\n if p\n if p.class.name == page_arg.class.name # Do this if it looks like an instance of a page.\n return p\n elsif p.class == page_arg # Do this if it looks like a page class name.\n return p\n elsif page_arg.is_a?(Symbol) && p.class.name.underscore.to_sym == page_arg\n return p\n else\n raise SiteObject::WrongPageError, \"Expected #{page_arg} page to be displayed but the URL doesn't look right. \\n\\n#{caller.join(\"\\n\")}\"\n end\n else\n raise SiteObject::WrongPageError, \"Expected #{page_arg} page to be displayed but the URL doesn't appear to match the URL template of any known page. \\n\\n#{caller.join(\"\\n\")}\"\n end\n end",
"def find_page_by_title(title: nil, space_key: nil)\n parameters = {\n title: title,\n spaceKey: space_key,\n expand: 'ancestors,version'\n }\n target_url = @base_url + \"/content\"\n\n resp = Typhoeus.get(target_url, params: parameters, userpwd: \"#{@user}:#{@pass}\")\n\n if resp.response_code == 401\n puts \"Unauthenticated. User or password was incorrect?\"\n hsh = Hash.new\n else\n hsh = JSON.parse(resp.response_body)\n end\n\n # Return a page hash or empty hash\n hsh['results']&.first || Hash.new\n end",
"def get_page(id)\n uri = URI.parse(\"#{BaseURI}#{id}\")\n\n Nokogiri::HTML(open(uri))\nend",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n CompositionHookPage.new(@version, response, @solution)\n end",
"def show\n @page = Page.find(params[:page_id])\n # @url = Url.find(params[:id]) # set_url\n end",
"def create\n url = params['url']\n doc = Crawl::PageHandler.fetch_page(url)\n page_data = Crawl::PageHandler.parse_page(url, doc)\n page = Page.create(url: url,\n chksum: Zlib.crc32(url),\n parsed: page_data.to_json)\n render json: { url: page[:url],\n chksum: page[:chksum],\n parsed: page[:parsed] }\n end",
"def url; (page.url rescue ''); end",
"def url; (page.url rescue ''); end",
"def url\n page&.url_path || read_attribute(:url).presence\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n ChannelPage.new(@version, response, @solution)\n end",
"def unique_page_object(key, container)\n unique_page_class(key).new(container)\nend",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n SimPage.new(@version, response, @solution)\n end",
"def test_that_find_by_url_finds_us_when_nothing_else_matches\n assert_equal @page, @root.find_by_url(\"a/page\")\n end",
"def get_page(url)\n # If Nokogiri can't get the url stop the execution\n # and return a message to client\n begin\n Nokogiri::HTML(open(params[:url]))\n rescue => exception\n return render json: {errors: exception.message}, status: 422\n end\n end",
"def page\n obj\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n RoomPage.new(@version, response, @solution)\n end",
"def find(url)\n @database.get(url) rescue nil\n end",
"def get_page(id)\n @client.raw('get', \"/content/pages/#{id}\")\n end",
"def fetch_page\n Varnisher.log.info \"Looking for external resources on #{@url}...\"\n\n begin\n @html = Net::HTTP.get_response(@uri).body\n rescue\n Varnisher.log.info \"Hmm, I couldn't fetch that URL. Sure it's right?\\n\"\n return\n end\n end",
"def page_path_from_url(url)\n ::URI.parse(url).request_uri\n end",
"def get_page(priority)\n sitemap.resources.select { |resource| resource.data.type == 'page' and get_page_priority(resource.data) == priority }\n end",
"def add_page(url)\n unless robot_txt_allowed?(url)\n @scanned_pages << url\n return nil\n end\n page = Page.new(url)\n @pages << page\n @scanned_pages << url\n end",
"def main_page\n find_by(url: 'http://class.rambler.ru/')\n end",
"def page\n @page ||= Page.new(browser)\n end",
"def get_page(target_url)\n response = @version.domain.request(\n 'GET',\n target_url\n )\n MediaProcessorPage.new(@version, response, @solution)\n end",
"def page_url(page, obj = nil)\n url = case page\n when 'home' then '/'\n when 'featured events' then '#/featured'\n when 'browse all events' then '#/browse/events'\n when 'browse all places' then '#/browse/places'\n when 'browse publishers' then '#/fun'\n when 'my redrover' then '/my'\n when 'settings' then '#/settings'\n else raise \"Unknown page_url: #{page}\"\n end\nend"
] | [
"0.8597803",
"0.8333806",
"0.8118418",
"0.73395467",
"0.7280933",
"0.72130805",
"0.6951641",
"0.69040656",
"0.6886852",
"0.6777563",
"0.6535708",
"0.65314656",
"0.6522608",
"0.64791226",
"0.63877803",
"0.63153005",
"0.6297834",
"0.62097734",
"0.6172128",
"0.6127341",
"0.61022174",
"0.60859275",
"0.6080943",
"0.60794204",
"0.6065653",
"0.6060103",
"0.60554606",
"0.6039661",
"0.60305107",
"0.60305107",
"0.6017802",
"0.5997219",
"0.5992768",
"0.59850734",
"0.597997",
"0.59770226",
"0.596306",
"0.5961949",
"0.5929413",
"0.5929171",
"0.5927575",
"0.5925597",
"0.5901856",
"0.5892783",
"0.58613706",
"0.5858948",
"0.58570325",
"0.5852454",
"0.58524173",
"0.5846342",
"0.58424085",
"0.5839173",
"0.58252084",
"0.58113897",
"0.58063334",
"0.5805663",
"0.58013713",
"0.5796523",
"0.5796523",
"0.5796102",
"0.57913345",
"0.57892454",
"0.57863814",
"0.5770559",
"0.57638",
"0.57589656",
"0.57492346",
"0.57344157",
"0.57306844",
"0.5692152",
"0.568215",
"0.56680185",
"0.5655166",
"0.56515783",
"0.5649911",
"0.56469446",
"0.5645108",
"0.5637638",
"0.56293887",
"0.5621583",
"0.5618177",
"0.5618177",
"0.56066",
"0.5604192",
"0.55981195",
"0.5593145",
"0.5576546",
"0.5575429",
"0.5569207",
"0.5564077",
"0.55551517",
"0.55537766",
"0.5549044",
"0.55459106",
"0.5504882",
"0.55017895",
"0.54990494",
"0.54855937",
"0.5481617",
"0.54807776"
] | 0.7226216 | 5 |
Gets Page object that has given path. Very inefficient O(n) solution. | def get_pages_from_path(path,col)
a = []
col.each do |page|
if page.data['title']
pt = page.url.split("/")
fl=pt[-1]
if pt[0..-2].join("/") == path and fl != "index.html"
a << page
elsif pt[0..-3].join("/") == path and fl=="index.html"
a << page
end
end
end
return a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_page_by_path(page_path, output = :OBJECT, post_type = 'page')\n slugs = page_path.split('/')\n ancestors = []\n p_class = Railspress::WpPost.find_sti_class(post_type)\n page = nil\n begin\n post_parent = 0\n slugs.each do |slug|\n begin\n page = p_class.where(post_name: slug, post_parent: post_parent).first!\n post_parent = page.id\n ancestors << page\n rescue ActiveRecord::RecordNotFound\n page = nil\n break\n end\n end\n rescue ActiveRecord::RecordNotFound\n page = if slugs.size == 1 # retry without considering the parent\n p_class.where(post_name: params[:slug]).first\n else\n nil\n end\n end\n page\n end",
"def find_by_path(path)\n Pages::Finder.by_path(path)\n end",
"def page(path)\n path = normalize_path(path)\n @pages[path]\n end",
"def find(path)\n path = full_path(path)\n page_blob = find_blob(path)\n raise MissingResource unless page_blob\n new(page_blob, path)\n end",
"def get(path)\n path = Pathname.new(path)\n @bags.lazy.map { |bag| bag.get(path, do_raise: false) }.find { |page| page }\n end",
"def find_or_create(path)\n path = full_path(path)\n if page_blob = find_blob(path)\n new(page_blob, path)\n else\n new(create_blob_for(path), path)\n end\n end",
"def find_by_path_or_id!(path, id)\n page = find_by_path_or_id(path, id)\n\n raise ::ActiveRecord::RecordNotFound unless page\n\n page\n end",
"def find_object(path)\n path_array = path.split(/\\//)\n n = CGI::unescape(path_array.shift)\n #puts \"looking for #{n} #{path} #{path_array.inspect}\"\n \n children.each do |c|\n # look for an object with named by n\n if c.name == n\n return c if path_array.empty?\n return c.find_object(path_array.join('/'))\n end\n end\n return nil\n end",
"def find_by_path_or_id(path, id)\n Pages::Finder.by_path_or_id(path, id)\n end",
"def find(page)\n Page.find(page)\n end",
"def find\n path = clean_content_pathname.join(page_id.tr(\"\\\\\", \"/\")).cleanpath.to_s\n if !path.start_with?(\"#{clean_content_pathname}/\")\n raise InvalidPageIdError.new \"Invalid page id: #{page_id}\"\n end\n path\n rescue ArgumentError\n raise InvalidPageIdError.new \"Invalid page id: #{page_id}\"\n end",
"def object_for(path)\n # We do the traversal so that the user does not need to.\n path.split(\"/\").inject(self) {|tree, name|\n tree.objects.find {|obj| obj.name == name }\n }\n end",
"def page\n return @most_recent_page if @most_recent_page && @most_recent_page.on_page?\n\n if @browser.is_a? Watir::Browser\n url = @browser.url\n elsif @browser.is_a? Selenium::WebDriver::Driver\n url = @browser.current_url\n else\n raise SiteObject::BrowserLibraryNotSupportedError, \"Unsupported browser library: #{@browser.class}\"\n end\n\n found_page = nil\n @pages.each do |p|\n if p.url_matcher && p.url_matcher =~ url\n found_page = p\n elsif p.query_arguments && p.url_template.match(url)\n found_page = p\n elsif !p.query_arguments && p.url_template.match(url.split(/(\\?|#)/)[0])\n found_page = p\n end\n\n break if found_page\n end\n\n if found_page && !found_page.required_arguments.empty?\n if hsh = found_page.url_template.extract(url)\n return found_page.new(self, found_page.url_template.extract(url))\n else\n return found_page.new(self, found_page.url_template.extract(url.split(/(\\?|#)/)[0]))\n end\n elsif found_page\n return found_page.new(self)\n else\n return nil\n end\n end",
"def page_by_destination(destination_path)\n # TODO: memoize this\n destination_path = normalize_path(destination_path)\n pages.find do |p|\n p.destination_path == destination_path ||\n p.destination_path == destination_path.sub(\"/#{@app.index_file}\", \"\")\n end\n end",
"def page\n @page_object ||= Page.find(self.page_id)\n rescue\n nil\n end",
"def get_page_from_url(url)\n (site.pages + site.posts).each do |page|\n return page if page.url == url\n end\nend",
"def page( lang, path )\n root_page( lang ).descendant( path )\n end",
"def get_page_from_url(url)\n site.pages.each do |page|\n if page.url == url then\n return page\n end\n end\n end",
"def page(path, version = nil, global_match = false)\n ::Gollum::Page.find(self, path, version.nil? ? @ref : version, false, global_match)\n end",
"def get_page(site,page)\n page.blank? ? Page.find_by_slug_and_site_id(Page::INDEX, site.id, :include => { :parts => :part_type }) : Page.find_by_slug_and_site_id(page, site.id, :include => { :parts => :part_type} )\n end",
"def find_or_create_object_by_absolute_path(path, options = {})\n path = path.to_s\n options.to_options!\n head = options.has_key?(:head) ? options.delete(:head) : true\n object = nil\n objects(:prefix => path, :head => head).each do |candidate|\n break(object = candidate) if candidate.name == path\n end\n object ||= Object.new(bucket, path)\n end",
"def findPageNamed(name)\n return unless name.is_a?(String)\n Sketchup.active_model.pages.each { |p|\n return p if p.name.casecmp(name) == 0\n }\n nil\n end",
"def page_identifier(path)\n # TODO: Speed this up by adding an index & unique constraint on path attribute\n Integral::Page.not_archived.find_by_path(path)&.id\n end",
"def page\n\t\t@visited_pages = []\n\t\tlogger.debug \"retreiving page for #{name}\"\n\t\tfind_page(name, false)\n\tend",
"def path_to_object(path)\n treeish = (@staging_index ? staging.sha : @current_branch)\n tree = self.tree(treeish, [path])\n return tree.blobs.first if tree && (not tree.blobs.empty?)\n return tree.trees.first if tree && (not tree.trees.empty?)\n\n # check staging index in case object has not been written to object DB\n staging? ? staging.path_to_object(path) : nil\n end",
"def find_page(title)\n title = normalize_title(title)\n \n store[title + '.md'] or Page.new(:title => title)\n end",
"def get(path)\n key, subkeys = split_path(path)\n if subkeys.any?\n if self[key].is_a?(Droom::LazyHash)\n self[key].get(subkeys)\n else\n nil\n end\n elsif self.key?(key)\n self[key]\n else\n nil\n end\n end",
"def get_child(path)\n children.find { |child| child.name == path } || OneDrive404.new\n end",
"def by_path(path); end",
"def find_by_path(resource_path)\n idents = resource_path.split(/#/).delete_if {|x| x.blank? }\n return unless ident.eql?(idents.shift)\n return self if idents.empty?\n child = children.select{|r| r.ident == idents.first}.first\n child and child.find_by_path(idents * '#')\n end",
"def find_page_object_for_custom_methods\n find_page_object\n end",
"def [](path)\n first, *rest_path = path.split(\"/\") \n obj = case first\n when nil\n if path == \"/\"\n root\n elsif path == \"\"\n self\n end\n when \"\"\n root\n when \"..\"\n parent\n when \".\"\n self\n else\n children[first.to_sym]\n end\n\n return nil if obj.nil?\n if rest_path.size > 0\n obj[rest_path.join(\"/\")]\n else\n obj\n end\n end",
"def wiki_page(name, path = nil, version = nil, exact = true)\n wiki = wiki_new\n path = name if path.nil?\n name = extract_name(name) || wiki.index_page\n path = extract_path(path)\n path = '/' if exact && path.nil?\n\n OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, exact, version),\n :name => name, :path => path)\n end",
"def get_with_path(path)\n get(*key_paths(path))\n end",
"def find_by_title(*opts)\n find_by_titles(opts).pages.first\n end",
"def get_page_from_url(url)\n\t(site.pages + site.posts).each do |page|\n\t\treturn page if page.url == url\n\tend\n\n\treturn nil\nend",
"def set_page\n @page = Page.find_by_path(params[:path])\n\n raise ActionController::RoutingError.new('Not Found') unless @page.present?\n end",
"def page\n Page.where(:text_id => primary_key).first\n end",
"def page_for_url(url)\n logger.debug(\"checking if this page url \" + self.url.to_s + \" == \" + url.to_s);\n if (self.url == url)\n logger.debug(\"true, match found\");\n return self\n else\n children.each do |child|\n if (url =~ Regexp.compile( '^' + Regexp.quote(child.url)))\n found = child.page_for_url(url)\n return found if found\n end\n end\n end\n return nil;\n end",
"def find_or_create_page_from_url\n if self.page_id.nil? and @url.present?\n self.page_id = (Page.where(url: @url).first || Page.create!(url: @url)).id\n end\n end",
"def get_page(name, version='master')\n IO.read(page_path(name, version)) if cache_hit?(name, version)\n end",
"def find_page(url)\n found = Page.find_by_url(url)\n found if found #and (found.published?)\n end",
"def find_page(title, version = nil, load_content: true)\n page_title, page_dir = page_title_and_dir(title)\n\n if page = wiki.page(title: page_title, version: version, dir: page_dir, load_content: load_content)\n WikiPage.new(self, page)\n end\n end",
"def template_page(site)\n site.pages.dup.select do |page|\n Pager.pagination_candidate?(site.config, page)\n end.sort do |one, two|\n two.path.size <=> one.path.size\n end.first\n end",
"def find_by_alias(path)\n alias_name = path.match(/\\((.*?)\\)/)[1]\n data[\"pages_by_name\"][alias_name&.strip]\n end",
"def get(path)\n unless path.empty?\n root = path.getRoot\n return nil unless self.keys.include? root\n if path.hasChild? then\n return self[root].get(path.getChild)\n else\n return self[root]\n end\n end\n nil\n end",
"def page\n @page ||= retrieve_page\n end",
"def page\n @page ||= retrieve_page\n end",
"def show\n @page = if params[:path]\n Page.find(params[:path].split('/').last, :include => [:parts, :slugs])\n else\n Page.find(params[:id], :include => [:parts, :slugs])\n end\n\n if @page.try(:live?) or\n (refinery_user? and\n current_user.authorized_plugins.include?(\"refinery_pages\"))\n # if the admin wants this to be a \"placeholder\" page which goes to its first child, go to that instead.\n if @page.skip_to_first_child\n first_live_child = @page.children.find_by_draft(false, :order => \"position ASC\")\n redirect_to first_live_child.url if first_live_child.present?\n end\n else\n error_404\n end\n end",
"def get_page(priority)\n sitemap.resources.select { |resource| resource.data.type == 'page' and get_page_priority(resource.data) == priority }\n end",
"def page(slug_id)\n\t\treturn self.pages.where(:slug => slug_id).first\n\tend",
"def page\n\t\tpage = request.path.split(\"/\")[-1]\n\tend",
"def get_page_path\n\n #in rails 2.0, params[:page] comes back as just an Array, so to_s doesn't do join('/')\n if params[:page].is_a? Array\n page_name = params[:page].join(\"/\")\n #in rails 1.x, params[:page] comes back as ActionController::Routing::PathSegment::Result\n elsif params[:page].is_a? ActionController::Routing::PathSegment::Result\n page_name = params[:page].to_s\n else\n logger.debug \"get_page_path - params[:page] is an unrecognized type, may cause problems: #{params[:page].class}\"\n page_name = params[:page].to_s\n end\n\n page_ext = page_name.split('.')[1] unless page_name.empty?\n # TODO: Automatic support for page RSS feeds... ????\n if page_name.nil? or page_name.empty?\n page_name = params[:index]\n params[:cache_path] = \"#{request.request_uri}/index\"\n elsif !params[:index].empty?\n page_name = \"#{params[:index]}/#{page_name}\"\n end\n return page_name, page_ext\n end",
"def get(path)\n self.class.get(path)\n end",
"def find_by_path_with_draft_versioning(path, live = true, clean = true)\n if live\n find_by_path_without_draft_versioning(path, live, clean)\n else\n return nil if virtual?\n path = clean_path(path) if clean\n my_path = self.path(live)\n if (my_path == path) && (not live or published?)\n self.current\n elsif (path =~ /^#{Regexp.quote(my_path)}([^\\/]*)/)\n slug_child = current_children.find {|child| child.slug == $1 }\n if slug_child\n found = slug_child.find_by_path(path, live, clean)\n return found if found\n end\n current_children.each do |child|\n found = child.find_by_path(path, live, clean)\n return found if found\n end\n file_not_found_names = ([FileNotFoundPage] + FileNotFoundPage.descendants).map(&:name)\n condition = (['class_name = ?'] * file_not_found_names.length).join(' or ')\n file_not_found_page = children.find(:first, :conditions => [condition] + file_not_found_names)\n file_not_found_page.current if file_not_found_page\n end\n end\n end",
"def page\n obj\n end",
"def scene_object_for_path( path )\n if @scene_root.nil?\n lp \"Unable to fetch '#{path}' while @scene_root is still nil.\",\n force_color: red\n return nil\n end\n\n case path\n when @scene_root.name\n @scene_root\n when ':body'\n @story_bundle.document.body\n else\n escaped_path = path.gsub(/[\\[\\]]/){ |c| \"\\\\#{c}\" }\n @scene_root.childNodeWithName(escaped_path)\n end\n end",
"def page_by_name(name)\n fetch(:page, name)\n end",
"def find(args)\n page = page_files.select {|pf| File.basename(pf) =~ /#{args}/i }.map {|pf| new(pf)}\n page = page.first\n end",
"def [](path)\n find_subpath(path, false)\n end",
"def [](path)\n find_subpath(path, false)\n end",
"def initialize_requested_page_by_shortcut(shortcut)\n return root_page if shortcut.blank?\n pages.where(:shortcut => shortcut).try(:first)\n end",
"def get_page(id)\n @client.raw('get', \"/content/pages/#{id}\")\n end",
"def search(path)\n self.find_by_xpath(path)\n end",
"def find_by_trail(trail)\n fetch_or_cache_by_key(\"TRAIL::\" + trail.to_s) do\n pages = Backpack.interface.list_pages['pages'].first['page']\n p = pages.detect { |p| p['title'].downcase.squish == trail.downcase.squish }\n p ? Page.find(p['id'].to_i) : nil\n end\n end",
"def initialize(path, page)\n @path = path\n @page_name = page\n end",
"def get_page(path, raw = false)\n\n #head = @repo.commits.first\n #tree = head.tree @branch\n\n tree = @repo.tree @branch\n blob = tree / path\n\n return nil if ! blob.is_a? Grit::Blob\n\n text = blob.data.force_encoding('utf-8').encode\n return [ text, blob.id ]\n end",
"def get(page)\n case page\n when Model\n page\n when String\n new site.get page\n when Sitepress::Resource\n new page\n else\n raise ModelNotFoundError, \"#{self.inspect} could not find #{page.inspect}\"\n end\n end",
"def page_by_name(name)\n fetch(:page,\"#{name.gsub!(/\\s/, '_')}\")\n end",
"def page_request(path, params={})\n if params[PARAM_PAGE] && params[PARAM_PAGE] == NOT_FOUND\n params[PARAM_PAGE] = default_page\n end\n\n current_api.get_request(path, ParamsHash.new(params))\n end",
"def get_resource(resource_path)\n \n return self if path == resource_path\n\n @children.each do |c|\n resource = c.get_resource(resource_path)\n return resource if resource\n end if @children\n\n return nil\n end",
"def show\n @page = Page.find_by_path(params[:path].join('/'))\n\n return show_404 unless @page\n\n respond_with @page\n end",
"def find(path); end",
"def find(path); end",
"def get_page(idx)\n raise PageOverflowError.new(\"Cannot insert more records.\") if idx >= PAGE_COUNT\n\n if @pages[idx].nil? # Cache miss\n num_saved_pages = @file_length / PAGE_SIZE\n\n # partial page can be saved at end of file...\n if @file_length % PAGE_SIZE\n num_saved_pages += 1\n end\n\n # if page exists, read it...\n if idx <= num_saved_pages\n @file.seek(idx * PAGE_SIZE, IO::SEEK_SET)\n page = @file.read(PAGE_SIZE)\n end\n\n # TODO: This could overwrite data if there's an error.\n page ||= [0].pack(\"C\") * PAGE_SIZE\n\n @pages[idx] = page\n end\n\n @pages[idx]\n end",
"def lookup(path)\n unless @cached.has_key?(path)\n @cached[path] = _lookup!(path)\n end\n return @cached[path]\n end",
"def template_page(site)\n site.pages.dup.select do |page|\n CategoryPager.pagination_candidate?(site.config, page)\n end.sort do |one, two|\n two.path.size <=> one.path.size\n end.first\n end",
"def page_post\n Post.find_by_permalink(params[:id])\n end",
"def page_object\n @page\n end",
"def page_object\n @page\n end",
"def lookup_path(path, dir)\n dir = ::File.expand_path(dir)\n top = ::File.expand_path(wiki.path)\n home = ::File.expand_path('~')\n\n loop do\n found = Dir[::File.join(dir, path)].first\n return found if found\n return nil if dir == top\n return nil if dir == home # just in case\n return nil if dir == '/' # doubly so\n dir = ::File.dirname(dir)\n end\n end",
"def page\n get_page\n nil\n end",
"def get_element(path)\n elements = get_elements(path)\n elements[0] if elements\n end",
"def find_gracefully path\n path = full_path(path)\n if blob = find_blob(path)\n new(blob, path)\n else\n nil\n end\n end",
"def get_page(query)\n\t# FOR OFFLINE DEVELOPMENT\n\t# uri = BASE_URL + query + \".html\"\n\t# page = Nokogiri::HTML(open(uri))\n\t\n\turi = BASE_URL + query\n\tpage = Nokogiri::HTML(open(uri).read)\n\treturn page\nend",
"def find_path(path)\n @data.each_pair do |name, dir|\n if dir[:directory] == path\n return Directory::new(name, dir)\n end\n end\n \n return nil\n end",
"def exists?(path)\n @pages.has_key?(normalize_path(path))\n end",
"def entity_for_path(path)\n local_entities_list.find do |e|\n path[0, e.path.length] == e.path\n end\n end",
"def page\n @page ||= revision.try(:page)\n end",
"def first_page\n Page.find(self.first_page_id)\n end",
"def find_or_create_child(path)\n path = self.class.name_to_hierarchy(path) if path.kind_of?(String)\n raise \"bad account path\" unless path.kind_of?(Array)\n result = self\n while path.length > 0\n result = result.children[path.shift]\n end\n return result\n end",
"def page_cache(page)\n if page\n \"/page-#{page}\"\n else\n \"\"\n end\n end",
"def path_to_page(page, tag = nil)\n if tag\n blogo_tag_page_path(tag, page)\n else\n blogo_page_path(page)\n end\n end",
"def find_page_with_group_check(path)\n page = find_page_without_group_check(path)\n if page && page.restricted?\n raise ReaderError::LoginRequired, t(\"reader_extension.page_not_public\") unless current_reader\n raise ReaderError::ActivationRequired, t(\"reader_extension.page_not_public\") unless current_reader.activated?\n raise ReaderError::AccessDenied, t(\"reader_extension.page_permission_denied\") unless page.visible_to?(current_reader)\n end\n page\n end",
"def fetch_page(url, from_page = nil)\n begin\n url = URI(url) unless url.is_a?(URI)\n\n if from_page\n referer = from_page.url\n depth = from_page.depth + 1\n end\n\n response, code, location, response_time = get(url, referer)\n\n aka = nil\n if !url.eql?(location)\n aka = location\n end\n\n return Page.new(url, response.body, code, response.to_hash, aka, referer, depth, response_time)\n rescue\n return Page.new(url)\n end\n end",
"def get(path)\n path = \"/#{path}\" unless path[0] == '/'\n with_cache(:get, path) do\n OneDriveItem.smart_new(@od, @od.request(\"#{api_path}:/#{@od.url_path_encode(path[1..-1])}\"))\n end\n end",
"def find_by_path(path, flags={})\n if parseit = path.match(/^.*?(([^\\/]+)\\/)?([^\\/]+?)(\\.git)?$/)\n if proj = Project.find_by_identifier(parseit[3]) || !GitHosting.multi_repos?\n # return default or first repo with blank identifier (or first Git repo--very rare?)\n proj && (proj.repository || proj.repo_blank_ident || proj.gitolite_repos.first)\n elsif repo_ident_unique? || flags[:loose] && parseit[2].nil?\n find_by_identifier(parseit[3])\n elsif parseit[2] && proj = Project.find_by_identifier(parseit[2])\n find_by_identifier_and_project_id(parseit[3],proj.id) ||\n flags[:loose] && find_by_identifier(parseit[3]) || nil\n else\n nil\n end\n else\n nil\n end\n end",
"def find_object(name)\n @search_paths.unshift(@cache[name]) if @cache[name]\n @search_paths.unshift(Registry.yardoc_file)\n\n # Try to load it from in memory cache\n log.debug \"Searching for #{name} in memory\"\n obj = try_load_object(name, nil)\n return obj if obj\n\n log.debug \"Searching for #{name} in search paths\"\n @search_paths.each do |path|\n next unless File.exist?(path)\n log.debug \"Searching for #{name} in #{path}...\"\n Registry.load(path)\n obj = try_load_object(name, path)\n return obj if obj\n end\n nil\n end",
"def retrieve_pages(dir, dot_pages); end",
"def [](path)\n path = normalize_path(path)\n return self if path.empty?\n entry = @children[path.first]\n if path.size == 1\n entry\n elsif entry\n raise 'Not a tree' if entry.type != :tree\n entry[path[1..-1]]\n end\n end"
] | [
"0.7723916",
"0.76899713",
"0.7555201",
"0.71748966",
"0.67586327",
"0.6656543",
"0.65503126",
"0.6549743",
"0.65392",
"0.64404523",
"0.6359445",
"0.63447756",
"0.6318401",
"0.62927735",
"0.6291127",
"0.6221604",
"0.6218575",
"0.61995095",
"0.61596596",
"0.6033376",
"0.6021296",
"0.60179836",
"0.60035247",
"0.5975156",
"0.59488803",
"0.5936579",
"0.5907125",
"0.58992285",
"0.5893028",
"0.58785754",
"0.5878483",
"0.5870526",
"0.58665496",
"0.5862907",
"0.58602667",
"0.5832428",
"0.57989615",
"0.5776891",
"0.5752641",
"0.57198006",
"0.5718039",
"0.5716835",
"0.5712395",
"0.5694786",
"0.5694573",
"0.5684391",
"0.56813794",
"0.56813794",
"0.56632024",
"0.56556684",
"0.56551343",
"0.56496006",
"0.56368005",
"0.5623118",
"0.56075597",
"0.55957246",
"0.5589544",
"0.55814403",
"0.5571689",
"0.55639",
"0.55639",
"0.556157",
"0.5554204",
"0.5547695",
"0.5543027",
"0.55412596",
"0.5528586",
"0.55219",
"0.5520935",
"0.5499998",
"0.54986835",
"0.5497733",
"0.5487805",
"0.5487805",
"0.54785717",
"0.5474024",
"0.54724354",
"0.54712206",
"0.54632527",
"0.54632527",
"0.5463056",
"0.546212",
"0.5451407",
"0.54502666",
"0.5443587",
"0.5434356",
"0.5413269",
"0.54106843",
"0.54030544",
"0.53955746",
"0.53859377",
"0.5383145",
"0.5378929",
"0.5375751",
"0.5369856",
"0.53645",
"0.5346204",
"0.5343439",
"0.5334979",
"0.5330368"
] | 0.5869679 | 32 |
uses the string instance method scan. scan matches a given pattern and for every match populates an array with the match. | def print_in_box(string)
lines = string.scan(/.{1,76}/)
width = lines.first.to_s.size + 2
top_bot = "+#{'-' * width}+"
padding = "|#{' ' * width}|"
text = lines.map { |line| "| #{line.ljust(width - 2)} |" }
puts [top_bot, padding, text, padding, top_bot]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan(pattern); end",
"def scan(pattern, &blk)\n @string.scan(pattern, &blk)\n end",
"def scan(pattern, &blk)\n @string.scan(pattern, &blk)\n end",
"def scan(pattern)\n do_scan pattern, true, true, true\n end",
"def scan\n list = []\n io.each do |input|\n # TODO: limit to text files, how?\n begin\n text = read(input)\n text.scan(regex) do\n list << Match.new(input, $~)\n end\n rescue => err\n warn(input.inspect + ' ' + err.to_s) if $VERBOSE\n end\n end\n list\n end",
"def grab_all_sins(string)\n # TODO how do we >> strings into the array, but not just one. \n # we need all the possible iterations of regex \n string.scan(SIN_NUMBER) \nend",
"def createArray(scanner)\n pattern = []\n until scanner.scan(/\\]/) or scanner.scan(/\\)/)\n checkStringElement(scanner, pattern)\n end\n return pattern\nend",
"def match_array(string, match_string)\n arr = []\n string.scan(Regexp.new(match_string)) do |element|\n arr << element\n end\n return arr\n end",
"def check_scan(s, pattern); end",
"def check_scan(s, pattern); end",
"def scan_md(aPattern)\n\t\tresult = []\n\t\tself.scan(aPattern) {|s| result << $~ }\n\t\tresult\n\tend",
"def test_scan_is_like_find_all\n ##assert_equal __, \"one two-three\".scan(/\\w+/)\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def fullscan\n array = []\n\n self.scan { |token, str|\n # Ignore any definition nesting problems\n @indefine = false\n array.push([token,str])\n }\n array\n end",
"def multireg(regpexp, str)\n result = []\n while regpexp.match(str)\n result.push regpexp.match(str)\n str = regpexp.match(str).post_match\n end\n result\n end",
"def test_scan_is_like_find_all\n assert_equal ['one', 'two', 'three'], \"one two-three\".scan(/\\w+/)\n end",
"def test_scan_is_like_find_all\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def test_scan_is_like_find_all\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def to_array(string)\n word_array=[]\n string.scan(/\\w+/)\nend",
"def grep(pattern, &block)\n ary = []\n self.each{|*val|\n sv = val.__svalue\n if pattern === sv\n ary.push((block)? block.call(*val): sv)\n end\n }\n ary\n end",
"def scan(reg, &block)\n ### *** TODO *** ###\n unless Object.const_defined?(:Regexp)\n raise NotImplementedError, \"scan not available (yet)\"\n end\n end",
"def matches(str)\n each_match(str).to_a\n end",
"def scan(regex)\n while @scanner.scan_until(regex)\n match = @scanner.matched\n position = @scanner.charpos - match.length\n yield match, position, match.length\n end\n end",
"def consume(pattern)\n if input.match?(pattern)\n append input.scan(pattern)\n end\n end",
"def extract(pattern); end",
"def checkStringElement(scanner, pattern)\n if scanner.scan(/(\\w\\:\\d+)/) # e.g. \"c:23\"\n soundBank = scanner[0].scan(/\\w+/) # soundBank is an array [letter, number] as string\n pattern << (sample_paths @sounds[soundBank[0].to_sym])[soundBank[1].to_i]\n elsif scanner.scan(/\\w/) # one letter e.g. \"a\"\n pattern << @sounds[scanner[0].to_sym]\n elsif scanner.scan(/\\-\\:\\d+/) # e.g. \"-:23\"\n soundBank = scanner[0].scan(/\\d+/) # soundBank is just a number\n pattern << (sample_paths @sounds[:hyphen])[soundBank[0].to_i]\n elsif scanner.scan(/\\-/)\n pattern << @sounds[:hyphen]\n elsif scanner.scan(/\\ /)\n pattern << @sounds[:whitespace]\n elsif scanner.scan(/\\[/)\n arryResult = createArray(scanner) # call function to create an array\n pattern << arryResult\n elsif scanner.scan(/\\(/) != nil\n arryResult = createArray(scanner) # call function to create an array\n pattern << arryResult.ring # convert result to a ring\n elsif scanner.scan(/\\{/)\n arryResult = createRandomArray(scanner) # call function to create an array\n pattern << arryResult\n else\n scanner.scan(/./)\n end\nend",
"def parseBeatString(str)\n pattern = []\n scanner = StringScanner.new(str)\n until scanner.pos == str.length\n checkStringElement(scanner, pattern)\n end\n pattern\nend",
"def process(items) \n out = []\n \n if items.is_a?(Array)\n items.each do |item|\n out << item.scan(@regex).flatten\n end\n \n elsif items.is_a?(String)\n out = items.scan(@regex).flatten#{|m| m.to_s}\n \n else\n out = items\n end\n \n out.flatten\n end",
"def scan(pattern)\n _scan_headonly(pattern, true, true)\n end",
"def pattern_matcher *pattern\n lambda do |string, index = 0, counts:|\n original_counts = counts.dup\n\n pattern.inject([]) do |memo, part|\n found = part.call(string, index, counts: counts)\n\n if match? found\n index += found.size\n memo.push(*found)\n else\n counts.replace(original_counts)\n return found\n end\n end\n end\n end",
"def search pattern\n\t\tresults = all.map {|key|\n\t\t\tkey if key.to_s =~ /#{pattern}/i\n\t\t}\n\t\tresults.delete nil\n\t\tresults\n\tend",
"def match(pattern); end",
"def fscan(string, fuzziness=2)\n @scanners.map do |fdscan|\n matches = fdscan.fscan!(string, fuzziness)\n [matches, fdscan.format] if !matches.empty?\n end.compact\n end",
"def scan strOrRegexp\n @in.scan /\\s*/ # Skip whitespace\n @match = @in.scan strOrRegexp\n @last_matched_token = @match if @match # Update last matched only if a token was matched\n end",
"def parseBeatString(str)\n pattern = []\n scanner = StringScanner.new(str)\n until scanner.pos == str.length\n checkStringElement(scanner, pattern)\n end\n pattern.ring\nend",
"def words\n self.scan(WORD_PATTERN)\n end",
"def scan_tokens(tokens, options); end",
"def scan_full(pattern, advance_pointer, return_string)\n do_scan pattern, advance_pointer, return_string, true\n end",
"def scan(text, pattern, &block)\n # convert tabs to spaces\n text.gsub!(/^(\\t+)/) {|tabs| ' ' * (8 * tabs.length)}\n\n text.scan(pattern).each do |matches|\n hash = Hash[pattern.names.zip(matches)]\n yield hash if block\n\n section = hash.delete('section')\n section ||= hash.delete('attach')\n\n if section\n hash['approved'] &&= hash['approved'].strip.split(/[ ,]+/)\n\n @sections[section] ||= {}\n next if hash['text'] and @sections[section]['text']\n @sections[section].merge!(hash)\n end\n end\n end",
"def scan2(regexp)\n captures = Hash.new\n scan(regexp).collect do |match|\n captures.add(:tagcapt, match[0].remove(\"@\"))\n end\n\n return (captures == {}) ? nil : captures\n end",
"def extract_string(range, strscan); end",
"def scan(s)\n\n if s =~ /^\\w+\\(/ then\n func = s.slice!(/\\w+\\(/)\n remainder = s[0..-2]\n if remainder =~ /^\\w+\\(/ then\n scan(remainder)\n else\n [func, match(remainder)]\n end\n else\n s\n end\n end",
"def scan_for_all(token); end",
"def scan_for_all(token); end",
"def scan_for_all(token); end",
"def grab_all_ssns(string)\n\tssn = /\\d{3}[^\\d]?\\d{2}[^\\d]?\\d{4}/\n\treturnString = \"\"\n\tif ssn =~ string\n\t\treturnString = string.scan(ssn)\n\t\treturn returnString\n\telse\n\t\t#puts \"not match\"\n\t\treturn []\n\tend\nend",
"def get_patterns(pattern_string)\r\n split_and_strip(pattern_string, \";\").select do |name|\r\n name != \"\"\r\n end.map {|name| Regexp.new(name, true)}\r\n end",
"def patterns; end",
"def scan_string\n scanner = StringScanner.new(glob)\n\n output, pos = \"\", 0\n\n # keep scanning until end of String\n until scanner.eos?\n\n # look for **/, *, {...}, or the end of the string\n new_chars = scanner.scan_until %r{\n \\*\\*/\n | /\\*\\*/\n | \\*\n | \\{[^\\}]*\\}\n | $\n }x\n\n # get the new part of the string up to the match\n before = new_chars[0, new_chars.size - scanner.matched_size]\n\n # get the match and new position\n match = scanner.matched\n pos = scanner.pos\n\n # add any literal characters to the output\n output << Regexp.escape(before) if before\n\n output << case match\n when \"/**/\"\n # /**/ matches either a \"/\" followed by any number\n # of characters or a single \"/\"\n \"(/.*|/)\"\n when \"**/\"\n # **/ matches the beginning of the path or\n # any number of characters followed by a \"/\"\n \"(^|.*/)\"\n when \"*\"\n # * matches any number of non-\"/\" characters\n \"[^/]*\"\n when /\\{.*\\}/\n # {...} is split over \",\" and glued back together\n # as an or condition\n \"(\" + match[1...-1].gsub(\",\", \"|\") + \")\"\n else String\n # otherwise, we've grabbed until the end\n match\n end\n end\n\n if glob.include?(\"/\")\n # if the pattern includes a /, it must match the\n # entire input, not just the end.\n Regexp.new(\"^#{output}$\", \"i\")\n else\n # anchor the pattern either at the beginning of the\n # path or at any \"/\" character\n Regexp.new(\"(^|/)#{output}$\", \"i\")\n end\n end",
"def brute_force_matches string, pattern\n i = 0\n pos = []\n while i + pattern.length - 1 < string.length\n pos << i if string[i..(i + pattern.length - 1)] == pattern\n i += 1\n end\n pos\nend",
"def __captures(ary)\n i = 1 # Captures do NOT include $& (the entire matched string)\n lim = length\n in_str = @inputString\n while i < lim\n x = self.begin(i)\n if x == -1\n ary << nil\n else\n y = self.end(i)\n ary << in_str[x, y-x] # GEMSTONE\n end\n i += 1\n end\n ary\n end",
"def segment (pattern)\n pattern.scan(/[A-Z]?[^A-Z]+|[A-Z]+/)\nend",
"def find_array\n set_pattern\n @array.reject! do |item|\n item.match(@pattern) == nil\n end\n end",
"def scan!\n find_match until @scanner.eos?\n end",
"def match_and_parse(string)\n meme = match(string)\n if meme.nil?\n return meme\n end\n bits = parse(meme, string)\n [meme, bits]\n end",
"def scan\n @segments.each_with_index do |segment, i|\n if @found_wildcard || segment.include?('*')\n add_to_wildcard(segment)\n else\n if i == @segments.size - 1 # For the last segment it might be a filename so we check\n add_to_wildcard(segment)\n else\n add_to_root(segment)\n end\n end\n end\n end",
"def each_match_range(range, regex); end",
"def repeat_matcher *pattern\n submatcher = MatchWrapper.new(pattern_matcher(*pattern), SplatExpression)\n\n lambda do |string, index = 0, counts:|\n result = []\n\n while nonempty_match?(found = submatcher.call(string, index, counts: counts))\n index += found.size\n result.push(*found)\n end\n\n result unless result.empty?\n end\n end",
"def pattern_matching(pattern, genome)\n # Pattern Matching Problem: Find all occurrences of a pattern in a string.\n # Input: Two strings, Pattern and Genome.\n # Output: All starting positions where Pattern appears as a substring of Genome.\n\n # Sample Input:\n # ATAT\n # GATATATGCATATACTT\n\n # Sample Output:\n # 1 3 9\n\n match_indexes = []\n search_start_pos = 0\n while index = genome.index(pattern, search_start_pos)\n match_indexes << index\n # puts index\n search_start_pos = index + 1\n end\n return match_indexes\n end",
"def scan_next(pattern)\n return unless @s.scan_until(pattern)\n @s.matched\n end",
"def scan_until(pattern); end",
"def search(pattern)\n # Initialize loop variables\n cursor = nil\n list = []\n\n # Scan and capture matching keys\n client.with do |conn|\n while cursor != 0\n scan = conn.scan(cursor || 0, match: pattern)\n list += scan[1]\n cursor = scan[0].to_i\n end\n end\n\n list\n end",
"def roboclassify(desc)\n @pat_matches = []\n Pattern.all.each do |pattern|\n @pat_matches += pattern.codes if regex(pattern).match(desc)\n end\n @pat_matches\n end",
"def matches(s, re)\r\n start_at = 0\r\n matches = [ ]\r\n while(m = s.match(re, start_at))\r\n matches.push(m)\r\n start_at = m.end(0)\r\n end\r\n return matches\r\n end",
"def obtainDrivers(contents)\n\n # variable to hold the list of drivers\n drivers = []\n\n # for every line...\n contents.each do |line|\n\n # use regex to ensure the line matches the expected\n captures = /^Driver ([A-Za-z]{1,64})$/.match(line)\n\n # safety check, ensure the capture isn't nil\n if captures.nil?\n next\n end\n\n # if the regex capture has a length of at least one,\n # push it to the list of drivers\n if captures.length > 0\n drivers.push(captures[1])\n end\n end\n\n # return the list drivers\n return drivers\nend",
"def grab_all_sins(string)\n sins2 = string.scan(/\\b\\d{3}-\\d{3}-\\d{3}\\b/)\n return sins2\nend",
"def read_to(pattern); end",
"def search_full(pattern, succptr, getstr)\n _scan(pattern, succptr, getstr)\n end",
"def scan(s)\n until s.nil?\n len = s[0...2].ret2ushort\n ele = s[2...4].ret2ushort\n tpe = s[4...6].ret2ushort\n dat = s[6...len]\n if s.length > len\n s = s[len...s.length]\n else\n s = nil\n end\n case ele\n when Fields::DE32\n dat = scan(dat)\n when Fields::CALL_SEARCH_RESULT\n add_field(Fields::IRIS, dat[0...12])\n add_field(Fields::CALL_SEARCH_RESULT, dat[12...dat.length])\n next\n end\n add_field( ele, dat)\n end\n r\n end",
"def word_pattern(pattern, input)\n \nend",
"def grab_all_sins(string)\n match = string.scan(/(^|\\s)(\\d{3}-\\d{3}-\\d{3})(\\D|$)/)\n unless match == []\n return match.transpose[1]\n end\n []\n end",
"def scan(pattern)\n self.checkpoint()\n result = self.old_scan(pattern)\n return result if result\n self.rollback()\n return result\n end",
"def retrieveRObjects(p, pattern)\n p.puts %{cat(ls(pat=\"#{pattern}\"),\"\\\\n\")}\n arrayCode = %{%w[#{p.gets.chomp!}]}\n eval(arrayCode)\n end",
"def expand_ic(xs, pattern)\n re1 = /\\A#{Regexp.quote(pattern)}/i\n result1 = xs.select {|x| x.name_match?(re1) }\n return [] if result1.empty?\n return result1 if result1.size == 1\n re2 = /\\A#{Regexp.quote(pattern)}\\z/i\n result2 = result1.select {|x| x.name_match?(re2) }\n return result1 if result2.empty?\n return result2 if result2.size == 1 # no mean\n result2\n end",
"def match(text)\n shift = 0\n result = []\n\n # Try to take previous element from cache, if .test() called before\n if (@__index__ >= 0 && @__text_cache__ == text)\n result.push(Match.createMatch(self, shift))\n shift = @__last_index__\n end\n\n # Cut head if cache was used\n tail = shift ? text.slice(shift..-1) : text\n\n # Scan string until end reached\n while (self.test(tail))\n result.push(Match.createMatch(self, shift))\n\n tail = tail.slice(@__last_index__..-1)\n shift += @__last_index__\n end\n\n if (result.length)\n return result\n end\n\n return nil\n end",
"def grab_all_ssns(string)\n regexp_key = /(\\d{3}-\\d{2}-\\d{4})/\n string.scan(regexp_key).flatten\nend",
"def parse_text\n text.split(\"\\n\").map { |r| r.scan(/.../) } \n end",
"def grab_all_sins(string)\n string.scan(/\\d{3}-\\d{3}-\\d{3}/)\nend",
"def find_pattern(weight_string, pattern)\n indexes = []\n i = 0\n case pattern\n when String\n while (match = weight_string.index(pattern, i))\n i_end = match + pattern.length - 1\n indexes << (match..i_end)\n i = i_end + 1\n end\n when Regexp\n while (match = pattern.match(weight_string, i))\n i_start = match.begin(0)\n i_end = i_start + match[0].length - 1\n indexes << (i_start..i_end)\n i = i_end + 1\n end\n end\n indexes\n end",
"def exec(input, events=[])\n match = input.scan(@regexp)\n\n if match\n events << self\n events << CLOSE\n events << match.length\n end\n\n events\n end",
"def do_parse text, pattern\n data = pattern[:blk].call(text.scan(pattern[:exp]))\n\n puts data.inspect\n end",
"def matches_at_offset(input, input_start_offset)\n reset_current_states\n\n matches = []\n (input_start_offset...input.length).each do |offset|\n token = input[offset]\n self << token\n matches << MatchRef.new(input, input_start_offset..offset) if accept?\n end\n matches\n end",
"def matches\n parse_file.lines.each_with_object([]) do |line, matches|\n matches << line.scan(REGEXP[:name_and_score])\n end\n end",
"def scan; return nil; end",
"def match?(pattern)\n do_scan pattern, false, false, true\n end",
"def patterns\n\t\t@@patterns ||= []\n\n\t\tif @@patterns.size == 0\n\t\t\tfor i in 0..9\n\t\t\t\tfor j in 0..9\n\t\t\t\t\tfor k in 0..9\n\t\t\t\t\t\tfor l in 0..9\n\t\t\t\t\t\t\t@@patterns << Regexp.new(\"[#{i}]{4}[#{j}]{4}[#{k}]{4}[#{l}]{4}\")\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t@@patterns\n\tend",
"def find_a(array)\n a_array = []\n\n array.each do |string|\n if string.start_with?(\"a\")\n a_array << string\n end\n end\n\n a_array\nend",
"def match(words)\n#iterate over the array of words that the .match method takes as an argument.\n words.select do |word|\n is_anagram?(word)\n end\n end",
"def substrings(string)\n substring_array = []\n string.each do |letter|\n \n end\n substring_array\nend",
"def extract_from(data, pattern)\n matches = data.rstrip.scan pattern\n matches.first if matches.size == 1 && matches.first.size > 0\n end",
"def matching_lines(regex); end",
"def patterns\n @patterns ||= []\n end",
"def each\r\n @input.rewind\r\n \r\n @input.each do |line|\r\n if line =~ REGEXP_ENTRY\r\n yield $1\r\n end\r\n end\r\n end",
"def match_next(pattern,mms,buf_size=524288)\r\n while true\r\n start_pos = @[email protected]\r\n result = pattern.match(@buffer)\r\n if result\r\n offset_begin, offset_end = result.offset(0)\r\n @buffer = @buffer[offset_end,@buffer.length]\r\n return [result,start_pos+offset_begin,start_pos+offset_end]\r\n else\r\n return nil if @io.eof?\r\n @buffer = @buffer[-mms..-1] if @buffer.length>mms # backup by one mms\r\n @buffer << (@io.read(buf_size) || '')\r\n end\r\n end\r\n\r\n end",
"def my_array_finding_method(source, thing_to_find)\n result = [] # result is the output array\n source.each do |word|\n word_array = word.to_s.split(//) # This creates an array of charaters of 'word'\n if word_array.include?(thing_to_find)\n result.push(word)\n end\n end\n return result\nend",
"def scan(search_exp, used_as_search_exp_occurence = nil)\n if used_as_search_exp_occurence then\n encode(@str).\n gsub(Regexp.new(used_as_search_exp_occurence.encoded_regexp_str)) do |o|\n \"S#{o.hex_encode}S\"\n end.\n scan(Regexp.new(search_exp.encoded_regexp_str)).\n map do |part|\n part.gsub!(/S\\h+S/) { |m| m[1...-1].hex_decode }\n Text.new(decode(part))\n end\n else\n encode(@str).\n scan(Regexp.new(\"(#{search_exp.encoded_regexp_str})\")).map(&:first).\n map { |part| Text.new(decode(part)) }\n end\n end",
"def matches(s, re)\n start_at = 0\n matches = []\n while(m = s.match(re, start_at))\n matches.push(m)\n start_at = m.end(0)\n end\n matches\n end",
"def scan_text(&block)\n scan_all(text_criteria, &block)\n end",
"def match(s)\n\n a = []\n\n if s =~ /^\\w+\\(/ then\n\n found, token, remainder = lmatch(s.chars, '(',')')\n\n if found == ')' then\n a << token\n end\n\n elsif s =~ /^[\\w\\/]+\\[/\n\n found, token, remainder = lmatch(s.chars, '[',']') \n a << token\n a2 = match remainder\n\n token << a2.first if a2.first \n a.concat a2[1..-1]\n\n a2\n\n else\n token = s.slice!(/^[\\w\\/]+/)\n a << token\n remainder = s\n end\n\n operator = remainder.slice!(/^\\s*\\|\\s*/)\n\n if operator then\n a.concat [operator, *match(remainder)]\n end\n \n a\n end",
"def match_strings(matched_lines)\n matched_strings = []\n\n matched_lines.each do |line|\n check_patterns.each do |pattern|\n line.scan(pattern).each do |matched|\n matched_strings += matched\n end\n end\n end\n\n return matched_strings\n end",
"def scan_arguments(*how)\n if how.count == 1\n pattern = how.first\n else\n left_delimiter = how[0] || self.left_delimiter\n right_delimiter = how[1] || self.right_delimiter\n\n return [] unless left_delimiter && right_delimiter\n\n pattern = Regexp.new(Regexp.escape(left_delimiter) + '(.*?)' + Regexp.escape(right_delimiter))\n end\n\n @arguments = @base.scan(pattern).flatten\n end",
"def match(regexp); end"
] | [
"0.749408",
"0.72997355",
"0.72997355",
"0.697791",
"0.6790932",
"0.6716557",
"0.6712049",
"0.65929854",
"0.64626783",
"0.64626783",
"0.6414182",
"0.6297995",
"0.6211988",
"0.61919695",
"0.6190965",
"0.6146892",
"0.6146892",
"0.6144913",
"0.613808",
"0.60917413",
"0.6038085",
"0.6029051",
"0.6022591",
"0.59191793",
"0.5857791",
"0.58146507",
"0.5814353",
"0.58096635",
"0.5758768",
"0.5750529",
"0.5723327",
"0.562745",
"0.5618604",
"0.560762",
"0.5579647",
"0.5564005",
"0.55418897",
"0.5527002",
"0.5506885",
"0.5501603",
"0.5478564",
"0.5460296",
"0.5460296",
"0.5460296",
"0.5454869",
"0.5423505",
"0.5419154",
"0.5417206",
"0.54079",
"0.53891706",
"0.5386683",
"0.53767",
"0.5374483",
"0.5365896",
"0.5362252",
"0.536075",
"0.5360062",
"0.5339962",
"0.5323662",
"0.53199315",
"0.53018427",
"0.5292388",
"0.5290104",
"0.52829814",
"0.5278872",
"0.52723736",
"0.52687865",
"0.5266219",
"0.52601993",
"0.525675",
"0.5234648",
"0.5223616",
"0.5216729",
"0.52121466",
"0.5211571",
"0.52105975",
"0.5210535",
"0.52104527",
"0.5192569",
"0.5191436",
"0.5181868",
"0.5177445",
"0.51724494",
"0.51629364",
"0.51588076",
"0.5157501",
"0.51531",
"0.5152911",
"0.51479983",
"0.51461524",
"0.5134296",
"0.5125247",
"0.51239204",
"0.51222354",
"0.51220614",
"0.51186794",
"0.5118175",
"0.5116738",
"0.5115326",
"0.510647",
"0.51033366"
] | 0.0 | -1 |
Map out the columns for future reference on type conversion :nodoc: | def _protobuf_map_columns(force = false)
COLUMN_TYPE_MAP_MUTEX.synchronize do
@_protobuf_mapped_columns = false if force
return unless table_exists?
return if _protobuf_mapped_columns?
@_protobuf_columns = {}
@_protobuf_column_types = ::Hash.new { |h, k| h[k] = ::Set.new }
@_protobuf_date_datetime_time_or_timestamp_column = ::Set.new
columns.map do |column|
column_name_symbol = column.name.to_sym
column_type_symbol = column.type.to_sym
@_protobuf_columns[column_name_symbol] = column
@_protobuf_column_types[column_type_symbol] << column_name_symbol
if DATE_OR_TIME_TYPES.include?(column_type_symbol)
@_protobuf_date_datetime_time_or_timestamp_column << column_name_symbol
end
end
@_protobuf_mapped_columns = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_columns\n @map_columns ||= attribute_definitions.values.select { |c| c.type == :map }\n end",
"def mapped_columns\n @columns.map do |column|\n @mappings[column] || column.to_s.send(@inflector)\n end\n end",
"def convert_columns(arr)\n if ccs = @column_converters\n arr.zip(ccs).map{|v, pr| (v && pr) ? pr.call(v) : v}\n else\n arr \n end\n end",
"def add_typecast_on_load_columns(*columns)\n @typecast_on_load_columns.concat(columns)\n end",
"def transformed_columns\n @transformed_columns ||= computed_columns.map do |key, value|\n transform_column(key, value)\n end\n end",
"def map_types!(column_mapping)\n\t\tself.column_mapping = column_mapping\n\t\tself\n\tend",
"def columns\n @columns ||= [].tap do |fields|\n @model.columns.reject { |a| a.name.match(/_id$/) }.each do |column|\n fields << resolve(column.type, column.name)\n end\n end\n end",
"def columns\n select.inject([]) do |columns, column|\n columns << {\n :type => all_columns[column][:type]\n }.merge({\n :id => column.to_s,\n :label => column_label(column)\n })\n end\n end",
"def make_column_mapping\n self.column_mapping = Hash.new.tap do |mapping|\n headers.collect { |h| canonicalize_header(h) }.each.with_index do |header, index|\n raise RuntimeError, \"Unrecognized canonical header #{header}\" unless HEADER_MAPPING.has_key?(header)\n if value = HEADER_MAPPING[header]\n mapping[index] = value\n end\n end\n end\n end",
"def column_mappings\n @column_mappings ||= raw_column_mappings.map do |column_mapping|\n NdrImport::NonTabular::ColumnMapping.new(column_mapping)\n end\n end",
"def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end",
"def columns()\n \t cols = {}\n cols['oml_sender_id'] = {:type => 'INTEGER'}\n cols['oml_seq'] = {:type => 'INTEGER'}\n cols['oml_ts_client'] = {:type => 'REAL'}\n cols['oml_ts_server'] = {:type => 'REAL'}\n \t if @filters.size > 0\n \t @filters.each do |f|\n cols.merge!(f.columns)\n \t end\n \t else\n #appDef = AppDefinition[@application.to_s]\n appDef = @application.appDefinition\n appDef.measurements[@mdef].metrics.each do |name, opts|\n #[name] = {:type => type, :description => description, :seqNo => @metrics.length}\n case (type = opts[:type])\n when 'xsd:string' then\n cols[name] = {:type => 'TEXT'}\n when 'xsd:long', 'xsd:float' then\n if @single_sample_mode\n cols[name] = {:type => Xsd2SqlType[type]}\n else\n cols[\"#{name}_avg\"] = cols[\"#{name}_min\"] = cols[\"#{name}_max\"] = {:type => 'REAL'}\n end\n else\n error \"Type '#{opts[:type]}' for '#{name}' not implemented\"\n end\n \t end\n \t end\n cols\n \tend",
"def _protobuf_map_columns(force = false)\n return unless table_exists?\n\n @_protobuf_mapped_columns = false if force\n return if _protobuf_mapped_columns?\n\n @_protobuf_columns = {}\n @_protobuf_column_types = Hash.new { |h,k| h[k] = [] }\n\n columns.map do |column|\n @_protobuf_columns[column.name.to_sym] = column\n @_protobuf_column_types[column.type.to_sym] << column.name.to_sym\n end\n\n @_protobuf_mapped_columns = true\n end",
"def translated_columns(klass); end",
"def process_select_columns(select_columns)\n select_columns.map do |column|\n if column.is_a?(String) or column.is_a?(Symbol)\n as_table[column]\n else\n column\n end\n end\n end",
"def reference_columns(excluded_supertypes) #:nodoc:\n trace :columns, \"Reference Columns for #{name}\" do\n if is_table\n if isr = injected_surrogate_role\n ref_from = references_from.detect{|ref| ref.from_role == isr}\n [ActiveFacts::RMap::Column.new(ref_from)]\n else\n [ActiveFacts::RMap::Column.new(self_value_reference)]\n end\n else\n [ActiveFacts::RMap::Column.new]\n end\n end\n end",
"def columns\n ColumnCollection.new(@data)\n end",
"def map_data_types(hsh)\n hsh.each_with_object({}) { |(column_name, column_type), hash| hash[column_name] = map_value(column_type) }\n end",
"def finalize_datatypes_for_csv\n csv_column_datatypes.map { |column_name, possible_datatypes|\n #If there is string type even atleast 1 there is no other option but to set the datatype to string => varchar\n if possible_datatypes.has_key?(:string)\n csv_column_datatypes[column_name] = :string\n else\n #set the max occurance datatype as the datatype of column\n csv_column_datatypes[column_name] = possible_datatypes.key(possible_datatypes.values.max)\n end\n }\n end",
"def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n columns << {:name => column[:name], :special => column}\n end\n end\n columns\n end",
"def all_columns(excluded_supertypes) #:nodoc:\n columns = []\n trace :columns, \"All Columns for #{name}\" do\n if is_table\n self_value_reference\n else\n columns << ActiveFacts::RMap::Column.new\n end\n references_from.each do |ref|\n trace :columns, \"Columns absorbed via #{ref}\" do\n columns += ref.columns({})\n end\n end\n end\n columns\n end",
"def columns\n @columns = @clazz.columns_hash.map do |name, column|\n [name, @columns[name] || Column.new(column, @dump)]\n end.to_h.with_indifferent_access\n end",
"def columns\n map.keys\n end",
"def column_types\n @column_types ||= @columns.values\n end",
"def columns(tables)\n columns = execute <<-SQL\n SELECT\n s.nspname || '.' || t.relname AS table_name,\n a.attname AS column_name,\n pg_catalog.format_type(a.atttypid, a.atttypmod) AS data_type\n FROM pg_attribute a\n JOIN pg_class t on a.attrelid = t.oid\n JOIN pg_namespace s on t.relnamespace = s.oid\n WHERE a.attnum > 0\n AND NOT a.attisdropped\n AND s.nspname || '.' || t.relname IN (#{tables.map {|t| quote(t)}.join(\", \")})\n ORDER BY\n 1, 2\n SQL\n\n columns.map {|v| {table: v[\"table_name\"], column: v[\"column_name\"], type: v[\"data_type\"]}}\n end",
"def columns(table_name)\n column_definitions(table_name.to_s).map do |column_name, type, default, notnull, oid, fmod|\n default_value = extract_value_from_default(default)\n type_metadata = fetch_type_metadata(column_name, type, oid, fmod)\n default_function = extract_default_function(default_value, default)\n new_column(column_name, default_value, type_metadata, notnull == 'f', table_name, default_function)\n end\n end",
"def proxy_columns(columns)\n columns.each do |column|\n if (type = column_type(column.type)).present?\n # When setting the default value, note that +main_instance+ might be nil, so we have to use +try+\n attribute column.name, type, default: proc { |f| f.main_instance.try(column.name) }\n end\n end\n end",
"def columns; @columns_hash.values; end",
"def columns\n raise NotImplementedError\n end",
"def infer_types!\n types = Array.new(ncols)\n each do |row| merge_types(types, row[:*].infer_string_types) end\n types.each.with_index do |type, i|\n colname = @colnames[i]\n if type <= Integer then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Integer(@rows[rowid][colname]) end\n elsif type <= Float then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Float(@rows[rowid][colname]) end\n end\n end\n self\n end",
"def real_column; end",
"def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end",
"def geography_columns!; end",
"def to_a\n columns.map { |column| @attributes[column.name.underscore] }\n end",
"def column_mappings\n raise SolidusImportProducts::AbstractMthodCall\n end",
"def to_columns\n @columns = transpose_to_columns\n end",
"def convert_data(*args)\n data = {}\n\n Observation.column_names.each do |column_name|\n method_name = \"get_#{column_name}\"\n if self.respond_to? method_name\n value = self.send(method_name, *args)\n data[column_name.to_sym] = value\n end\n end\n\n return data\n end",
"def col_types\n result = {}\n columns.each do |c|\n result[c.header] = c.type\n end\n result\n end",
"def columns\n collect = []\n recursive_columns(@base, collect)\n end",
"def columns; end",
"def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end",
"def columns; @columns; end",
"def serialized_columns\n serialization_map.keys\n end",
"def columns\n @columns ||= begin\n column_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end",
"def column_fields(json=true)\n data = @data.map do |data|\n data = data.dup\n editor = parse_column_editor(data.delete(\"editor\"))\n renderer = parse_column_renderer(data.delete(\"renderer\"))\n data.merge!(editor) if editor\n data.merge!(renderer) if renderer\n data.delete(\"method\")\n data.delete(\"mapping\")\n data\n end\n json ? JSON.pretty_generate(data) : data\n end",
"def sql_for_columns; @sql_for_columns end",
"def setup_type_convertor_map\n super\n @type_convertor_map[Java::JavaSQL::Types::INTEGER] = @type_convertor_map[Java::JavaSQL::Types::BIGINT]\n @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] = @basic_type_convertor_map[Java::JavaSQL::Types::BIGINT]\n @type_convertor_map[Java::JavaSQL::Types::DATE] = lambda do |r, i|\n if v = r.getString(i)\n Sequel.string_to_date(v)\n end\n end\n @type_convertor_map[Java::JavaSQL::Types::BLOB] = lambda do |r, i|\n if v = r.getBytes(i)\n Sequel::SQL::Blob.new(String.from_java_bytes(v))\n elsif !r.wasNull\n Sequel::SQL::Blob.new('')\n end\n end\n end",
"def map_value(column_type)\n case column_type\n when :datetime then :timestamp\n when :json then :string\n else column_type\n end\n end",
"def to_s_columns(columns = T.unsafe(nil)); end",
"def map_values(row, columns)\n values = columns.map do |v|\n # TODO - stw - which other cases do we need to handle?\n case v[1]\n when /int/: \n row[v[0]] || 'NULL'\n else \n (row[v[0]].nil? ? 'NULL' : \"'\" + @db1.escape_string(row[v[0]].to_s) + \"'\")\n end\n end\n values = values.join(',') \n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def synthetic_columns\n @columns ||= [:id]\n end",
"def data\n datacolumns.reduce({}) do |t, col|\n t[col.name] = col.data; t\n end\n end",
"def table_columns(table)\n fields = db_client.query(\"SHOW FIELDS FROM #{table['name']}\")\n columns = {}\n fields.each do |field|\n if (table['columns'].nil? || table['columns'].include?(field['Field']))\n t = field['Type']\n t = 'varchar' if t.start_with?('varchar')\n t = 'decimal' if t.start_with?('decimal')\n t = 'int' if (t.start_with?('int') || t.start_with?('tinyint') || t.start_with?('bigint') || t.start_with?('smallint'))\n if !(COLUMN_TYPES.include?(t))\n raise \"Unknown column type #{t}, exiting.\"\n end\n columns[field['Field']] = t\n end\n end\n columns\n end",
"def columns\n _columns || columns!\n end",
"def columns; self.class.columns; end",
"def columns(table_name, name = nil) #:nodoc:\n cdef = column_definitions(table_name)\n cdef = cdef.collect(&:values) if cdef.size > 0 && cdef.first.is_a?(Hash)\n cdef.collect do |name, type, default, notnull|\n col = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new(name, default, type, notnull == \"f\")\n raw_geom_info = PostgresGis::RawGeomInfo.from_sql_type(type)\n col.set_gis(raw_geom_info.srid, raw_geom_info.with_z, raw_geom_info.with_m, raw_geom_info.geographic)\n col\n end\n end",
"def columns\n @columns = columns_hash.values\n end",
"def columns\n end",
"def to_fields(fields, mapping_method)\n fields.each { |field| to_field field, mapping_method }\n end",
"def dbd_types (model,model_attributes)\n #hard coded mapping look mapping table\n mapping = Hash[ \"binary\"=>\"base64Binary\",\"boolean\"=>\"boolean\",\"date\"=>\"date\",\"datetime\"=>\"dateTime\",\"decimal\"=>\"decimal\",\"float\"=>\"float\",\"integer\"=>\"integer\",\"string\"=>\"string\",\"text\"=>\"string\",\"time\"=>\"time\",\"timestamp\"=>\"dateTime\",]\n dtypes = Hash.new\n model.columns_hash.each_key do |m|\n #make xsd datatye\n dtypes[m.to_s] =\"xsd:#{mapping[model.columns_hash[m].type.to_s] }\"\n end\n #replace mapping\n model_attributes.each do |k,v|\n dtypes[k.to_s]=dtypes[v.to_s]\n end\n dtypes\n end",
"def expected_columns; end",
"def attributes\n [type, column_options]\n end",
"def types\n must_be_open!\n @columns.map(&:last)\n end",
"def columns(table_name, name = nil)#:nodoc:\n sql = \"SHOW FIELDS FROM #{quote_table_name(table_name)}\"\n columns = []\n result = execute(sql, name)\n result.each do |field|\n klass = field[1] =~ /geometry|point|linestring|polygon|multipoint|multilinestring|multipolygon|geometrycollection/i ? ActiveRecord::ConnectionAdapters::SpatialMysql2Column : ActiveRecord::ConnectionAdapters::Mysql2Column\n columns << klass.new(field[0], field[4], field[1], field[2] == \"YES\")\n end\n columns\n end",
"def cast_types; end",
"def set_raw_columns(cols)\n @columns = cols.collect { |args| Column.new(*args) }\n end",
"def geography_columns; end",
"def query_columns\n explicit_columns\n end",
"def map_datapackage_column_types(datapackage_json, csv_name)\n csv_dp_detail = datapackage_json[\"resources\"].detect{ |a| a[\"path\"] == csv_name }\n dp_column_types = {}\n csv_dp_detail[\"schema\"][\"fields\"].each do |sf|\n dp_column_types[sf[\"name\"]] = DATAPACKAGE_TYPE_MAP[sf[\"type\"]]\n end\n dp_column_types\n end",
"def db_columns\n @db_columns = {}\n\n field_types.each do |field_name, field_type|\n ft = field_type.to_s\n config = {\n type: ft\n }\n\n config[:array] = true if array_fields&.dig(field_name)\n\n @db_columns[field_name] = config\n end\n\n @db_columns\n end",
"def column_for_attribute(method)\n if method.to_s == \"value\" && [VTYPE_BOOLEAN,\n VTYPE_NUMBER,\n VTYPE_DATETIME].include?(self.vtype)\n dressed_like_column = OpenStruct.new(\n name: \"value\", type: nil, sql_type: nil, klass: nil,\n coder: nil, default: false, null: true, primary: false,\n limit: nil, precision: nil, scale: nil\n )\n case self.vtype\n when VTYPE_BOOLEAN\n dressed_like_column.type = :boolean\n dressed_like_column.sql_type = \"boolean\"\n dressed_like_column.klass = Object\n when VTYPE_NUMBER\n dressed_like_column.type = :decimal\n dressed_like_column.sql_type = \"numeric\"\n dressed_like_column.klass = BigDecimal\n when VTYPE_DATETIME\n dressed_like_column.type = :datetime\n dressed_like_column.sql_type = \"timestamp without time zone\"\n dressed_like_column.klass = Time\n end\n dressed_like_column\n else\n super(method)\n end\n end",
"def add_column_types obj\n FbArray.new(obj)\n end",
"def rows_as_native\n unless @rows_as_native\n @rows_as_native = @rows.collect { |row| Array.new(row.size) { |i| @columns[i].type.translate(row[i]) } }\n end\n @rows_as_native\n end",
"def type(column); self[column]['type']; end",
"def format_schema_helper(hsh)\n hsh = map_data_types(hsh)\n hsh.map { |column_name,column_type| [\"#{column_type}\".to_sym,\"#{column_name}\"] }\n end",
"def load_schema!\n @columns_hash = _projection_fields.except(*ignored_columns)\n\n @columns_hash.each do |name, column|\n define_attribute(\n name,\n connection.lookup_cast_type_from_column(column),\n default: column.default,\n user_provided_default: false\n )\n end\n end",
"def column_methods_hash #:nodoc:\n @dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr|\n attr_name = attr.to_s\n methods[attr.to_sym] = attr_name\n methods[\"#{attr}=\".to_sym] = attr_name\n methods[\"#{attr}?\".to_sym] = attr_name\n methods[\"#{attr}_before_type_cast\".to_sym] = attr_name\n methods\n end\n end",
"def to_a\n @table.columns.map { |col| @attributes[col] }\n end",
"def spatial_columns!\n geometry_columns! + geography_columns!\n end",
"def set_column_mapping\n @columns_maps = {}\n\n column_alias = MC_COLUMNS_ALIAS.invert\n\n # check if column name in worksheet has an alias - if so - save the column id\n column_names = get_columns_names\n column_names.each_index do |i|\n if column_alias[column_names[i]] != nil\n @columns_maps[column_alias[column_names[i]]] = i\n end\n end\n\n @columns_maps # we return it only for tests\n end",
"def columns\n @pz.group_by.each_with_index { |val, n| column_id(n) }\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def columns\r\n # TODO: transpose possibly doesn't work for rectangular (non-square) maps\r\n @all_columns ||= rows.transpose\r\n end",
"def columns\n unless @columns\n @columns = collection_info[table_name].columns.collect { |col_def|\n col = ActiveRecord::ConnectionAdapters::Column.new(col_def.name, col_def.default, col_def.sql_type, col_def.null)\n col.primary = col.name == primary_key\n col\n }\n end\n @columns\n end",
"def types_from_array_records(samples)\n columnar_types = []\n samples.each do |record|\n record.each_with_index {|value,i| (columnar_types[i] ||= []) << guess_type(value) }\n end\n columnar_types.map {|types| merge_types(types) }\n end",
"def type_cast(table, row)\n @table_columns ||= {}\n unless @table_columns.include?(table)\n column_array = session.left.columns(table)\n column_hash = {}\n column_array.each {|column| column_hash[column.name] = column}\n @table_columns[table] = column_hash\n end\n columns = @table_columns[table]\n type_casted_row = {}\n row.each_pair do |column_name, value|\n type_casted_row[column_name] = columns[column_name].type_cast(value)\n end\n type_casted_row\n end",
"def column_for_attribute(attr)\n FauxColumnInfo.new(self.class.types[attr])\n end",
"def columns\n single_record unless @columns\n @columns || []\n end",
"def columns\n @columns\n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def columns_for_search\n self.entity_columns.select(\"name, ref_type, ref_name, col_type\")\n end",
"def to_a\n columns\n end",
"def columns( table )\n sanity_check\n @handle.columns( table ).collect {|col| ColumnInfo.new(col) }\n end",
"def label_columns\n ensure_full_data!\n Array(@gapi_json[:labelColumns]).map do |field_gapi_json|\n field_gapi = Google::Apis::BigqueryV2::StandardSqlField.from_json field_gapi_json.to_json\n StandardSql::Field.from_gapi field_gapi\n end\n end",
"def cast_data_for_column(data, col)\n if !@columns\n raise \"need to fetch columns but in a query\"\n end\n\n case @columns[col][:type]\n when /boolean/i\n return data == true ? 1 : 0\n when /datetime/i\n return (data == nil ? nil : data.to_i)\n when /integer/i\n return (data == nil ? nil : data.to_i)\n else\n return data\n end\n end",
"def fields_to_classify\n columns = klass.columns_hash\n columns.select { |key| columns[key].type == :string }.keys\n end",
"def columns(table_name, name = nil)\n column_info = SpatialColumnInfo.new(self, quote_string(table_name.to_s))\n # Limit, precision, and scale are all handled by the superclass.\n column_definitions(table_name).map do |column_name, type, default, notnull, oid, fmod|\n # JDBC gets true/false in Rails 4, where other platforms get\n # 't'/'f' strings.\n if(notnull.is_a?(String))\n notnull = (notnull == 't')\n end\n\n oid = column_type_map.fetch(oid.to_i, fmod.to_i) { OID::Identity.new }\n SpatialColumn.new(@rgeo_factory_settings,\n table_name,\n column_name,\n default,\n oid,\n type,\n !notnull,\n column_info.get(column_name, type))\n end\n end",
"def fixup_columns\n @columns.each_index do |idx| \n\n if @columns[idx][:searchable].nil? then\n @columns[idx][:searchable] = @model_class.column_methods_hash[@columns[idx][:id].intern] ? true : false\n end\n @columns[idx][:query] = @columns[idx][:id] if @columns[idx][:query].nil?\n \n if @columns[idx][:sortable].nil? then\n @columns[idx][:sortable] = @columns[idx][:query] == false ? false : true\n end\n \n end\n end",
"def columns\n @columns.to_enum\n end"
] | [
"0.71485853",
"0.6956067",
"0.6920979",
"0.6796395",
"0.6789203",
"0.6781656",
"0.6765806",
"0.6754353",
"0.6662339",
"0.66538286",
"0.6539466",
"0.6534895",
"0.65174633",
"0.64978445",
"0.6494216",
"0.64723724",
"0.64312786",
"0.6411026",
"0.63987535",
"0.6382866",
"0.6366044",
"0.63574886",
"0.6351054",
"0.62907064",
"0.6289073",
"0.6281415",
"0.62725",
"0.6271028",
"0.62677276",
"0.62653303",
"0.6264032",
"0.62600535",
"0.62433803",
"0.62304586",
"0.621835",
"0.6191943",
"0.61844146",
"0.6182395",
"0.6167552",
"0.61599356",
"0.61412895",
"0.61412334",
"0.6131755",
"0.6130464",
"0.6116704",
"0.61085206",
"0.6096899",
"0.6083593",
"0.6074034",
"0.60738146",
"0.6061133",
"0.60354286",
"0.60334104",
"0.60306484",
"0.60180545",
"0.6017329",
"0.60145384",
"0.6013275",
"0.6006596",
"0.6003087",
"0.5975034",
"0.5970327",
"0.59690076",
"0.59656715",
"0.5964158",
"0.5951179",
"0.5941424",
"0.59409493",
"0.5938825",
"0.5916163",
"0.591529",
"0.5914125",
"0.5912189",
"0.59092844",
"0.5904404",
"0.5895058",
"0.58907557",
"0.5881328",
"0.58789414",
"0.58668905",
"0.5866393",
"0.58584225",
"0.5857828",
"0.5848726",
"0.5835609",
"0.5830696",
"0.5830242",
"0.582929",
"0.58291954",
"0.5814764",
"0.58119327",
"0.58103067",
"0.5803496",
"0.5798671",
"0.5796452",
"0.5793777",
"0.5789247",
"0.57845575",
"0.5778967",
"0.5770181"
] | 0.6365645 | 21 |
PUT /grants/1 PUT /grants/1.json | def update
@grant = Grant.find(params[:id])
respond_to do |format|
if @grant.update_attributes(params[:grant])
format.html { redirect_to @grant, :notice => 'Grant was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.json { render :json => @grant.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @grant = Grant.find(params[:id])\n\n respond_to do |format|\n if @grant.update_attributes(params[:grant])\n format.html { redirect_to root_url, notice: 'Training was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @grant.update(grant_params)\n format.html { redirect_to grants_url, notice: 'Grant was successfully updated.' }\n format.json { render :index, status: :ok, location: @grant }\n else\n format.html { render :edit }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @grant.update(grant_params)\n format.html { redirect_to @grant, notice: \"Grant was successfully updated.\" }\n format.json { render :show, status: :ok, location: @grant }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @grant = current_user.grants.new(grant_params)\n authorize(@grant)\n\n respond_to do |format|\n if @grant.save\n format.html { redirect_to @grant, notice: \"Grant was successfully created.\" }\n format.json { render :show, status: :created, location: @grant }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @grantee.update(grantee_params)\n format.html { redirect_to @grantee, notice: 'Grantee was successfully updated.' }\n format.json { render :show, status: :ok, location: @grantee }\n else\n format.html { render :edit }\n format.json { render json: @grantee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_tenant_scope(args = {}) \n put(\"/tenants.json/scope/#{args[:tenantId]}\", args)\nend",
"def assign_tenants_to_circle(args = {}) \n body_put(\"/tenantcircles.json/tenants/#{args[:circleId]}\", args[:array_of_ids])\nend",
"def update\n @grant_record = GrantRecord.find(params[:id])\n\n respond_to do |format|\n if @grant_record.update_attributes(params[:grant_record])\n format.html { redirect_to @grant_record, :notice => 'Grant record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @grant_record.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @grant.update(grant_params)\n format.html { redirect_to grants_path, notice: 'تمّ تعديل منحة بنجاح' }\n format.json { render :show, status: :ok, location: @grant }\n else\n format.html { render :edit }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end",
"def tenant_update(name, description, id)\n\t\n\t\tif(name.length != 0 and description.length != 0 and id.length != 0)\n\t\t\ttenant = {\"tenant\" => {\"name\" => name, \"description\" => description, \"enabled\" => true}}\n\t\tend\n\t\n\t\tjson_string = JSON.generate(tenant)\n\t\n\t\tpost_call = Curl::Easy.http_post(\"#{@ip_address}:#{@port_2}/tenants/#{id}\", json_string\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['Content-Type'] = 'application/json'\n\t\tend\n\t\tparsed_json = JSON.parse(post_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def grant\n self.status = 'granted'\n save\n end",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def set_grant\n @grant = Grant.find(params[:id])\n end",
"def set_grant\n @grant = Grant.find(params[:id])\n end",
"def update\n @conference_grant = ConferenceGrant.find(params[:id])\n\n respond_to do |format|\n if @conference_grant.update_attributes(params[:conference_grant])\n format.html { redirect_to @conference_grant, notice: 'Conference grant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conference_grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @grant = Grant.find(params[:id])\n @grant.destroy\n\n respond_to do |format|\n format.html { redirect_to grants_url }\n format.json { head :ok }\n end\n end",
"def create\n @grant = Grant.new(grant_params)\n\n respond_to do |format|\n if @grant.save\n format.html { redirect_to grants_url, notice: 'Grant was successfully created.' }\n format.json { render :index, status: :created, location: @grant }\n else\n format.html { render :new }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @tenant.update(tenant_params)\n p_id = Property.searchSecond(@tenant.tenantbuildinginfo)\n Property.find_by(id: p_id).tenants << @tenant\n format.html { redirect_to @tenant, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { render :edit }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n\n if params[:generate_lease]\n generate_lease(@tenant)\n elsif params[:expense_add]\n expense_addendum(@tenant)\n else\n #do nothing\n end\n\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def add_user_for_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/users\", args)\nend",
"def update\n respond_to do |format|\n if @tenancy.update(tenancy_params)\n format.html { redirect_to @tenancy, notice: 'Tenancy was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenancy }\n else\n format.html { render :edit }\n format.json { render json: @tenancy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_to_specified_shard(args = {}) \n post(\"/tenants.json/shard/#{args[:shardId]}\", args)\nend",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def update\n @tenant = Tenant.find(params[:id])\n\n respond_to do |format|\n if @tenant.update_attributes(params[:tenant])\n format.html { redirect_to @tenant, notice: 'Tenant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @gift.user == @current_user\n if @gift.update(gift_params)\n render json: @gift, include: :ages\n else\n render json: @gift.errors, status: :unprocessable_entity\n end\n else\n render json: { errors: \"not authorized\" }, status: :unauthorized\n end\n end",
"def update\n customer = Customer.find_by_authentication_token(params[:token])\n pwd = 111111 #SecureRandom.hex(4)\n if customer.blank?\n render json: {\n message: \"Impossible d'activer ce badge\"\n }\n else\n #on met à jour les informations\n query = customer.update(\n name: params[:name],\n second_name: params[:second_name],\n cni: params[:cni],\n phone: params[:phone],\n sexe: params[:sexe],\n two_fa: params[:authenticated],\n password: pwd\n )\n\n #verification de la mise a jour\n Sms.new(params[:phone], \"Votre mot de passe est #{pwd}, conservez en toute securité\")\n end\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n @grant_round = GrantRound.find(params[:id])\n\n if @grant_round.update(grant_round_params (params[:grant_round]))\n head :no_content\n else\n render json: @grant_round.errors, status: :unprocessable_entity\n end\n end",
"def update\n @claimant = Claimant.find(params[:id])\n\n respond_to do |format|\n if @claimant.update_attributes(params[:claimant])\n format.html { redirect_to @claimant, notice: 'Claimant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @claimant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def authorise\n # checks can go here (is the application registered for example)\n grant = generate_grant\n valid_grants << grant\n grant\n end",
"def update\n @grave.updated_by_id = current_user.id\n respond_to do |format|\n if @grave.update(grave_params)\n format.html { redirect_to graves_url, notice: 'Grave was successfully updated.' }\n format.json { render :show, status: :ok, location: @grave }\n else\n format.html { render :edit }\n format.json { render json: @grave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_grantee\n @grantee = Grantee.find(params[:id])\n end",
"def update\n @granted_scope = GrantedScope.find(params[:id])\n\n respond_to do |format|\n if @granted_scope.update_attributes(params[:granted_scope])\n format.html { redirect_to @granted_scope, notice: 'Granted scope was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @granted_scope.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @grant.destroy\n respond_to do |format|\n format.html { redirect_to grants_url, notice: 'Grant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grant.destroy\n respond_to do |format|\n format.html { redirect_to grants_url, notice: \"Grant was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def update\n data = tenant_update_params\n tookan = {\"api_key\": \"50646180f541481e4c422b614c5825431be3c2f82fd57936541c03\",\"customer_id\": @tenant.customer_id,\"user_type\": 0,\"name\": data[:name],\"phone\": data[:phone1],\"email\": data[:email],\"address\": data[:address],\"latitude\": data[:latitude],\"longitude\": data[:longitude]}\n response = RestClient.post \"https://api.tookanapp.com/v2/customer/edit\", tookan.to_json, :content_type => \"application/json\"\n response = JSON.parse(response)\n respond_to do |format|\n if response[\"status\"] == 200\n if @tenant.update(tenant_update_params)\n food_category = FoodCategory.find_or_create_by(name: \"Veg\")\n @tenant.tenant_details.update(food_category_id: food_category.id)\n if @tenant.active == true\n end\n end\n @tenant.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { redirect_to tenants_url, notice: 'Tenant was not updated.' }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\nend",
"def set_grant\n @grant = Grant.find(params[:id])\n rescue\n @grant = Grant.find(params[:grant_id])\n end",
"def update\n authorize! :update, @gf_travel_request\n respond_to do |format|\n if @gf_travel_request.update(grant_funded_travel_request_params)\n format.html { redirect_to @gf_travel_request, notice: 'Grant funded travel request was successfully updated.' }\n format.json { render :show, status: :ok, location: @gf_travel_request }\n else\n format.html { render :edit }\n format.json { render json: @gf_travel_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def permission_grants=(value)\n @permission_grants = value\n end",
"def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @person.authorizer = current_person\n\n respond_to do |format|\n if @person.update(person_params)\n @person.invite!(current_person) if params['resend_invite']=='true' \n \n format.html { redirect_to :people, notice: 'Profile successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tenancy_agreement = TenancyAgreement.find(params[:id])\n\n respond_to do |format|\n if @tenancy_agreement.update_attributes(params[:tenancy_agreement])\n format.html { redirect_to tenancy_agreements_path, notice: 'Tenancy agreement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenancy_agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:user_goal_id] && params[user_id]\n goals = @user.update!(user_goal_params)\n render json: goals, status: :accepted\n end\n end",
"def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def grant_params\n params.require(:grant).permit(:user_id, :entry_id, :status)\n end",
"def update\n @tenant_user = TenantUser.find(params[:id])\n\n respond_to do |format|\n if @tenant_user.update_attributes(params[:tenant_user])\n format.html { redirect_to @tenant_user, notice: 'Tenant user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenant_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reset_tenant_scope_to_default \n put(\"/tenants.json/scope/clear\")\nend",
"def update\n @tenant = Tenant.find(params[:id])\n\n respond_to do |format|\n if @tenant.update_attributes(params[:tenant])\n format.html { redirect_to(@tenant, :notice => 'tenant was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tenant.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @user = User.find(params[:id])\n user = @user.attributes\n user[\"role\"] = 2\n @user.update!(user)\n admin_params = Administrator.new.attributes\n admin_params[\"superadmin\"] = 0\n admin_params[\"user\"] = @user\n admin_params[\"geofence\"] = Geofence.first\n @administrator = Administrator.new(admin_params)\n respond_to do |format|\n if @administrator.save\n format.html { redirect_to administrators_path, notice: 'Administrator was successfully created.' }\n format.json { render :show, status: :created, location: @administrator }\n else\n format.html { render :new }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def b_admin\n @user = User.find(params[:id])\n @user.admin = true\n @user.save\n render json: { message: 'User is now an admin you can test the houses endpoint now.' }\n end",
"def update_profile(body={})\n perform_post(\"/account/update_profile.json\", :body => body)\nend",
"def update\n @guarantor = Guarantor.find(params[:id])\n\n respond_to do |format|\n if @guarantor.update_attributes(params[:guarantor])\n format.html { redirect_to @guarantor, notice: 'Guarantor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @guarantor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def put!\n request! :put\n end",
"def update\n errors = {}\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if params[:person]\n begin\n if @person.json_update_attributes(params[:person])\n render_json :entry => @person.to_hash(@user, @client) and return\n end\n rescue NoMethodError => e\n errors = e.to_s\n end\n end\n\n render_json :status => :bad_request, :messages => @person.errors.full_messages\n @person = nil\n end",
"def update\n @plant = Plant.find(params[:id])\n if @plant.user != current_user\n return render text: 'Not Allowed', status: :forbidden\n end\n\n @plant.update_attributes(plant_params)\n if @plant.valid?\n redirect_to edit_plant_path(@plant)\n else\n render :edit, status: :unprocessable_entity\n end\n end",
"def update\n @sundry_grn = SundryGrn.find(params[:id])\n\n respond_to do |format|\n if @sundry_grn.update_attributes(params[:sundry_grn])\n format.html { redirect_to @sundry_grn, :notice => 'Sundry grn was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sundry_grn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @mutant.update(mutant_params)\n render :show, status: :ok, location: api_v1_mutant_url(@mutant)\n else\n render json: @mutant.errors, status: :unprocessable_entity\n end\n end",
"def update\n # this action is not provided for partyroles\n end",
"def update\n if not check_logged_in then\n return\n end\n\n @plant = Plant.find(params[:id])\n\n respond_to do |format|\n if @plant.update_attributes(params[:plant])\n format.html { redirect_to @plant, notice: 'Plant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n assign_if_empty\n if @tenant.update(tenant_params)\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { render :edit }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@user = User.find(params[:id])\n \n if @gym.update(gym_params)\n render JSON: @gym\n else\n render JSON: @gym.errors, status: :unprocessable_entity\nend\nend",
"def set_tenancy\n @tenancy = Tenancy.find(params[:id])\n end",
"def update!(**args)\n @allow_tenants = args[:allow_tenants] if args.key?(:allow_tenants)\n @default_tenant_location = args[:default_tenant_location] if args.key?(:default_tenant_location)\n end",
"def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend",
"def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend",
"def update\n account = current_organization.accounts.find(params[:id])\n return forbidden unless account && current_account.allowed_to_edit_account?(account, current_organization)\n return json(account) unless account.update_attributes pick(params, :first_name, :last_name, :email,:language, :document_language)\n\n role = pick(params, :role)\n #account.update_attributes(role) if !role.empty? && current_account.admin?\n membership = current_organization.role_of(account)\n membership.update_attributes(role) if !role.empty? && current_account.admin?\n password = pick(params, :password)[:password]\n if (current_account.id == account.id) && password\n account.update(password: password)\n end\n json account.canonical(membership: membership)\n end",
"def update\n respond_to do |format|\n if @tenant.update(tenant_params)\n format.html { redirect_to @tenant, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { render :edit }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end",
"def edit\n @therapist_consent = TherapistConsent.find(params[:id])\n respond_to do |format|\n format.html { render action: 'edit' }\n format.json { render :status => 200, :json => { action: 'edit', therapist_consent: @therapist_consent}}\n end\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n #@user = User.find(params[:id])\n \n if @trainer.update(trainer_params)\n render json: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\nend",
"def update\n respond_to do |format|\n if @uniform.update(uniform_params)\n format.html { redirect_to @uniform, notice: 'Uniform was successfully updated.' }\n format.json { render :show, status: :ok, location: @uniform }\n else\n format.html { render :edit }\n format.json { render json: @uniform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end",
"def create\n @tenant = keystone.create_tenant({:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n \n format.html { redirect_to @tenant, :notice => 'Tenant was successfully created.' }\n format.json { render :json => @tenant, :status => :created, :location => @tenant }\n \n end\n end",
"def update_array_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/arrays/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n #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 @taker = Taker.find(params[:id])\n\n respond_to do |format|\n if @taker.update_attributes(params[:taker])\n format.html { redirect_to @taker, notice: 'Taker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rant = Rant.find(params[:id])\n\n respond_to do |format|\n if @rant.update_attributes(params[:rant])\n format.html { redirect_to(@rant, :notice => 'Rant was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rant.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @accountant.update(accountant_params)\n format.html { redirect_to @accountant, notice: 'Accountant was successfully updated.' }\n format.json { render :show, status: :ok, location: @accountant }\n else\n format.html { render :edit }\n format.json { render json: @accountant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end",
"def claim\n put :claim\n end",
"def set_and_authorize_grant\n @grant = Grant.find_by(slug: params[:id]) || Grant.find(params[:id])\n authorize(@grant)\n\n @grant\n end",
"def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def update\n @gaz_assay = GazAssay.find(params[:id])\n @authorized_user = User.find(session[:user_id])\n respond_to do |format|\n if @gaz_assay.update_attributes(params[:gaz_assay])\n format.html { redirect_to gaz_assays_url, notice: 'Данные качественного анализа газа успешно скорректированы.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gaz_assay.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n UserComposite.new( user_params.merge(id: params[:id]) ).update!\n render json: StatusSerializer.new(:accepted), status: :accepted\n rescue ActiveRecord::RecordInvalid => ex\n render json: UserSerializer.new( ex.record ), status: :unprocessable_entity\n end",
"def new\n @grant = Grant.new\n\n respond_to do |format|\n format.html { render :layout => false } # new.html.erb\n format.json { render json: @grant }\n end\n end",
"def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend",
"def update\n @stress = current_user.stresses.find(params[:id])\n\n respond_to do |format|\n if @stress.update_attributes(params[:stress])\n flash[:notice] = 'Stress was successfully updated.'\n format.html { redirect_to(@stress) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n head :unauthorized\n end",
"def update\n @grm = Grm.find(params[:id])\n\n respond_to do |format|\n if @grm.update_attributes(params[:grm])\n format.html { redirect_to @grm, notice: 'Grm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @grm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @gather = Gather.find(params[:id])\n\n respond_to do |format|\n if @gather.update_attributes(params[:gather])\n format.html { redirect_to @gather, notice: 'Gather was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gather.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.64853686",
"0.62773246",
"0.6226604",
"0.61623996",
"0.61225176",
"0.60765207",
"0.6064201",
"0.5903576",
"0.58978826",
"0.57945323",
"0.57646036",
"0.5749848",
"0.566394",
"0.5653271",
"0.56494325",
"0.5623392",
"0.5623392",
"0.56206733",
"0.56206733",
"0.5608681",
"0.5594841",
"0.55873984",
"0.55837506",
"0.5549604",
"0.5539512",
"0.55366725",
"0.5515513",
"0.55018544",
"0.5496914",
"0.5474648",
"0.5456473",
"0.54518926",
"0.54273343",
"0.54261845",
"0.5418913",
"0.5415074",
"0.5395885",
"0.5385893",
"0.53808904",
"0.5378908",
"0.53650236",
"0.53586304",
"0.5350206",
"0.5336145",
"0.53331774",
"0.5329618",
"0.5323481",
"0.5317852",
"0.5316335",
"0.53019357",
"0.5296466",
"0.5291727",
"0.52915984",
"0.5290898",
"0.5289172",
"0.52778685",
"0.5268857",
"0.5259858",
"0.52584356",
"0.5231076",
"0.5216422",
"0.5216221",
"0.5214555",
"0.52142435",
"0.5210707",
"0.51919967",
"0.5189618",
"0.51880777",
"0.5184263",
"0.5182927",
"0.5182048",
"0.5182048",
"0.5177527",
"0.5176984",
"0.5170812",
"0.516297",
"0.51585436",
"0.5157006",
"0.51503795",
"0.51500833",
"0.5147628",
"0.5144355",
"0.5142758",
"0.51389873",
"0.51368636",
"0.5132947",
"0.51310813",
"0.51287305",
"0.5120756",
"0.5119294",
"0.5118483",
"0.5117983",
"0.5109788",
"0.51096207",
"0.5094099",
"0.508968",
"0.50890964",
"0.50877076",
"0.5087572",
"0.5084261"
] | 0.6564642 | 0 |
Very permissive. Might get unnecessary reloads. That's okay. | def pm_is_in_ancestry?(vc, screen_names)
screen_names.any? do |screen_name|
vc.class.to_s.include?(screen_name) ||
vc.class.ancestors.any? do |ancestor|
screen_name.include?(ancestor.to_s)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pausable; end",
"def private; end",
"def reloader; end",
"def reloader; end",
"def used?; end",
"def reload!\n begin\n #TODO not implemented 2007/04/09 by shino\n raise \"not yet implemented!\"\n end\n end",
"def reload!\n begin\n #TODO not implemented 2007/04/09 by shino\n raise \"not yet implemented!\"\n end\n end",
"def reload!\n begin\n #TODO not implemented 2007/04/09 by shino\n raise \"not yet implemented!\"\n end\n end",
"def reload!\n begin\n #TODO not implemented 2007/04/09 by shino\n raise \"not yet implemented!\"\n end\n end",
"def freeze; end",
"def refutal()\n end",
"def autorestore; end",
"def refork; end",
"def safe_by_default; end",
"def reload!; end",
"def reload!; end",
"def reload!; end",
"def reload!; end",
"def lock; end",
"def lock; end",
"def lock; end",
"def reload\n raise 'not implemented'\n end",
"def internal; end",
"def permanent; end",
"def reload;end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def preload=(_); end",
"def preload=(_); end",
"def freeze() end",
"def freeze() end",
"def load!; end",
"def prepareForReuse; end",
"def sharded?; true; end",
"def singleton0_cache; end",
"def old_sync; end",
"def access_locked?; end",
"def safe; end",
"def post_hard_load(mod); end",
"def preload; end",
"def preload; end",
"def sharded?; false; end",
"def loaded()\n end",
"def locked; end",
"def instance_cache; end",
"def singleton_cache; end",
"def dirty; end",
"def storage; end",
"def load; end",
"def load; end",
"def load; end",
"def frozen?; end",
"def cached?; end",
"def restore; end",
"def refresh!; end",
"def lock!; end",
"def probers; end",
"def if_access_locked; end",
"def allow_concurrency; end",
"def allow_concurrency; end",
"def internal?; end",
"def freeze\n end",
"def freeze\n end",
"def sharing \n end",
"def load_error; end",
"def escaper=(_); end",
"def interface_cache; end",
"def disable_caching=(_arg0); end",
"def global; end",
"def refresh; end",
"def move_to_cache\n true\n end",
"def post_soft_load(mod); end",
"def one_singleton_ancestors_cache; end",
"def reload\n end",
"def reload\n end",
"def phantom_load_raise?(e); end",
"def requires_reloading?\n false\n end",
"def defuse!\n @@mutex.synchronize { @defused = true }\n end",
"def disable_caching; end",
"def placebo?; false end",
"def isolated; end",
"def isolated; end",
"def hijacked; end",
"def global?; end",
"def move_to_cache\r\n true\r\n end",
"def requires_reloading?\n false\n end",
"def requires_reloading?\n false\n end",
"def requires_reloading?\n false\n end",
"def used?\n true\n end",
"def move_to_cache\n true\n end",
"def move_to_cache\n true\n end",
"def move_to_cache\n true\n end",
"def current_load\n NotImplementedError\n end",
"def loader; end",
"def reloadable?\n return false\n end"
] | [
"0.693961",
"0.6875048",
"0.6596903",
"0.6596903",
"0.65255535",
"0.65233326",
"0.65233326",
"0.65233326",
"0.65233326",
"0.6450183",
"0.6417622",
"0.63835275",
"0.63705623",
"0.63209975",
"0.6285962",
"0.6285962",
"0.6285962",
"0.6285962",
"0.6283785",
"0.6283785",
"0.6283785",
"0.6273254",
"0.61621255",
"0.6144045",
"0.61369264",
"0.613669",
"0.613669",
"0.613669",
"0.613669",
"0.613669",
"0.613669",
"0.613669",
"0.61320364",
"0.6121186",
"0.6121186",
"0.61158097",
"0.61158097",
"0.610065",
"0.60437065",
"0.6033321",
"0.6025629",
"0.60226774",
"0.60164154",
"0.6001867",
"0.5998642",
"0.5985025",
"0.5985025",
"0.597157",
"0.5965494",
"0.59524727",
"0.5936785",
"0.5934981",
"0.5933396",
"0.5911423",
"0.5908254",
"0.5908254",
"0.5908254",
"0.588938",
"0.587985",
"0.587846",
"0.5839229",
"0.583863",
"0.5818576",
"0.58158004",
"0.5802131",
"0.5802131",
"0.5796336",
"0.5795731",
"0.5795731",
"0.57909286",
"0.5789551",
"0.57859415",
"0.5780372",
"0.5778434",
"0.57762337",
"0.57758135",
"0.57698023",
"0.57623535",
"0.5758183",
"0.57542825",
"0.57542825",
"0.57481194",
"0.5741865",
"0.5736248",
"0.5729719",
"0.57292134",
"0.5722629",
"0.5722629",
"0.57182795",
"0.57047796",
"0.57025844",
"0.56956303",
"0.56956303",
"0.56956303",
"0.56942356",
"0.56846017",
"0.56846017",
"0.56846017",
"0.567367",
"0.56719565",
"0.5656175"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_blog_post
@blog_post = BlogPost.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def blog_post_params
params.require(:blog_post).permit(:title, :content, :published, :category_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params\n true\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def user_params\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def user_params\r\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def parameters\n nil\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\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 pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.71230334",
"0.70530915",
"0.69479465",
"0.6902122",
"0.67367256",
"0.67172784",
"0.6689043",
"0.66784793",
"0.6660117",
"0.6555213",
"0.6528485",
"0.6458438",
"0.6452378",
"0.6451654",
"0.64478326",
"0.6433326",
"0.6413599",
"0.6413599",
"0.63907677",
"0.63787645",
"0.63787645",
"0.6375229",
"0.63608277",
"0.635366",
"0.6283652",
"0.62798274",
"0.6245606",
"0.62283605",
"0.6224614",
"0.6223649",
"0.62118477",
"0.6207179",
"0.61780804",
"0.6173056",
"0.61674094",
"0.615996",
"0.6145132",
"0.613597",
"0.612235",
"0.6108622",
"0.6098955",
"0.60767287",
"0.6055062",
"0.60391796",
"0.60363555",
"0.6030472",
"0.6018476",
"0.60174584",
"0.60163116",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60052663",
"0.6003681",
"0.6001089",
"0.5996807",
"0.5994288",
"0.59942675",
"0.5984987",
"0.59827954",
"0.59777087",
"0.5975369",
"0.59706473",
"0.5966046",
"0.5965166",
"0.5965166",
"0.59577847",
"0.5952617",
"0.59503365",
"0.59480196",
"0.5943258",
"0.5931462",
"0.59299",
"0.5927073",
"0.5924737",
"0.5919184",
"0.5918459",
"0.591457",
"0.59142643",
"0.59062785",
"0.59054136",
"0.59047925",
"0.5902357",
"0.5900476",
"0.5898475",
"0.5898218",
"0.5895328"
] | 0.0 | -1 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts #GROUP BY will get rid of repeats
#projects have many pledges, pledges belong to projects
"SELECT projects.title, SUM(pledges.amount)
FROM pledges INNER JOIN projects ON pledges.project_id = projects.id
GROUP BY projects.title"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'music';\n\"\nend",
"def current_categories(db)\r\n\tretrieve_categories = '\r\n\tSELECT name FROM categories'\r\n\tcategories = db.execute(retrieve_categories)\r\nend",
"def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category\n\"SELECT projects.category, SUM(pledges.amount)\nFROM pledges\nINNER JOIN projects\nON pledges.project_id = projects.id \nWHERE projects.category = 'books';\"\nend",
"def selects_the_category_name_and_the_sum_total_of_the_all_its_pledges_for_the_books_category\n\"SELECT Projects.category, SUM(Pledges.amount) FROM Projects JOIN Pledges ON Pledges.project_id = Projects.id WHERE Projects.category = 'books';\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"Write your SQL query Here\"\nend",
"def categories()\n db = connect()\n db.execute('SELECT * FROM categories')\n end",
"def category()\n sql = \"SELECT * FROM categories WHERE id = $1 ORDER BY name;\"\n values = [@category_id]\n sql_result = SqlRunner.run(sql, values)\n return Category.new(sql_result[0])\n end",
"def get_category_name(category_id)\n db = SQLite3::Database.new \"#{$script_dir}/cfps.db\"\n category = db.get_first_value(\"select name from category where id = ?\", [category_id])\n\n return categor\nend",
"def projects\n where(:_type => ProjectCategory.name)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"Write your SQL query Here\"\n \"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title ORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n \"SELECT projects.title, SUM(amount) FROM projects\n INNER JOIN pledges ON project_id = projects.id\n GROUP BY title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY title\nORDER BY title\"\n\n# FROM owners\n# INNER JOIN cats_owners\n# ON owners.id = cats_owners.owner_id\n# JOIN cats ON cats_owners.cat_id = cats.id\n# WHERE cats_owners.owner_id = 2;\n\nend",
"def current_categorized_expenses(db, user_name)\r\n\tretrieve_categorized_expenses = '\r\n\tSELECT categories.name, amount FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE users.name = ?'\r\n\tcategorized_expenses = db.execute(retrieve_categorized_expenses, [user_name])\r\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n\"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY(projects.title) ;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n sql = <<-SQL\n SELECT projects.title, SUM(pledges.amount) FROM projects JOIN pledges ON pledges.project_id = projects.id GROUP BY projects.title;\n SQL\n\nend",
"def getCategories(_, _, _)\n @db.categories\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n <<-SQL\n SELECT projects.title , sum(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY pledges.project_id\n ORDER BY projects.title\n SQL\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"Write your SQL query Here\"\n \n\"SELECT projects.title, SUM(amount) \nFROM pledges \nINNER JOIN projects \nON pledges.project_id = projects.id GROUP BY projects.title;\"\nend",
"def category(id)\n db = connect()\n return db.execute('SELECT Id,Title FROM discussions WHERE CatId=?', id), db.execute('SELECT * FROM categories WHERE Id=?', id)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Write your SQL query Here\"\n \"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON pledges.project_id = projects.id GROUP BY projects.title ORDER BY title\"\nend",
"def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end",
"def get_category_id(category)\n db = SQLite3::Database.new \"#{$script_dir}/cfps.db\"\n category_id = db.get_first_value(\"select id from category where name = ?\", [category])\n\n return category_id\nend",
"def select(db); end",
"def select(db); end",
"def get_records_for_category categ\n if categ.nil? or categ == \"\"\n #return @records\n get_data \"select * from todo\"\n else\n #return @records.select { |row| row[0] == categ }\n get_data \"select * from todo where categ = '#{categ}' \"\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL \n SELECT projects.title, SUM(pledges.amount)\n FROM projects \n INNER JOIN pledges on projects.id = pledges.project_id \n GROUP BY projects.title\n ORDER BY projects.title\n SQL\nend",
"def project_statement\n project_clauses = []\n active_subprojects_ids = []\n\n active_subprojects_ids = project.descendants.active.map(&:id) if project\n if active_subprojects_ids.any?\n if has_filter?(\"subproject_id\")\n case operator_for(\"subproject_id\")\n when '='\n # include the selected subprojects\n ################\n # Smile specific : [project.id] + removed\n ids = values_for(\"subproject_id\").map(&:to_i)\n project_clauses << \"#{Project.table_name}.id IN (%s)\" % ids.join(',')\n when '!'\n # exclude the selected subprojects\n\n ################\n # Smile specific : [project.id] + removed\n ids = active_subprojects_ids - values_for(\"subproject_id\").map(&:to_i)\n project_clauses << \"#{Project.table_name}.id IN (%s)\" % ids.join(',')\n when '!*'\n # main project only\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n else\n # all subprojects\n project_clauses << \"#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}\"\n end\n elsif Setting.display_subprojects_issues?\n project_clauses << \"#{Project.table_name}.lft >= #{project.lft} AND #{Project.table_name}.rgt <= #{project.rgt}\"\n else\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n end\n elsif project\n project_clauses << \"#{Project.table_name}.id = %d\" % project.id\n end\n project_clauses.any? ? project_clauses.join(' AND ') : nil\n end",
"def select(sql, name = nil)\n raise NotImplementedError, \"select is an abstract method\"\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\nSQL\nend",
"def index\n\n # @sql = \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n @sql = params[:name].present? ? \"Projects.name ILIKE '#{'%'+params[:name]+'%'}' \" : \"Projects.name ILIKE '%' \"\n @sql += \"OR Projects.description ILIKE '#{'%'+params[:name]+'%'}' \" if params[:name].present?\n\n @sql += \"and Projects.category ILIKE '#{'%'+params[:categorysdigital]+'%'}' \" if params[:categorysdigital].present?\n if params[:categorysdigital].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysmarketing]+'%'}' \" if params[:categorysmarketing].present?\n end\n\n if params[:categorysdigital].present? || params[:categorysmarketing].present?\n @sql += \"or Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n else\n @sql += \"And Projects.category ILIKE '#{'%'+params[:categorysdesign]+'%'}' \" if params[:categorysdesign].present?\n end\n\n @sql += \"and Projects.progress = #{params[:progresspropose].to_i} \" if params[:progresspropose].present?\n if params[:progresspropose].present?\n @sql += \"or Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n else\n @sql += \"and Projects.progress = #{params[:progressselected].to_i} \" if params[:progressselected].present?\n end\n\n if params[:progressselected].present?\n @sql += \"or Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n else\n @sql += \"and Projects.progress = #{params[:progressclose].to_i} \" if params[:progressclose].present?\n end\n\n # @sql += \"ORDER progress\"\n @projects = Project.where(@sql).order(:progress)\n @count = @projects.count\n @count_tt = Project.count\n end",
"def projects_countries(site, category_id = nil)\n if category_id.present? && category_id.to_i > 0\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id\n inner join projects as p on p.id=pr.project_id\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n #{category_join}\n where p.primary_organization_id=#{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end",
"def projects_countries(site, category_id = nil)\n if category_id.present?\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id\n inner join projects as p on p.id=pr.project_id and (p.end_date is null OR p.end_date > now())\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n #{category_join}\n where p.primary_organization_id=#{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM pledges\nINNER JOIN projects \nON pledges.project_id = projects.id\nGROUP BY project_id\nORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n# Select projects title column and the sum of the pledges amount column\n# from the projects database,\n# join the pledges (Join table)\n# with projects.id and the pledges project id. Match these numbers\n# Group the tables together by Projects title and then\n# sort by projects.title\n\"SELECT Projects.title, SUM(Pledges.amount)\n FROM Projects\n JOIN Pledges\n ON Projects.id = Pledges.project_id\n GROUP BY Projects.title\n ORDER BY Projects.title;\n\"\nend",
"def get_project_name(id)\n con = PG::Connection.connect(\"localhost\",5432,nil,nil,\"aaa\",\"admin\")\n sql = \"SELECT name \"\n sql += \"FROM projects \"\n sql += \"WHERE id='#{id}' \"\n res = con.exec(sql)\n con.close\n name = \"NA\"\n name = res[0]['name'] if res.num_tuples > 0\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\n SELECT DISTINCT title ,SUM(amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title\n SQL\nend",
"def sql\n <<-SQL\n -- Search learning paths\n SELECT DISTINCT\n c.id,\n c.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_path' AS content_type,\n c.id AS learning_path_id,\n 0 AS learning_objective_id\n FROM courses c\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = c.id AND ts.taggable_type = 'LearningPath'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = c.id AND cc.contentable_type = 'LearningPath'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_course_worklow_clause}\n #{construct_name_sql}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning objectives\n SELECT DISTINCT\n cm.id,\n cm.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_objective' AS content_type,\n cm.context_id::bigint AS learning_path_id,\n cm.id::bigint AS learning_objective_id\n FROM context_modules cm\n INNER JOIN courses c\n ON c.id = cm.context_id\n AND cm.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = cm.id AND ts.taggable_type = 'LearningObjective'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = cm.id AND cc.contentable_type = 'LearningObjective'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('cm')}\n #{construct_name_sql('cm')}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning learning_event\n SELECT DISTINCT\n ct.id,\n ct.title AS name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_event' AS content_type,\n ct.context_id::bigint AS learning_path_id,\n ct.context_module_id::bigint AS learning_objective_id\n FROM content_tags ct\n INNER JOIN courses c\n ON c.id = ct.context_id\n AND ct.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = ct.id AND ts.taggable_type = 'LearningEvent'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = ct.id AND cc.contentable_type = 'LearningEvent'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('ct')}\n #{construct_name_sql('ct', 'title')}\n #{construct_all_tags_search('t', 'name')}\n SQL\n end",
"def get_category_name\n Category.find(:first, :select => ['name'],:conditions=>['has_complexity=?',false]).name rescue ''\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"\nSELECT \nProjects.title,\nSUM(Pledges.amount)\nFROM Pledges\nINNER JOIN Projects\nON Pledges.project_id = Projects.id\nGROUP BY Projects.title\nORDER BY Projects.title\n\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT Projects.title, SUM(pledges.amount) \nFROM projects \nJOIN pledges \nON Projects.id = pledges.project_id \nGROUP BY title\"; \nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nINNER JOIN pledges \nON projects.id=pledges.project_id\nGROUP BY projects.id\nORDER BY projects.title;\"\nend",
"def makeQueryTableAll(tableName)\n #sql = \"SELECT * FROM [\" << tableName << \"]\"\n sql = \"SELECT * FROM [\" << tableName << \"]\" << \" WHERE id < 3\"\n #puts(sql) #debug\n return sql\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n \"SELECT projects.title, sum_pledges FROM (SELECT pledges.project_id, SUM(pledges.amount) AS sum_pledges FROM pledges GROUP BY pledges.project_id) INNER JOIN projects ON projects.id = project_id ORDER BY projects.title\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n<<-SQL\nSELECT projects.title, SUM(pledges.amount) \nFROM projects \nINNER JOIN pledges on projects.id = pledges.project_id\nGROUP BY (pledges.project_id)\nORDER BY projects.title;\nSQL\nend",
"def category_totals(db, user_name, number)\r\n\tretrieve_totals = '\r\n\tSELECT categories.name, SUM(amount) FROM expenses\r\n\tJOIN users ON expenses.user_id = users.id\r\n\tJOIN categories ON expenses.category_id = categories.id\r\n\tWHERE categories.id = ?\r\n\tAND users.name = ?'\r\n\ttotals = db.execute(retrieve_totals, [number, user_name])[0]\r\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\r\n\"SELECT title, SUM(pledges.amount) FROM projects\r\nJOIN pledges ON projects.id = pledges.project_id\r\nGROUP BY projects.id\r\nORDER BY title ASC\"\r\nend",
"def add_category(db, category)\r\n\tnew_category = '\r\n\tINSERT INTO categories (name)\r\n\tVALUES (?)'\r\n\tdb.execute(new_category, [category])\r\nend",
"def select_category\n #Parbauda vai ekrans ir redzams\n @screens.screen_create_filter.visible?\n #Pievieno kategoriju no filtra datiem\n @screens.screen_create_filter.select_row(@filter_data.category)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"Select title, amount from projects, pledges where projects.id = pledges.id order by title ASC;\"\nend",
"def projects_countries(site, category_id = nil, organization_id = nil, location_id = nil)\n if category_id.present? && category_id.to_i > 0\n if site.navigate_by_cluster?\n category_join = \"inner join clusters_projects as cp on cp.project_id = p.id and cp.cluster_id = #{category_id}\"\n else\n category_join = \"inner join projects_sectors as pse on pse.project_id = p.id and pse.sector_id = #{category_id}\"\n end\n end\n\n if organization_id.present? && organization_id.to_i > 0\n organization_filter = \"and p.primary_organization_id = #{organization_id}\"\n end\n\n if location_id.present?\n location_filter = \"and c.id IN (#{location_id})\"\n end\n\n Country.find_by_sql(\n<<-SQL\nselect c.id,c.name,count(ps.*) as count from countries as c\n inner join countries_projects as pr on c.id=pr.country_id #{location_filter}\n inner join projects as p on p.id=pr.project_id and (p.end_date is null OR p.end_date > now()) #{organization_filter}\n inner join projects_sites as ps on p.id=ps.project_id and ps.site_id=#{site.id}\n inner join donations as dn on dn.project_id = p.id\n #{category_join}\n where dn.donor_id = #{self.id}\n group by c.id, c.name order by count DESC\nSQL\n ).map do |r|\n [r, r.count.to_i]\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON projects.id=pledges.project_id GROUP BY projects.title;\"\n## FROM - where are they talking to each other - where is the scotch tape\nend",
"def select(componentName, text, componentInfo=nil)\n $marathon.select(ComponentId.new(componentName, componentInfo), text.to_s)\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title,\n SUM(pledges.amount)\n FROM pledges\n INNER JOIN projects\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\n\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, \nSUM(pledges.amount) \nFROM projects\nJOIN pledges ON pledges.project_id = projects.id\nGROUP BY projects.title\nORDER BY projects.title ASC;\"\nend",
"def select_all(sql, name = nil) end",
"def select\n @pds_projects = PdsProject.includes(:company).where('ProjectID in (?)', PROJECT_LIST)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, sum(amount) AS pledge_amount\nFROM pledges\nJOIN projects\nWHERE pledges.project_id = projects.id\nGROUP BY project_id\nORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n <<-SQL\n SELECT\n title, sum(amount)\n FROM\n projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY\n title\n ORDER BY\n title\n SQL\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount )\nFROM projects \nJOIN pledges\nON projects.id = pledges.project_id \nGROUP BY projects.title \nORDER BY projects.title \";\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title,(SELECT SUM(pledges.amount))\n FROM projects\n INNER JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, sum(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY pledges.project_id\n ORDER BY projects.title ASC;\n \"\nend",
"def db_fetch\n \"SELECT *\" + from_table_where + sql_match_conditions\n end",
"def get_category(cate, limitl, limitr)\n return Product.find_by_sql(\"select * from products where tag like '%#{cate}%' order by id limit #{limitl}, #{limitr}\")\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount) FROM pledges INNER JOIN projects ON projects.id = pledges.project_id GROUP BY projects.title ORDER BY projects.title \"\nend",
"def select_project\n @projects = Project.find(:all)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges\n ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY projects.title\nORDER BY projects.title;\"\nend",
"def sql_statement_find\n @sql_statement_find ||=\n <<-SQL\n SELECT\n applications.id AS id,\n teams.name AS team_name,\n projects.name AS project_name,\n (application_data -> :project_id)::int AS project_id,\n application_data -> :project_plan AS project_plan,\n application_data -> :why_selected_project AS why_selected_project,\n application_data -> :signed_off_at AS signed_off_at,\n (application_data -> :signed_off_by)::int AS signed_off_by,\n application_data -> :mentor_fav AS mentor_fav,\n CASE WHEN :project_id::text = 'project1_id' THEN 1 ELSE 2 END AS choice,\n hstore_to_json_loose(slice(application_data, ARRAY[:student0_attrs])) AS student0,\n hstore_to_json_loose(slice(application_data, ARRAY[:student1_attrs])) AS student1\n FROM applications\n INNER JOIN teams\n ON teams.id = applications.team_id\n INNER JOIN projects\n ON projects.id::text = applications.application_data -> :project_id\n WHERE (application_data -> :project_id)::int IN (:project_ids)\n AND applications.season_id = :season_id\n AND applications.id = :id;\n SQL\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT Projects.title, SUM(Pledges.amount)\n FROM projects\n JOIN pledges\n ON Projects.id = Pledges.project_id\n GROUP BY project_id\n ORDER BY Projects.title\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\n FROM pledges\n INNER JOIN projects\n ON pledges.project_id = projects.id\n GROUP BY projects.title\n ORDER BY projects.title\n\"\nend",
"def select(componentName, text, componentInfo=nil)\n $marathon.select(ComponentId.new(componentName, componentInfo), text.to_s)\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nJOIN pledges\nON projects.id = pledges.project_id\nGROUP BY projects.title;\"\nend",
"def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end",
"def getCat \n\t\tputs ''\n\t\tputs 'Fetching categories . . '\n\t\[email protected]('ul.dropdown li a').each do |cat|\n\t\t\tarr=[]\n\t\t\tarr.push cat.text\n\t\t\tarr.push cat['href']\n\t\t\t@arr_cat.push arr\n\t\t\tprint '. '\n\t\tend\n\t\ti=0\n\t\t@arr_cat.each do |pair|\n\t\t\[email protected] 'insert into category values (?, ? ,?)', i, pair[0], pair[1]\n \t\t\ti +=1\n \t\tend\n\tend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM (pledges.amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY title\nORDER BY title ASC;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT Projects.title, SUM(Pledges.amount) FROM Projects JOIN Pledges ON Pledges.project_id = Projects.id GROUP BY Projects.title;\"\nend",
"def add_project_name_to_jql jql_string\n unless jql_string.empty?\n jql_string.insert(0, \"project=#{@project} AND \")\n else\n \"project=#{@project}\"\n end\n end",
"def search(category, query_term)\nresult = @conn.exec(\"SELECT * FROM students WHERE #{category} = '#{query_term}';\");\n puts student\n result.each do |student|\n puts \"#{k}: #{v}\"\n end\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount) FROM pledges INNER JOIN projects ON projects.id = pledges.project_id GROUP BY projects.id ORDER BY title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n\"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n INNER JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY(projects.title);\"\nend",
"def show_categories(html_dsl)\r\n categories = Category.where(\"user_id = #{session[:user_id]} and category_id is null\").order('name ASC')\r\n category_html = create_category_table(categories)\r\n html_dsl.inject(category_html)\r\n end",
"def show_categories(html_dsl)\r\n categories = Category.where(\"user_id = #{session[:user_id]} and category_id is null\").order('name ASC')\r\n category_html = create_category_table(categories)\r\n html_dsl.inject(category_html)\r\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, sum(pledges.amount) FROM projects INNER JOIN pledges on pledges.project_id=projects.id group by pledges.project_id ORDER BY projects.title ASC\"\nend",
"def selects_all_female_bears_return_name_and_age\n <<-SQL \n SELECT \n bears.name, \n bears.age \n FROM bears \n WHERE sex='F';\n SQL\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, SUM(pledges.amount) FROM projects\n JOIN pledges ON projects.id = pledges.project_id\n GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON pledges.project_id=projects.id GROUP BY projects.title ORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id GROUP BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_title\n # SELECT titles, amounts FROM projects, pledges ORDER BY titles ASC\n #SELECT titles.projects, pledges.amounts ORDER BY titles ASC\n \"SELECT projects.title, SUM(pledges.amount) FROM projects\n JOIN pledges \n ON pledges.project_id = projects.id \n GROUP BY(pledges.project_id)\n ORDER BY projects.title ASC\n \";\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n \"SELECT projects.title, SUM(pledges.amount)\n FROM projects\n JOIN pledges ON pledges.project_id = projects.id\n GROUP BY title\n ORDER BY title ASC;\"\nend",
"def sql_statement_all\n @sql_statement_all ||=\n <<-SQL\n SELECT\n applications.id AS id,\n teams.name AS team_name,\n projects.name AS project_name,\n (application_data -> :project_id)::int AS project_id,\n application_data -> :signed_off_at AS signed_off_at,\n (application_data -> :signed_off_by)::int AS signed_off_by,\n application_data -> :mentor_fav AS mentor_fav,\n CASE WHEN :project_id::text = 'project1_id' THEN 1 ELSE 2 END AS choice\n FROM applications\n INNER JOIN teams\n ON teams.id = applications.team_id\n INNER JOIN projects\n ON projects.id::text = applications.application_data -> :project_id\n WHERE (application_data -> :project_id)::int IN (:project_ids)\n AND applications.season_id = :season_id;\n SQL\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY projects.title ORDER BY projects.title ASC;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"select\nprojects.title,\nsum(pledges.amount) as sum_all_pledges\nfrom projects\ninner join pledges\non projects.id = pledges.project_id\ngroup by projects.title\norder by projects.title;\n\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts\n \"SELECT projects.title, SUM(pledges.amount) \n FROM projects\n JOIN pledges\n ON pledges.project_id = projects.id\n GROUP BY projects.title;\"\nend",
"def category_selection(category)\n category = Public_apis.find_by_name(category)\n #goes over list item array . find method to find item\n\n \n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT projects.title, SUM(pledges.amount)\nFROM projects\nLEFT JOIN pledges\nON projects.id=pledges.project_id\nGROUP BY projects.title\nORDER BY projects.title;\"\nend",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n #SELECT title, SUM(quantity) FROM groceries GROUP BY aisle ORDER BY SUM(quantity);\n\n \"SELECT projects.title, sum( pledges.amount)\nFROM projects\nJOIN pledges\nwhere projects.id=pledges.project_id\ngroup by projects.title order by projects.title\n;\"\n\nend",
"def frey_example\n # Find all the cats that are the same color as the cat named 'Freyja'.\n # Including 'Freyja' in the results.\n # DO NOT USE A SUBQUERY\n\n execute(<<-SQL)\n SELECT\n color_cats.name\n FROM\n cats AS freyja_cats\n JOIN\n cats AS color_cats ON freyja_cats.color = color_cats.color\n WHERE\n freyja_cats.name = 'Freyja';\n SQL\nend",
"def select &blck\n @projects.select(&blck)\n end",
"def select &blck\n @projects.select(&blck)\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT p.title, SUM(pl.amount) FROM pledges pl INNER JOIN projects p ON pl.project_id = p.id GROUP BY pl.project_id ORDER BY p.title\"\nend"
] | [
"0.9197428",
"0.70681554",
"0.69905895",
"0.6650687",
"0.6622008",
"0.65134215",
"0.6487074",
"0.63231736",
"0.60595876",
"0.59397984",
"0.5938012",
"0.59359765",
"0.59009475",
"0.58821595",
"0.58702105",
"0.58538514",
"0.5852772",
"0.58400726",
"0.58187836",
"0.5783952",
"0.5781836",
"0.5699433",
"0.56956494",
"0.56917065",
"0.56917065",
"0.5690233",
"0.5682429",
"0.5678716",
"0.56345487",
"0.562825",
"0.56200427",
"0.5618499",
"0.5614793",
"0.5589031",
"0.5582006",
"0.5574134",
"0.55731916",
"0.5572146",
"0.55663043",
"0.5543936",
"0.55408674",
"0.55273974",
"0.54872346",
"0.5480151",
"0.54790336",
"0.5477612",
"0.5475731",
"0.54650974",
"0.5460519",
"0.5458991",
"0.5450393",
"0.54474175",
"0.543396",
"0.5430399",
"0.54298806",
"0.5428744",
"0.5424535",
"0.54231083",
"0.54223335",
"0.5415754",
"0.5407502",
"0.5392763",
"0.5385772",
"0.53838485",
"0.53815895",
"0.53814566",
"0.5380899",
"0.53729725",
"0.5361706",
"0.5351655",
"0.5351099",
"0.53493774",
"0.53478605",
"0.5347711",
"0.53405917",
"0.534054",
"0.533232",
"0.5331863",
"0.53221244",
"0.53216356",
"0.531914",
"0.53109",
"0.53109",
"0.53063357",
"0.5299247",
"0.52962613",
"0.5290562",
"0.5286517",
"0.5284508",
"0.5284136",
"0.5283787",
"0.52830637",
"0.5276121",
"0.5273314",
"0.527148",
"0.5268409",
"0.52644026",
"0.5259888",
"0.5257563",
"0.5257563",
"0.52546746"
] | 0.0 | -1 |
SELECT Cats.name, Cats.breed, Owners.name FROM Cats INNER JOIN Owners ON Cats.owner_id = Owners.id; | def selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_amount
#Select users.name, SUM(pledges.amount) #Group by users.name #order by SUM(pledges.amount)
#pledges belong to users, users have many pledges --> pledges go after from
"SELECT users.name, SUM(pledges.amount)
FROM pledges INNER JOIN users ON pledges.user_id = users.id
GROUP BY users.name
ORDER BY SUM(pledges.amount)"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_owners\n Owner.all.each_with_index do |owner, i|\n puts \"\\n#{i + 1}. #{owner.name} \\nAddress: #{owner.address}\"\n puts \"Food provided: #{owner.food_provided.capitalize}\"\n puts \"Has a cat? #{owner.cat_already.to_s.capitalize} | Has a dog? #{owner.dog.to_s.capitalize}\"\n puts \"Lives in #{owner.neighborhood.name}\"\n all_cats = Cat.all.select { |x| x.owner_id == owner.id}\n cats_list = all_cats.map{ |x| x.name }.join(\", \")\n puts \"#{owner.name}'s cat(s): #{cats_list}\"\n puts \"\\n----------------------------------------------------------------------------\"\n end\n end",
"def bikes_owned\n DATABASE.execute(\"SELECT bikes.bike_name FROM bikes JOIN cyclists ON bikes.cyclist_id = cyclists.id WHERE cyclists.id = #{id}\")\n end",
"def bikes_owned\n DATABASE.execute(\"SELECT bikes.bike_name FROM bikes JOIN cyclists ON bikes.cyclist_id = cyclists.id WHERE cyclists.id = #{id}\")\n end",
"def cats\n Cat.all.select do |cat| \n cat.owner == self \n end \n end",
"def cats \n Cat.all.select {|one_cat| one_cat.owner == self} \n end",
"def cats\n Cat.all.select do |cat|\n cat.owner == self\n end\n end",
"def cats\n Cat.all.select {|cat| cat.owner == self}\n end",
"def owner_names\n self.pets.map {|p| p.owner}.pluck(:name).uniq\n end",
"def cats \n Cat.all.select do |cat_instance|\n cat_instance.owner == self \n end\n end",
"def cats\n Cat.all.select { |cats| cats.owner == self }\n end",
"def carowner_names\n CarOwner.all.select do |c|\n if c.mechanic == self\n c.name\n end\n end\nend",
"def owners_of_cars_serviced\n self.personal_mechanic_of.map{|owner_obj| owner_obj.name}\nend",
"def print_owners_with_hero (fwt, hero_name)\n\t\n\ttemp = fwt.execute(\"SELECT owners.first_name, owners.last_name, ratings.descripton FROM acquisitions JOIN owners ON acquisitions.owners_id = owners.id JOIN heros ON acquisitions.heros_id = heros.id JOIN ratings ON acquisitions.ratings_id = ratings.id WHERE heros.name = ? ORDER BY first_name, last_name\",[hero_name])\n\t\n\tputs \"\\n\\n#{hero_name} is owned by the following owners:\"\n\t\n\ttemp.each do |first_name,last_name,descripton|\n\t\tputs \"First Name:#{first_name} Last Name:#{last_name} Rating:#{descripton}\"\n\tend\nend",
"def people\n Person.find(dogs.map(&:owner_id))\n end",
"def select_name_and_series_subgenres_of_authors\n \"SELECT authors.name, subgenres.name FROM authors INNER JOIN series ON authors.id=series.author_id INNER JOIN subgenres ON series.subgenre_id = subgenres.id; \"\nend",
"def toys_that_jet_owns\n # Find all of the toys that Jet owns. Then list the the names of all \n # the other cats that own those toys as well as the toys names.\n # Exclude Jet from the results.\n # Order alphabetically by cat name. \n\n # DO NOT USE A SUBQUERY\n execute(<<-SQL)\n SELECT DISTINCT\n notjetcats.name, toys.name \n FROM \n toys \n JOIN \n cattoys as notjetjoins ON toys.id = notjetjoins.toy_id \n JOIN \n cats as notjetcats ON notjetcats.id = notjetjoins.cat_id \n JOIN \n cattoys as jetcatjoins ON toys.id = jetcatjoins.toy_id \n JOIN \n cats as jetcats ON jetcats.id= jetcatjoins.cat_id \n WHERE \n jetcats.name = 'Jet' AND notjetcats.name != 'Jet'\n ORDER BY\n notjetcats.name ASC;\n SQL\n end",
"def owners\n self.authors.collect(&:user)\n end",
"def show_all\n @owners = Owner.all\n end",
"def zombie_cast\n MovieDatabase.execute(<<-SQL)\n select actor.name\n from movie\n join casting on movie.id = casting.movieid\n join actor on casting.actorid = actor.id\n where movie.title = 'Zombies of the Stratosphere'\n order by actor.name\n SQL\nend",
"def zoolander_cast\n MovieDatabase.execute(<<-SQL)\n SELECT actors.name\n FROM movies\n JOIN castings on movies.id = castings.movie_id\n JOIN actors on actors.id = castings.actor_id\n WHERE movies.title = \"Zoolander\"\n ORDER BY actors.name\nSQL\nend",
"def select_name_and_series_subgenres_of_authors\n \"SELECT authors.name, subgenres.name\n FROM series\n INNER JOIN authors\n ON series.author_id = authors.id\n INNER JOIN subgenres\n ON series.subgenre_id = subgenres.id\"\nend",
"def cats\n\t\t# Note that you call upon the other class within this class.\n\t\tCat.all.select do |cat|\n\t\t\tcat.owner == self\n\t\tend\n\tend",
"def print_owners_heros (fwt, last_name)\n\n\ttemp = fwt.execute(\"SELECT heros.name, ratings.rating, ratings.descripton FROM acquisitions JOIN owners ON acquisitions.owners_id = owners.id JOIN heros ON acquisitions.heros_id = heros.id JOIN ratings ON acquisitions.ratings_id = ratings.id WHERE owners.last_name = ? ORDER BY first_name, last_name\",[last_name])\n\n\tputs \"\\n\\n#{last_name} owns the following heros:\"\n\t\n\ttemp.each do |hero_name,ratings, descripton|\n\t\tputs \"Hero's Name:#{hero_name} Rating:#{ratings} Description:#{descripton}\"\n\tend\nend",
"def car_owner_names\n car_owners_arr = Car.all.select do |car_ob|\n #binding.pry\n car_ob.mechanic == self\n end\n car_owners_arr.map do |car_ob|\n car_ob.owner.name\n end\nend",
"def owner()\n sql = \"SELECT * FROM owners\n WHERE id = $1\"\n values = [@owner_id]\n owner_data = SqlRunner.run( sql, values ).first\n result = Owner.new(owner_data)\n end",
"def casablanca_cast\n MovieDatabase.execute(<<-SQL)\n SELECT\n a.name\n FROM\n actor a\n JOIN\n casting c ON a.id = c.actorid\n JOIN\n movie m ON m.id = c.movieid\n WHERE\n m.title = \"Casablanca\"\n ORDER BY\n a.name;\nSQL\nend",
"def print_voters_who_voted_for_politician\n\tputs \"People & Who they voted for\"\n\tputs $db.execute(SELECT name || ' - ' ||GROUP_CONCAT(first_name|| ' ' ||last_name, ', ')FROM congress_members JOIN votes ON congress_members.id = cotes.politician_id JOIN voters ON voters.id = votes.voter_id GROUP BY name)\n\nend",
"def on(owner = nil)\n if owner.present?\n where :owner_id => owner.id, :owner_type => owner.class.name\n else\n where :owner_id => nil, :owner_type => nil\n end\n end",
"def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name\n\"SELECT title, SUM(amount)\nFROM projects\nINNER JOIN pledges\nON projects.id = pledges.project_id\nGROUP BY title\nORDER BY title\"\n\n# FROM owners\n# INNER JOIN cats_owners\n# ON owners.id = cats_owners.owner_id\n# JOIN cats ON cats_owners.cat_id = cats.id\n# WHERE cats_owners.owner_id = 2;\n\nend",
"def index\n @owners = Owner.all\n end",
"def index\n @owners = Owner.all\n end",
"def owners_name\n if self.owner.is_a?(Person) && self.owner.user\n self.owner.user.login\n elsif self.owner.respond_to?(:name)\n self.owner.name\n else\n \"disclosed\".t\n end\n end",
"def show\n @borrows = Borrow.joins(:indentify, :book).where(user_id: current_user).select(\"borrows.*,indentifies.*,books.*,borrows.id\",)\n\n end",
"def find\n @owner = Owner.find(params[:id])\n @dogs = Owner.find(params[:id]).dogs\n end",
"def toys_that_jet_owns_sub\n # Find all of the toys that Jet owns. Then list the the names of all \n # the other cats that own those toys as well as the toys names.\n # Exclude Jet from the results.\n # Order alphabetically by cat name. \n\n # USE A SUBQUERY\n execute(<<-SQL)\n SELECT\n cats.name, toys.name\n FROM cattoys\n JOIN cats ON cat_id = cats.id\n JOIN toys ON toy_id = toys.id\n WHERE\n toys.id IN (\n SELECT toys.id\n FROM cattoys\n JOIN cats ON cat_id = cats.id\n JOIN toys ON toy_id = toys.id\n WHERE cats.name = 'Jet'\n ) AND cats.name != 'Jet'\n ORDER BY cats.name;\n SQL\nend",
"def my_clients\n self.client_cars.map do |car|\n car.owner\n end\n end",
"def owners\n self.cars.map{|car_instance| car_instance.owner}.uniq\n end",
"def get_all_files()\n return $db.execute(\"SELECT users.username, files.* \n FROM files \n INNER JOIN users ON files.owner_id = users.user_id\")\nend",
"def dogs\nDog.all.find_all do |dog|\n dog.owner == self\nend\n\nend",
"def dogs\n Dog.all.select do |dog|\n dog.owner == self\n end\n end",
"def owners\n @data['owners']\n end",
"def friends # I dont' understand associations well enough....\n User.find_by_sql(\"select * from users join networks on networks.user_id='#{self.id}' where users.id=networks.friend_id order by id desc\")\n end",
"def list_of_owners\n @owners = Owner.find(:all, :order=>\"state,city\")\n @report_name = \"List of Owners\"\n end",
"def dogs\n Dog.all.select do |dog_instance|\n dog_instance.owner == self \n end\n end",
"def kent_supporting_actor_films\n MovieDatabase.execute(<<-SQL)\n SELECT \n movies.title,\n actors.name\n FROM\n movies\n INNER JOIN\n castings ON movies.id = castings.movie_id\n INNER JOIN \n actors ON castings.actor_id = actors.id\n WHERE \n actors.name LIKE '% Kent'AND castings.ord != 1\n ORDER BY movies.title;\n SQL\nend",
"def bearded_films\n MovieDatabase.execute(<<-SQL)\n select movie.title\n from movie\n join casting on movie.id = casting.movieid\n join actor on casting.actorid = actor.id\n where actor.name = 'Chuck Norris'\n SQL\nend",
"def dogs\n Dog.all.select {|d| d.owner == self}\n end",
"def rain_man_cast\n MovieDatabase.execute(<<-SQL)\n SELECT\n actors.name\n FROM\n actors\n JOIN castings ON castings.actor_id = actors.id\n JOIN movies ON castings.movie_id = movies.id\n WHERE\n movies.title = 'Rain Man'\n ORDER BY\n actors.name \nSQL\nend",
"def owner_and_coowners\n vals = Role.access_values_for(:creator).concat(Role.access_values_for(:administrator))\n User.joins(:roles).where(\"roles.plan_id = ? AND roles.access IN (?)\", self.id, vals)\n end",
"def cars\n Car.all.select {|c| c.owner == self}\n end",
"def owners\n self.car.map do |car| car.owner.uniq\nend\n\n\n\nend",
"def owners\n # set @owners instance variable by\n # 1) grabbing all Ownerships containing this panlist\n # 2) converting each Ownership into an Owner\n @owners ||= Ownership.where(list_id: self.id).map do |ownership|\n Owner.find_by_netid(ownership.owner_id)\n end\n end",
"def costars(name)\n # List the names of the actors that the named actor has ever\n # appeared with.\n # Hint: use a subquery\n movielist = Movie.joins(:actors).where('actors.name = ?', name).pluck(:id)\n Actor.joins(:movies).where('movies.id IN (?) AND name != ?', movielist, name).pluck(:name).uniq\nend",
"def car_owners\n car_owners_arr = Car.all.select do |car_ob|\n #binding.pry\n car_ob.mechanic == self\n end\n car_owners_arr.map do |car_ob|\n car_ob.owner\n end\nend",
"def find_owner_cat\n @cat = @owner.cats.find_by!(id: params[:id]) if @owner\n end",
"def owner_rent_out\n cuties = []\n Rental.all.each do |r|\n temp_arr = []\n if r.cutie.user == self\n temp_arr[0] = r.cutie\n temp_arr[1] = r\n cuties << temp_arr\n end\n end\n return cuties\n end",
"def select_character_names_and_number_of_books_they_are_in\n \"SELECT characters.name, COUNT(cb.book_id)\n FROM character_books cb\n INNER JOIN characters ON cb.character_id == characters.id\n GROUP BY characters.name\n ORDER BY COUNT(cb.book_id) DESC\n \"\nend",
"def matt_damon_films\n MovieDatabase.execute(<<-SQL)\n SELECT\n movies.title\n FROM\n movies\n JOIN actors ON castings.actor_id = actors.id\n JOIN castings ON castings.movie_id = movies.id\n WHERE\n actors.name = 'Matt Damon'\n ORDER BY\n movies.title \nSQL\nend",
"def list_cats\n Cat.all.each_with_index do |kitty, i| \n puts \"\\n#{i + 1}. #{kitty.name} 🐈\"\n ##### if no owner\n if kitty.owner.nil?\n puts \"Breed: #{kitty.breed} | Color: #{kitty.color.capitalize}\"\n puts \"Food preference: #{kitty.favorite_food.capitalize} | Gets along with other cats? #{kitty.temperament.to_s.capitalize}\"\n puts \"\\n----------------------------------------------------------------------------\"\n ##############\n else\n puts \"Owner: #{kitty.owner.name}\"\n puts \"Breed: #{kitty.breed} | Color: #{kitty.color.capitalize}\"\n puts \"Food preference: #{kitty.favorite_food.capitalize} | Gets along with other cats? #{kitty.temperament.to_s.capitalize}\"\n puts \"\\n----------------------------------------------------------------------------\"\n end\n end\n end",
"def owners\n @obj['owners']\n end",
"def customers\n sql = \"SELECT customers.* FROM customers INNER JOIN tickets ON tickets.customer_id = customers.id WHERE tickets.film_id = #{@id};\"\n return Customer.map_items(sql) \n end",
"def select_character_names_and_number_of_books_they_are_in\n \"SELECT characters.name, COUNT(character_books.book_id) as book_count FROM characters INNER JOIN character_books ON characters.id = character_books.character_id GROUP BY characters.name ORDER BY book_count DESC\"\nend",
"def personal_mechanic_of\n self.cars_serviced.map{|car| car.car_owner}\nend",
"def list_pets\n @owner.dogs.count\n @owner.cats.count\n end",
"def what_songs_does_he_own()\n $songs.select{|song| song.owners.include?(@name)}\n \tend",
"def owners\n get_user_with_role(:owner)\n end",
"def getOwners\r\n\t\t\t\t\treturn @owners\r\n\t\t\t\tend",
"def select_character_names_and_number_of_books_they_are_in\n \"SELECT characters.name, COUNT(*) \n FROM character_books INNER JOIN characters\n ON character_books.character_id = characters.id\n INNER JOIN books\n ON character_books.book_id = books.id\n GROUP BY characters.name\n ORDER BY COUNT(*) DESC;\" \nend",
"def all_cars\n Car.all.select do |car|\n car.owner == self\n end\n end",
"def matt_damon_supporting_actor_films\n MovieDatabase.execute(<<-SQL)\n SELECT\n movies.title\n FROM\n movies\n JOIN actors ON castings.actor_id = actors.id\n JOIN castings ON castings.movie_id = movies.id\n WHERE\n actors.name = 'Matt Damon'\n AND\n castings.ord != 1 \n ORDER BY\n movies.title \nSQL\nend",
"def carowners\n CarOwner.all.each do |c|\n c.mechanic == self\n end\nend",
"def actors_list\n # characters.where(show_id: self.id)\n self.characters.map do |character|\n character.actor.full_name\n end\n end",
"def get_owner_info(owner)\n get(\"/owners/#{owner}/info\")\n end",
"def select_character_names_and_number_of_books_they_are_in\n \"select characters.name, count(book_id)\n from character_books\n inner join characters \n \n on characters.id = character_books.character_id\n group by characters.name\n order by count(book_id) desc\"\nend",
"def albums\n # binding.pry\n albums = CONN.execute(\"\n SELECT * FROM artists \n INNER JOIN albums\n ON artists.id = albums.artist_id\"\n )\n albums.map { |album| Album.new(album)}\n end",
"def index\n @owner_properties = @owner.ownerProperties\n end",
"def julie_andrews_stars\n MovieDatabase.execute(<<-SQL)\n SELECT\n m.title, a.name\n FROM\n movie m \n JOIN\n casting c ON m.id = c.movieid\n JOIN\n actor a ON a.id = c.actorid\n WHERE\n c.ord = 1 AND c.movieid in (SELECT\n DISTINCT(m.id)\n FROM\n movie m \n JOIN\n casting c ON m.id = c.movieid\n JOIN\n actor a ON a.id = c.actorid\n WHERE\n a.name = 'Julie Andrews')\n ORDER BY\n m.title;\nSQL\nend",
"def owners_by_key\n @owners_by_key ||= owners.group_by do |owner|\n key = owner[owner_key_name]\n key && key.to_s\n end\n end",
"def julie_andrews_stars\n MovieDatabase.execute(<<-SQL)\n SELECT DISTINCT(movies.title), lead_actors.name\n FROM actors AS julie_actors\n JOIN castings AS julie_castings on julie_actors.id = julie_castings.actor_id\n JOIN movies ON julie_castings.movie_id = movies.id\n JOIN castings AS lead_castings ON movies.id = lead_castings.movie_id\n JOIN actors AS lead_actors on lead_actors.id = lead_castings.actor_id\n WHERE julie_actors.name = 'Julie Andrews' AND lead_castings.ord = 1\nSQL\nend",
"def films_customer_sees()\n sql = \"SELECT * FROM films INNER JOIN tickets\n ON films.id = tickets.film_id WHERE customer_id = $1\"\n values = [@id]\n films = SqlRunner.run(sql, values)\n result = films.map {|film_hash| Film.new(film_hash)}\n return result\nend",
"def index\n @accessors = Accessor.where(\"access_owner = ?\" , current_user.id)\n @accessors_by_others = Accessor.where(\"accessor_id = ?\" , current_user.id)\n\n end",
"def more_cage_please\n MovieDatabase.execute(<<-SQL)\n select movie.title\n from movie\n join casting on movie.id = casting.movieid\n join actor on casting.actorid = actor.id\n where actor.name = 'Nicolas Cage' and ord != 1\n order by movie.title\n SQL\nend",
"def friends_can_access_garage \n @accessors = Accessor.joins(\"INNER JOIN friends on accessors.friend_id = friends.id\").where(\"garage_id=:gid\", {gid: params[:id]}).select(\"accessors.*, accessors.id as accessor_id, friends.*\")\n end",
"def get_all_file_data(file_id)\n return $db.execute(\"SELECT files.*, users.username\n FROM files \n INNER JOIN users ON files.owner_id = users.user_id \n WHERE file_id = ?\", file_id)\nend",
"def select_character_names_and_number_of_books_they_are_in\n \"\n SELECT characters.name, COUNT(character_books.book_id) AS cameos\n FROM characters\n JOIN character_books\n ON character_books.character_id = characters.id\n GROUP BY characters.id\n ORDER BY cameos DESC, characters.name\n \"\nend",
"def cars\n Car.all.select do |car|\n car.car_owner == self\n end\n end",
"def cats\n #loop through .all class method for the class Cat\n #select the value for variable cat and return it to a new array\n #every time cat.owner == self is true\n Cat.all.select do |cat|\n #block determines true value\n cat.owner == self #returns if true\n end\n end",
"def index\n current_user = Borrow.where(user_id: session[:user_id]).distinct.pluck(:user_id)\n @borrows = Borrow.joins(:indentify, :book).where(user_id: current_user,mode:0).select(\"indentifies.*,borrows.*,books.*,borrows.mode\",).paginate(:per_page => 2, :page => params[:page])\n end",
"def show_fans(player) \n player1 = Player.find_by(name: player)\n fans_array = player1.fans\n fans_array.each do |fan|\n puts fan.name \n end\nend",
"def print_personal_list(db, name)\r\n\tputs \"Chores for #{name}\"\r\n\tprint_chores = db.execute(\"SELECT chores.complete_by_day, chores.name FROM chores, family WHERE family.name = ? AND chores.family_id = family.id\", [name])\r\n\tprint_chores.each do |x|\r\n\t\tputs \"#{x[0]} : #{x[1]}\"\r\n\tend\r\nend",
"def harrison_ford_supporting_actor_films\n MovieDatabase.execute(<<-SQL)\n SELECT\n m.title\n FROM\n movie m \n JOIN\n casting c ON m.id = c.movieid\n WHERE\n c.ord != 1 AND c.actorid = (SELECT\n a.id\n FROM\n actor a\n WHERE\n a.name = 'Harrison Ford')\n ORDER BY\n m.title;\n\nSQL\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'music';\n\"\nend",
"def name\n @owner\n end",
"def best_friend_name\n # what is self? self is a pet instance ===> self.owner\n # what is self.owner? an user instance ===> so i can use User instance methods\n # self.owner.name\n # PROCESS!!!! what is the thing you have access to? What methods can you call? which will be useful here? \n if self.owner\n self.owner.name\n else\n nil\n end\n # tech debt - if owner is nil this will throw an error! \n end",
"def customers()\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets\n ON tickets.customer_id = customers.id\n WHERE tickets.screening_id = $1\"\n values = [@id]\n customers = SqlRunner.run(sql, values)\n return customers.map{|customer| Customer.new(customer)}\nend",
"def owners\n return @owners\n end",
"def show_customers\n sql = \"SELECT customers.* FROM films INNER JOIN screenings ON films.id = screenings.film_id INNER JOIN tickets ON screenings.id = tickets.screening_id INNER JOIN customers on tickets.customer_id = customers.id WHERE films.id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values)\n return result.map {|customer| Customer.new(customer)}\n end",
"def dogs\n Dog.doggies.select { |dogs| dogs.owner == self }\n end",
"def show_all_reservations\n Reservation.find_by_sql [\"SELECT * FROM reservations r\n LEFT JOIN events e ON e.id = r.event_id\n LEFT JOIN normal_dinings nd ON nd.id = r.normal_dining_id\n LEFT JOIN halls h ON h.id = e.hall_id OR h.id = nd.hall_id\n INNER JOIN clubs c ON c.id = h.club_id\n WHERE c.id = ?\", \n self.id]\n end",
"def list_of_politician_and_their_voters\nputs \"REPS and A List of their Voters.\"\n pol_votes = $db.execute(\"SELECT n.name, r.first_name, r.last_name) \n FROM congress_members n, voters r, votes v \n WHERE n.id = v.politician_id AND v.votes_id = r.id \n GROUP BY n.name\")\n \n pol_votes.each {|rep, fn, ln| puts \"#{rep}\"\n puts \"#{fn}\"\n puts \"#{ln}\"}\nend",
"def index\n @object_owners = ObjectOwner.all\n end"
] | [
"0.7125217",
"0.66479516",
"0.66479516",
"0.6584939",
"0.65329665",
"0.64940083",
"0.64466745",
"0.64332014",
"0.64326346",
"0.6429383",
"0.63726604",
"0.62606883",
"0.620419",
"0.6121527",
"0.61146575",
"0.60934967",
"0.6089321",
"0.60817194",
"0.60728776",
"0.6055935",
"0.6049486",
"0.6041071",
"0.6035286",
"0.60304046",
"0.6003209",
"0.5994402",
"0.5969528",
"0.59580487",
"0.59446585",
"0.5924237",
"0.5924237",
"0.5913983",
"0.58980334",
"0.58948976",
"0.5891522",
"0.5844121",
"0.5836793",
"0.5828963",
"0.57872695",
"0.5781221",
"0.57707906",
"0.5747744",
"0.5737837",
"0.57369435",
"0.5730485",
"0.5720157",
"0.57168466",
"0.5715126",
"0.57138383",
"0.5713547",
"0.5689709",
"0.56884384",
"0.5670998",
"0.56660676",
"0.56484145",
"0.5628704",
"0.5619486",
"0.5617099",
"0.5615673",
"0.5614683",
"0.5600192",
"0.5579828",
"0.557594",
"0.5554905",
"0.55503035",
"0.5540427",
"0.5530035",
"0.55281407",
"0.55171245",
"0.55144215",
"0.5512832",
"0.550457",
"0.55035716",
"0.5494466",
"0.5493505",
"0.5488892",
"0.5486141",
"0.5482414",
"0.5475816",
"0.54725343",
"0.5460769",
"0.5457571",
"0.5448491",
"0.544501",
"0.54423726",
"0.54389715",
"0.54373497",
"0.54358965",
"0.5435742",
"0.542966",
"0.5416782",
"0.5414596",
"0.5413337",
"0.54100055",
"0.540754",
"0.5403749",
"0.5399911",
"0.5397636",
"0.5390275",
"0.5387681",
"0.53866905"
] | 0.0 | -1 |
Replace this with your real tests. | def test_accessors
assert_kind_of WikiVisit, @visit
assert_kind_of WikiPage, @visit.wiki_page
assert_kind_of User, @visit.user
assert_equal Time.parse("2007-01-08 00:43:00"), @visit.time_of_visit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def __dummy_test__\n end",
"def tests; end",
"def tests; end",
"def spec; end",
"def spec; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test_0_dummy\n\t\tend",
"def test\n\n end",
"def test\n end",
"def test\n end",
"def test\n end",
"def private; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def test_method\n end",
"def before_test(test); end",
"def before_test(test); end",
"def graffiti_test\n end",
"def test_truth\n end",
"def test_should_get_index \n get :index\n assert_response :success #making sure the request was successful\n assert_not_nil (:products) # ensuring that it assigns a valid products instance variable.\n end",
"def test_case; end",
"def test_cases; end",
"def running_test_case; end",
"def test_connection\n end",
"def testloop\n \n end",
"def should; super end",
"def test_nothing\n end",
"def default_test\r\n end",
"def my_tests\n end",
"def test_setup\r\n \r\n end",
"def test_intialize\r\n\tassert_equal 0, @test_prospector.current_gold\r\n\tassert_equal 0, @test_prospector.current_silver\r\n\tassert_equal 0, @test_prospector.total_gold\r\n\tassert_equal 0, @test_prospector.total_silver\r\n\tassert_equal 0, @test_prospector.move_count\r\n\tassert_nil @test_prospector.previous_location\r\n\tassert_equal 0, @test_prospector.num_days\r\n\tassert_equal 'Sutter Creek', @test_prospector.current_location\r\n end",
"def testing_end\n end",
"def test_next_song\n \n \n assert true\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def assertions; end",
"def assertions; end",
"def test_hack\n assert(true)\n end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n\n end",
"def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end",
"def teardown; end",
"def teardown; end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def before_assert\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def test_entry\n raise \"Implement this method in your test class\"\n end",
"def tests_song_not_found\n assert_equal =\n end\n\nend",
"def test_playlist\n end",
"def test_listchunk_attributes\n\t\t\n\tend",
"def love_test\nend",
"def test_entry_attrs\n raise \"Implement this method in your test class\"\n end",
"def test_truth\n assert true\n end",
"def stest_method_1(test); end",
"def teardown\r\n end",
"def default_test\n end",
"def test_037\n\n login\n\n #Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Arbitrary filtering is performed to PU name.\n assert_equal _(\"PU name\"), get_selected_label(\"find_box\")\n\n\n # you have no relevance\n filtering('3')\n assert !is_text_present('sample_pu1')\n assert !is_text_present('sample_pu2')\n assert is_text_present(_('A PU does not exist.'))\n sleep 2\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n end",
"def run_fe_tests\n end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def setup; end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end",
"def test_BooksForAnAuthor\n loginRegisterBazzarVoice\n writeReview \n assert true \n end"
] | [
"0.7446459",
"0.6956364",
"0.69155836",
"0.69155836",
"0.6864151",
"0.6864151",
"0.66406286",
"0.66406286",
"0.66253287",
"0.6547665",
"0.6524571",
"0.6484549",
"0.6484549",
"0.6484549",
"0.6403847",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6385941",
"0.6354074",
"0.6354074",
"0.6350063",
"0.6317573",
"0.6271346",
"0.62341285",
"0.6210424",
"0.6183045",
"0.61626923",
"0.61574936",
"0.6137384",
"0.61362237",
"0.61194503",
"0.611745",
"0.61087",
"0.6098303",
"0.606717",
"0.6058555",
"0.6057699",
"0.6057699",
"0.6057699",
"0.6057699",
"0.6045397",
"0.6045397",
"0.6029009",
"0.60160005",
"0.60160005",
"0.60160005",
"0.6014079",
"0.5998994",
"0.5998994",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5989936",
"0.59822077",
"0.59556234",
"0.59556234",
"0.59556234",
"0.59556234",
"0.59556234",
"0.59556234",
"0.5950605",
"0.59497803",
"0.5943133",
"0.59424186",
"0.5932352",
"0.59296894",
"0.5929659",
"0.5917424",
"0.59144044",
"0.5913393",
"0.5905494",
"0.5899468",
"0.58910733",
"0.58910733",
"0.58910733",
"0.5889112",
"0.5883961",
"0.5883961",
"0.5880121",
"0.5877717"
] | 0.0 | -1 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge by myself. 1. Pseudocode What is the input? The input for the first method will be an array of numbers, and for the second method will be an array of numbers and strings. What is the output? (i.e. What should the code return?) The output for the first method will be an integer, and for the second will be a string. What are the steps needed to solve the problem? Steps for method 1: 1. input an array of integers 2. loop through each element of the array while adding them all together 3. keep track of that sum 4. return the sum Steps for method 2 1. input an array of mixed elements (integers, strings, symbols, etc.) 2. join each element in the array into one string with one space between the elements 3. capitalize the first element in the new string 4. interpolate the string into a new string with a period at the end 2. Initial Solution | def total(an_array)
an_array.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\twhile x <= array.length-1\n\t\tif x == array.length-1\n\t\t\tsum += array[x].to_s\n\t\t\tx += 1\n\t\telse \n\t\t\tsum += array[x].to_s + \" \"\n\t\t\tx += 1\n\t\tend\t\n\tend\n\tsum += \".\"\n\tsum.capitalize!\n\treturn sum\nend",
"def sentence_maker(array)\n x = 0\n sum = \"\"\n while x <= array.length-1\n sum += array[x].to_s + \" \"\n x += 1\n end\n sum.rstrip!\n sum += \".\"\n sum.capitalize!\n return sum\nend",
"def sentence_maker(array)\n\tlength = array.length\n\tsum = array[0].to_s.capitalize!\n\tfor i in 1...length\n\t\tsum = sum + \" \" + array[i].to_s\n\tend\n \tsum + \".\"\nend",
"def consec_ints\n puts \">> Please enter an integer greater than 0:\"\n num = gets.chomp.to_i\n arr = Array.new(num) { |i| i + 1 }\n puts \">> Enter 's' to compute the sum, 'p' to compute the product.\"\n method = gets.chomp.downcase\n if method == 's'\n puts \"#{arr.reduce(&:+)}\"\n else\n puts \"#{arr.reduce(&:*)}\"\n end\nend",
"def sentence_maker(array)\n combination = \"\"\n array[0].capitalize!\n array.each {|x| combination = combination + x.to_s + \" \"}\n combination.rstrip!\n combination = combination + \".\"\n return combination\nend",
"def sum_of_2\n array = Array.new\n puts \"Give me an array\"\n array = gets.chomp\n puts array\n length = array.length\n case length\n when 0\n puts \"Sum = 0\"\n when 1\n puts \"Sum = #{array[0]}\"\n else\n sum = array[0].to_i+array[1].to_i\n puts \"Sum = #{sum}\"\n end\nend",
"def sum(input)\n arr = input.to_s.chars.map { |x| x.to_i }\n arr.reduce { |sum, num| sum + num }\n # number.to_s.chars.map(&:to_i).reduce(:+) # read up on symbols and procs\nend",
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes 0!=1 class Quiz\n # find even values\n def solution1(input)\n # Final solution\n input.flatten.select do |value|\n value.even?\n end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.select do |value|\n # value.even?\n # end\n # end.flatten\n end\n\n # find value sum\n def solution2(input)\n # Final Solution\n input.flatten.inject(:+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.flatten.inject do |sum, value|\n # sum += value\n # end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.inject do |sum, value|\n # sum += value\n # end\n # end.inject do |sum, value|\n # sum += value\n # end\n end\n\n # find max value\n def solution3(input)\n # Final solution\n input.flatten.max\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.max\n # end.max\n end\n\n # sum the array lengths\n def solution4(input)\n # Final solution\n input.map(&:length).inject(0, :+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.map(&:length).inject{|sum, value| sum += value}\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.length\n # end.inject {|sum, value| sum += value}\n end\n\n # transform to factorials\n # Factorial is defined as the product of all the whole numbers from 1 to n\n # Examples:\n # 4! = 4*3*2*1\n # 1! = 1\n # 0! = 1\n def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end\nend",
"def solution(a)\n number = a.to_s.chars\n first_arrays = []\n (number.length/2).times do\n first_arrays << number.shift\n first_arrays << number.rotate(number.length-1).shift\n number.pop\n end\n ( first_arrays + number ).join(\"\").to_i\nend",
"def perform(array)\n case array[2]\n when \"1\", \"add\", \"addition\"\n puts \"The result is: #{(array[0] + array[1]).round(4)}\"\n when \"2\", \"subtract\", \"subtraction\"\n puts \"The result is: #{(array[0] - array[1]).round(4)}\"\n when \"3\", \"multiply\", \"multiplication\"\n puts \"The result is: #{(array[0] * array[1]).round(4)}\"\n when \"4\", \"divide\", \"division\"\n puts \"Remainder or decimal?\"\n case gets.chomp.downcase\n when \"remainder\"\n puts \"The result is: #{(array[0].to_i / array[1].to_i).floor} Remainder: #{(array[0].to_i % array[1].to_i)}\"\n when \"decimal\"\n puts \"The result is: #{(array[0] / array[1]).round(4)}\"\n else\n puts \"Did not understand. Restarting...\"\n end\n when \"5\", \"exponent\", \"exponential\"\n puts \"The result is: #{(array[0] ** array[1]).round(4)}\"\n else\n puts \"Did not understand. Restarting...\"\n end\nend",
"def sum_of_array(array)\n if array.empty?\n return 0\n else\n item = array.shift\n if item.is_a?(String)\n puts item = num_value(item)\n end\n \n item = item + sum_of_array(array)\n end\nend",
"def accum(s)\n newArr = []\n i = 1\n\ts.split('').each { |let|\n let *= i\n i += 1 \n newArr.push(let.downcase)\n }\n newArr.each { |let|\n let[0] = let[0].upcase\n }\n return newArr.join(\"-\")\nend",
"def sentence_maker(arr)\n string = \"\"\n arr.each do |i|\n string += i.to_s + ' '\n end\n string[-1] = \".\"\n return string = string.capitalize\nend",
"def output(input)\n array = input.split (\" \")\n array.map! {\n |x|\n x = x.to_i\n }\n sum = 0\n array.each {\n |x|\n sum += x\n }\n sum\nend",
"def accum(s)\n arr = s.split('')\n arr.map!.each_with_index do |letter, index|\n (letter * (index + 1)).capitalize\n # binding.pry\n end\n arr.join('-')\nend",
"def sum(number)\n array = number.to_s.split('')\n array.map! { |num| num.to_i }\n sum_nums = 0\n array.each { |num| sum_nums += num }\n sum_nums\nend",
"def numbers_sum(input_array)\n output = input_array[0] + input_array[1] # Sums the first array's input with the second array's input\n return output\nend",
"def sentence_maker(array)\n\tanswer=\"\"\n\tarray[0]=array[0].capitalize\n\tarray.each do |x|\n\t\tx=x.to_s\n\t\tanswer+=x+\" \"\n\tend\t\n\tanswer=answer.chop+\".\"\n\treturn answer\nend",
"def sentence_maker(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend",
"def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n sentence + \".\"\nend",
"def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\n\t\twhile x < (array.length - 1)\n\t\t\tsum += array[x].concat \" \" \n\t\t\tx += 1\n\t\tend \n\t\t\tsum += array[x].concat \".\" \n\treturn sum\n\nend",
"def capitalize(str)\narr2 = []\n\nlower = str.downcase\narr = lower.split()\n\narr.each do |x|\nx[0]= x[0].upcase\narr2.push(x)\nend\n\nreturn arr.join(\" \")\n\nend",
"def sentence_maker(array_of_strings)\n return array_of_strings.join(\" \").capitalize + '.'\nend",
"def sentence_maker (array)\n index = 0\n sentence = \"\"\n array = array.map {|x| x.to_s}\n\nuntil index == array.length-1\n sentence += array[index] + \" \"\n index += 1\nend\n\nsentence += array[-1] + \".\"\nreturn sentence.capitalize\n\nend",
"def add_array_numbers(array)\n result = array.sum\n # .sum cannot be used on a string, only integars and floats\n return result\nend",
"def array_translate(array)\n # can be done in a single loop\n # grab two elements at a time, using a while loop\n # add string to the return string the specified number of times\n translated_str = \"\"\n i = 0\n while i < array.length\n str = array[i]\n num = array[i + 1]\n num.times do |useless|\n translated_str += str\n end\n # translated_str += str * num #<= also works (in Ruby)\n i += 2\n end\n return translated_str\nend",
"def sentence_maker(array_of_strings)\n\n sentence = array_of_strings[0].capitalize\n \n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n p sentence + \".\"\n \nend",
"def run_conversion( arr )\n converted_answer = ''\n if @vals_to_convert[0] === 'celsius' && @vals_to_convert[1] === 'farenheit'\n converted_answer = \"#{@vals_to_convert[2]} #{@vals_to_convert[0]} is #{(@vals_to_convert[2] * 9)/5 + 32} #{@vals_to_convert[1]}\"\n elsif @vals_to_convert[0] === 'farenheit' && @vals_to_convert[1] === 'celsius'\n converted_answer = \"#{@vals_to_convert[2]} #{@vals_to_convert[0]} is #{(@vals_to_convert[2] - 32) * 5/9} #{@vals_to_convert[1]}\"\n elsif @vals_to_convert[0] === 'celsius' && @vals_to_convert[1] === 'kelvin'\n converted_answer = \"#{@vals_to_convert[2]} #{@vals_to_convert[0]} is #{@vals_to_convert[2]+ 273.15} #{@vals_to_convert[1]}\"\n elsif @vals_to_convert[0] === 'farenheit' && @vals_to_convert[1] === 'kelvin'\n converted_answer = \"#{@vals_to_convert[2]} #{@vals_to_convert[0]} is #{(@vals_to_convert[2] - 32) * 5/9 + 273.15} #{@vals_to_convert[1]}\"\n elsif @vals_to_convert[0] === 'kelvin' && @vals_to_convert[1] === 'celsius'\n converted_answer = \"#{@vals_to_convert[2]} #{@vals_to_convert[0]} is #{@vals_to_convert[2] - 273.15} #{@vals_to_convert[1]}\"\n else\n converted_answer = \"#{@vals_to_convert[2]} #{@vals_to_convert[0]} is #{(@vals_to_convert[2] - 273.15) * 1.80 + 32 } #{@vals_to_convert[1]}\"\n end\n print converted_answer\n print \"\\r\\nWould you like to do another conversion?\"\n answer = gets.chomp\n answer_outcome = parse_response( 'run_conversion', answer, 0 )\n if answer_outcome === true\n self.x = 0\n @vals_to_convert = ''\n print_temp_prompt\n else\n say_goodbye\n end\n end",
"def sum_difference_product(input)\n puts \"give me an integer\"\n input= gets.chomp\narray_of_input = input.split(\"\").map {|numb| numb.to_i }\nsum = array_of_input[0]+ array_of_input[2]\nputs \"#{sum}\"\nputs \"#{array_of_input[0] - array_of_input[2]}\"\nputs array_of_input[0] * array_of_input[2]\n\nend",
"def sentence_maker(arr)\n x = ''\n #Concatenate each element with a space\n arr.each{|y| x << y.to_s << ' '}\n\n #Take out any leading or trailing white space\n x.strip!\n x[0] = x[0].capitalize\n x << '.'\n p x\nend",
"def sentence_maker (array)\n array[0].capitalize!\n return array.join(\" \") + \".\"\nend",
"def sentence_maker(array)\n\tnew_array = array.join(\" \").capitalize + \".\"\n\t\nend",
"def sentence_maker(array)\n sentence = \"\"\n array[0].capitalize!\n array.each do |i|\n sentence << \"#{i}\"\n unless i == array.last\n sentence << \" \"\n end\n end\n sentence << \".\"\n return sentence\nend",
"def sentence_maker(array_of_strings)\n array_of_strings.join(' ').capitalize + \".\"\nend",
"def sentence_maker(array)\n\tsentence = array[0].capitalize.to_s\n\ti = 1\n\twhile i < array.length\n\t\tsentence = sentence + \" \" + array[i].to_s\n\t\ti += 1\n\tend\n\tsentence = sentence + \".\"\n\tp sentence\n\nend",
"def sentence_maker(array)\n array.join(\" \").capitalize << \".\"\nend",
"def nums_to_words() \n number_array = @number.to_s.split(\"\").map! {|item| item.to_i}\n if number_array.length === 4\n thousands_array = [number_array.shift]\n space_array = [three_array(thousands_array), \"thousand\"] \n num_total = 0\n number_array.each do |num|\n num_total += num\n end\n if num_total !=0\n space_array.push(three_array(number_array))\n end\n return space_array.join(\" \")\n end\n three_array(number_array)\n end",
"def sentence_maker(array)\n sentence = array[0].capitalize\n for w in 1...array.length\n sentence = sentence + \" \" + array[w].to_s\n end\n return sentence + \".\"\nend",
"def sentence_maker(string_array)\n string_array.join(\" \").capitalize + \".\"\nend",
"def array_translate(array)\n new_str = ''\n i = 0\n while i < array.length\n ele = array[i]\n num = array[i+1]\n num.times {new_str += ele}\n i += 2\n end\n return new_str\nend",
"def sentence_maker(arr)\n string = \"\"\n i = 1\n while i < arr.length-1\n string += arr[i].to_s + ' '\n i+=1\n end\n sentence = arr[0].capitalize! + \" \" + string + arr[-1] + \".\"\n return sentence\nend",
"def sentence_maker(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\nend",
"def sentence_maker(arr)\n arr[0] = arr[0].capitalize\n return arr.join(\" \") + \".\"\nend",
"def sentence_maker ( strArray )\r\n\r\n\tanswer = ''\r\n\r\n\tstrArray.each do |thisStr|\r\n\t\tanswer += thisStr.to_s + ' '\r\n\tend\r\n\r\n\tanswer.slice!(answer.length-1)\r\n\r\n\tanswer += '.'\r\n\r\n\treturn answer.capitalize!\r\n\r\nend",
"def sentence_maker array\n array = array.join(' ').capitalize << \".\"\n\nend",
"def sentence_maker arr\n catenated_str = ''\n space = ' '\n i = 0\n\n arr.each do |el|\n catenated_str += i == 0 ? el.capitalize.to_s : i == (arr.length - 1) ? space + el.to_s + '.' : space + el.to_s\n i+=1\n end\n catenated_str\nend",
"def sentence_maker(array)\n\ti = 0\n\twhile i < array.length do\n\t\tif i == 0\n\t\t\tsentence = (array[i].capitalize.to_s + \" \")\n\t\telsif i == array.length-1\n\t\t\tsentence = sentence + (array[i].to_s + \".\") \n\t\telse\n\t\t\tsentence = sentence + (array[i].to_s + \" \")\n\t\tend\n\t\ti += 1\n\tend\n\treturn sentence\nend",
"def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend",
"def sentence_maker(array)\n array.join(\" \").capitalize + \".\"\nend",
"def sentence_maker(array)\n array[0].capitalize!\n array.join(\" \") << \".\"\nend",
"def combine (arr1, arr2)\n puts \"Combining #{arr1.join.reverse}, #{arr2.join.reverse}\"\n arr3 = []\n len1 = arr1.length\n puts \"len1 = #{len1}\"\n len2 = arr2.length\n puts \"len2 = #{len2}\"\n $divisor = 0\n if len1 > len2\n longest = len1\n else\n longest = len2\n end\n\nfor i in (0..longest-1)\n if i>len1\n arr3[i] = arr1[i].to_i+$divisor\n elsif i>len2\n arr3[i]=arr2[i].to_i+$divisor\n else\n arr3[i]=arr1[i].to_i+arr2[i].to_i+$divisor \n $divisor = arr3[i]/10\n arr3[i] %= 10\n end\n end\nwhile ($divisor > 0)\n arr3[len1+=1] = $divisor%10\n $divisor /= 10\n end\n\nreturn arr3\n end",
"def romanNumerator(romanString)\n charArray = romanString.chars\n romanSum = 0\n\n charArray.each_with_index do |char, index|\n\n nextChar = charArray[index + 1]\n charCombo = []\n charCombo << charArray[index]\n charCombo << charArray[index+1]\n charCombo = charCombo.join.upcase\n\n\n if charCombo == \"IV\" || charCombo == \"IX\" || charCombo == \"XL\" || charCombo == \"XC\" || charCombo == \"CD\" || charCombo == \"CM\"\n if charCombo == \"IV\"\n romanSum += 4\n charArray[index+1] = 0\n elsif charCombo == \"IX\"\n romanSum += 9\n charArray[index+1] = 0\n elsif charCombo == \"XL\"\n romanSum += 40\n charArray[index+1] = 0\n elsif charCombo == \"XC\"\n romanSum += 90\n charArray[index+1] = 0\n elsif charCombo == \"CD\"\n romanSum += 400\n charArray[index+1] = 0\n elsif charCombo == \"CM\"\n romanSum += 900\n charArray[index+1] = 0\n end\n elsif char == \"I\"\n romanSum += 1\n elsif char == \"V\"\n romanSum += 5\n elsif char == \"X\"\n romanSum += 10\n elsif char == \"L\"\n romanSum += 50\n elsif char == \"C\"\n romanSum += 100\n elsif char == \"D\"\n romanSum += 500\n elsif char == \"M\"\n romanSum += 1000\n end\n end\n\n return romanSum\n\nend",
"def solution(roman)\n split = roman.split(\"\")\n last_value = 0\n split.reduce(0) do |final, char|\n current = CONVERSION[char.upcase]\n binding.pry\n if current >= last_value\n final += current\n else\n final -= current\n end\n binding.pry\n last_value = current\n final\n end\nend",
"def sentence_maker(array)\n sentence = \"\"\n array.each do |x|\n sentence = sentence + x.to_s + \" \"\n end\n\n sentence[0] = sentence[0].upcase\n sentence = sentence.rstrip\n sentence = sentence + \".\"\n return sentence\n\nend",
"def accum(s)\n\t# your code\n arr = s.split(\"\")\n arr.map!.with_index do |el, idx|\n mapper = el * (idx+1)\n mapper = mapper.capitalize\n puts mapper\n mapper\n end \n\n arr.join(\"-\")\nend",
"def arr_sum(array)\n\tnum_list = []\n\tarray.to_s.each_char do |char|\n\t\tp char\n\t\tif char.match(/[0-9]/) #== true\n\t\t\tnum_list << char\n\t\tend\n\tend\n\tsum = 0\n\tnum_list.each do |s|\n\t\tsum += s.to_i\n\tend\n\treturn num_list, sum\nend",
"def sentence_maker (arr)\n sentence = \"\"\n arr[0] = arr[0].capitalize\n for i in 0...arr.length-1\n sentence = sentence + arr[i].to_s + \" \"\n end\n return sentence + arr[arr.length-1] + \".\"\nend",
"def sum_numbers (numbers)\r\n##INJECT METHOD\r\n # numbers.each do |thing|\r\n # thing \r\n # this is where you put the thing to check for strings/not numbers\r\n # end \r\n numbers.inject(:+)\r\n# ##ACCUMULATOR METHOD\r\n# accumulator = 0\r\n# numbers.each do |num|\r\n# accumulator += num\r\n# end \r\nend",
"def sentence_maker(array)\n str_array = array.collect{|i| i.to_s} #collect method returns entire array or hash; we are converting all elements of array into string\n sentence = array[0] #converts first element of array into new array\n sentence[0] = str_array[0][0].upcase #makes first letter uppercase\n str_array.shift\n\tstr_array.each { |i| sentence = sentence + \" \" + i.to_s}\n\treturn sentence + \".\"\nend",
"def sentence_maker (arr)\n\n arr[0] = arr[0].capitalize\n sentence = arr.join(\" \")\n\n return sentence + \".\"\nend",
"def sentence_maker(array)\n sentence = array.join(\" \")\n sentence << \".\"\n sentence.capitalize!\nend",
"def sentence_maker(array)\n result = array.join(' ')\n result = result.capitalize + \".\"\nend",
"def sentence_maker(array)\n array.join(' ').capitalize << \".\"\nend",
"def solution(number)\n accumulator =\n number.to_s.reverse.each_char.with_index.map do |letter, index|\n character_map(letter.to_i, *@roman_symbols[index * 2, 3])\n end\n accumulator.reverse.join \nend",
"def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend",
"def solution(line, people)\n total_p = people.first.to_f\n t_l = people.last.to_f\n\n arr = line.split(\" \").map{|v| v.to_f}\n total = arr.inject(:+)\n add_to_one(arr, total_p, total)\nend",
"def sentence_maker(array)\n string = array.join(' ').capitalize! + '.'\nend",
"def sentence_maker(a)\n\tsum = \"\"\n\ta.each {|a| sum += (a + \" \")}\n\n\treturn sum.chomp(\" \").capitalize + \".\"\nend",
"def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\n \nend",
"def sum1(array)\r\n sum = 0\r\n array.each do |number|\r\n sum += number\r\n end\r\n sum\r\nend",
"def sentence_maker(arraystring)\n fullsentence = ''\n length_of_arraystring = arraystring.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraystring\n if current_index_of_array == 0\n word = arraystring[current_index_of_array].to_s.capitalize\n fullsentence = fullsentence + word + ' '\n\n elsif current_index_of_array == length_of_arraystring - 1\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + '.'\n else\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + ' '\n end\n current_index_of_array = current_index_of_array + 1\n\n end\n# puts fullsentence\n return fullsentence\nend",
"def numbersToWords(a,b)\n\nnumbers = {0 => \"\", 1 => \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\"} \nnumbers.merge! 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\"\nnumbers.merge! 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\" \nnumbers.merge! 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\" \nnumbers.merge! 19 => \"nineteen\", 20 => \"twenty\", 30 => \"thirty\", 40 => \"forty\" \nnumbers.merge! 50 => \"fifty\", 60 => \"sixty\", 70 => \"seventy\", 80 => \"eighty\", 90 => \"ninety\" \nnumbers.merge! 100 => \"hundred\", 1000 => \"thousand\"\nwords = 0\n\nfor n in (a..b)\n\nthousands = n/1000\nhundredsAndTensAndOnes = n % 1000\nhundreds = (hundredsAndTensAndOnes / 100) * 100\ntensAndOnes = hundredsAndTensAndOnes - hundreds\ntens = (tensAndOnes / 10) * 10\nones = tensAndOnes - tens\n\nif thousands != 0 \nprint \"#{numbers[thousands]} thousand \"\nwords += numbers[thousands].length\nwords += numbers[1000].length\nend\n\nif thousands != 0 && hundreds == 0 && tensAndOnes != 0\nprint \"and \"\nwords += 3\nend\n\nif hundreds != 0\nprint \"#{numbers[hundreds/100]} hundred \"\nwords += numbers[hundreds/100].length\nwords += numbers[100].length\nend\n\nif hundreds != 0 && tensAndOnes != 0\nprint \"and \"\nwords += 3\nend\n\nif tensAndOnes > 19\nprint \"#{numbers[tens]} #{numbers[ones]}\"\nwords += numbers[tens].length\nwords += numbers[ones].length\nend\n\nif tensAndOnes < 20\nprint \"#{numbers[tensAndOnes]}\"\nwords += numbers[tensAndOnes].length\nend\n\nputs \"\"\n\nend\n\nprint \"There are #{words} letters in the written-out numbers between #{a} and #{b} (inclusive).\"\n\nend",
"def sentence_maker(array)\n array.join(\" \")\n array(0,1).capitalize + array(1..-1) + \".\"\nend",
"def add(arr1, arr2)\n sum_arr = []\n arr1.each_index do |i|\n if arr1[i] == ' '\n sum_arr << ' '\n next\n end\n sum = arr1[i] + arr2[i]\n sum_arr << (sum > 26 ? sum - 26 : sum)\n end\n sum_arr\nend",
"def q4\n array1 = [\"dog\", \"cat\", \"fish\"]\n array2 = [\"bird\", \"bat\", \"tiger\"]\n\n p array1 + array2\nend",
"def sum_many(*numbers)\r\n\t#numbers is an array, so we can call and do array stuff\r\n\t#puts numbers.size\r\n\t#puts numbers.first\r\n\t#puts numbers.last\r\n\t#numbers.each {|num| puts num }\r\n\tnumbers.each do |num|\r\n\t\tprint num,\" \"\r\n\tend\r\n\tputs\r\n\t#puts numbers[1]\r\n\t#sum = 0\r\n\t#numbers.each{|num| sum += num }\r\n\t#sum\r\n\t#inject == accumulate\r\n\t#accumulute, sum || concatenation\r\n\tnumbers.inject(0) {|sum,num| sum+=num}\r\nend",
"def sentence_maker (array)\n sentence = \"\"\n array.each do |i|\n sentence = sentence + i.to_s + \" \"\n end\n sentence = sentence.capitalize.chop + \".\"\nend",
"def fun(input)\n array = input.split(\"\")\n array.each_with_index do |letter, index|\n if index % 2 == 0\n puts letter.capitalize!\n else\n puts letter\n end\n end\n joined_string = array.join(\"\")\n output = joined_string.reverse\n p output\nend",
"def sum(numbers)\n string = numbers.digits.reverse\n string.reduce(:+)\nend",
"def sentence_maker (array)\n\tindex = 0\n\twhile index < array.length\n\t\tif index == 0\n\t\t\tsentence = array[index].to_s.capitalize\n\t\telse \n\t\t\tsentence = sentence + \" \" + array[index].to_s\n\t\tend\n\t\tindex += 1\n\tend\n\tsentence = sentence + \".\"\n\treturn sentence \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def accum(string)\n result = []\n string.chars.each_with_index do |char, index|\n n = index + 1\n result << (char * n).capitalize\n end\n result.join('-')\nend",
"def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(array)\n x=array.join(\" \")\n return x.capitalize + \".\"\n end",
"def sentence_maker(array)\n sentence = array.join(\" \")\n sentence = sentence.capitalize + \".\"\nend",
"def capitalize_words(string)\n\t\n\t#split up string into old array of words \n\told_words_array = string.split\n\t\n\t#set up new array of words \n\tnew_words_array = []\n\t\n\t#loop to go through each word\n\ti = 0 \n\twhile (i < old_words_array.length)\n\t\n\t\t#separate each word into characters\n\t\tchars = old_words_array[i].scan /\\w/\n\t\t\n\t\t#shift off first char \n\t\tfirst_char = chars.shift\n\t\t\n\t\t#make first char uppercase \n\t\tfirst_char = first_char.upcase\n\t\t\n\t\t#join first char with the rest of the chars \n\t\tchars = chars.unshift(first_char)\n\t\t\n\t\t#make the chars back into a string \n\t\tcapitalized_word = chars.join\"\"\n\t\t\n\t\t#put the string into new words array of strings \n\t\tnew_words_array.push(capitalized_word)\n\t\t\n\t\t#increase i \n\t\ti += 1 \n\t\n\tend\n\t\n\t#join new words array back into single string\n\treturn new_words_array.join(\" \")\n\t\nend",
"def solution(n)\n\t(1..n).map(&:to_s).map(&:chars).join.chars.map(&:to_i).reduce(:+)\nend",
"def sum(number)\n num_array = number.to_s.split(//)\n number_sum = 0\n num_array.each { |num| number_sum += num.to_i }\n number_sum\nend",
"def aux_sum(n)\n result = 0\n\tarray_n = n.to_s.split('').map(&:to_i)\n\tfor i in 0..array_n.length-1\n\t\tresult += array_n[i]\n\tend\n\treturn result\nend",
"def add_numbers(array)\n#add first in array to next in array. replace next in array\n#until array.length < 1\n return array[0] if array.length <= 1\n num1, num2 = array.pop, array.pop\n sum = num1.to_i + num2.to_i\n array.unshift(sum)\n add_numbers(array)\nend",
"def sum(num)\n num.to_s.chars.map(&:to_i).reduce(:+)\nend",
"def sum(num)\n num.to_s.chars.map(&:to_i).reduce(:+)\nend",
"def add_casing_types(original_array)\n lowercase_array = []\n uppercase_array = []\n capitalized_array = []\n # go over original_array once to to create temporary arrays\n original_array.each do |array|\n temp_lowercase_array = []\n temp_uppercase_array = []\n temp_capitalized_array = []\n array.each do |word|\n temp_lowercase_array << word.downcase\n temp_uppercase_array << word.upcase\n # split the first letter, capitalize it\n temp_capitalized_array << word.split.map(&:capitalize)[0]\n end\n lowercase_array << temp_lowercase_array\n uppercase_array << temp_uppercase_array\n capitalized_array << temp_capitalized_array\n end\n # appending because at this point, we'll want to append a cased array\n # just like any other list of words\n final_array = [].concat(lowercase_array)\n final_array = final_array.concat(uppercase_array)\n final_array = final_array.concat(capitalized_array)\nend",
"def sentence_maker(array_of_strings)\n\n p array_of_strings.join(' ').capitalize + \".\"\n\n end",
"def sum(num)\n num.to_s.chars.map(&:to_i).sum\nend",
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end",
"def total(array_of_numbers)\n sum = 0\n array_of_numbers.each do |num|\n sum += num\n end\n return sum\nend",
"def sum_two_arrays(array1, array2)\n sums = array1.zip(array2)\n sums.map! do |p|\n s = p[0] + p[1]\n if s > 26\n s -= 26\n end\n s\n end\n return sums\n end"
] | [
"0.6243902",
"0.62435853",
"0.59667695",
"0.593968",
"0.59014624",
"0.583775",
"0.58294076",
"0.5768723",
"0.57597804",
"0.5749126",
"0.5747635",
"0.5744971",
"0.56973886",
"0.5681837",
"0.5654107",
"0.56465286",
"0.56130755",
"0.560964",
"0.5604325",
"0.5599078",
"0.5583098",
"0.55320865",
"0.55111295",
"0.5499917",
"0.54934555",
"0.5489115",
"0.5477206",
"0.54591435",
"0.5445873",
"0.5442951",
"0.54377645",
"0.5436709",
"0.5432022",
"0.54269433",
"0.54185915",
"0.5413215",
"0.54076934",
"0.54063773",
"0.5405218",
"0.5397366",
"0.5395086",
"0.5394962",
"0.5394133",
"0.53926855",
"0.538727",
"0.53870904",
"0.53857684",
"0.53838867",
"0.538305",
"0.53794825",
"0.5379081",
"0.5363233",
"0.5350667",
"0.53490937",
"0.53487897",
"0.5348551",
"0.53478724",
"0.53454906",
"0.53420275",
"0.534119",
"0.5341086",
"0.5340667",
"0.53363466",
"0.53357553",
"0.5326302",
"0.53248143",
"0.5322961",
"0.53209436",
"0.53181046",
"0.53089345",
"0.5294356",
"0.5291519",
"0.52878964",
"0.52764815",
"0.5273598",
"0.5268752",
"0.5264645",
"0.5263386",
"0.5262937",
"0.5262795",
"0.52596104",
"0.52596104",
"0.52596104",
"0.5258551",
"0.5245967",
"0.5245967",
"0.52382123",
"0.5234896",
"0.5233655",
"0.5231994",
"0.52277255",
"0.5225538",
"0.52233696",
"0.5220424",
"0.5220424",
"0.52130365",
"0.5209359",
"0.520913",
"0.5206328",
"0.5202675",
"0.5199073"
] | 0.0 | -1 |
Multiples of 3 and 5 Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. | def brut_force_solution
(1...1000).inject(0){|sum, digit| ((digit % 3 == 0) || (digit % 5 == 0)) ? sum += digit : sum}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_sum_of_multiples_of_3_and_5_below_1000\n answer = 0\n for number in 1...1000\n answer += number if number % 3 == 0 || number % 5 == 0\n end\n answer\nend",
"def sum_of_multiples\n multiples_of_three_or_five = []\n\n for n in 3...1000\n if n % 3 == 0\n multiples_of_three_or_five.push(n)\n end\n end\n\n for n in 5...1000\n if n % 5 == 0\n unless multiples_of_three_or_five.include?(n)\n multiples_of_three_or_five.push(n)\n end\n end\n end\n\n sum = multiples_of_three_or_five.inject { |sum, x| sum + x }\n return sum\nend",
"def sum_of_multiples_of_three_and_five(num)\n\ta = sum_of_first_n_multiples(3, (1000/3))\n\tb = sum_of_first_n_multiples(5, (1000/5))\n\tc = sum_of_first_n_multiples(15, (1000/15))\n\treturn (a + b - c - 1000)\nend",
"def multiples_3_5_v2\n\tsum = 0\n\n\t1.upto(999) do |i|\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tsum = sum + i\n\t\tend\n\tend\n\n\treturn sum\nend",
"def multiples_of_three_and_five(number)\n total = 0\n\n (1..(number - 1)).each { |n| total += n if n % 3 == 0 || n % 5 == 0 }\n \n return total\nend",
"def multiples_three_five(max_number)\n sum = 0\n max_number = max_number - 1\n (0..max_number).each do |number|\n if number % 3 == 0 || number % 5 == 0\n sum = sum + number\n end\n end\n return sum\nend",
"def multiples_of_3_and_5\r\n total = 0\r\n (3...1000).each do |x|\r\n if x % 3 == 0 || x % 5 == 0\r\n # puts x\r\n total += x\r\n end\r\n end\r\n total\r\nend",
"def multiples\n numbers = (1...1000)\n sum = 0\n\n numbers.each do |num|\n sum += num if num % 5 == 0 || num % 3 == 0\n end\n sum\nend",
"def sum_multiples_of_3_or_5\n (1..999).to_a.select { |n| n.multiple_of?(3) or n.multiple_of?(5) }.inject(&:+)\nend",
"def multiples_3_5_v1\n\tmultiples = (1...1000).find_all do |i| \n\t\ti % 3 == 0 || i % 5 == 0\n\tend\n\n\tanswer = multiples.inject do |memo, num|\n\t\tmemo + num\n\tend\n\n\treturn answer\nend",
"def find_multiples(number)\n sum_of_multiples = (3...number).each_with_object([]) do |element, list|\n list << element if element % 3 == 0 || element % 5 == 0\n end.sum\nend",
"def sum_multiples\n sum = 0\n\n (1...1000).each do |n|\n sum += n if n % 3 == 0 || n % 5 == 0\n end\n\n sum\nend",
"def sum_of_multiples\n list_of_multiples = [ ]\n 1000.times do |number| \n list_of_multiples << number if number % 3 == 0 || number % 5 == 0\n end\n list_of_multiples.inject(&:+)\nend",
"def sum_of_multiples_3_5_below(n)\n (1...n).select {|x| x%3==0 || x%5==0}.inject(&:+)\nend",
"def multiples_of_3_and_5(number)\n (1...number).select{|num| num % 3 == 0 || num % 5 == 0}.inject(:+)\nend",
"def sum_of_3_and_5_multiples(nbr)\n nbr_a = (1...nbr).to_a\n ls35 = nbr_a.select { |x| (x % 3).zero? || (x % 5).zero? }\n if nbr % 1 != 0 || nbr < 0 # conditiions pour les entiers relatifs\n return 'I said natural number only idiot!'\n elsif nbr > 1000 # pour ne pas calculer les > 1000\n return 'too high!'\n else\n return ls35.sum\n end\nend",
"def sum_multiples_3_and_5(number)\n\tsum = 0\n\t(1...number).each do |x|\n\t\tif x % 3 == 0\n\t\t\tsum += x\n\t\telsif x % 5 == 0\n\t\t\tsum += x\n\t\tend\n\tend\n\tsum\nend",
"def sum_multiples_three_five\n sum = 0\n n = 0\n while n < 1000\n if(((n%3) == 0) || ((n%5) == 0))\n sum += n\n end\n n+=1\n end\n puts \"#{sum}\"\nend",
"def sum_of_multiples(number)\n sum_three = 0\n sum_five = 0\n sum_total = 0\n count_three = 3\n count_five = 5\n\n if number < 5\n sum_five\n else\n while count_five < number\n sum_five += count_five\n count_five += 5\n end\n end\n\n if number < 3\n sum_three\n else\n while count_three < number\n if count_three % 5 != 0\n sum_three += count_three\n end\n count_three += 3\n end\n end\n\n sum_total = sum_five + sum_three\n\n puts sum_total\n return sum_total\nend",
"def sum_of_multiples(min,max)\n natural_set = (min...max).to_a\n multiples = natural_set.select { |n| (n % 3 == 0) or (n % 5 == 0) }\n sum = multiples.reduce(&:+)\n puts \"Sum of natural numbers between #{min} and #{max} that are divisible by 3 or 5 is #{sum}\"\n sum\nend",
"def sum_of_multiples_of_three_and_five(n)\r\n (1...n).to_a.select{|x| x % 3 == 0 || x % 5 == 0 }.reduce(:+)\r\nend",
"def sum_of_multiples(n)\n multiples_of_3_or_5 = []\n for i in 1..n\n if i % 3 == 0 || i % 5 == 0\n multiples_of_3_or_5 << i\n end\n end\n multiples_of_3_or_5.sum\nend",
"def sum_multiples(limit)\n(3...limit).find_all {|n| n % 3 == 0 || n % 5 == 0}.inject(:+)\nend",
"def mult_3_5\n\n p=0\n for x in 1..999 do \n if (x % 3 == 0) || (x % 5 == 0)\n p += x\n end\n end\n return p\nend",
"def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.sum\nend",
"def sumOfMultiples()\n sum = 0\n 1.upto(999) do |i|\n if (i % 3 == 0) or (i % 5 == 0)\n sum += i\n end\n end\n sum\nend",
"def sum_of_multiples(n)\n (1...n).select{ |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend",
"def multiples(num)\n (1...num).select { |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend",
"def multisum(number)\n multiples = (1..number).select { |x| (x % 3 == 0) || (x % 5 == 0) }\n multiples.reduce(:+)\nend",
"def find_multiples_of_3_or_5_below_x x\n sum = 0\n n = 3\n while n < x\n sum += n\n n += 3\n end\n n = 5\n while n < x\n sum += n if n % 3 != 0\n n += 5\n end\n sum\nend",
"def threefive(num)\n\n if num < 1 || num > 100\n return \"Number must be between 1-100\"\n end\n mult_arr = []\n mult_arr << 0\n i = 0\n\n while num > i\n if (i % 3) == 0\n mult_arr << i\n elsif (i % 5) == 0\n mult_arr << i\n end\n i += 1\n end\n return mult_arr.inject{|sum,n| sum + n}\n\nend",
"def sum_multiples_3_and_5\n return 3 * 333 * 334 / 2 + 5 * 199 * 200 / 2 - 15 * 66 * 67 / 2\nend",
"def multiples\n sum = (1..999).select {|num| num % 3 == 0 || num % 5 == 0}.reduce(:+)\n puts sum\nend",
"def sum_multiples()\n index = sum = 0\n while index < 1000\n sum += index if index%3 == 0 || index%5 == 0\n index+=1\n end\n sum\nend",
"def multisum(limit)\n multiples = []\n\n for num in 1..limit\n multiples << num if num % 3 == 0 || num % 5 == 0\n end\n\n multiples.inject(:+)\nend",
"def multiple_sum int\n (1..int).select { |n| (n % 3 == 0 || n % 5 == 0) }.sum\nend",
"def multisum(number)\n (1..number).select { |multiple| multiple % 3 == 0 || multiple % 5 == 0 }.inject(:+)\nend",
"def multiples(n)\n (1...n).select do |num|\n num if (num % 3).zero? || (num % 5).zero?\n end.reduce(:+)\nend",
"def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.inject(:+)\nend",
"def sum_multiples_of_3_and_5(range)\n range.select { |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend",
"def multisum(number)\n (0..number).reduce { |sum, n| n % 5 == 0 || n % 3 == 0 ? sum + n : sum }\nend",
"def multisum(number)\n multiples = (1..number).select do |num|\n num % 3 == 0 || num % 5 == 0\n end\n\n multiples.inject(:+)\nend",
"def multiples_3_and_5 (top_range_num)\n three_five_array = []\n i = 1\n while i < top_range_num\n if i%3 == 0\n three_five_array.push(i)\n elsif i%5 == 0\n three_five_array.push(i)\n end\n i += 1\n end\n three_five_array = three_five_array.uniq\n sum = three_five_array.inject {|total, x| total + x}\n puts sum\nend",
"def three_five_sum\n outcome = (1...1000).to_a.select do |num|\n num % 3 == 0 || num % 5 == 0\n end\n total = 0\n outcome.each do |num|\n total += num\n end\n total\nend",
"def multiple_of_three_and_five(limit)\r\n (3...limit).select { |number| number % 3 == 0 || number % 5 ==0 }.inject(:+)\r\nend",
"def multisum(num)\n arr = [*1..num]\n multiples_3_5 = arr.select{ |ele| ele % 3 == 0 || ele % 5 == 0}\n multiples_3_5.sum\nend",
"def multisum(num)\n multiples_3_and_5 = (1..num).to_a.map do |n|\n n if (n % 3).zero? || (n % 5).zero?\n end\n multiples_3_and_5.compact.inject(:+)\nend",
"def multisum(num)\n multiples = []\n 1.upto(num) do |x| \n if x % 3 == 0 || x % 5 == 0\n multiples << x\n end\n end\n multiples.inject(:+)\nend",
"def multiples_of_3_and_5_recursive(num, sum = 0)\n return sum if num == 0\n\n num = num - 1\n\n if (num % 3 == 0) || (num % 5 == 0)\n sum += num\n end\n\n multiples_of_3_and_5_recursive(num, sum)\n\nend",
"def multiples(numbers)\n numbers.inject(0) do |a, e|\n # sum the elements into the accumulator\n # if they are divisible by 3 or 5\n a += e if e % 3 == 0 || e % 5 == 0\n a\n end\nend",
"def sum_multiples_of_3_or_5(n)\n (1...n).inject(0) do |sum, n|\n sum + if n % 3 == 0 || n % 5 == 0\n n\n else\n 0\n end\n end\nend",
"def solution(number)\n return 0 if number <= 3\n\n sum = 0\n (1..(number - 1)).each do |n|\n if (n % 3 == 0) || (n % 5 == 0)\n sum += n\n end\n end\n\n sum\nend",
"def sum_of_3_or_5_multiples(n)\n n = n.to_i\n #compteur de boucle\n i = 0\n #tableu incluant les multiple de 3 et 5\n result_array = []\n while i < n\n a = i%3\n b = i%5\n if a == 0 || b == 0\n result_array << i\n i+=1\n else\n i+=1\t\n end\n \n end\n sum = 0\n result_array.each do |p|\n \t sum = sum + p\n end\n return sum \nend",
"def solve\n sum = 0\n (1..999).each do |n|\n if n % 3 == 0 or n % 5 == 0\n sum += n\n end\n end\n sum\nend",
"def multiple()\n\tresult = 0\n\t\tfor i in 1...1000\n\t\t\tif i%3 == 0 || i%5 == 0\n\tresult += i\n\t\t\tend\n\t\tend\n\treturn result\nend",
"def mult_sum num\n(1...num).select{|x| x%3==0 || x%5==0}.reduce(:+)\nend",
"def multisum(number)\n sum = 0\n (1..number).each do |num|\n if num % 3 == 0 || num % 5 == 0\n sum += num\n end\n end\n sum\nend",
"def multisum(num)\n numbers = (1..num).to_a\n multiples = numbers.select { |element| element % 3 == 0 || element % 5 == 0 }\n multiples.inject(:+)\nend",
"def multiples_of_3_or_5(max)\n multiples = []\n for i in 3...max #two dots are inclusive, three dots are not\n if i % 3 == 0 || i % 5 == 0 then multiples << i end\n end\n multiples\nend",
"def mult(number)\n (1..number).select { |i| i % 3 == 0 || i % 5 == 0 }.inject(:+)\nend",
"def multisum(number) # number 1..10 determines which numbers are divisible by 3 and 5\n sum = 0\n 1.upto(number) do |num|\n if num % 3 == 0 || num % 5 == 0\n sum += num # this adds the numbers from 1..num that either are multiples of 3 or 5\n end\n end\n sum # returns sum, need this here to run program successfully\nend",
"def multiples(input)\n (1..input).select { |num| (num % 3).zero? || (num % 5).zero? }.reduce(:+)\nend",
"def solution(int)\n multiples_3 = []\n multiples_5 = []\n threes = 3\n fives = 5\n \n until threes >= int\n multiples_3 << threes\n threes += 3\n end\n until fives >= int\n multiples_5 << fives\n fives += 5\n end\n \n (multiples_3 | multiples_5).sum\nend",
"def multisum(num)\n (1..num).to_a.select { |n| n % 3 == 0 || n % 5 == 0 }.sum\nend",
"def multisum(number)\n (0..number).select { |num| num % 3 == 0 || num % 5 == 0 }.inject(:+)\nend",
"def solution(number)\n [*1...number].select {|n| (n % 3 == 0) or (n % 5 == 0)}.sum\nend",
"def sum_of_mults(num)\n ary = []\n num.times do |num|\n if num % 3 == 0 || num % 5 == 0\n ary << num\n end\n num -= 1\n end\n ary.inject(:+)\nend",
"def sum_3_5(n)\n x = 3\n multiple_sum = 0\n while x < n\n current = x\n if (current % 3 == 0) or (current % 5 == 0)\n multiple_sum += current\n end\n x += 1\n end\n multiple_sum\nend",
"def multisum(max_value)\n (1..max_value).select {|num| num % 3 == 0 || num % 5 == 0}.reduce(:+)\nend",
"def multisum(num)\n (1..num).select { |i| i % 3 == 0 || i % 5 == 0 }.reduce(:+)\nend",
"def multisum(max)\n sum = 0\n 1.upto(max) { |num| sum += num if num % 3 == 0 || num % 5 == 0 }\n sum\nend",
"def multisum(limit)\n (1..limit).select { |num| (num % 3).zero? || (num % 5).zero? }.sum\nend",
"def sum_of_multiples(max, a, b)\n (1..max).select { |i| i % a == 0 || i % 5 == 0 }.reduce(:+)\nend",
"def multisum(number)\n sum = 0\n\n 1.upto(number) { |i| sum += i if i % 3 == 0 || i % 5 == 0 }\n sum\nend",
"def multisum(num)\n divisables = []\n 1.upto(num) {|num| num % 3 == 0 || num % 5 == 0 ? divisables << num : next}\n divisables.sum\nend",
"def multisum2(number)\n 1.upto(number).select { |num| num % 3 == 0 || num % 5 == 0 }.reduce(:+)\nend",
"def multisum(integer)\n total = 0\n (1..integer).each do |num|\n total += num if (num % 3 ==0) || (num % 5 == 0)\n end\n total\nend",
"def multisum(integer)\n multiples = []\n 1.upto(integer) do |index|\n multiples << index if index % 3 == 0 || index % 5 == 0\n end\n multiples.sum\nend",
"def refactored_sum_of_multiples(range)\n sum = 0 \n range.each do |num|\n if num % 3 == 0 || num % 5 == 0\n sum = sum + num\n end\n end\n sum\nend",
"def multiples(num)\n\tresult = []\n\tsum = 0\n\ti = 1\n\twhile i < num\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tresult << i\n\t\tend\n\t\ti += 1\n\tend\n\tresult.each do |digit|\n\t\tsum += digit\n\tend\n\tsum\t\nend",
"def multisum(num)\n 1.upto(num).select { |number| number % 3 == 0 || number % 5 == 0 }.sum\nend",
"def multisum(num)\n (1..num).select { |num| num % 3 == 0 || num % 5 == 0 }.reduce(:+)\nend",
"def sum_of_3_or_5_multiples?(final_number)\n \n final_sum=0\n \n if (final_number)is_i?(Fixnum) && final_number >= 0\n \n 0.upto(final_number-1) do |current_number|\n if is_multiple_of_3_or_5? (current_number) == true \n final_sum = final_sum + current_number\n else \n end \n end\n return \"Yo ! Je ne prends que les entiers naturels. TG\"\n end\n return final_sum\n end",
"def sum_multiples_of_3_and_5(num)\n arr = Array(0..(num-1))\n keep = arr.select do |n|\n n % 3 == 0 || n % 5 == 0\n end\n puts keep.reduce(:+)\nend",
"def multiples(x)\n array = []\n while x > 0\n x = x - 1\n if (x % 3 == 0) || (x % 5 == 0)\n array << x\n end\n end\n return array.inject{|sum,x| sum + x }\nend",
"def multisum(max_value)\n (1..max_value).inject(0) do |sum, n|\n n % 3 == 0 || n % 5 == 0 ? sum + n : sum\n end\nend",
"def sumOf(n)\n i = 0\n multiples = []\n while i < n do\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n i += 1\n end\n multiples.inspect\n multiples.reduce(:+)\nend",
"def solution(number)\n return 0 if number < 3\n result = 0\n count = 3\n \n until count > number\n if count % 3 == 0 || count % 5 == 0\n result += count \n end\n count += 1\n end\n \n result\nend",
"def multisum(limit)\n nums = []\n 1.upto(limit) { |num| nums << num if (num % 3 == 0 || num % 5 == 0)}\n nums.sum\nend",
"def solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend",
"def solution(number)\n sum = 0\n multipliers = (1..number-1).select {|x| x % 3 == 0 or x % 5 == 0}\n print multipliers\n multipliers.inject do |sum, x|\n sum + x\n end\nend",
"def multisum(n)\n sum = 0\n (1..n).each do |x|\n sum += x if (x % 3 == 0) || (x % 5 == 0)\n end\n sum\nend",
"def multiples_sums(int)\n sum = 0\n (1...int).to_a.each do |x|\n \tif x % 3 == 0 || x % 5 == 0\n \t\tsum += x.to_int\n \tend\n end\n sum\nend",
"def sum_multiples\n @sum35 = (1..@limit).select{|num| num%3 == 0 || num%5 == 0}\n @sum35 = @sum35.reduce(:+)\n @sum35\n end",
"def find_multiples (cap)\n\tsum = 0\n\t(0..(cap-1)).each {|num| sum += num if (num % 3 == 0 || num % 5 == 0) }\n\n\treturn sum\nend",
"def multisum(num)\n (1..num).select{ |x| (x % 3 == 0) || (x % 5 == 0) }.sum\nend",
"def collect_multiples(num)\n range = (3...num)\n multiples = []\n range.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples << num\n end\n end\n multiples\nend",
"def mult \n\tsum = 0\n (0...1000).select do |i| \n\t\tif (i % 3 === 0 || i % 5 === 0)\n\t\t\tsum += i\n\t\tend\n\tend\n\tputs sum\nend",
"def solve( maxValue )\n\n return if maxValue < 1\n\n sum = 0;\n count = 1;\n while count < maxValue\n sum += count if count % 3 == 0 or count % 5 == 0\n count += 1\n end\n puts sum\nend",
"def sum_multiples(factors, max)\n multiples = []\n (1...max).each do |num| \n factors.each { |fac| multiples << num if num % fac == 0 && !multiples.include?(num)}\n end\n multiples.sum\nend",
"def solution(number)\n return (0...number).select{ |x| ((x % 3 == 0) || (x % 5 == 0))}.reduce(:+)\nend"
] | [
"0.8610462",
"0.85608023",
"0.8475745",
"0.84110177",
"0.83885396",
"0.8364759",
"0.8358236",
"0.8334711",
"0.83078986",
"0.8298419",
"0.82765603",
"0.82644993",
"0.82576615",
"0.8125646",
"0.8122031",
"0.8110295",
"0.80918163",
"0.8063683",
"0.7961667",
"0.79474473",
"0.7945319",
"0.79346",
"0.79344064",
"0.79126894",
"0.7908107",
"0.7898542",
"0.789329",
"0.789132",
"0.7890089",
"0.78852284",
"0.7876749",
"0.7856494",
"0.78454393",
"0.78314286",
"0.782744",
"0.7814641",
"0.781453",
"0.780507",
"0.77912885",
"0.77899885",
"0.7781522",
"0.77567995",
"0.7755994",
"0.7753762",
"0.77519745",
"0.773162",
"0.7726551",
"0.77261835",
"0.770878",
"0.7679996",
"0.7670352",
"0.76565266",
"0.76555836",
"0.76378727",
"0.7624805",
"0.76104844",
"0.7595333",
"0.7590604",
"0.75831425",
"0.7583044",
"0.75826865",
"0.75656205",
"0.75478506",
"0.7547267",
"0.7538564",
"0.75299037",
"0.75294656",
"0.7525399",
"0.7519603",
"0.75145924",
"0.751195",
"0.7504163",
"0.74868345",
"0.74865544",
"0.7486247",
"0.74856067",
"0.74843395",
"0.7477508",
"0.7476038",
"0.7471296",
"0.74707276",
"0.7469993",
"0.7468196",
"0.7466819",
"0.74634373",
"0.74625504",
"0.7455474",
"0.7443295",
"0.7442602",
"0.744239",
"0.74315125",
"0.7418182",
"0.7416419",
"0.7397791",
"0.7389368",
"0.7388841",
"0.73860395",
"0.7376752",
"0.7375429",
"0.73696274",
"0.73657674"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.