query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Displays attendance records of a workshop
|
def attendee
@training_records = @training.training_records
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @attendances = Attendance.all\n end",
"def index\n @title = 'Workout Records'\n @workout_records = current_user.workout_records.find(:all, :order => 'date_performed')\n end",
"def show\n # authorize @timesheet\n @shifts = @timesheet.shifts.order(time_in: :desc)\n @employee = @timesheet.employee\n @job = @timesheet.job\n @last_complete_shift = @timesheet.shifts.clocked_out.last\n @current_shift = @timesheet.shifts.clocked_in.last if @timesheet.clocked_in?\n gon.timesheet = @timesheet\n gon.pay = @timesheet.gross_pay\n gon.status = @timesheet.shifts.last.state.titleize\n \n end",
"def show\n @att_data = @attendance.att_data\n end",
"def show\n @timesheets = @payroll.timesheets.includes(:payroll, :user)\n reports_data([@payroll])\n end",
"def index\n\t\t@attendances = Attendance.all\n\tend",
"def show\n @list_attendaces = Employee.select(\"A.id, A.date, A.time, A.check_type\").\n joins(\"JOIN attendaces A ON employees.private_number = A.private_number\").\n where(private_number: @employee.private_number)\n end",
"def index\n @attendances = Attendance.all\n end",
"def index\n @attendances = Attendance.all\n end",
"def index\n @attendances = Attendance.all\n end",
"def index\n @attendances = Attendance.all\n end",
"def index\n if @laboratory\n @appointments = @laboratory.appointments.where(user_id: @user.id)\n else\n @appointments = @user.appointments.all\n end\n end",
"def show\n\t@schedule = Schedule.find(params[:id])\n\t#if @schedule.start != @schedule.shifts[0].start then\n\t#\t#flash[:notice]=\"Warning: schedule starts at \", @schedule.start.to_s,\" but shifts start at \",@schedule.shifts[0].start.to_s\n\t#end\n\t@shift_days=@schedule.shifts.group_by{|x| x.start.day}\n\t@shifts=@schedule.shifts.to_a.sort_by!{|x| [x.start, x.location]}\n\t@locations=Location.where(:area_id => @schedule.area_id)\n\t@x=@locations.size + 1\n\t@n_assigned=0\n\t@schedule.shifts.each{|x| @n_assigned+=1 if x.volunteer}\n\t\n\t@ppl_sh=@schedule.shifts.group_by{|v| v.volunteer}\n\t@ppl_sh.delete(nil)\n\t@ppl_sh_s=@ppl_sh.keys.sort_by{|x| [x.hat.to_s,x.name]}\n\t@tms=@schedule.shifttimes\n\tputs \"*****shifttimes: \"+@schedule.shifttimes.to_s\n respond_to do |format|\n format.html # show.html.erb \n \n format.xml { render :xml => @schedule }\n end\n \n end",
"def index\n @shop_stylist_workdays = ShopStylistWorkday.all\n end",
"def index\n @employee_workinghours = EmployeeWorkinghour.all\n end",
"def show\n\t\t#@today = DateTime.now.to_i\n\t\t@appointment = Appointment.find(params[:id])\n\t\t@client = Client.where(:client => @appointment.client).where(:profile => @appointment.profile).first\n\n\t\ttoday_start = @appointment.start\n\t\ttoday_end = today_start.end_of_day\n\t\t@day = today_start\n\n\t\t@schedule= [];\n\t\t\n\t\t@day_openings = Opening.where(:user => @user).where(\"start >= ? AND start <= ?\",today_start, today_end).order(:start)\n \t@day_client_appointments = Appointment.where(:client => @user).where(\"start >= ? AND start <= ?\",today_start, today_end).order(:start)\n \t@day_owner_appointments = Appointment.where(:owner => @user).where(\"start >= ? AND start <= ?\",today_start, today_end).order(:start)\n\t\t@schedule = @day_openings + @day_client_appointments + @day_owner_appointments\n\n\t\t@schedule.sort_by! do |item|\n\t item[:start]\n\t end\n\tend",
"def show\n @shifts = Person.find(params[:id]).shifts.order(start: :asc)\n @weeks = build_shifts\n end",
"def show\n @attendances = Attendance.find(:id)\n end",
"def attendances\n # nothing here, everything is asked to JSON API\n # this action should render initial template only.\n end",
"def index\n @work_times = WorkTime.all\n\n # below are filters for the employee list\n # header title is for the index views for each queries\n @header_title = \"All Employee\"\n # query for the work time ID\n # filter list according to a specific work time ID\n # id is usually given by default in rails andis used mainly in the show method\n if id = params[:id]\n @header_title = \"\"\n @work_times = @work_times.where(id: id)\n end\n # query for work time under a certain employee through their employee ID\n # filter list according to employee ID\n if employee_id = params[:employee_id]\n employee = Employee.find(employee_id)\n @header_title = \"#{employee.name}'s\"\n @work_times = @work_times.where(employee_id: employee_id)\n end\n # query for work time of a specific time of scan\n # filter list according to the time the work time had been scanned or made\n # must input until the last second\n # format: HH:MM:SS\n if time_of_scan = params[:time_of_scan]\n @header_title = \"All #{time_of_scan} timed\"\n @work_times = @work_times.where(employee_id: employee_id)\n end \n # query for time flag of work times\n # filter list according to what is logged in or what is logged out in the table\n # only two choices must be \"logged_in\" or \"logged_out\" else it will return nothing\n if time_flag = params[:time_flag]\n @header_title = \"All #{employee.name}'s\"\n @work_times = @work_times.where(employee_id: employee_id)\n end \n # query for the date of the work time\n # filter list according to the date of creation of the work time\n # format: YYYY-MM-DD\n if work_date = params[:work_date]\n if params[:work_date] = Date.current\n @header_title = \"Today's\"\n else\n @header_title = \"All #{params[:work_date]} Dated\"\n end\n @work_times = @work_times.where(work_date: work_date)\n end \n\n # renders the display according to what format the URL or request was in\n respond_to do |format|\n # HTML requests will render the index.html.erb present in app/views/work_times folder\n # displays the list of work times in index.html.erb\n format.html { render \"work_times/index\", status: :ok }\n # JSON requests will render the list of work times in json format\n format.json { render json: @work_times, status: :ok }\n # XML requests will render the list of work times in xml format\n format.xml { render xml: @work_times, status: :ok }\n end\n end",
"def index\n @work_days = WorkDay.all\n end",
"def show\n @workshops = Workshop.where(:host_id => @user).first_meeting_in_the_future\n @other_workshops = Workshop.where(:host_id => @user).where(%Q(#{Workshop.quoted_table_column(:id)} NOT IN (#{@workshops.select(Workshop.quoted_table_column(:id)).to_sql})))\n @workshops = @workshops.order(%Q(#{Meeting.quoted_table_column(:start_time)}))\n @workshops = @workshops.to_a.uniq\n @sort_order = 'date'\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def index\n @workdays = Workday.all\n end",
"def index\n @attendance_histories = AttendanceHistory.all\n end",
"def show\n @work_time = WorkTime.find(params[:id])\n # search for employee for the header of the work time view in show.html.erb\n # makes use of the employee ID present in the current work time being seen\n @employee = Employee.find(@work_time.employee_id)\n\n # renders the display according to what format the URL or request was in\n respond_to do |format|\n # HTML requests will render the show.html.erb present in app/views/work_times folder\n # displays the work time in show.html.erb\n format.html { render \"work_times/show\", status: :ok }\n # JSON requests will render the employee profile in json format\n format.json { render json: @work_times, status: :ok }\n # XML requests will render the employee profile in xml format\n format.xml { render xml: @work_times, status: :ok }\n end\n end",
"def show\n \n unless log_in? || cus_indentify(get_id)\n flash[:danger] = \"Please Log in!\"\n redirect_to new_session_path\n end\n #change\n @events = Event.where(\"for_student = true\").pluck(:id,:name)\n $students = Student.all.order(:UIN)\n $students.each do |x|\n @arr = Hash.new([])\n @tslots = x.timeslots\n @events.each do |ev|\n @check = FALSE\n @tslots.each do |t|\n if(t.event_id == ev[0])\n @arr[ev[1]] = (t.start_time.strftime(\"%I:%M%p\") + \"-\" + t.end_time.strftime(\"%I:%M%p\"))\n @check = TRUE\n break\n end\n end\n if(@check == FALSE)\n @arr[ev[1]] = (\"Not Attend\")\n end\n end\n $stu_slot[x.id] = @arr\n end\n #change end\n end",
"def show\n\n @school_students = @school.students.order(:name => :asc)\n @school_rooms = @school.rooms\n @school_periods = @school.periods.order(:start_at => :asc)\n if params[:day]\n @day = params[:day].to_date\n else\n @day = Date.today\n end\n @day_of_week = Time.now.to_date.wday\n @todays_class_sessions = @school.class_sessions.where(:day => @day)\n\n #--ALLOW FOR A NEW CLASS SESSION\n @class_session = ClassSession.new\n @class_session.school = @school\n\n end",
"def index\n works = Work.where(doctor_id: current_user.doctor.id)\n @workhours = Workhour.where(work_id: works.pluck(:id))\n end",
"def index\n @event_attendances = EventAttendance.all\n end",
"def index\n # @employee_shifts = EmployeeShift.all\n @company_shifts = CompanyShift.all\n end",
"def show\n\n #if student, show class enrollments/bookings\n @enrollments = @current_user.enrollments.sort_by {\n |enrollment| enrollment['date']\n }\n\n # if instructor show classes that they are teaching\n @classes_teaching = @current_user.classes_teaching\n\n\n end",
"def index\n @schedule_practices = SchedulePractice.all\n end",
"def index\n @working_hours = WorkingHour.all\n end",
"def index\n @employee_has_shifts = EmployeeHasShift.all\n end",
"def index\n @student_homeworks = StudentHomework.all\n end",
"def show\n @schedules=@teaching.get_schedules\n end",
"def index\n @shifts = current_user.shiftweeks.last.shifts\n end",
"def attendance_statistics\n # retrieves courses which are supervised by the course coordinator\n @courses = current_staff.courses\n # used to display how many student attended out of enrolled students\n @num_of_students_enrolled = {}\n # initiliasing hashes to gather neccessary information\n @practicals_on_specific_weeks = {}\n @attendance_statistics = {}\n \n # groupping the past practicals for each course by weeks\n @courses.each do |course|\n # retrieves the number of students enrolled to the course\n @num_of_students_enrolled[course.course_title] = course.enrolments.count\n # retrives the week number from the start_time of the first practical\n week_number = course.practicals.first.start_time.strftime(\"%U\").to_i\n @practicals_on_specific_weeks[course.course_title] = [[]]\n index = 0\n course.practicals.where(\"end_time < ?\", DateTime.now).each do |practical|\n # moving to the next array element when the week number of the current practical\n # is not equal to the week number of the previous one\n if practical.start_time.strftime(\"%U\").to_i != week_number\n week_number = practical.start_time.strftime(\"%U\").to_i\n index += 1\n @practicals_on_specific_weeks[course.course_title][index] = []\n end\n @practicals_on_specific_weeks[course.course_title][index] << practical\n end\n end\n \n # calculates how many student attended the practicals during the week\n @courses.each do |course|\n @attendance_statistics[course.course_title] = Array.new(@practicals_on_specific_weeks[course.course_title].count, 0)\n @practicals_on_specific_weeks[course.course_title].each_with_index do |practicals_on_same_week, index|\n practicals_on_same_week.each do |practical|\n @attendance_statistics[course.course_title][index] += practical.attendances.count\n end\n end\n end\n end",
"def index\n @workdays = Workday.find_all_by_user_id(current_user)\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def show\n @program_attendance = ProgramAttendance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @program_attendance }\n end\n end",
"def show\n @attendance = Attendance.find(params[:id])\n end",
"def attendance_statistics_for_certain_student\n # retrieves courses which are supervised by the course coordinator\n @courses = current_staff.courses\n # checks whether the required data is submitted so the procudere can proceed\n if !params[:sam_student_id].nil? && !params[:course_id].nil?\n \n # checks whether submitted the student ID belongs to a student in the database\n # if so, it retrieves the student's and course's data\n if Student.exists?(sam_student_id: params[:sam_student_id])\n @student = Student.find_by(sam_student_id: params[:sam_student_id])\n @course = @courses.find(params[:course_id])\n \n # checks whether the student is enrolled to that course\n if Enrolment.exists?(student_id: @student.id, course_id: @course.id)\n # retrives the week number from the start_time of the first practical\n week_number = @course.practicals.first.start_time.strftime(\"%U\").to_i\n @practicals_on_specific_weeks = [[]]\n index = 0\n \n # retrieves only the past practicals for the course and groups them by week\n @course.practicals.where(\"end_time < ?\", DateTime.now).each do |practical|\n if practical.start_time.strftime(\"%U\").to_i != week_number\n week_number = practical.start_time.strftime(\"%U\").to_i\n index += 1\n @practicals_on_specific_weeks[index] = []\n end\n @practicals_on_specific_weeks[index] << practical\n end\n \n @attendance_on_practicals = Array.new(@practicals_on_specific_weeks.count,false)\n index = 0\n \n # goes through the practicals for each week and checks whether \n # the student attended at least one practical on a given week\n @practicals_on_specific_weeks.each do |practicals|\n practicals.each do |practical|\n if Attendance.exists?(practical_id: practical.id, student_id: @student.id)\n @attendance_on_practicals[index] = true\n end\n end\n index += 1\n end\n # if the submitted student ID is valid, but the student is not enrolled to that course,\n # it sets an alert message and redirects the user to the attendance_history page\n else\n flash[:alert] = \"Student with ID: \\'#{params[:sam_student_id]}\\' is not enrolled for that course!\"\n redirect_to attendance_history_path \n end\n \n # if an invalid student ID was submitted, it sets an alert message\n # and redirects the user to the attendance_history page\n else\n flash[:alert] = \"Student with ID: \\'#{params[:sam_student_id]}\\' not found!\"\n redirect_to attendance_history_path\n end\n end\n end",
"def show_team\n if Accruel_rate.all.count == 0\n else\n @tronc_total = get_tronc_total_for_current_period\n @table_dates=[]\n start_date = get_tronc_start # Current period tronc start \n end_date = get_tronc_end # Current period tronc end\n my_days = [0] # day of the week in 0-6. Sunday is day-of-week 0; Saturday is day-of-week 6.\n @table_dates = (start_date..end_date).to_a.select {|k| my_days.include?(k.wday)} # populate table head\n \n @pure_foh_staffhours =Staffhour.joins(:staff).where(staffs: {area: \"Front of House\", payment_terms: \"Hourly Rate\", status: \"Active\"}).where('week_end_date BETWEEN ? AND ?', start_date, end_date )\n @foh_staffhours = @pure_foh_staffhours.sort_by { |hsh| hsh[:staff_id] }\n @foh_staffhours = @foh_staffhours.group_by {|i| i.staff_id} # array grouped by staff member \n @foh_staff =Staff.where(area: \"Front of House\", status: \"Active\", payment_terms: \"Hourly Rate\")\n \n @pure_kit_staffhours =Staffhour.joins(:staff).where(staffs: {area: \"Kitchen\", payment_terms: \"Hourly Rate\", status: \"Active\"}).where('week_end_date BETWEEN ? AND ?', start_date, end_date )\n @kit_staffhours = @pure_kit_staffhours.sort_by { |hsh| hsh[:staff_id] }\n @kit_staffhours = @kit_staffhours.group_by {|i| i.staff_id} # array grouped by staff member \n @kit_staff =Staff.where(area: \"Kitchen\", status: \"Active\", payment_terms: \"Hourly Rate\")\n \n @mgrs =Staff.where(area: \"Manager\", status: \"Active\")\n \n end\n end",
"def index\n @work_schedules = WorkSchedule.all\n end",
"def index\n @training_workshops = TrainingWorkshop.all\n end",
"def print\n current_ts = Timesheet.find(params[:current_ts_id])\n if params[:weekof].present?\n weekof = Date.parse(params[:weekof]) \n else\n weekof = Date.today\n end\n name = User.current.firstname\n wage = User.current.wage.amount.to_s\n current = Date.today\n\n #TODO change the name of the default scopes on TimeEntry for dates, they need to express that the collection includes the dates indicated.\n usrtiments = TimeEntry.foruser(User.current).after(weekof).before(weekof + 6.days) #this use of before and after is cool\n\n mon = (usrtiments.select {|t| t.spent_on == weekof}).inject(0) {|sum, x| sum + x.hours}\n tue = (usrtiments.select {|t| t.spent_on == (weekof + 1)}).inject(0) {|sum, x| sum + x.hours} \n wed = (usrtiments.select {|t| t.spent_on == (weekof + 2)}).inject(0) {|sum, x| sum + x.hours}\n thu = (usrtiments.select {|t| t.spent_on == (weekof + 3)}).inject(0) {|sum, x| sum + x.hours}\n fri = (usrtiments.select {|t| t.spent_on == (weekof + 4)}).inject(0) {|sum, x| sum + x.hours}\n sat = (usrtiments.select {|t| t.spent_on == (weekof + 5)}).inject(0) {|sum, x| sum + x.hours}\n sun = (usrtiments.select {|t| t.spent_on == (weekof + 6)}).inject(0) {|sum, x| sum + x.hours}\n\n hours = mon + tue + wed + thu + fri + sat + sun\n status =\"\"\n\n #need to check for valid datetime instead of nil\n if current_ts.paid != nil\n status = \"Paid\"\n elsif current_ts.paid == nil && current_ts.submitted != nil\n status = \"Submitted, but not paid\"\n else\n status = \"Not submitted and not paid\"\n end\n\n if hours == 0 || hours > 100\n #flash[:warning] = 'You do not have any hours for the specified week! Add hours to print a timecard.'\n flash[:warning] = 'Error, error! Either you are printing a timesheet with no need for payment or you got some wiring loose and logged too many hours.'\n redirect_to :action => 'employee_index' #potential problem with this when admin uses it\n else #method in timesheethelper\n send_data (generate_timesheet_pdf(name, wage, current, weekof, mon, tue, wed, thu, fri, sat, sun,status),\n :filename => name + \"_timecard_from_\" + weekof.to_s + \"_to_\" + (weekof + 6.days).to_s + \".pdf\",\n :type => \"application/pdf\")\n end\n end",
"def show\n @exercises = Exercise.all\n @workout_routines = WorkoutRoutine.all\n end",
"def index\n\n @attendances = @training_class.attendances\n\n if(params[:student_id])\n @student= Student.find(params[:student_id])\n @stu_attendances =@training_class.student_attendance(@student)\n @week_dates = WeekDate.group_days(@stu_attendances,@training_class)\n\n # @student_attendances =@attendances.student_attendances.where(student_id: @student)\n\n render \"index_for_special_student\"\n else\n render \"index\"\n end\n end",
"def show\n\n @courses = Course.select(\"id, course_code, course_name\")\n\n require 'ostruct'\n\n\n @mycourses = @user.courses.all\n\n timetable = Array.new\n\n colors = ['#FFBBFF','#FFFFCC','#CCFFFF','#BBBBEE','#EEBBBB','#BBEEBB','#CCCCCC','#6699FF']\n color_index = 0\n\n @mycourses.each do |mycourse|\n\n current_color = colors[color_index % colors.size]\n color_index = color_index + 1\n\n mycourse.course_users.first.section_ids.each do |lecture|\n\n if not(mycourse.Wintersections[lecture].nil? or mycourse.Wintersections[lecture].empty?)\n\n for meeting in mycourse.Wintersections[lecture][3]\n\n\n\n (1..meeting.count).each_with_index do |val, i|\n\n meet = OpenStruct.new\n meet.place = meeting[0]\n meet.day = meeting[i][0]\n meet.start_time = meeting[i][1].to_i\n meet.end_time = meeting[i][2].to_i\n meet.payload = mycourse.course_name() + \"\\n\" + lecture + \"\\n\" + meeting[0]\n meet.color = current_color\n if meet.start_time != 0\n timetable << meet\n end\n end\n\n end\n end\n end\n end\n\n\n\n\n #timetable.sort! { |a,b| a.start_time <=> b.start_time }\n\n ##display timetableadding to an instance array rails\n @timeTableEntries = timetable\n\n\n end",
"def overview\n @my_appointments = current_user.appointments \n @my_user_hours = current_user.user_hours \n @recipient_appointment = RecipientAppointment.new \n end",
"def index\n @program_califications = ProgramCalification.all\n end",
"def index\n @professor_schedules = ProfessorSchedule.all\n end",
"def index\n @work_shifts = WorkShift.all\n @work_shifts_by_date = @work_shifts.group_by{ |work_shift| work_shift.start_of_shift.to_date}\n @date = params[:date] ? Date.parse(params[:date]) : Date.today\n end",
"def index\n @appointments = current_user.fetch_appointments\n end",
"def index\n @recurring_shifts = RecurringShift.all\n end",
"def schedule\n @allotments = Allotment.where(:role_id =>current_user.role_id, :department_id => current_user.department_id).order('date ASC')\n\n\n @cohort = User.where(:department_id =>current_user.department_id, :role_id => current_user.role_id)\n @cohort_requests_full_days = Request.where(:user_id => @cohort.ids, :length => \"full day\")\n @cohort_requests_half_days = Request.where(:user_id => @cohort.ids, :length => [\"am half day\", \"pm half day\"])\n\n render(\"requests/schedule_vacation.html.erb\")\n end",
"def view_attendance\n\t\t@semester_events = Event.this_semester\n\t\t@current_cms = Member.current_members\n\t\t# event_member_join = Event.join(curr)\n\t\tevent_members = EventMember.all\n\t\t# @attended_dict = \n\n\t\t@mappings_dict = Hash.new\n\t\t@current_cms.each do |cm|\n\t\t\t@mappings_dict[cm.id] = cm.attendance_mapping(@semester_events)\n\t\tend\n\tend",
"def index\n @attendance_others = current_user.attendan_others\n end",
"def index\n current = Time.now\n @firefighters = User.includes(:schedules).joins(:schedules).where('? <= start_at AND end_at <= ?', current.beginning_of_day, current.beginning_of_day + 1.day )\n @availabilities = format_multiple_availabilities(@firefighters)\n end",
"def details_view_patient\n @patient = current_user.user_record\n @appointments = Appointment.all(:conditions => { :patient_id => @patient.id })\n find_reports(current_user.id)\n end",
"def show\n @teacher = Teacher.find(params[:id])\n @tt_rows = Array.new\n (1..16).each do |i|\n entries = @teacher.entries.map{|e| e if e.lession == i}.compact\n schooldays = [\"monday\",\"thuesday\",\"wendnesday\",\"thursday\",\"friday\",\"saturday\"]\n @tt_rows[i] = Hash.new\n @tt_rows[i][\"lession\"] = i\n @tt_rows[i][\"days\"] = Array.new\n schooldays.each_with_index do |day,di|\n @tt_rows[i][\"days\"] << entries.map{|e| {:subject => e.subject, :klass => e.klass, :rooms => e.rooms.map{|r| r.short}} if e.schoolday == day}.compact\n end\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @teacher }\n end\n end",
"def show\n @upcoming_appointments = Appointment.where('resident_id = ?', @resident.id)\n end",
"def show\n @assignment = Assignment.find(params[:id])\n if params[:start_date].nil?\n @date = Time.now\n else\n @date = Date.parse(params[:start_date])\n end \n @date = @date - (@date.wday==0 ? 6 : @date.wday-1).days\n @start_date = Date.new(@date.year, @date.month, @date.day)\n @events = Shift.joins{:assignment}.where('assignment_id = ?',@assignment.id).where('date between ? and ?', @start_date, @start_date+7).chronological.to_a \n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end",
"def show\n @use_case.works << Work.where(use_case_no: @use_case.use_case_no)\n @use_case.hard_infos << HardInfo.where(use_case_no: @use_case.use_case_no)\n @use_case.sales_details << SalesDetail.where(use_case_no: @use_case.use_case_no)\n #calculate id issued / sc count\n @use_case.id_issued = 0\n @use_case.sc_count = 0\n @use_case.hard_infos.each do |hi|\n if hi.id_issued == nil\n hi.id_issued = 0\n end\n if hi.sc_count == nil\n hi.sc_count = 0\n end\n @use_case.id_issued = @use_case.id_issued + hi.id_issued\n @use_case.sc_count = @use_case.sc_count + hi.sc_count\n end\n\n end",
"def show\n @assistance = []\n @assistance = []\n aux = Assistance.all\n aux.each do |ass|\n @assistance << ass if ass.course_id == @course.id\n end\n @dates = []\n @assistance.each do |ass|\n @dates << ass.date unless @dates.include?(ass.date)\n end\n end",
"def index\n @workshops = Workshop.all\n end",
"def show\n #Get Resume this entry belongs to\n @Resumes = Resume.all\n @UsersResumes = Array.new\n @EducationEntries = Array.new\n @ActivityEntries = Array.new\n @WorkEntries = Array.new\n \n @Resumes.each do |resume|\n if resume.user_id == @user.id\n @UsersResumes.push(resume)\n \n \n #Get Education Entries\n @Educations = EducationEntry.all\n @Educations.each do |education|\n if education.resume_id == resume.id\n \n @EducationEntries.push(education)\n end\n end \n \n #Get Work Entries\n @Works = WorkEntry.all\n @Works.each do |work|\n if work.resume_id == resume.id\n \n @WorkEntries.push(work)\n end\n end \n \n #Get Work Entries\n @Activities = ActivityEntry.all\n @Activities.each do |activity|\n if activity.resume_id == resume.id\n @ActivityEntries.push(activity)\n end\n end \n end # if resume.user_id = @user.id\n end #end loop\n \n \n end",
"def show\n @work_order_schedules = WorkOrderSchedule.where('work_order_id = ?', params[:id])\n end",
"def show\n @workout_session = WorkoutSession.find(params[:id])\n if !user_is_allowed?(@workout_session)\n redirect_to workout_sessions_path\n return\n end\n\n exercises = @workout_session.exercises\n exerciseWorkoutThrills = @workout_session.exercises_workout_thrills\n\n @exerciseList = Hash.new\n exercises.each do |e|\n if !@exerciseList.has_key?(e)\n @exerciseList[e] = []\n end\n end\n exerciseWorkoutThrills.each do |ewt|\n @exerciseList[ewt.exercise] << {:id => ewt.id, :multiplier => ewt.multiplier, :value => ewt.value}\n end\n\n #render :text => @exerciseList.as_json.to_s, :layout => false\n #return\n\n #if @workout_session.workout_day.nil?\n # @day = \"No Training Day in WorkOut Session\"\n # else\n # @day = @workout_session.workout_day.day\n #end\n\n\n #@exercises = []\n #exerciseWorkoutThrills.each do |e|\n # @exercises << {:e => e.exercise, :id => e.id, :value => e.value, :multiplier => e.multiplier}\n #end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout_session }\n end\n end",
"def index\n if current_user.admin?\n @appointments = Appointment.all\n @appointments_report = Appointment.report\n else\n @appointments_report = Appointment.where(user_id: current_user.id).report\n end\n end",
"def index\n @shifts = Shift.all\n @shiftsmanager = Shift.where(assignment_id: Assignment.for_store(current_user.employee.current_assignment.store_id))\n end",
"def show\n @next_inspection_schedule = @equipment.next_inspection_schedule\n @inspection_histories = @equipment.inspection_schedules.where(schedule_status: ScheduleStatus.of_completed)\n end",
"def show\n @workout_day = WorkoutDay.find(params[:id])\n\n @exercises = @workout_day.exercises\n\n assign_exercises_selection_list\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout_day }\n end\n end",
"def index\n @homeworks = Homework.all\n @assignments = Assignment.all\n @users = User.all\n end",
"def index\n @homeworks = Homework.all\n end",
"def index\n @weekinfos = Weekinfo.all\n end",
"def show\n \t@recordings = Recording.where(surah_id: @surah.id, user_id: current_user.id)\n end",
"def show\n \t@department_name = Department.find(@instrument.department_id).name\n \t\n \t@avaliable = Array.new(16){ Array.new(7)}\n \t@week = [@instrument.monday, @instrument.tuesday, @instrument.wednesday, @instrument.thursday, \n \t\t\t @instrument.friday, @instrument.saturday, @instrument.sunday ]\n \t@day = [ @instrument.morning, @instrument.afternoon, @instrument.night]\n\n for n in 0..6\n \t if @week[n] == '1'\n \t for k in 0..2\n \t \t if @day[k] != nil\n \t @array = @day[k].split(',')\n \t @start_hour = @array[0].to_i\n \t @end_hour = @array[1].to_i\n \t for i in (@start_hour - 6)..(@end_hour - 6 - 1)\n \t @avaliable[i][n] = 1\n \t\t end\n \t \t end\n \t end\n \t end\n \tend\n end",
"def show\n @timeclocks = @job.time_clocks\n @expenses = @job.expenses\n end",
"def index\n @firework_details = FireworkDetail.all\n end",
"def show\n\n @week = @inclass.week\n end",
"def index\n @app_appointments = AppAppointment.all\n end",
"def index\n @dictations = @training_class.dictations\n\n if(params[:student_id])\n @student= Student.find(params[:student_id])\n @stu_diction_scores =@training_class.student_dictions(@student)\n @week_dates = WeekDate.group_days(@stu_diction_scores,@training_class)\n # @student_attendances =@attendances.student_attendances.where(student_id: @student)\n\n render \"index_for_special_student\"\n else\n render \"index\"\n end\n end",
"def display\n print_out = $db.execute(\"SELECT Exercise.name, Workouts.date, Workouts.weight FROM Workouts JOIN Exercise ON Exercise.id = Workouts.exercise_id \")\n #print print_out\n puts \"Date: #{print_out[0][1]}\"\n puts \"Exercise: #{print_out[0][0]}\"\n\nend",
"def fetch_attendance\n Attendance.where(:course_id => teaching.course.id, :enrollment_id => enrollments).order(:attendance_date).group_by(&:attendance_date)\n end",
"def show\n @tutor_attendance = TutorAttendance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tutor_attendance }\n end\n end",
"def list_fit_wit_workout(e)\n \"#{e.name} on #{e.date_accomplished}\"\n end",
"def index\n if params[:standard_id] && params[:division] && params[:date] && params[:subject]\n @attendance = Attendance.where(:standard_id => params[:standard_id],\n :division_id => params[:division],\n :date => params[:date], :subject_id => params[:subject]).limit(1).last\n @standard = Standard.find(params[:standard_id])\n @division = Division.find(params[:division])\n @students = @division.students.where(is_enquiry: false)\n else\n @attendances = Attendance.all\n end\n end",
"def index\n\n if current_user.admin?\n @attendances = Attendance.all\n else\n @attendances = current_user.attendances\n end\n\n @attendances = @attendances.order(created_at: :desc).page params[:page]\n\n @time_in_present = current_user.attendances.where(time_in: Date.today.all_day).present?\n @time_out_present = current_user.attendances.where(time_out: Date.today.all_day).present?\n\n end",
"def index\n @program_employees = ProgramEmployee.all\n end",
"def show\n @patient = Patient.find(params[:id])\n @appointments = Appointment.where(patient_id: @patient.id)\n end",
"def day\n @client = Client.new\n @title = @current_user.name\n @view = 'day'\n # TODO is Date.parse in current time zone? If not add.\n @date = params[:date].nil? ? Date.current : Date.parse(params[:date])\n # TODO: brakeman is warning of security problem with this line\n @nav_title = @date.strftime(NAV_TITLE[@view.to_sym])\n # TODO: should employees stay or go?\n @employees = [1]\n\n @appointments_by_hour = Hash.new\n r = Appointment.where(time: @date.in_time_zone.beginning_of_day..@date.in_time_zone.end_of_day).order(:time).includes(:client)\n r.each do |appointment| #.order(:time).group_by(&:time)\n k = appointment.time.hour\n if @appointments_by_hour.has_key?(k)\n @appointments_by_hour[k].push(appointment)\n else\n @appointments_by_hour[k] = [appointment]\n end\n end\n\n render 'index'\n end",
"def list\n _work_date = params[:work_date]\n employee = params[:employee].blank? ? '' : params[:employee]\n \n work_date = Date.strptime(_work_date, '%d-%m-%Y') if _work_date.present?\n \n pgnum = params[:pgnum].blank? ? 1 : params[:pgnum].to_i\n pgsize = params[:pgsize].blank? ? 0 : params[:pgsize].to_i\n sortcolumn = params[:sortcolumn].blank? ? AttendanceHelper::DEFAULT_SORT_COLUMN \n : params[:sortcolumn]\n sortdir = params[:sortdir].blank? ? AttendanceHelper::DEFAULT_SORT_DIR : \n params[:sortdir]\n \n sort = ApplicationHelper::Sort.new(sortcolumn, sortdir)\n \n filters = { :work_date => work_date,\n :employee => employee }\n \n if work_date.blank? && employee.blank?\n @data = AttendanceHelper.get_all(pgnum, pgsize, sort)\n \n else\n @data = AttendanceHelper.get_filter_by(filters, pgnum, pgsize, sort)\n end\n \n respond_to do |fmt|\n fmt.html { render :partial => 'list' }\n fmt.json { render :json => @data }\n end\n end",
"def index\n # @workshop = @workshops.last # Useful to display the last workshop\n # if @workshops.count != 0 # If there is no workshop, don't create these variables\n # @id = @workshop.id\n # @project = @workshop.projects\n # @count = count_groups(@project)\n # end\n # render :show\n\n end",
"def employee\n @employee = current_user.employee\n @past_shifts = Shift.past.for_employee(@employee.id).paginate(:page => params[:pasts_page]).per_page(10)\n @shifts = Shift.for_employee(@employee.id).for_next_days(14).paginate(:page => params[:shifts_page]).per_page(10)\n end",
"def index\n @appointments = Appointment.all.order(:section, :time_slot)\n end",
"def index\n @shifts = Shift.all\n end",
"def index\n @shifts = Shift.all\n end",
"def index\r\n @workshop_salaries = WorkshopSalary.all\r\n @locations = Location.all\r\n end",
"def show\n @blocks = @schedule.blocks(:for_registration => true).sort_by { |b| b.start }\n @attendances = if current_person\n current_person.attendances\n else\n []\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @schedule }\n end\n end",
"def show\n\t\t@guardian = @student.guardian || Guardian.new\n\t\t@health_care = @student.health_care || HealthCare.new\n @schools = School.all\n\t\t@activities = Activity.joins(:students).where(students: {id: @student.id})\n\t\t@programs_edu =\tProgram.includes(:activities).where(line: \"epc\").joins(:activities).where(activities: {id: @activities})\n\t\t@programs_m =\tProgram.includes(:activities).where(line: \"n\").joins(:activities).where(activities: {id: @activities})\n\t\t@programs_h =\tProgram.includes(:activities).where(line: \"h\").joins(:activities).where(activities: {id: @activities})\n end"
] |
[
"0.6609895",
"0.6524233",
"0.6500905",
"0.6472271",
"0.64557993",
"0.6253594",
"0.6214651",
"0.62002087",
"0.62002087",
"0.62002087",
"0.62002087",
"0.61990535",
"0.61906576",
"0.6179133",
"0.61508965",
"0.6149542",
"0.6121683",
"0.6116071",
"0.6087156",
"0.6083659",
"0.60543394",
"0.60528487",
"0.6050952",
"0.60290176",
"0.6016327",
"0.60106796",
"0.600081",
"0.59891045",
"0.59870994",
"0.598693",
"0.5964939",
"0.59604114",
"0.59550196",
"0.59516406",
"0.59289414",
"0.5908491",
"0.59077495",
"0.5900584",
"0.58884084",
"0.58846253",
"0.5878868",
"0.58737606",
"0.58707374",
"0.58629125",
"0.5861132",
"0.5848863",
"0.5847681",
"0.58323056",
"0.58263767",
"0.5811016",
"0.57943714",
"0.5792634",
"0.57841134",
"0.57838213",
"0.5772968",
"0.57704973",
"0.5757195",
"0.57539755",
"0.57526445",
"0.57488894",
"0.5735763",
"0.5735628",
"0.57348907",
"0.57298845",
"0.57298297",
"0.57093483",
"0.57076514",
"0.57061374",
"0.5705403",
"0.5694427",
"0.5694218",
"0.5693999",
"0.5691625",
"0.56878006",
"0.567863",
"0.56712663",
"0.5664099",
"0.56612414",
"0.56595355",
"0.56580585",
"0.56575584",
"0.56549203",
"0.56519306",
"0.5647564",
"0.56427836",
"0.56305933",
"0.5626711",
"0.5620404",
"0.5616296",
"0.5608969",
"0.56010085",
"0.5599191",
"0.55987734",
"0.5598736",
"0.5595016",
"0.55920285",
"0.55909574",
"0.55909574",
"0.5588745",
"0.5585221",
"0.5580142"
] |
0.0
|
-1
|
Custom method to mark the attendance record of a training event
|
def record_attendance
TrainingRecord.where(id: params[:unattended_ids]).update_all(attended: true)
redirect_to trainings_url, notice: "The attendance was successfully updated"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attend_event(event, status = :pending)\n a = Attendance.where(user_id: self.id, event_id: event.id).first_or_create\n a.status = status\n a.save\n end",
"def set_event\n @attendance = Attendance.find(params[:id])\n end",
"def certify_event_attendence\n @event = Event.find_by_id(params[:event_id].to_i)\n if @event != nil && !@event.submitted_for_certification\n if @event.is_expired\n\n # the auto attendance array\n auto_attendance = []\n\n # populate auto attendance array and mark auto attendances as processed\n EventAutoAttendance.where(event_id: params[:event_id].to_i, processed: false).each do |auto| # .map(&:user_id)\n # add the id to the array\n auto_attendance << auto.user_id\n\n # processed\n auto.processed = true\n auto.save\n end\n\n # check to see if any records have been processed if this is the case set the boolean\n processing_done = true if EventAutoAttendance.where(event_id: params[:event_id].to_i, processed: true).count > 0\n\n # array of all current attendees\n attender_ids = []\n\n # loop through the current attendances and..\n # 1. Get their user.id into the attender_ids array\n # 2. Adjust the user's attendance type/status based on the auto attendance\n Attendence.where(event_id: params[:event_id]).each do |attendance| # .map(&:user_id)\n # add the list to the attender_ids\n attender_ids << attendance.user_id\n\n # set the attendance for the current attendees based on the auto attendance if they have a valid discord_identity\n if attendance.user.discord_identity && !processing_done\n # are the in the attendance list?\n if auto_attendance.include? attendance.user_id\n attendance.attendence_type_id = 1 # attending\n else\n attendance.attendence_type_id = 2 # not attending\n end\n\n # save the modified attendance record\n attendance.save\n end\n end\n\n # get all of the users not in the `attendance` table id list\n users = Role.find_by_id(0).role_full_users.filter { |user| !attender_ids.include? user.id }\n\n # interate through the list and assign negative attendance unless they are present in the auto attendance table\n users.each do |user|\n # if the user exists in the auto attendance for the event the mark as attending\n # this is in case they didn't say either way but Discord knows they showed up\n if auto_attendance.include? user.id\n attendence_type_id = 1\n else\n attendence_type_id = 2\n end\n\n # create the new attendance\n attendence = Attendence.new(event_id: params[:event_id].to_i,\n user_id: user.id,\n character_id: user.main_character.id,\n attendence_type_id: attendence_type_id)\n attendence.save\n end\n\n # then we reload the event to get the attendences\n @event = Event.find_by_id(params[:event_id].to_i)\n\n # return attendances\n render status: 200, json: @event.attendences.as_json(include: { character: { methods: [:full_name] }})\n else\n render status: 403, json: { message: 'Event end time has not expired. You can not certify an event until after it has concluded.' }\n end\n else\n render status: 404, json: { message: 'Event not found. It may have been removed.' }\n end\n end",
"def set_event_attendance\n @event_attendance = EventAttendance.find(params[:id])\n end",
"def run_before_add(attendance)\n puts 'before adding attendance'\n end",
"def attending?(event)\n \tattendances.find_by(event_id: event.id)\n \tend",
"def attendances?(event)\n attendances.include?(event)\n end",
"def set_event\n @attendances = Attendances.find(params[:id])\n end",
"def toggle_attendance(user_id, event_id, attend, output_as_flash)\n status = EventStatus.find_by(user_id: user_id, event_id: event_id)\n text_output = \"\"\n if !status.blank?\n if attend\n if !status.attending?\n status.attending!\n output_as_flash ? flash.notice = I18n.t('events.attending_success_response') : text_output = I18n.t('events.attending_success_response')\n else\n output_as_flash ? flash.alert = I18n.t('events.attending_failed_response') : text_output = I18n.t('events.attending_failed_response')\n end\n else\n if !status.not_attending?\n status.not_attending!\n output_as_flash ? flash.notice = I18n.t('events.not_attending_success_response') : text_output = I18n.t('events.not_attending_success_response')\n else\n output_as_flash ? flash.alert = I18n.t('events.not_attending_failed_response') : text_output = I18n.t('events.not_attending_failed_response')\n end\n end\n else\n output_as_flash ? flash.alert = I18n.t('global.invalid_input') : text_output = I18n.t('global.invalid_input')\n end\n output_as_flash ? events_path : text_output\n end",
"def set_auto_attendance\n @event = Event.find_by_id(params[:event_id].to_i)\n if @event\n current_auto_attenders = EventAutoAttendance.where(\"event_id = ?\", params[:event_id]).map(&:user_id) if params[:discord_user_ids].count > 0\n # iterate through each user\n params[:discord_user_ids].each do |discord_id|\n # check to see if there already is a record\n discord_identity = DiscordIdentity.find_by discord_id: discord_id\n if discord_identity\n if !current_auto_attenders.include? discord_identity.user_id\n eaa = EventAutoAttendance.new(event_id: params[:event_id], user_id: discord_identity.user_id)\n if !eaa.save\n raise \"Could not save auto-attendance because: #{eaa.errors.full_messages.to_sentence}\"\n end\n end\n end\n end\n\n render status: 200, json: { message: 'Auto attendance completed!' }\n else\n render status: 404, json: { message: 'Event not found.' }\n end\n end",
"def set_attendence\n @event = Event.find_by id: params[:event_id].to_i\n # Look if the event exists and if it has already been submitted_for_certification\n if @event != nil && !@event.submitted_for_certification\n if !@event.is_expired\n # Look and see if the attendence already exists if so we are just going to update it\n @attendence = Attendence.where('user_id = ? AND event_id = ?', current_user.id, params[:event_id]).first\n if @attendence != nil\n @attendence.attendence_type_id = params[:attendence_type_id].to_i\n\n if @attendence.save\n render status: 200, json: @attendence.as_json(include: { character: { methods: [:full_name] }, attendence_type: { } })\n else\n render status: 500, json: { message: 'Error: Attendence could not be updated.' }\n end\n else # if the attendence does not exist then we are going to create it\n @attendence = Attendence.new(event_id: params[:event_id].to_i,\n user_id: current_user.id,\n character_id: current_user.main_character.id,\n attendence_type_id: params[:attendence_type_id].to_i)\n if @attendence.save\n render status: 201, json: @attendence.as_json(include: { character: { methods: [:full_name] }, attendence_type: { } })\n else\n render status: 500, json: { message: 'Error: Attendence could not be updated.' }\n end\n end\n else\n render status: 403, json: { message: 'Event expired. Attendance cannot be changed!' }\n end\n else\n render status: 404, json: { message: 'Event not found.' }\n end\n end",
"def attending_status(event)\n return 'admin' if self.owner_of?(event)\n a = Attendance.where(user_id: self.id, event_id: event.id).first\n a && a.status\n end",
"def attend(event, status)\n post(:session, {:method => \"event.attend\", :event => event, :status => status})\n end",
"def attendance_for(event)\n attendances.where(event_id: event.id).first\n end",
"def attend\n\n @event = Event.find(params[:id])\n if attending?\n @text = \"unattended\"\n else\n @attendee =@event.attendees.create(user_id: current_user.id)\n @text = \"attending\"\n end\n redirect_to event_path(@event)\n end",
"def create\n @event = Event.find(params[:attended_event_id])\n if current_user.attend(@event)\n flash[:success] = \"Confirmed. Enjoy #{@event.title} on #{@event.date.strftime(\"%a, %b %d %Y %I : %M %p\")}\"\n redirect_to user_path(current_user)\n end\n end",
"def create\n @attend_event = AttendEvent.new(attend_event_params)\n @attend_event.user_id = current_user.id\n @attend_event.event_id = params[:event_id]\n @attend_event.seen = false\n\n respond_to do |format|\n if @attend_event.save\n format.html { redirect_to events_url, notice: 'Your request has been recorded.' }\n else\n format.html { render :new }\n format.json { render json: @attend_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_tools_attendance_event\n @tools_attendance_event = Tools::Attendance::Event.find(params[:id])\n end",
"def set_attend_event\n @attend_event = AttendEvent.find(params[:id])\n end",
"def mark_lead_approved(event)\n if event.job.lead && event.job.lead.approved_at.nil?\n event.job.lead.update(approved_at: Time.now.utc)\n end\n end",
"def create\n @event = Event.new(event_params)\n \n if @event.save\n redirect_to @event, success: \"New #{@event.primaryType} event on #{@event.eventDate} has been successfully created.\"\n else\n redirect_to '/events/new', danger: \"Event not created.\"\n end\n \n @cadets = Cadet.where(approved: true).order(:lastName)\n @cadets.each do |cadet|\n if cadet.approved == true\n Attendance.create!(:attended => 1, :cadet_id => cadet.id, :event_id => @event.id)\n end\n end\n end",
"def run_after_add(attendance)\n puts 'after adding attendance'\n end",
"def create\n @event = Event.new(event_params)\n @event.id = SecureRandom.uuid\n @event.phone_number = @the_user.phone_number\n Attendance.create(:id => @the_user.phone_number, :event_id => @event.id)\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attendance_options\n [\"Attended\"]\n end",
"def attend(status=:yes)\n i = [:yes, :maybe, :no].index(status)\n @session.event_facade.attend(id, i)\n true\n end",
"def create\n @absence = AttendanceRecord.find(params[:excuse][:attendance_record_id])\n @excuse = Excuse.new(excuse_params)\n @excuse.attendance_record = @absence\n @excuse.save\n redirect_to excuses_my_absences_path\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance_record\n @attendance_record = AttendanceRecord.find(params[:id])\n end",
"def create\n @attendance = Attendance.find(:first,:conditions=>{:user_id=>current_user.id,:event_id=>params[:event_id]}) || Attendance.new(params[:attendance])\n @attendance.user_id = current_user.id\n @attendance.event_id = params[:event_id]\n\n respond_to do |format|\n if @attendance.save\n format.html { redirect_to event_path(params[:event_id]), notice: 'Attendance was successfully created.' }\n format.json { render json: @attendance, status: :created, location: @attendance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attendance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attended_event = EventAttendance.new(event_params)\n\n respond_to do |format|\n if @attended_event.save\n format.html do\n redirect_to event_url(event_params[:attended_event_id]),\n notice: 'Event attendance was successfully confirmed.'\n end\n else\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_record\n @absence = AttendanceRecord.find(params[:attendance_record_id])\n end",
"def invite_employee(employees, event)\n employees.each do |e|\n Attendance.create(user_id: e, event_id: event, rsvp: \"Invited\")\n end\n end",
"def set_event_attacment\n @event_attacment = EventAttacment.find(params[:id])\n end",
"def create_att(att)\n if att.save\n emp_leave = EmployeeLeave.edit_att(att)\n unless emp_leave.nil?\n if att.is_half_day\n leave_taken = emp_leave.leave_taken.to_f + (0.5)\n emp_leave.update(leave_taken: leave_taken)\n else\n leave_taken = emp_leave.leave_taken.to_f + (1)\n emp_leave.update(leave_taken: leave_taken)\n end\n end\n end\n end",
"def create\n\t\tattendance = Attendance.create(attendance_params)\n\t\tmsg = \"Thanks, #{attendance.student.name}. You're checked in.\"\n\n\t\tredirect_to new_event_checkin_path(params[:event_id]), notice: msg\n\tend",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def set_attendance\n @attendance = Attendance.find(params[:id])\n end",
"def event_attendence\n @event = Event.find(params[:event_id])\n @e = @event.member_attending_event_registers.build(:user_id => current_user.id, :event_id => \"#{@event.id}\",:owner_id => \"#{@event.user_id}\" )\n\n respond_to do |format|\n if @e.save\n @total_attendence = MemberAttendingEventRegister.find(\"#{@e.id}\").event.update_attributes(:no_of_guests_attending => (@event.no_of_guests_attending)+1)\n format.html { redirect_to(@event, :notice => 'Request has been sent to the event owner.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(events_path, :notice => 'Something has gone wrong , please try again.') }\n format.xml { render :xml => @event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @attendances = Attendance.new(user_id: current_user.id, event_id: params[:event_id])\n\n if Attendance.find_by(event_id: params[:event_id]).nil?\n redirect_to event_path(params[:event_id]) if @attendances.save\n elsif current_user.id == Attendance.find_by(event_id: params[:event_id]).user_id\n redirect_to event_path(params[:event_id])\n flash.alert = 'You are currently in this event'\n\n elsif @attendances.save\n redirect_to event_path(params[:event_id])\n\n end\n end",
"def set_annual_event\n @annual_event = AnnualEvent.find(params[:id])\n end",
"def update_attendance\n unless params[:attendees_ids].blank?\n EventAttendee.update_event_invitee_presence(params[:event_id],params[:attendees_ids])\n EventAttendee.update_event_invitee_absence(params[:event_id],params[:attendees_ids])\n else\n EventAttendee.update_all_event_invitee_absence(params[:event_id])\n end\n flash[:notice] = \"The attendance of the members for the Event '#{params[:event_name]}' has been updated successfully.\"\n redirect_to \"/events/attendees_list?event_id=#{params[:event_id]}\"\n end",
"def create\n\n @training_session = TrainingSession.find enrollment_params[:training_session_id]\n if @training_session.full?\n respond_to do |format|\n format.html {redirect_to @training_session, notice: 'This training session is already full'}\n format.json {render @training_session, notice: 'This training session is already full'}\n end\n else\n @enrollment = Enrollment.new(enrollment_params)\n respond_to do |format|\n if @enrollment.valid?\n add_attendee(event_id: @enrollment.training_session.google_calendar_event_id, attendee: Google::Apis::CalendarV3::EventAttendee.new(email: @enrollment.user.email))\n if @enrollment.save\n format.html { redirect_to @enrollment.training_session, notice: 'Enrollment Successful' }\n format.json { render @enrollment.training_session, status: :created, location: @training_session }\n else\n format.html { redirect_to training_sessions_path, notice: @enrollment.errors}\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to training_sessions_path, notice: @enrollment.errors}\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def attendee\n @training_records = @training.training_records\n end",
"def create\n @attendance_history = AttendanceHistory.new(attendance_history_params)\n\n respond_to do |format|\n if @attendance_history.save\n format.html { \n flash[:success] = \"Event Access Granted!\"\n redirect_to @attendance_history.event }\n format.json { render @attendance_history.event, status: :created, location: @attendance_history }\n else\n format.html { \n flash[:success] = \"Sorry, check In failed!\"\n redirect_to current_user }\n format.json { render json: @attendance_history.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mark_worker_was_here\n @adventure.events.create(action: 'worker_ran')\n end",
"def update\n\n if @event.update(event_params)\n redirect_to @event, success: \"Event was successfully updated.\"\n @event.attendances.each do |attendance|\n @cadet = Cadet.find_by_id(attendance.cadet_id)\n if attendance.attended == 0\n CadetMailer.with(cadet: @cadet, event: @event).absent_email.deliver_later\n elsif attendance.attended == 2\n CadetMailer.with(cadet: @cadet, event: @event).tardy_email.deliver_later\n else\n CadetMailer.with(cadet: @cadet, event: @event).present_email.deliver_later\n end\n end\n else\n redirect_to edit_event_path(@event), danger: \"Event was not updated.\"\n end\n end",
"def use_event_attributes?; end",
"def create\n # Get user\n user = AuthorizeApiRequest.call(params).result\n #Find the event that they are try to mark as attending\n @event = Event.find(params[:event_id])\n #See if event exists and does not belong to this host and user is not already going to it\n if (@event && !user.event.exists?(params[:event_id]) && !@event.going.include?(user.id.to_s))\n #Save the person as going to the event \n if @event.going == nil\n @event.update!(going: [ user.id ] )\n render :attendance_event, status: :ok\n elsif @event.update!(going: @event.going.push(user.id ))\n render :attendance_event, status: :ok\n else\n render json: { status: 'error' }, status: :unprocessable_entity\n end\n else\n render json: { status: 'error' }, status: :unprocessable_entity\n end\n rescue ActiveRecord::RecordNotFound => e\n render json: {\n error: e.to_s\n }, status: :not_found\n end",
"def create\n @attendance = current_employee.attendances.last\n if @attendance\n if @attendance.state == \"in\"\n @attendance.state = \"out\"\n else\n @attendance = current_employee.attendances.new(state: \"in\")\n @attendance.location = Location.new(helpers.get_loc request.ip)\n end\n else\n @attendance = current_employee.attendances.new(state: \"in\")\n @attendance.location = Location.new(helpers.get_loc request.ip)\n @attendance.useragent = Useragent.new(helpers.get_ua request.headers[\"User-Agent\"])\n end\n\n respond_to do |format|\n if @attendance.save\n format.html { redirect_to new_attendance_path, notice: \"Successfully checked #{@attendance.state}\" }\n format.json { render :show, status: :created, location: new_attendance_path }\n else\n format.html { render :new }\n format.json { render json: @attendance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attendance_params\n params.require(:attendance).permit(:id, :user, :event)\n end",
"def recordOn()\n @record = true ;\n end",
"def attend!(exerciseclass)\n \tself.class_bookings.create!(exercise_class_id: exerciseclass.id)\n \tend",
"def attending?(event)\n attended_events.include?(event)\n end",
"def schedule_prediction(appointment_id)\n\tend",
"def update_event(event)\n\t\teventDataset = @DB[:events].where(id: event.get_id)\n\t\tattendeeDataset = @DB[:attendees].where(parent_id: event.get_id)\n\n\t\t#if there are any missing attendees from the attendee table, add them\n\t\tevent.get_attendees.each do |attendee|\n\t\t\tif attendeeDataset.where(name: attendee.get_name).empty?\n\t\t\t\tpersist_attendee(attendee, event.get_id)\n\t\t\tend\n\t\tend\n\tend",
"def create\n @event_attendance = EventAttendance.new(event_attendance_params)\n\n respond_to do |format|\n if @event_attendance.save\n format.html { redirect_to @event_attendance, notice: 'Event attendance was successfully created.' }\n format.json { render :show, status: :created, location: @event_attendance }\n else\n format.html { render :new }\n format.json { render json: @event_attendance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attend_event\n current_user.attended_events << Event.find(params[:event_id])\n flash[:notice] = 'Event was successfully added to your attended events!'\n redirect_to user_path\n end",
"def attend\n user_id = current_user.id\n training_id = params[:id]\n TrainingRecord.create_new_record user_id, training_id\n redirect_to @training, notice: \"You have successfully registered for #{@training.title}\"\n end",
"def attended?(event)\n return false unless event.is_a?(Event) || event.is_a?(EventGroup) || event.is_a?(EventType)\n\n if event.is_a?(Event)\n return false unless events.include?(event)\n event_attendances.find_by_event_id(event.id).attended?\n elsif event.is_a?(EventGroup)\n attendances = event_attendances.find(:all, :joins => [:event], :conditions => { :events => { :event_group_id => event.id }})\n return false if attendances.empty?\n attendances.collect(&:attended?).include?(true)\n elsif event.is_a?(EventType)\n attendances = event_attendances.find(:all, :joins => [:event], :conditions => { :events => { :event_type_id => event.id }})\n return false if attendances.empty?\n attendances.collect(&:attended?).include?(true)\n else\n false\n end\n end",
"def create\n attendance = Attendance.new(params[:attendance])\n event = Event.find(attendance.event_id)\n #fill out the vote and selection allowances for attendees\n attendance.votes_remaining = event.votes_per_attendee\n attendance.selections_remaining = event.selections_per_attendee\n \n if attendance.save\n Notifier.invite_email(attendance).deliver\n redirect_to(event, :notice => 'Invitation was successfully created.')\n else\n flash[:error] = 'Sorry, could not create invitation.'\n redirect_to(event)\n end\n end",
"def save_attendance\n attendances = TransportAttendance.all(:conditions => {:attendance_date => attendance_date, :route_id => route_id, :route_type => route_type})\n attendance_day = TransportAttendanceDay.find_or_initialize_by_attendance_date_and_route_id_and_receiver_type_and_route_type(attendance_date, route_id, passenger, route_type)\n attendance_day.all_present = all_present\n attendance_day.save\n transport_attendances.each do |a|\n attnd = attendances.detect{|at| ((at.receiver_id == a.receiver_id) and (at.receiver_type == a.receiver_type))}\n if attnd.present? \n attnd.destroy if a.marked.to_i == 0\n else\n a.save if a.marked.to_i == 1\n end\n end\n end",
"def mark; end",
"def set_event\n @event = Event.find(params[:attended_event_id])\n end",
"def mark!\n\t\t\t\t@marked = true\n\t\t\tend",
"def set_attendance\n @attendance = Attendance.find(attendance_params[:id])\n @course = @attendance.course\n end",
"def add_mark(assessment, student_number, mark)\n assessment.marks[student_number] = mark\n end",
"def batch_track_attendance(body)\n # checks if all required parameters are set\n \n raise ArgumentError, 'Missing required parameter \"body\"' if body.nil?\n \n\n op = NovacastSDK::Client::Operation.new '/attendances/batch', :POST\n\n # path parameters\n path_params = {}\n op.params = path_params\n\n # header parameters\n header_params = {}\n op.headers = header_params\n\n # query parameters\n query_params = {}\n op.query = query_params\n\n # http body (model)\n \n op.body = body.to_json\n \n\n \n # authentication requirement\n op.auths = [\n { name: 'accessKey', key: 'access_token', in_query: true }\n ]\n \n\n resp = call_api op\n\n \n NovacastSDK::EventV1::Models::BatchTrackAttendanceResponse.from_json resp.body\n \n end",
"def create_attend\n @attend = Attend.create(userID: current_user.id, eventID: @event.id)\n redirect_to @event\n end",
"def set_eatup_event\n @eatup_event = EatupEvent.find(params[:id])\n end",
"def create\n @attendance = Attendance.new(attendance_params)\n\n @attendance.training_class =@training_class\n\n if @attendance.save\n redirect_to training_class_attendances_path(@training_class), notice: 'Attendance was successfully created.'\n\n else\n render :new\n\n end\n\n end",
"def attendance_option(event)\n return false unless event.is_a?(Event)\n return false unless events.include?(event)\n event_attendances.find_by_event_id(event.id).attendance_option\n end",
"def find_attendance\n @attendance = Attendance.where(user: current_user, event: params[:event_id]).first\n end",
"def event_params\n params.require(:event).permit(:eventDate, :primaryType, :subType, :details, attendances_attributes: [:id, :attended, :cadet_id, :event_id, :created_at, :updated_at])\n end",
"def create\n @event_attendance = EventAttendance.new(params[:event_attendance])\n\n respond_to do |format|\n if @event_attendance.save\n format.html { redirect_to @event_attendance, notice: 'Event attendance was successfully created.' }\n format.json { render json: @event_attendance, status: :created, location: @event_attendance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_attendance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n connection = Attendence.open_connection\n\n if (self.attendenceid)\n # update\n sql = \"UPDATE attendence SET dateofattendence='#{self.date}', status='#{self.status}', comment='#{self.comments}' WHERE attendenceid = #{self.attendenceid}\"\n else\n # add\n sql = \"INSERT INTO attendence (dateofattendence, studentid, status, comment) VALUES ('#{self.date}', '#{self.studentid}', '#{self.status}', '#{self.comments}') ;\"\n end\n\n connection.exec(sql)\n end",
"def update\n @subject = Subject.all\n @classes = Classes.all\n @student = Student.find_by(id: params[:id])\n @attendance = Attend.new\n if @attendance.present != true\n @attendance.present = true\n @attendance.student_id = params[:id] \n @attendance.date = Date.today\n @attendance.classes_id = params[:classes_id]\n @attendance.save\n redirect_back(fallback_location: root_path)\n end\n end",
"def save\n this_event = FedoraAccessEvent.new\n this_event.pid = pid\n this_event.agent = agent.truncate(254)\n this_event.event = event\n this_event.location = ip_format(ip)\n this_event.event_time = event_time\n this_event.save\n end",
"def update\n @attendance = Attendance.find(params[:id])\n @attendance.user_id = current_user.id\n\n respond_to do |format|\n if @attendance.update_attributes(params[:attendance])\n format.html { redirect_to event_path(@attendance.event_id), notice: 'Attendance was successfully updated.' }\n format.json { head :ok }\n else\n format.html { redirect_to event_path(@attendance.event_id), notice: 'Something is wrong while updating attendance.' }\n format.json { render json: @attendance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def event_params\n params.require(:event_attendance).permit(:attended_event_id, :attendee_id)\n end",
"def attending?(fun_event)\n if eu_rels.find_by(attended_id: fun_event).nil?\n false\n else\n eu_rels.find_by(attended_id: fun_event).checked_in?\n end\n end",
"def attend\n \t@event = Event.find(params[:id])\n \t@attendee = User.find(session[:user_id])\n\n\t\t# get @attendee's event_commitment with this event, if any\n\t\t@event_commitment = @attendee.event_commitments.where(:event_id => @event.id).first\n\n\t\t# create a new event_commitment, or change @event_commitment's description to \"attend\"\n\t\tif @event_commitment == nil\n\t\t\t@event_commitment = EventCommitment.create(:user => @attendee, :event => @event, :description => \"attend\")\n\t\telsif @event_commitment.description != \"attend\"\n\t\t\t# use update_attributes b/c saves automatically\n\t\t\t@event_commitment.update_attributes(:description => \"attend\")\n end\n\n @event_commitments = @event.event_commitments(true) # use \"true\" to reload info from the db\n\n # respond to: calls attend.js.erb\n respond_to do |format|\n format.js\n format.html { redirect_to(@event) }\n end\n end",
"def update\n @attendance = Attendance.find(params[:id])\n @attendance.toggle!(:active)\n end",
"def set_attendance_other\n @attendance_other = AttendanceOther.find(params[:id])\n end",
"def attendance_params\n params.require(:attendance).permit(:attendee_id, :event_to_attend_id)\n end",
"def events_user_is_attending\n events = Attendance.where(:user_uid => self.uid)\n event_ids = events.pluck(:event_id)\n return Event.where(:id => event_ids)\nend",
"def evented\n @evented = true\n end",
"def attendance_prediction\n\n @attendance = Math.exp(Coefficient.find_by({:name =>\"intercept\"}).value).round(0)\n end"
] |
[
"0.71377575",
"0.65374744",
"0.6376546",
"0.6375869",
"0.62864804",
"0.6283579",
"0.62629837",
"0.62422925",
"0.6220341",
"0.62051284",
"0.6196048",
"0.61597455",
"0.6122399",
"0.6092125",
"0.6073184",
"0.6018037",
"0.5998513",
"0.5910962",
"0.5872051",
"0.5844412",
"0.5835681",
"0.5834375",
"0.5817195",
"0.5807534",
"0.579725",
"0.57822543",
"0.5781157",
"0.5774968",
"0.57685393",
"0.57556933",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5745468",
"0.5744587",
"0.5744587",
"0.572416",
"0.57220316",
"0.5711653",
"0.5700892",
"0.5698114",
"0.56767595",
"0.56767595",
"0.5674646",
"0.566109",
"0.5636219",
"0.5635897",
"0.5622346",
"0.5599147",
"0.5595596",
"0.5580414",
"0.5578035",
"0.5569469",
"0.5567879",
"0.55652106",
"0.55613744",
"0.5558019",
"0.5548677",
"0.5543164",
"0.55265516",
"0.5518859",
"0.55161595",
"0.55063874",
"0.5486625",
"0.548629",
"0.54833466",
"0.547283",
"0.54701734",
"0.54546875",
"0.5451452",
"0.54464823",
"0.544099",
"0.5436531",
"0.5426695",
"0.5426172",
"0.5420103",
"0.5397448",
"0.53893113",
"0.5370666",
"0.5367329",
"0.53618497",
"0.53617793",
"0.53463167",
"0.5339876",
"0.5331711",
"0.53241825",
"0.531869",
"0.53108555",
"0.5300615",
"0.5288549",
"0.5285498",
"0.5283174",
"0.5279"
] |
0.5924925
|
17
|
Use callbacks to share common setup or constraints between actions.
|
def set_training
@training = Training.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 training_params
params.require(:training).permit(:title, :category, :description, :date, :time, :duration)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] |
[
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] |
0.0
|
-1
|
creates a new mentorship relationship paramters from JSON: name, pdSupervisor, pdInstitution, pdStartYear, pdEndYear currently assumes that all parameters are not nil not sure if we should render as json
|
def create
Rails.logger.info(params)
if params.has_key?(:name) && params.has_key?(:pdSupervisor) && params.has_key?(:pdInstitution) && params.has_key?(:pdStartYear) && params.has_key(:pdEndYear)
# need to find the person, supervisor, and institution IDs first
name_id = Person.find_person_id(params[:name])
supervisor_id = Person.find_mentor_supervisor_id(params[:pdSupervisor], params[:pdInstitution])
instit_id = Institution.find_institution_id(params[:pdInstitution])
# check if the mentorship already exists
unless Mentorship.exists?(:person_id => name_id, :mentor_id => supervisor_id, :institution_id => instit_id, :start => params[:pdStartYear], :end => params[:pdEndYear])
@mentorship = Mentorship.new_degree(params[:name], params[:pdSupervisor], params[:pdInstitution], params[:pdStartYear], params[:pdEndYear])
if @mentorship != nil && @mentorship.save
render json: @mentorship.as_json, status: :created
return
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new_relations_data(personality)\n new_relations_data = {}\n new_relations_data[:personality_id] = personality.id\n new_relations_data[:related_content_data] = personality.content\n new_relations_data\n end",
"def create \n @mentorship = Mentorship.new(params[:mentorship])\n \n # REFACTOR: This probably belongs in the model\n # Instead of having a separate params[:skills] should just have params[:mentorship][:skills]\n # And handle all this skill setting in the model.\n skills = []\n params[:skills].keys.each do |skill_id|\n skill = Skill.find(skill_id)\n skills << skill\n end\n @mentorship.skills = skills\n\n respond_to do |format|\n if @mentorship.save\n flash[:notice] = 'Mentorship was successfully created.'\n format.html { redirect_to created_mentorship_url(@mentorship) }\n format.xml { render :xml => @mentorship, :status => :created, :location => @mentorship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mentorship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def npc_relation_params\n params.require(:npc_relation).permit(:campaign_id, :npc1_id, :npc2_id, :status, :notes)\n end",
"def create\n Rails.logger.info(params)\n # check if all the criterias are filled\n # first I just continue to create iff name, positionl, institution exists\n if params.has_key?(:name) && params.has_key?(:position) && params.has_key?(:institution)\n # check if the person already exists? The person might exists as a mentor of other maybe\n unless Person.exists?(name: params[:name])\n @person = Person.new_person(params[:name], params[:position], params[:institution])\n if @person != nil && @person.save\n render json: @person.as_json, status: :created\n return\n end\n else\n render json: {error: 'person exists'}, status: :bad_request\n end\n end\n #render json: {warning: 'not implemented'}, status: 200\n end",
"def create\n @personnel = Personnel.new(personnel_params)\n\n if ( @date && @date != \"\" )\n @date = params[:date].split('-')\n @personnel.birth_date = Date.new(@date[0].to_i,@date[1].to_i,@date[2].to_i)\n end\n\n if ( params[:department] && params[:department] != \"\")\n @deparment = Department.where(name: params[:department])[0]\n @personnel.workin_department_id = @deparment.id\n end\n\n if ( params[:department_manager] && params[:department_manager] != \"\")\n @department_manager = Department.where(name: params[:department_manager])[0]\n @personnel.manage_department_id = @department_manager.id\n end\n\n respond_to do |format|\n if @personnel.save\n format.html { redirect_to @personnel, notice: 'Personnel was successfully created.' }\n format.json { render :show, status: :created, location: @personnel }\n else\n format.html { redirect_to personnels_url, notice: @personnel.errors }\n format.json { render json: @personnel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_relationship_to_participant\n relationship_code = params[:relationship_code]\n if @participant && relationship_code\n ParticipantPersonLink.create(:participant => @participant, :person => @person,\n :relationship_code => params[:relationship_code])\n end\n end",
"def create\n @related_person = RelatedPerson.new(related_person_params)\n\n respond_to do |format|\n if @related_person.save\n format.html { redirect_to @related_person, notice: 'Related person was successfully created.' }\n format.json { render :show, status: :created, location: @related_person }\n else\n format.html { render :new }\n format.json { render json: @related_person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @referent = Referent.new(referent_params)\n if params[:referent][:organisme_id] == \"\"\n #@referent.organisme = Organisme.first\n else\n @referent.organisme = Organisme.find(params[:referent][:organisme_id])\n end\n respond_to do |format|\n if @referent.save\n format.html { redirect_to @referent, notice: 'Referent was successfully created.' }\n format.json { render :show, status: :created, location: @referent }\n else\n format.html { render :new }\n format.json { render json: @referent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mentorship_request_params\n params.require(:mentorship_request).permit(:user_id, :mentor_id, :title, :status, :urgency, :description, :screenshot, tech:[])\n end",
"def spr_person_params\n params.require(:spr_person).permit(:document, :asv_member, :representative, \n :first_name, :second_name, :first_last_name, \n :second_last_name, :gender, :mobile_phone, \n :phone, :main_email, :second_email, :address, \n :ocupation_id, :nationality_id, :academic_level_id, \n :relationship_id, :document_type_id,\n people_attributes: [:id, :dnis, :birth, :promise_day, :parish_id])\n end",
"def create\n @npc_relation = NpcRelation.new(npc_relation_params)\n\n respond_to do |format|\n if @npc_relation.save\n format.html { redirect_to @npc_relation, notice: 'Npc relation was successfully created.' }\n format.json { render :show, status: :created, location: @npc_relation }\n else\n format.html { render :new }\n format.json { render json: @npc_relation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mentor_params\n params.require(:mentor).permit(:FirstName, :LastName, :presentation, :BirthDay, :image, :user_id)\n end",
"def mentor_profile_params\n params.require(\n :mentor_profile).permit(\n :interest, :company, :jobtitle, :yearsofexperience)\n end",
"def relationship_params\n params.require(:relationship).permit(:follower_id, :followed_id)\n end",
"def relationship_params\n params.require(:relationship).permit(:follower_id, :followed_id)\n end",
"def relationship_params\n params.require(:relationship).permit(:follower_id, :followed_id)\n end",
"def relationship_params\n params.require(:relationship).permit(:follower_id, :followed_id)\n end",
"def mentor_params\n params.require(:mentor).permit(:name, :title, :about, :image_url, :department_id)\n end",
"def create\n passenger = Passenger.new(:name => params[:name], :contact_number => params[:contact_number], :nationality => params[:nationality], :meal_pref => params[:meal_pref])\n passenger.save\n render :json => passenger\n end",
"def provisor_params\n params.require(:provisor).permit(:name, :surname, :fathername, :birthday, :inn, :passport, :pharmacy_id)\n end",
"def personal_info_params\n params.require(:personal_info).permit(:fathers_name, :mothers_name, :halls_id, :date_of_birth, :address, :phone_number, :genders_id, :users_id, :batches_id)\n end",
"def relationship_params\n params.require(:relationship).permit(:character_id, :relative_id, :relation_type)\n end",
"def relationship_params\n params.require(:relationship).permit(:donor_id, :target, :link_description)\n end",
"def person_params\n # 結構似乎跟送上來的不大一樣, 要稍作轉換, 還要吻合 Nested Attributes 架構\n # For each hash that \"does not have an id\" key a new record will be instantiated, unless the hash also contains a \"_destroy\" key that evaluates to \"true\".\n # 果資料沒有 id 欄位將自動轉成建立\n # ref: http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html\n params[:roles].each do |role| role[:privileges_attributes] = role[:privileges] end\n params[:person][:roles_attributes] = params[:roles]\n params.require(:person).permit(:label, :content, :roles_attributes => [:id, :role_id, :user_id, :privileges_attributes => [:id, :privilege_id, :privilege_label]])\n end",
"def ab_reltionship_params\n params.require(:ab_reltionship).permit(:abmaster_id, :relatedto_id, :relationtype)\n end",
"def relationship_params\n params.require(:relationship).permit(:follower_user_id, :followed_act_id)\n end",
"def repor_person_params\n params.require(:repor_person).permit(:repor_person)\n end",
"def orphan_sponsorship_params\n params.require(:orphan_sponsorship).permit(:first_name, :age, :sponsorship_number, :bio, :image, :slug)\n end",
"def legislation_sponsor_params\n params.require(:legislation_sponsor).permit(:sponsor_id, :legislation_id)\n end",
"def create\n @participant = Participant.new(participant_params)\n if @participant.organization_type and @participant.organization_type.name == 'FMOH'\n @directorates = Directorate.all\n end\n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant, notice: 'Participant was successfully created.' }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sponsorship_params\n params.require(:sponsorship).permit(:user_id, :animal_id, :donation, :public, :firstname, :lastname, :email)\n end",
"def related_person_params\n params.fetch(:related_person, {})\n end",
"def create\n @person = Person.new(person_params)\n @person.user_id= current_user.id \n respond_to do |format|\n if @person.save\n if params[:skillid]!=nil\n params[:skillid].each do |i| \n\t\t @person.skills << Skill.find_by_id(i)\n\t\tend\n\t\tend\n format.html { redirect_to @person }\n format.json { render :show, status: :created, location: @person }\n else\n org=Organization.where( :user_id =>current_user.id)\n\t\tif org.nil?\n\t\t@groups=org.first.groups\n\t\t@skills=@groups.first.skills\n\t\telse\n\t\t@groups=Group.where( :user_id =>current_user.id)\n\t\t@skills=Skill.where( :user_id =>current_user.id)\n end\n format.html { render :new }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def relatorio_pedagogico_params\n params.require(:relatorio_pedagogico).permit(:rpe_objetivo, :rpe_atendimento, :relatorio_id, :relatorio_attributes => [:relatorio_data, :aluno_id, :funcionario_id])\n end",
"def public_relation_params\n params[:public_relation].permit(:country, :description, :round, :pr_amount)\n end",
"def create\n relationship = Relationship.new(\n sender_id: current_user.id,\n recipient_id: params[:recipient_id]\n )\n if relationship.save\n render json: relationship\n else\n render json: { errors: relationship.errors.full_messages }, status: :unprocessable_entity\n end\n end",
"def personnel_params\n params.permit(:first_name, :last_name, :phone_number, :title, :email, :is_verified)\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? ? 'unknown@nieuwedelft.nl.invalid' : 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 medical_reimbursement_params\n params.require(:medical_reimbursement).permit(*MedicalReimbursement.create_params)\n end",
"def create\n\n partnership = Partnership.new\n partnership.user = current_user\n\n if (partnership.participants.find_by(reference: params[:first_participant_id]) == nil)\n participant1= Participant.find_by(reference: params[:first_participant_id])\n partnership.participants.concat(participant1)\n end\n\n if (partnership.participants.find_by(reference: params[:second_participant_id]) == nil)\n participant2= Participant.find_by(reference: params[:second_participant_id])\n partnership.participants.concat(participant2)\n end\n\n #partnership.first_participant = Participant.find_by(reference: params[:first_participant_id])\n #partnership.second_participant = Participant.find_by(reference: params[:second_participant_id])\n\n partnership.save\n @partnership = partnership\n\n=begin\n respond_to do |format|\n if partnership.save\n format.html { redirect_to @partnership, notice: 'Partnership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partnership }\n else\n format.html { render action: 'new' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n=end\n end",
"def create\n params[:coordinator][:city_id] = @cities_ids\n @coordinator = Coordinator.new(params[:coordinator])\n ong_desc = params[:ong_desc]\n union_movement_desc = params[:union_movement_desc]\n coordinator_years = params[:coordinator_years]\n coordinator_popular_education_years = params[:coordinator_popular_education_years]\n respond_to do |format|\n if @coordinator.save\n if !@coordinator.social_participations.first.nil?\n @coordinator.social_participations.first.save_with_descs(ong_desc, union_movement_desc)\n end\n if !@coordinator.coordinators_education_exps.first.nil?\n @coordinator.coordinators_education_exps.first.update_with_years(coordinator_years, coordinator_popular_education_years)\n end\n flash[:success] = t('coordinator.created')\n format.html { redirect_to(coordinators_path) }\n format.xml { render :xml => @coordinator, :status => :created, :location => @coordinator }\n else\n @rooms = []\n flash[:error] = t('default_error_message')\n format.html { render :action => \"new\" }\n format.xml { render :xml => @coordinator.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def residential_lead_params\n params.require(:residential_lead).permit(:first_name, :last_name, :email, :phone, :contact_type, :earliest_move_in, :latest_move_in, :price_min, :price_max, :properties_referenced, :profession, :employer, :people, :pets, :income, :source, :combined_income, :contact_date, :notes, :availability, :preferences, :appointment_date, :appointment_time, :spaces, :application_date, :application_on_file, :credit_score, :is_artist, :art_description, :status,\n prequalifications_attributes: [:residential_lead_id, :earliest_move_in, :latest_move_in, :price_min, :price_max, :people, :pets, :profession, :employer, :income, :combined_income, :preference, :preferences, :availability, :smoker, :prequalification_date, :prequalification_on_file])\n end",
"def crew_member_params\n params.require(:crew_member).permit(:name,:division,:bio,:starship_id,\n starship_attributes: [:name,:id])\n end",
"def create\n @party_relationship_type = PartyRelationshipType.new(party_relationship_type_params)\n\n respond_to do |format|\n if @party_relationship_type.save\n format.html { redirect_to @party_relationship_type, notice: 'Party relationship type was successfully created.' }\n format.json { render :show, status: :created, location: @party_relationship_type }\n else\n format.html { render :new }\n format.json { render json: @party_relationship_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n json = @json.with_indifferent_access.fetch(:dmp, {})\n render_error(errors: _('Invalid JSON!'), status: :bad_request) and return if json.blank?\n\n plan = Api::V2::DeserializationService.plan_from_dmp_id(dmp_id: json[:dmp_id])\n render_error(errors: _('Plan not found'), status: :not_found) and return if plan.blank?\n\n plan = Api::V2::PlansPolicy::Scope.new(@client, @resource_owner, nil).resolve\n .find { |p| p.id = plan.id }\n render_error(errors: _('Plan not found'), status: :not_found) and return if plan.blank?\n\n related_identifiers = json.fetch(:dmproadmap_related_identifiers, [])\n\n errs = Api::V2::JsonValidationService.related_identifiers_errors(\n json: related_identifiers\n )\n\n if errs.empty?\n RelatedIdentifier.transaction do\n related_identifiers.each do |related_identifier|\n id = Api::V2::Deserialization::RelatedIdentifier.deserialize(\n plan: plan, json: related_identifier\n )\n errs += id.errors.full_messages unless id.valid?\n next unless id.valid? && id.new_record?\n\n # TODO: Remove this once RSpace has updated their call to us\n id.relation_type = 'documents'\n\n id.save\n # Record this API activity\n log_activity(subject: id, change_type: :added)\n end\n end\n end\n\n if errs.flatten.any?\n render_error(errors: errs.flatten.uniq, status: :bad_request)\n else\n @items = paginate_response(results: [plan.reload])\n render '/api/v2/plans/index', status: :created\n end\n rescue StandardError => e\n Rails.logger.error \"API::V2::RelatedIdentifierController - create - #{e.message}\"\n Rails.logger.error e.backtrace\n render_error(errors: 'Unable to process the request at this time', status: 500)\n end",
"def create\n @care_circle = current_user.care_circles.new(care_circle_params)\n relationship = @care_circle.relationships.build\n relationship.user = current_user\n # TODO: figure out why I can't do this with strong parameters (Unpermitted parameters: relationship)\n relationship.relationship_type_id = params[:care_circle][:relationship][:relationship_type]\n\n respond_to do |format|\n if @care_circle.save\n format.html { redirect_to @care_circle, notice: 'Care circle was successfully created.' }\n format.json { render action: 'show', status: :created, location: @care_circle }\n else\n format.html { render action: 'new' }\n format.json { render json: @care_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mentor_profile = MentorProfile.new(mentor_profile_params)\n\n respond_to do |format|\n if @mentor_profile.save\n format.html { redirect_to @mentor_profile, notice: 'Mentor profile was successfully created.' }\n format.json { render :show, status: :created, location: @mentor_profile }\n else\n format.html { render :new }\n format.json { render json: @mentor_profile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @creator_accession_relationship = CreatorAccessionRelationship.new(params[:creator_accession_relationship])\n\n respond_to do |format|\n if @creator_accession_relationship.save\n format.html { redirect_to @creator_accession_relationship, notice: 'Creator accession relationship was successfully created.' }\n format.json { render json: @creator_accession_relationship, status: :created, location: @creator_accession_relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @creator_accession_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n if InfoNode.duplicate_key?(params[:info_types])\n redirect_to :back, :alert => \"Key in the additional information shoud be unique\"\n return\n end\n\n unless params[:rid].nil?\n @rid = params[:rid].strip\n end\n\n @type = params[:type] \n\n @refs = []\n\n params[:refids].each_with_index do |ref_id, idx|\n @refs << {:ref_id => ref_id, :role => params[:labels][idx]}\n end unless params[:refids].nil?\n\n if @refs.empty?\n redirect_to :back, :alert => \"Please add references for a new relation\"\n return\n end\n\n @info_nodes = {}\n (0...params[:info_types].size).each do |i|\n key = params[:info_types][i]\n value = params[:info_values][i]\n if !key.nil? && !key.strip.blank? && !value.nil? && !value.strip.blank?\n @info_nodes[key] = value\n end\n end\n\n begin\n @collection = current_user.collections.find(params[:collection_id])\n raise \"Cannot find the collection No. #{params[:collection_id]}\" if @collection.nil?\n \n @document = @collection.documents.find_by_pmid(params[:document_id])\n raise \"Cannot find the document No. #{params[:document_id]}\" if @document.nil?\n \n @rid = @document.create_new_relation_id if @rid.blank?\n \n @relation = @document.create_relation(@rid, @type, @refs, @info_nodes)\n\n respond_to do |format|\n format.html { redirect_to \"/collections/#{@collection.id}/documents/#{@document.pmid}?tab=relation\", :notice => 'Relation was successfully created.' }\n format.json { render :json => @relation, :status => :created, :location => @relation }\n end\n rescue Exception => e\n logger.debug(e.backtrace)\n respond_to do |format|\n format.html { redirect_to :back, :alert => e.message}\n format.json { render json: @relation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def party_relationship_type_params\n params.require(:party_relationship_type).permit(:from_role_id, :to_role_id, :description, :name)\n end",
"def create\n # authorize preorder_conversition\n member = Member.where(id: params[:preorder_conversition][:member_id]).first\n @preorder_conversition = @site.preorder_conversitions.new(permitted_attributes(PreorderConversition).merge(user_id: current_user.id, member_name: member.name, member_phone: member.mobile_phone))\n if @preorder_conversition.save\n render json: {status: 'ok', url: agent_preorder_conversitions_path}\n else\n render json: {status: 'error', message:@preorder_conversition.errors.full_messages.join(',')}\n end\n end",
"def relatorio_geral_params\n params.require(:relatorio_geral).permit(:rg_objetivo, :rg_atendimento, :relatorio_attributes => [:relatorio_data, :aluno_id, :funcionario_id])\n end",
"def createWithStaff\n created_location = Company.create(params[\"company\"])\n if params[\"id\"]\n updated_person = Person.setCompany(params[\"id\"], created_location)\n end\n render json: created_location\n end",
"def orphan_params\n params.require(:orphan).permit(:orphan_list, :name, :father_name, :father_is_martyr, :father_occupation, :father_place_of_death, :father_cause_of_death, :father_date_of_death, :mother_name, :mother_alive, :gender, :health_status, :schooling_status, :goes_to_school, :guardian_name, :guardian_relationship, :guardian_id, :original_address_gov, :original_address_city, :original_address_neighborhood, :original_address_street, :original_address_details, :current_address_gov, :current_address_city, :current_address_neighborhood, :current_address_street, :current_address_details, :contact_number, :alt_contact_number, :sponsored_by_another_org, :another_org_sponsorship_details, :minor_siblings_count, :sponsored_minor_siblings_count, :comments)\n end",
"def create\n @medicine_patient_relationship = MedicinePatientRelationship.new(params[:medicine_patient_relationship])\n\n respond_to do |format|\n if @medicine_patient_relationship.save\n format.html { redirect_to @medicine_patient_relationship, notice: 'Medicine patient relationship was successfully created.' }\n format.json { render json: @medicine_patient_relationship, status: :created, location: @medicine_patient_relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medicine_patient_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relation = Relation.new(relation_params)\n\n respond_to do |format|\n if @relation.save\n format.html { redirect_to edit_relation_path(@relation), notice: 'Relation was successfully created.' }\n format.json { render :show, status: :created, location: @relation }\n else\n format.html { render :new }\n format.json { render json: @relation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def management_patient_params\n params.require(:management_patient).permit(:title, :name, :mrn, :person_id)\n end",
"def create\n @relation = Relation.new(relation_params)\n name1 = @relation.user1_id\n name2 = @relation.user2_id\n user1 = User.where(name: name1).first\n user2 = User.where(name: name2).first\n @relation = Relation.create(user1_id: user1.id, user2_id: user2.id, status: 0)\n \n respond_to do |format|\n if @relation.save\n format.html { redirect_to @relation, notice: 'Relation was successfully created.' }\n format.json { render :show, status: :created, location: @relation }\n else\n format.html { render :new }\n format.json { render json: @relation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def person_params\n params.require(:person).permit(\n :first_name,\n :last_name,\n :role,\n :school_id,\n :grade,\n :dream_team,\n :future_fellow,\n :email,\n :phone,\n :sex,\n :birthday,\n :description,\n :ob_media_release,\n :ob_parental_consent,\n :ob_disclaimer,\n :facebook_handle,\n :twitter_handle,\n :instagram_handle,\n :parent_first_name,\n :parent_last_name,\n :parent_phone,\n :parent_email\n )\n end",
"def mayor_params\n params.require(:mayor).permit(:name, :last_name, :nacionality, :mail, :phone)\n end",
"def create\n @mentorship = Mentorship.new(params[:mentorship])\n\n respond_to do |format|\n if @mentorship.save\n format.html { redirect_to mentorships_url, notice: 'Mentorship was successfully created.' }\n format.json { render json: @mentorship, status: :created, location: @mentorship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mentorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n course = Course.includes(:professors).new(course_params)\n course.professor_ids=(params[:professors])\n\n if course.save\n render json: course.to_json(include: :professors)\n else\n render :json => { :errors => course.errors }, :status => 422\n end\n end",
"def resource_params\n params.require(:donor).permit(:persona, :cgdvcode, :name, :rfc, :birth, extradonors_attributes: [:id, :pautoriza, :pcontacto, :_destroy])\n end",
"def follower_params\n params.require(:follower).permit(:user_id, :lovedone_id, :request_status, :first_name, :last_name, :email, :phone_number, :apt_unit, :street, :city, :county, :state, :zip_code, :setting, :contact_method_setting, {:contact_method=>[]})\n end",
"def create\n @public_relation = PublicRelation.new(public_relation_params)\n\n respond_to do |format|\n if @public_relation.save\n format.html { redirect_to @public_relation, notice: 'Public relation was successfully created.' }\n format.json { render :show, status: :created, location: @public_relation }\n else\n format.html { render :new }\n format.json { render json: @public_relation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def taxon_name_relationship_params\n params.require(:taxon_name_relationship).permit(:subject_taxon_name_id, :object_taxon_name_id, :type, :created_by_id, :updated_by_id, :project_id, :source_id)\n end",
"def new\n \n # Get mentor and mentee via params + current user\n # Get sender and receiver based on current user and mentor/mentee params\n if params[:mentor_id]\n @mentor = User.find(params[:mentor_id])\n @mentee = current_user\n @sender = current_user\n @receiver = @mentor\n elsif params[:mentee_id]\n @mentor = current_user\n @mentee = User.find(params[:mentee_id])\n @sender = current_user\n @receiver = @mentee\n else\n redirect_to mentorships_path and return false\n end\n \n # Actually create the Mentorship object\n @mentorship = Mentorship.new( :mentor => @mentor,\n :mentee => @mentee,\n :sender => @sender,\n :receiver => @receiver )\n \n\n @matched_skills = @mentorship.matched_skills\n @matched_skills_skills = @matched_skills.collect{ |ms| ms[:skill] }\n @other_skills = [@mentor.skills, @mentee.skills].flatten.uniq.reject{ |s| @matched_skills_skills.include?(s) }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mentorship }\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 @campaign = Campaign.create!(name: params[:name], dm_id: params[:dm_id], theme: params[:theme], setting: params[:setting], calendar_id: params[:calendar_id], starting_level: params[:starting_level], skillset_id: params[:skillset_id], custom_notes: params[:custom_notes], starting_month: params[:month], starting_weekday: params[:weekday], starting_day: params[:day], starting_year: params[:year], starting_age: params[:age], current_month: params[:month], current_weekday: params[:weekday], current_day: params[:day], current_year: params[:year], current_age: params[:age])\n\n params[:race_ids].each do |ri|\n CampaignRace.create!(campaign_id: @campaign.id, race_id: ri)\n end\n\n params[:klass_ids].each do |ki|\n CampaignKlass.create!(campaign_id: @campaign.id, klass_id: ki)\n end\n\n render json: @campaign, status: 201\n\n end",
"def woman_params\n params.require(:woman).permit(:name, :area, :current_position, :linkedin)\n end",
"def person_params\n params.require(:person).permit(:first_name, :middle_name, :last_name, :parent_mother_id, :parent_father_id, :marriage, :description, :dob, :pob)\n end",
"def relationship_params\n params.require(:relationship).permit( :following_id, :created_at, :updated_at)\n end",
"def relation_params\n params.require(:relation).permit(:user_id, :friend_id)\n end",
"def personalinfo_params\n params.require(:personalinfo).permit(:type_human, :first_name, :middle_name, :last_name, :date_of_birth, :gender, :occupation, :member_id)\n end",
"def resource_params\n [params.require(:roster_person).permit(\n :home_phone, :cell_phone, :work_phone, :alternate_phone, :sms_phone, \n :home_phone_carrier_id, :cell_phone_carrier_id, :work_phone_carrier_id, :alternate_phone_carrier_id, :sms_phone_carrier_id, \n :home_phone_disable, :cell_phone_disable, :work_phone_disable, :alternate_phone_disable, :sms_phone_disable, \n :phone_1_preference, :phone_2_preference, :phone_3_preference, :phone_4_preference)]\n end",
"def profession_specific_create\n field_name_arr = params[:field_name]\n field_value_arr = params[:field_value]\n attributes_json = {}\n if (field_name_arr != nil)\n field_name_arr.each_with_index do |field_name, index|\n attributes_json[field_name] = field_value_arr[index]\n end\n end\n attributes_json = attributes_json.to_json\n ginfo_last = GeneralInfo.last # this would be last entry in general_info i.e. the one created by previous (general_info/new) page\n ginfo_last.specific_profile = attributes_json\n ginfo_last.save\n if ginfo_last.save!\n redirect_to '/show_profile'\n else\n render :action=> 'new'\n end\n end",
"def member_commision_params\n params.require(:member_commision).permit(:parliament_id, :commision_id, :structural_id)\n end",
"def create\n exit_if_not_manager and return\n @relation_type = RelationType.new(relation_type_params)\n if params[:relation_type][:entity_type].present?\n @relation_type.entity_type = params[:relation_type][:entity_type].select{|a| a.present? }.join(\",\")\n end\n @relation_type.project_id = @project.id\n respond_to do |format|\n if @relation_type.save\n format.html { redirect_to project_relation_types_path(@project), notice: 'Relation type was successfully created.' }\n format.json { render :show, status: :created, location: @relation_type }\n else\n format.html { render :new }\n format.json { render json: @relation_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n check_member_or_admin_of_group?\n @engagement = Engagement.new(engagement_params)\n @engagement.contact_id = Contact.friendly.find(params[:contact_id]).id\n #@engagement.contact_id = params[:contactid]\n respond_to do |format|\n if @engagement.save\n format.html { redirect_to request.referer, notice: 'Engagement was successfully created.' }\n format.json { render action: 'show', status: :created, location: @engagement }\n else\n format.html { render action: 'new' }\n format.json { render json: @engagement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mentor_params\n params.require(:mentor).permit(:men_id, :name, :gender, :dob, :doj, :contact, :email, :address, :country, :active, :dol, :pincode,\n :age)\n end",
"def profissional_params\n #params.fetch(:profissional, {})\n params.require(:profissional).permit(:specialization, person_attributes:[:name, :cpf, :rg, :home_phone, :cell_phone, :birth_date, :sex])\n\n end",
"def engagement_params\n params.require(:engagement_attendee).permit(\n :engagement_id,\n :person_id\n )\n end",
"def relatorio_params\n params.require(:relatorio).permit(:relatorio_data, :aluno_id, :funcionario_id)\n end",
"def creator_params\n json_params = ActionController::Parameters.new( JSON.parse(request.body.read) )\n json_params.require(:creator).permit(:name, :password)\n end",
"def create\n @p\n x = Person.where(login: params[:treatment][:patient_id]).last\n \n @patient = x.patient.id\n @treatment = Treatment.new(patient_id: @patient, specialist_id: params[:treatment][:specialist_id], treatment_type: params[:treatment][:treatment_type], start_date: params[:treatment][:start_date], end_date: params[:treatment][:end_date], observation: params[:treatment][:observation])\n \n #@treatment = Treatment.new(treatment_params)\n\n respond_to do |format|\n if @treatment.save\n format.html { redirect_to @treatment, notice: 'Treatment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @treatment }\n else\n format.html { render action: 'new' }\n format.json { render json: @treatment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def manifestation_relationship_type_params\n params.require(:manifestation_relationship_type).permit(:name, :display_name, :note)\n end",
"def provider_medico_params\n params.require(:provider_medico).permit(\n :code_medico,\n :c_m_l,\n :speciality_id, \n :phone_medico,\n :people_attributes => [\n :id,\n :first_name,\n :surname,\n :type_identification,\n :identification_document,\n :email,\n :date_birth,\n :sex,\n :civil_status,\n :cellphone,\n :address\n ]\n )\n end",
"def member_of_parliament_params\n params.require(:member_of_parliament).permit(:first_name, :last_name, :email, :electorate_id)\n end",
"def create\n super\n p = Person.new\n p.name_first = params[:first_name]\n p.name_last = params[:last_name]\n p.birth_date = params[:birthday]\n p.client_id = current_client.id\n p.physical_score = 0\n p.abstract_score = 0\n p.social_score = 0\n p.expressive_score = 0\n p.creative_score = 0\n p.save\n end",
"def create\n @profesor = Profesor.new(profesor_params)\n\n if @profesor.save\n render json: @profesor, status: :created, location: @profesor\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end",
"def create\n @product = Product.new(product_params)\n\n #permitted_columns = params[:products_purposes_relations].permit(:product_id, :purpose_id, :stars)\n # @products_purposes_relation = @product.products_purposes_relations.create(permitted_columns)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t('create_success') }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def passenger_detail_params\n params.require(:passenger_detail).permit(:first_name, :last_name, :gender, :nationality, :passport_number)\n end",
"def relationship_params\n params.require(:relationship).permit(:country_id, :friend_id, :score)\n end",
"def create\n @alumno = Alumno.new(params[:alumno])\n\n respond_to do |format|\n if @alumno.save\n render json: @alumno.as_json(include: :persona), status: :created, location: @alumno\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n @person = Person.new\n \tpopulate_attributes(@person, params[:person])\n \n respond_to do |format|\n if @person.save\n @person = Person.find(@person.id)\n populate_attributes(@person, params[:person])\n @person.save\n\n format.html { redirect_to @person, notice: 'Person was successfully created.' }\n format.json { render json: @person, status: :created, location: @person }\n else\n format.html { render action: \"new\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dependent_relationship = DependentRelationship.new(params[:dependent_relationship])\n\n respond_to do |format|\n if @dependent_relationship.save\n format.html { redirect_to @dependent_relationship, notice: 'Dependent relationship was successfully created.' }\n format.json { render json: @dependent_relationship, status: :created, location: @dependent_relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dependent_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def representative_profile_params\n params.require(:representative_profile).permit(:name, :office, :district, :term, :term_start, :bio, :profession, :party_affiliation, :official_email, :avatar, :district_id)\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 @orphan_sponsorship = OrphanSponsorship.new(orphan_sponsorship_params)\n\n respond_to do |format|\n if @orphan_sponsorship.save\n format.html { redirect_to @orphan_sponsorship, notice: 'Orphan sponsorship was successfully created.' }\n format.json { render :show, status: :created, location: @orphan_sponsorship }\n else\n format.html { render :new }\n format.json { render json: @orphan_sponsorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def programmer_params\n params.require(:programmer).permit(:firstname, :lastname, :references)\n end"
] |
[
"0.6167884",
"0.6143598",
"0.6023628",
"0.60101247",
"0.593652",
"0.59189564",
"0.5885262",
"0.58489144",
"0.5755231",
"0.57241064",
"0.5699846",
"0.56985736",
"0.5669499",
"0.56311494",
"0.56311494",
"0.56311494",
"0.5629569",
"0.5614089",
"0.5593516",
"0.55847037",
"0.55840963",
"0.55815923",
"0.55618054",
"0.555897",
"0.554757",
"0.5538243",
"0.5538214",
"0.5537775",
"0.5534772",
"0.5530832",
"0.5524815",
"0.5515828",
"0.5508171",
"0.5506493",
"0.55031955",
"0.54945654",
"0.5485874",
"0.5480324",
"0.5476944",
"0.5469643",
"0.5468602",
"0.5468044",
"0.5466743",
"0.5466087",
"0.54615253",
"0.5457552",
"0.5455457",
"0.5449283",
"0.54488134",
"0.5438814",
"0.5430089",
"0.54271674",
"0.54232347",
"0.54222953",
"0.54124445",
"0.5408635",
"0.54037714",
"0.54022205",
"0.5396567",
"0.5395768",
"0.53947955",
"0.53941345",
"0.53922284",
"0.5392221",
"0.53871995",
"0.53835166",
"0.5380377",
"0.5378567",
"0.53767127",
"0.5376118",
"0.53754604",
"0.53735185",
"0.5370376",
"0.53703725",
"0.5368335",
"0.53679335",
"0.5365998",
"0.5365676",
"0.5364005",
"0.53587836",
"0.53573525",
"0.535612",
"0.5351022",
"0.53416324",
"0.534102",
"0.5340978",
"0.53396964",
"0.5338437",
"0.53306276",
"0.53296345",
"0.5323531",
"0.532213",
"0.5320204",
"0.5312545",
"0.53113484",
"0.53090876",
"0.5308322",
"0.5307985",
"0.5307946",
"0.53078526"
] |
0.7405176
|
0
|
Deletes the least recently used item so your LRU cache is back to max size.
|
def eject!
#removes the first node
node = @store.first
@store.remove(node.key)
#get rid of the map's reference to the deleted node
@map.delete(node.key)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def lru_delete(item)\n lru_join(item.lru_prev, item.lru_next)\n return item\n end",
"def evict_least_recently_used\n @node_counts -= 1\n @table.delete(@head.key)\n delete_front_node\n end",
"def delete_min_locator\n return nil if empty?\n use_min\n loc = mode_call(:find_min_loc)\n @heapsize = mode_call(:delete_loc, loc)\n loc\n end",
"def delete(key)\n if item = super\n lru_delete(item)\n end\n end",
"def del_min\n min_elt = @head.value\n @size -= 1\n if not @head.left\n @head = nil\n return min_elt\n end\n merge_pairs(@head.left)\n return min_elt\n end",
"def remove()\n return nil if empty? \n swap(0, @store.length - 1) # swap last element with root, O(n) to calc length\n old_top = @store.pop() # remove former root with O(1) time\n\n heap_down(0) unless empty?# bubble down new top element so lowest element in 0 index\n\n return old_top.value # return old min's value\n end",
"def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_index\n end\n end\n deleted_index\n end",
"def delete_key key\n # decrease that key to new minimum, and extract it out.\n decrease_key key, min.key - 1\n extract_min\n print_heap\n end",
"def del_min\n return if @keys.size == 0\n @keys.delete_at(0)\n @values.delete_at(0)\n end",
"def delete\n raise \"Bad Things\" if @size == 0\n # @storage[@size-1] = 0 <-- don't need this since it doesn't matter whether the value is 0 or something else\n @size -= 1\n end",
"def delete\n raise \"Bad things happen\" if @size == 0\n @size -= 1\n end",
"def delete_max_locator\n return nil if empty?\n use_max\n loc = mode_call(:find_max_loc)\n @heapsize = mode_call(:delete_loc, loc)\n loc\n end",
"def remove()\n return if @store.empty?\n \n # swap last item in heap with smallest value\n swap(0, -1)\n\n # remove smallest value\n removedNode = @store.pop\n\n # maintain heap structure\n heap_down() if @store.length > 1\n \n return removedNode.value\n end",
"def pop\n return nil if @count == 0\n\n # get the index of the las titem\n @store.store.reverse.each_with_index do |ele, i|\n if ele != nil \n @last_ele = capacity() - (i+1) \n break\n end\n end\n #val = @store.store.delete_at(@last_ele)\n val = @store.store[@last_ele]\n @store.store[@last_ele] = nil\n @count -= 1\n return val\n end",
"def clear_item(**opt)\n cache_delete(**opt)\n end",
"def delete(item, count = 0)\n conn.lrem key, count, item\n end",
"def evict\n return if @cache.empty?\n @semaphor.synchronize(){|| \n keys = @cache.keys\n least_recently_used = keys.first\n @cache.each_pair do |url, response|\n least_recently_used = url if @cache[least_recently_used].timestamp > @cache[url].timestamp\n end\n @current_load = @current_load - @cache[least_recently_used].response.bytesize()\n @cache.delete(least_recently_used)\n }\n end",
"def delete_min\n @root = delete_min_node(@root)\n end",
"def clean!\n if @keys.size > Cache.max_size\n @keys = @keys[(Cache.max_size/2)...@keys.size]\n reject! { |key, value| !@keys.include?(key) }\n end\n end",
"def delete_min\n loc = delete_min_locator\n loc and loc.value\n end",
"def dequeue\n @items.delete_at(0)\n end",
"def remover_item\n # Remove um item do final do buffer\n BUFFER.pop\n end",
"def del_max\n return if @keys.size == 0\n @key.delete_at(@keys.size-1)\n @values.delete_at(@keys.size-1)\n end",
"def lru_touch(item)\n lru_append(@head, lru_delete(item))\n end",
"def remove()\n \n swap(0, @store.length - 1)\n removed = @store.pop()\n \n heap_down(0) unless @store.empty?\n \n return removed.value\n end",
"def remove_max\n return nil if heap.empty?\n deleted = @heap.delete_at 0\n last_one = @heap.pop\n if last_one #ei ole false tai nil\n @heap.insert 0, last_one\n heapify_down 0\n end\n deleted\n end",
"def remove()\n return if @store.empty?\n last = @store.length - 1\n curr = 0\n swap(last, curr)\n removed = @store.pop\n heap_down(curr)\n return removed.value\n end",
"def remove item #(item: pointer)\n freeitem item\n delete item\n end",
"def remove()\n return if @store.empty?\n\n swap(0, @store.length - 1)\n banished = @store.pop\n heap_down(0)\n\n return banished.value\n end",
"def delete(key)\r\n\t\t# If key does not exist then return nil otherwise delete node from list\r\n\t\t# and decrease total number of items in Hashmap by 1\r\n\t\treturn nil if key == nil || !get(key)\r\n\t\tindex = key.hash % @size\r\n\t\t@total -= 1\r\n\t\treturn @arr[index].delete(key)\r\n\tend",
"def delete(key)\n hashed_key = key.hash\n bucket_index = hashed_key % num_buckets\n return nil if !@store[bucket_index].include?(key)\n @count -=1\n @store[bucket_index].remove(key)\n end",
"def delete(val)\n count = self.lrem(0, val)\n if count > 0\n val\n else\n nil\n end\n end",
"def remove()\n removed = @store[0].value\n swap(0, @store.length - 1)\n @store.pop\n heap_down(0)\n return removed\n end",
"def zpopmin(key, count = T.unsafe(nil)); end",
"def unuse(n=1)\n self.used -= n\n end",
"def remove(key)\n slot = key % BUCKET_MOD\n head = @buckets[slot]\n return unless head\n if head.key == key\n @buckets[slot] = head.next\n else\n head = head.next while head.next && head.next.key != key\n if head.next && head.next.key == key\n head.next = head.next.next\n end\n end\n end",
"def remove()\n return nil if @store.empty? \n swap(0, @store.length - 1)\n result = @store.pop.value\n \n heap_down(0) unless @store.empty?\n return result \n end",
"def delete_at(index)\n return nil if index >= @size || index < 0\n element = self[index]\n if direct_index = @map[index]\n @added.delete_at(direct_index)\n @map.delete(index)\n @map.keys.sort.each do |key|\n if key > index\n value = @map.delete(key)\n value -= 1 if value > direct_index\n @map[key-1] = value\n else\n if (value = @map[key]) > direct_index\n @map[key] -= 1\n end\n end\n end\n else\n lazy_index = lazy_index(index)\n position = @deleted.bsearch_upper_boundary{|e| e <=> lazy_index }\n @deleted.insert(position,lazy_index)\n @map.keys.sort.each do |key|\n if key > index\n @map[key-1] = @map.delete(key)\n end\n end\n end\n #@commands << [:delete,[index]]\n @size -= 1\n element\n end",
"def purge()\n time = Time.now\n @data.each do |key, item|\n if item.expiration < time\n @data.delete(key)\n puts \"DELETE #{item.value}\"\n end\n end\n end",
"def remove(key)\n unless get(key) == -1\n @count -= 1\n bucket = @map[key.hash % @size]\n bucket.reject! {|k, v| k == key}\n end\n end",
"def remove_max(list, last_pos)\n removed = list[0]\n list[0] = list[last_pos] \n list[last_pos] = removed\n heap_down(0, last_pos - 1, list)\nend",
"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 remove()\n root = @store[0]\n new_root = @store[@store.length - 1]\n\n @store[@store.length - 1] = root\n @store[0] = new_root\n\n removed = @store.pop\n\n heap_down(0)\n return removed.value\n end",
"def delete(item)\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n if @buckets[first_index].remove(fingerprint) || @buckets[second_index].remove(fingerprint)\n decrement_filled_count\n return true\n end\n\n false\n end",
"def free\n cache.clear\n nil\n end",
"def remove_item(item)\n return unless @items.key? item\n\n @items.delete item\n @version += 1\n end",
"def purge\n @items.delete_if(&:is_done) \n end",
"def delete_max\n return -1 if @count == 0\n data = @array[0]\n @array[0] = @array.pop\n @count = @array.size\n percolate_down(0)\n data\n end",
"def purge\r\n @head = nil\r\n @tail = nil\r\n end",
"def delete_locator(loc)\n check_locator(loc)\n index = loc.send(:index)\n if @heapsize <= index\n priority, subpriority = get_entry_ps(index)\n last = self.size - 1\n if index != last\n loc2, priority2, subpriority2 = get_entry(last)\n set_entry(index, loc2, priority2, subpriority2)\n loc2.send(:index=, index)\n end\n delete_last_entry\n loc.send(:internal_deleted, priority, subpriority)\n loc\n else\n mode_heapify\n @heapsize = mode_call(:delete_loc, loc)\n loc\n end\n end",
"def delete(entry)\n if index = @cache.delete(entry)\n entries.delete_at(index)\n end\n end",
"def removed(node)\n\t\t\t@size -= 1\n\t\t\treturn node\n\t\tend",
"def remove\n unless self.empty?\n swap(0, @store.length - 1)\n removed_node = @store.pop\n\n heap_down(0)\n\n return removed_node.value\n end\n end",
"def clear\n @mutex.synchronize { @items.clear }\n self\n end",
"def delete(key)\n @mutex.synchronize do\n x = anchor\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # remove existing key\n \t if node_compare(x, key) == 0\n \t level = node_level(x)\n \t while level > 0\n \t level -= 1\n \t node_delete_after!(x, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def purge_items\n purge(@nodename)\n end",
"def clear_outdated\n redis.zremrangebyscore(REDIS_KEY, 0, score_limit)\n end",
"def remove_item(id, nb = 999)\n return if @locked\n return add_item(id, -nb) if nb < 0\n\n id = GameData::Item[id].id\n @items[id] ||= 0 unless @items[id]\n @items[id] -= nb\n if @items[id] <= 0\n @items[id] = 0\n remove_item_from_order(id)\n end\n end",
"def remove()\n return if @store.empty?\n if @store.size == 1\n return @store.pop\n end\n # swap the first and the last element in the underlying array\n @store[-1], @store[0] = @store[0], @store[-1]\n removed = @store.pop\n heap_down(0)\n return removed.value\n end",
"def remove()\n return nil if !@store\n\n swap(0, @store.length - 1)\n nope = @store.pop\n\n heap_down(0)\n return nope.value\n end",
"def pop()\n min_dist = 1.0/0.0\n min_tuple = nil\n @queue.each{ |tuple|\n if(tuple.distance < min_dist)\n min_dist = tuple.distance\n min_tuple = tuple\n end\n }\n return @queue.delete(min_tuple)\n end",
"def del(key)\n position = find(key)\n if position != nil\n # delete\n value = @values[position]\n @slots[position] = nil\n @values[position] = nil\n value\n else\n nil\n end\n end",
"def remove_first\n raise 'No such element' if @size == 0\n elt = @head.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @head = @head.next\n @head.previous.next = nil\n @head.previous = nil\n end\n @size -= 1\n return elt\n end",
"def deq\n\t\tremove(0)\n\tend",
"def cache_delete(key)\n @cache_store.delete(key)\n nil\n end",
"def delete_head\r\n delete_node @head\r\n end",
"def truncate_zset(key, since)\n @redis.zremrangebyscore key, 0, since\n end",
"def dealloc_temp(entry)\n if entry.is_temp\n @temp_memory.delete_at(entry.addr - Limits::TEMP_START_ADDR)\n @temp_deallocated << entry.addr\n end\n end",
"def clear_free_items\n free_items = @order.line_items.select {|item| item.price == 0}\n @order.line_items.delete(*free_items)\n end",
"def delete_max\n @root = delete_max_node(@root)\n end",
"def remove_slot\n @limit -= 1\n end",
"def remove_item(item)\n order_item = self.order_items.where(item: item).order('price asc').first\n if order_item.is_a? OrderItem\n order_item.remove 1\n recalculate!\n end\n end",
"def remove_front\n temp = @head\n @head.next = nil # This is for memory managment purposes\n @head = temp\n end",
"def delete_max\n loc = delete_max_locator\n loc and loc.value\n end",
"def clear\n self.lock_acquire_time = nil\n\n redis.del(key)\n end",
"def cleanup\n redis.zremrangebyscore(key, '-inf', time - timespan)\n end",
"def item_remover(hash, item, quantity = 1)\n hash[item] -= quantity\n if hash[item] <= 0\n hash.delete(item) \n end\n hash\nend",
"def clear\n return if check_locked\n @entries.clear\n self\n end",
"def remove(selected_item, count = nil)\n if item = find_item(selected_item)\n if count.nil? || item[\"count\"] <= count\n @items.delete_at(find_item_index(selected_item))\n elsif item[\"count\"] > count\n item[\"count\"] = (item[\"count\"] - count)\n end\n end\n end",
"def delete_at(index)\n return if (index + 1) > count || index < 0\n\n if index.zero?\n deleted = @head\n @head = @head.next\n else\n prev_item = @head\n\n (index - 1).times { prev_item = prev_item.next }\n\n deleted = prev_item.next\n prev_item.next = deleted.next\n @tail = prev_item if prev_item.next.nil?\n end\n\n @count -= 1\n deleted.value\n end",
"def pop\n self.size -= 1\n Readline::HISTORY.pop\n end",
"def purge \n\t\t@head = nil\n\t\t@tail = nil\n\tend",
"def remove(item)\n # TODO\n # - removes first occurence of `item` in list.\n # - uses '==', so beware if expecting eql? or equals? logic instead\n # - shifts element in array to fill in spot\n\n (0...@array.size).each do |i|\n if @array[i] == item\n @array[i] = nil\n\n # TODO\n # - consider resizing array if load is under some threshold (maybe 0.25?)\n\n shift_elements\n break\n end\n end\n\n end",
"def lru_update(key)\n @lru.unshift(@lru.delete(key)|| key)\n end",
"def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n end",
"def remove_at index\n return nil if empty?\n removed_value = @heap[index]\n last_item_index = size - 1\n swap_values_at(index, last_item_index)\n\n # Remove the actual value off the heap,\n # now that it's at the end/bottom of the heap\n @heap.pop\n remove_from_map(removed_value, last_item_index)\n\n # Return now, if this item was the last item already\n return removed_value if index == last_item_index\n\n # redefine our interested item, post-swap\n new_item_at_index = @heap[index]\n # Try to sink the item we moved, which now exists at `index`\n sink(index)\n # Otherwise try to swim it up, if it could not sink,\n # thus the \n swim(index) if @heap[index] == new_item_at_index\n\n return removed_value\n end",
"def remove\n @redis.lrem list, -1, @data if exists?\n @redis.srem md5_list, @md5_sum\n end",
"def eject!\n oldest_object = @store.first\n @map.delete(oldest_object.key)\n @store.remove(oldest_object.key)\n end",
"def getMin()\n element=@store[1]\n\n #copy last element to the first...\n @store[1]=@store[@store.length-1]\n @store.delete_at(@store.length-1) #delete the last element \n\n #We need to restore the Heap Structure if altered\n heapify(1)\n return element\n end",
"def remove()\n return nil if self.empty?\n\n # swap root node and last leaf node (swap head and rear of internal array) and pop it\n last_index = @store.length - 1\n swap(0, last_index)\n removed = @store.pop\n\n # ensure heap property via calling heap_down\n heap_down(0)\n return removed.value\n end",
"def maintain_key_pool(id, size=10)\n key_pool = storage.read(:key_pool) || []\n key_pool.unshift(id)\n keep, clear = key_pool.each_slice(size).to_a\n (clear||[]).each do |key|\n storage.delete(key)\n end\n storage.write(:key_pool, keep)\n end",
"def pop\r\n removed_item = @data\r\n @data = @data.next_node\r\n removed_item.next_node = nil\r\n removed_item\r\n end",
"def delete(key)\n return unless key? key\n\n @semaphore.synchronize do\n node = @hashed_storage[key]\n @head_node = node.previous_node if node == @head_node\n @tail_node = node.next_node if node == @tail_node\n node.previous_node.next_node = node.next_node if node.previous_node\n node.next_node.previous_node = node.previous_node if node.next_node\n @hashed_storage.delete(key)\n end\n end",
"def erase_head()\n aux = @head[:prev]\n aux[:next] = nil\n @head = aux\n end",
"def clear\n @next = nil\n @size = 0\n @stored = {}\n nil\n end",
"def pop\n delete_at(0)\n end",
"def delete\n locksmith.delete # Soft delete (don't forcefully remove when expiration is set)\n end",
"def delete_item(name)\n previous = items.size\n items.reject! { |item| item.name == name}\n previous != items.size\n end",
"def remove_first\n raise 'Cannot remove element from an empty list.' if empty?\n\n # Extract the data off of the head node\n # Move the head to the next node\n data = @head.data\n @head = @head.next_node\n @size -= 1\n\n # removes the same element from @tail, if it was final element/node\n if empty?\n @tail = nil\n else\n # send to garbage collector\n @head.prev_node = nil\n end\n\n return data\n end",
"def remove\n # Can you delete any other node besides the root?\n return nil if @store.empty?\n\n swap(0, @store.length - 1)\n target = @store.pop\n\n heap_down(0)\n return target.value\n end",
"def remove!(child)\n @last_items_count -= +1 if child && child.last\n super\n end"
] |
[
"0.74968547",
"0.7480868",
"0.6879096",
"0.67489374",
"0.6608478",
"0.62962925",
"0.62877434",
"0.6272144",
"0.618621",
"0.6099631",
"0.6088332",
"0.607148",
"0.60698366",
"0.6061431",
"0.6056884",
"0.60513735",
"0.60388476",
"0.60308874",
"0.6025646",
"0.60094714",
"0.59873086",
"0.59839183",
"0.5965052",
"0.59502715",
"0.5942504",
"0.593419",
"0.5932502",
"0.59088075",
"0.58487725",
"0.5848465",
"0.58336306",
"0.583262",
"0.5806629",
"0.5771086",
"0.5768161",
"0.5758145",
"0.5758066",
"0.57393974",
"0.573731",
"0.57351786",
"0.5722258",
"0.57219565",
"0.5717244",
"0.5713548",
"0.5713339",
"0.56994295",
"0.5698639",
"0.56973636",
"0.56837225",
"0.56618404",
"0.565813",
"0.56481975",
"0.56345814",
"0.56256336",
"0.56239104",
"0.56183386",
"0.559363",
"0.55900055",
"0.5588734",
"0.5580316",
"0.5580187",
"0.55800676",
"0.5575346",
"0.55590427",
"0.5551091",
"0.5541639",
"0.5532504",
"0.55249",
"0.55175805",
"0.55043125",
"0.54919654",
"0.5490892",
"0.5490353",
"0.54867405",
"0.5485698",
"0.5480244",
"0.5477995",
"0.5475695",
"0.54581475",
"0.54453236",
"0.5441402",
"0.5440185",
"0.54358745",
"0.54279983",
"0.54276866",
"0.5427058",
"0.54259294",
"0.54177153",
"0.54030347",
"0.54022676",
"0.5396779",
"0.53867155",
"0.5381836",
"0.5377718",
"0.5371398",
"0.53673804",
"0.5362837",
"0.536195",
"0.53585714",
"0.5357381",
"0.5356403"
] |
0.0
|
-1
|
Creates a new provider collection.
|
def initialize name, providers = {}, default = nil
@name = name
@configured_providers = providers
@configured_default = default || providers.values.first
reset
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new_collection\n Models::Collection.new\n end",
"def create_collections\n self.collections.each do |c|\n self.add_collection(c)\n end\n end",
"def new(*args)\n obj = super\n @provider_instances << obj\n obj\n end",
"def create_collections\n @client[URLS_COLLECTION].create\n @client[DOCUMENTS_COLLECTION].create\n\n nil\n end",
"def create\n # Manual load and authorize necessary because Cancan will pass in all\n # form attributes. When `permissions_attributes` are present the\n # collection is saved without a value for `has_model.`\n @collection = ::Collection.new\n authorize! :create, @collection\n # Coming from the UI, a collection type gid should always be present. Coming from the API, if a collection type gid is not specified,\n # use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)\n @collection.collection_type_gid = params[:collection_type_gid].presence || default_collection_type.gid\n @collection.id = Californica::IdGenerator.id_from_ark(collection_params[\"ark\"])\n @collection.attributes = collection_params.except(:members, :parent_id, :collection_type_gid)\n @collection.apply_depositor_metadata(current_user.user_key)\n add_members_to_collection unless batch.empty?\n @collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?\n if @collection.save\n after_create\n else\n after_create_error\n end\n end",
"def new\n @provider = Provider.new\n end",
"def new\n @collection = Collection.new\n end",
"def new_collection(query, resources = nil, &block)\n Collection.new(query, resources, &block)\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create_new_admin\n @provider = Provider.new\n end",
"def create_collection(name)\n @change_collections_mutex.synchronize do\n collection = native.collection(name)\n collection.create\n collections[name] = Robe::DB::Mongo::Collection.new(self, collection)\n end\n end",
"def make_collection\n @resource.make_collection\n end",
"def new_collection(query, resources = nil, &block)\n self.class.new(query, resources, &block)\n end",
"def create_collection\n return if collection\n\n google_session.root_collection.create_subcollection('riskcovry_uploads')\n end",
"def create\n @collection = Collection.new(collection_params)\n ensure_default_editors\n ensure_default_viewers\n authorize! :create, @collection\n flash[:notice] = 'Collection was successfully created.' if @collection.save\n respond_with(@collection)\n end",
"def make_collection\n raise NotImplementedError\n end",
"def initialize\n provider_builders = read_provider_builders\n @providers = Hash[provider_builders.map do |name, package_hash|\n packages = Hash[package_hash.map do |size, price|\n [size, Package.new(size, price)]\n end]\n [name, Provider.new(name, packages)]\n end]\n end",
"def new\n self.default_provider.new\n end",
"def spAdd\n provider_name = $prompt.ask('Provider Name:')\n provider_phone = $prompt.ask('Provider Phone Number:')\n $all_sp.push(ServiceProvider.new(provider_name, provider_phone, [], {}, []))\n successPrint()\n end",
"def new_collection\n primitive.new\n end",
"def new_input_set()\n return CreateCollectionInputSet.new()\n end",
"def collection\n Rails.logger.info \"XXXXX COLLECTION NAME #{collection_hash['collection name']}\"\n\n @collection ||= CollectionCreator.find_or_create_collection(\n collection_hash['collection name'],\n collection_hash['unit name'],\n collection_hash['collection description'],\n submitter_user_key\n )\n end",
"def create\n @collection = current_user.collections.new(collection_params)\n respond_to do |format|\n if @collection.save\n format.html { redirect_to account_collections_url, notice: 'Collection was successfully created.' }\n format.json { render action: 'show', status: :created, location: @collection }\n else\n format.html { render action: 'new' }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build(attrs, collection)\n collection.new(attrs)\n end",
"def create_simple_provider_source\n create_source(PROVIDER_TEMPLATE, provider_path)\n end",
"def create_collection(collectionName=nil)\n if collectionName.class == String && block_given?\n @j_del.java_method(:createCollection, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(collectionName,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling create_collection(#{collectionName})\"\n end",
"def get_provider_collections(params = {})\n collection_params = {\n 'provider' => current_user.provider_id,\n 'page_size' => 25\n }.stringify_keys.merge(params.stringify_keys)\n\n Rails.logger.debug \"Provider Collection Request parameters: #{collection_params}\" unless request.xhr?\n\n if collection_params.key?('short_name')\n collection_params['short_name'].concat('*')\n\n # In order to search with the wildcard parameter we need to tell CMR to use it\n collection_params['options'] = {\n 'short_name' => {\n 'pattern' => true\n }\n }\n end\n\n # Adds wildcard searching\n collection_params['keyword'].concat('*') if collection_params.key?('keyword')\n\n # Retreive the collections from CMR, allowing a few additional parameters\n cmr_client.get_collections_by_post(collection_params, token).body\n end",
"def create\n @title = t('view.providers.new_title')\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: t('view.providers.correctly_created') }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: 'new' }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_collection\n Dir.mkdir @src_path\n end",
"def create\n collection = Collection.create(collection_params)\n\n render json: collection\n end",
"def create\n collection = @current_user.collections.create\n collection.set_attributes(params)\n\n if not collection.valid?\n collection_errors(collection)\n redirect_to :back and return\n else\n collection.save\n end\n redirect_to collection_path(:id => collection.id)\n end",
"def create\n @collection = Collection.new(collection_params)\n authorize! :create, @collection\n respond_to do |format|\n if @collection.save\n format.html { redirect_to admin_collections_url, notice: \"Collection '#{@collection.title}' was successfully created.\" }\n format.json { render :show, status: :created, location: @collection }\n else\n format.html { render :new }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n collection = @current_user.collections.create\n collection.set_attributes(params)\n \n if not collection.valid?\n collection_errors(collection)\n redirect_to :back and return\n else\n collection.save\n end\n redirect_to collection_path(:id => collection.id)\n end",
"def create_collection(client, collection_name)\n client[collection_name].drop\n client[collection_name].create\n end",
"def new_resource\n base_collection.new\n end",
"def create\n @collection = current_user.collections.new(collection_params)\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, notice: 'Collection was successfully created.' }\n format.json { render :show, status: :created, location: @collection }\n else\n format.html { render :new }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend",
"def providers\n @providers ||= {}\n end",
"def collection(collection_name)\n Collection.new(@backend, @bucket_name, @name, collection_name)\n end",
"def add_provider!(provider, provider_info = {}, access = {})\n Api::Request.new do |request|\n request[:access] = access\n request[:method] = :POST\n request[:path] = \"/mgmt/{{client_id}}/storages/#{provider}\"\n request[:request_body] = provider_info\n end.execute!\n\n end",
"def create\n @users_collection = Users::Collection.new(users_collection_params)\n\n respond_to do |format|\n if @users_collection.save\n format.html { redirect_to @users_collection, notice: 'Collection was successfully created.' }\n format.json { render action: 'show', status: :created, location: @users_collection }\n else\n format.html { render action: 'new' }\n format.json { render json: @users_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n flash[:notice] = 'Provider was successfully created.'\n format.html { redirect_to providers_path }\n format.xml { render :xml => @provider, :status => :created, :location => @provider }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @provider = Provider.new(provider_params)\n\n if @provider.save\n render json: @provider, status: :created, location: @provider\n else\n render json: @provider.errors, status: :unprocessable_entity\n end\n end",
"def create\n @provider = Provider.new(provider_params)\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render :show, status: :created, location: @provider }\n else\n format.html { render :new }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_child_collection(name)\n return @coll_man_service.create_collection(name)\n end",
"def instantiate_collection_with_collection(collection, prefix_options = {})\n if collection.is_a?(Hash) && collection[\"type\"] == \"collection\"\n collectables = collection.values.find{|c| c.is_a?(Hash) || c.is_a?(Array) }\n collectables = [collectables].compact unless collectables.kind_of?(Array)\n instantiated_collection = WillPaginate::Collection.create(collection[\"current_page\"], collection[\"per_page\"], collection[\"total_entries\"]) do |pager|\n pager.replace instantiate_collection_without_collection(collectables, prefix_options)\n end \n else\n instantiate_collection_without_collection(collection, prefix_options)\n end \n end",
"def create_extended_collection(name, mkCol)\n end",
"def set_collection(options = {})\n self._collection = Collection.new(self, self.collection_name, options)\n end",
"def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end",
"def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n provider_klass = Vmpooler::PoolManager::Provider\n provider_klass.constants.each do |classname|\n next unless classname.to_s.casecmp(provider_class) == 0\n\n return provider_klass.const_get(classname).new(config, logger, metrics, redis_connection_pool, provider_name, options)\n end\n raise(\"Provider '#{provider_class}' is unknown for pool with provider name '#{provider_name}'\") if provider_klass.nil?\n end",
"def add_features_to_collection(features)\n\t\tRGeo::GeoJSON::FeatureCollection.new(features)\n\tend",
"def create\n @provider = Provider.new(params[:provider])\n @services = Service.all\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to providers_path, notice: 'As informacoes foram salvas com sucesso.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def instantiate_collection(collection)\n collection.collect! { |record| instantiate_record(record) }\n end",
"def new_collection\n h = SimpleMapper::Collection::Hash.new\n h.attribute = self\n h\n end",
"def create(title: \"\", description: \"\", private: false)\n params = {\n title: title,\n description: description,\n private: private\n }\n Unsplash::Collection.new JSON.parse(connection.post(\"/collections\", params).body)\n end",
"def _collection(name)\n @collections[name] ||= Dynamodb::Collection.new(\n @client,\n Lotus::Model::Adapters::Dynamodb::Coercer.new(_mapped_collection(name)),\n name,\n _identity(name),\n )\n end",
"def create\n @provider = Provider.new(provider_params)\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render action: 'show', status: :created, location: @provider }\n else\n format.html { render action: 'new' }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_collection(name, template: nil, bare: nil)\n unless exists_collection? name\n create_wiki(name, @meta_wiki_name, {\n :bare => bare,\n :assert_valid_collection => false,\n :template => template\n })\n else\n true\n end\n end",
"def create\n @collection = current_user.collections.build(params[:collection])\n\n # set some default values - set collection value to the number of current collections\n if Collection.where(\"name like ?\", \"%Untitled%\").count > 0\n count = Collection.where(\"name like ?\", \"%Untitled%\").order(\"created_at DESC\").first.name.sub('Untitled-Collection-','').to_i + 1\n else\n count = 1\n end\n \n @collection.name = \"Untitled-Collection-\"+count.to_s()\n @collection.user = current_user\n @collection.challenge = false\n @collection.privacy = \"unlisted\"\n\n respond_to do |format|\n if @collection.save\n @collection.update_attributes(:name => \"Untitled-Collection-\" + @collection.id.to_s)\n format.html { redirect_to @collection }\n format.json { render :json => @collection, :status => :created, :location => @collection }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @collection.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @collection = Admin::Collection.new(collection_params)\n\n if @collection.save\n render json: @collection, status: :created#, location: @collection\n else\n render json: @collection.errors, status: :unprocessable_entity\n end\n end",
"def create\n @provider = current_company.providers.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_collection(database_id:, collection_id:, name:, permissions: nil, document_security: nil)\n path = '/databases/{databaseId}/collections'\n .gsub('{databaseId}', database_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if collection_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"collectionId\"')\n end\n\n if name.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"name\"')\n end\n\n params = {\n collectionId: collection_id,\n name: name,\n permissions: permissions,\n documentSecurity: document_security,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'POST',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Collection\n )\n end",
"def create(attributes)\n attributes[:created_by] = attributes[:created_by].source if attributes[:created_by].kind_of? Atlas::User\n attributes[:created_by_id] = attributes[:created_by].id if attributes[:created_by].kind_of? Atlas::Source\n collection = new(attributes)\n collection.save!\n end",
"def add_pools(collection:, pooling_groups:)\n microtiter_plate = MicrotiterPlateFactory.build(\n collection: collection,\n group_size: 1,\n method: :row_wise\n )\n add_provenance(\n microtiter_plate: microtiter_plate,\n pooling_groups: pooling_groups\n )\n end",
"def create_fedora_object\n Collection.new(pid: next_pid)\n end",
"def create\n @collection = Collection.new(collection_params)\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to root_path, notice: 'Collection was successfully created.' }\n format.json { render :show, status: :created, location: @collection }\n else\n format.html { render :new }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def collection(name)\n Kernel.const_get(\"#{name}Collection\").new(@browser)\n end",
"def set_collection\n self._collection = Mongoid::Collection.new(self, self.collection_name)\n end",
"def create\n @provider = Provider.new(provider_params)\n @provider.user_id = current_user.id\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render :show, status: :created, location: @provider }\n else\n format.html { render :new }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def _collection(name)\n @collections[name] ||= Memory::Collection.new(name, _identity(name))\n end",
"def new_with_collection_path(collection, relative_path, site: Bridgetown::Current.site)\n collection = collection.label if collection.is_a?(Bridgetown::Collection)\n\n new(\"repo://#{collection}.collection/#{relative_path}\", site: site)\n end",
"def create\n @collection = Collection.new(params[:collection])\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, :notice => 'Collection was successfully created.' }\n format.json { render :json => @collection, :status => :created, :location => @collection }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @collection.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def collection(factory, count=3, opts={})\n results = []\n count.times do\n yield opts if block_given?\n results << FactoryBot.create(factory.to_sym, opts)\n end\n results\n end",
"def create\n @collection = Collection.new(params[:collection])\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, notice: 'Collection was successfully created.' }\n format.json { render json: @collection, status: :created, location: @collection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @collection = Collection.new(params[:collection])\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, notice: 'Collection was successfully created.' }\n format.json { render json: @collection, status: :created, location: @collection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(attrs, collection_name, klass, client, method_name, method_options)\n @attrs = attrs\n @client = client\n @method_name = method_name\n @method_options = method_options\n @collection = Array(attrs[collection_name.to_sym]).map do |item|\n if klass\n klass.fetch_or_new(item)\n else\n item\n end\n end\n singleton_class.class_eval do\n alias_method(collection_name.to_sym, :collection)\n end\n end",
"def collection(resource_name, model = nil)\n @collections[resource_name] = {:parent => self, :target => (model ? model : resource_name)} # workaround for weird bug with passing a class to Collection\n class_eval(<<-EOS)\n def #{resource_name}\n @#{resource_name} ||= []\n end\n\n def #{resource_name}=(array)\n @#{resource_name} = SurveyGizmo::Collection.new(#{self}, :#{resource_name}, array)\n end\n EOS\n end",
"def register_provider(name, klass)\n @providers[name] = klass\n end",
"def factory(id = nil)\n if id\n OneProvision::Provider.new_with_id(id, @client)\n else\n OneProvision::Provider.new(OneProvision::Provider.build_xml,\n @client)\n end\n end",
"def [](collection_name)\n Collection.new(self, collection_name)\n end",
"def create\n @content_provider = current_user.content_provider;\n params[:collection][:archive] = Archive.find_by_title(params[:collection][:archive])\n params[:collection][:plugin] = @content_provider.placeholder_plugin;\n params[:collection].delete(:plugin_name_other)\n \n @collection = Collection.new(params[:collection])\n \n respond_to do |format|\n if @collection.save\n flash[:notice] = 'Collection was successfully created.'\n format.html { redirect_to :id => @collection.id, :action => :show }\n format.xml { render :xml => @collection, :status => :created, :location => @collection }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @collection.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def initialize(client, collectionName)\n raise \"Must be implemented.\"\n end",
"def build_collection\n bucket = cluster.bucket(@couchbase_options[:bucket])\n if @couchbase_options[:scope] && @couchbase_options[:collection]\n bucket.scope(@couchbase_options[:scope]).collection(@couchbase_options[:collection])\n else\n bucket.default_collection\n end\n end",
"def create\n @user = User.find(params[:user_id])\n \n #@product = Product.find(params[:product_id])\n \n @collection = @user.collections.build(params[:collection])\n\n respond_to do |format|\n if @collection.save\n format.html { redirect_to user_path(@user.id), notice: 'Collection was successfully created.' }\n format.json { render json: @collection, status: :created, location: @collection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def register_new(provider_data)\n location = Location.find_or_create_by(zip_code: provider_data[:zip_code])\n competencies = provider_data[:competencies].select{|k, v| v == 1}.keys\n provider = location.providers.new(provider_data)\n if provider.save\n competencies.each do |competency|\n assessment = Assessment.find_by(word: competency)\n provider.competencies.create(assessment: assessment)\n end\n end\n end",
"def initialize(name, provider)\n @name = name\n @provider = provider\n end",
"def default_collection\n Collection.new(@backend, @name, \"_default\", \"_default\")\n end",
"def new\r\n @provider = Provider.new\r\n render_new\r\n end",
"def construct(provider)\n self.generate_resources_data(provider.id)\n self.generate_ingredients_data(provider.id)\n self.status = DeploymentRecommendation::UNEVALUATED\n self.save!\n end",
"def with_collection(options = {})\n return yield if options.empty?\n\n name = create(options)\n begin\n yield name\n ensure\n delete name\n end\n end",
"def initialize(provider)\n @provider = provider\n end",
"def create\n run_callbacks :create do\n connection.post(collection_path, encode, self.class.headers).tap do |response|\n self.id = id_from_response(response)\n load_attributes_from_response(response)\n end\n end\n end",
"def create\n provider = Manage::Provider.find_by(login: manage_provider_params[:login])\n if provider\n flash_msg('danger', \"此账号已经存在\", 'new')\n else\n manage_provider = Manage::Provider.new(manage_provider_params)\n begin\n if manage_provider.save\n flash_msg('success', '添加供应商成功!', 'index')\n end\n rescue Exception => e\n flash_msg('danger', \"添加供应商失败!#{error_msg(manage_provider)}\", 'new')\n end\n end\n end",
"def new_input_set()\n return GetCollectionInputSet.new()\n end",
"def initialize(collection)\n @collection = collection\n end",
"def create_features_collection\n\t\tfeatures = []\n\n\t\t# Factory to set SRID (WGS84)- Is this being set correctly? Discuss\n\t\tfactory = RGeo::Geographic.spherical_factory(:srid => 4326)\n\n\t\t# Open Shapefile with SRID factory\n\t\tRGeo::Shapefile::Reader.open(get_shp_file(@files), :factory => factory) do |file|\n\n\t\t\tfile.each do |record|\n\n\t\t\t\t# Factory to create a RGeo 'feature' for each record\n\t\t\t\tfactory = RGeo::GeoJSON::EntityFactory.instance\n\n\t\t\t\t# Feature object for each Shapefile record\n\t\t\t\tfeature = factory.feature(\n\t\t\t\t\trecord.geometry,\n\t\t\t\t\trecord.index,\n\t\t\t\t\trecord.attributes\n\t\t\t\t)\n\n\t\t\t\tfeatures << feature\n\t\t\tend\n\t\tend\n\n\t\t@features_collection = add_features_to_collection(features)\n\tend",
"def providers\n @providers.dup\n end"
] |
[
"0.69963115",
"0.6761887",
"0.67116195",
"0.6507936",
"0.6442271",
"0.6380323",
"0.6372822",
"0.6369834",
"0.6369523",
"0.6369523",
"0.6369523",
"0.6369523",
"0.6363703",
"0.62674165",
"0.6263163",
"0.6239566",
"0.6200413",
"0.6177408",
"0.6167212",
"0.60660404",
"0.6011751",
"0.59623224",
"0.5958614",
"0.5914555",
"0.5909815",
"0.59058553",
"0.5866221",
"0.5863511",
"0.57717127",
"0.57683504",
"0.5739876",
"0.5719441",
"0.5658111",
"0.56548584",
"0.56527454",
"0.5648794",
"0.56397134",
"0.56363165",
"0.56339216",
"0.5628042",
"0.5612595",
"0.56116474",
"0.56086344",
"0.56071824",
"0.5606721",
"0.5602791",
"0.5594",
"0.55928785",
"0.55814296",
"0.5576889",
"0.5562218",
"0.55594325",
"0.55575365",
"0.55392116",
"0.55271965",
"0.5522912",
"0.5514721",
"0.55078906",
"0.55046564",
"0.5477041",
"0.5465735",
"0.54494244",
"0.5444292",
"0.54427034",
"0.5436536",
"0.5423217",
"0.53979284",
"0.5397008",
"0.5380509",
"0.5379487",
"0.5376322",
"0.5374629",
"0.535371",
"0.53406286",
"0.5330493",
"0.53145367",
"0.53122056",
"0.53090745",
"0.53090745",
"0.53071845",
"0.53030264",
"0.53019506",
"0.53011703",
"0.5296994",
"0.5287576",
"0.5284004",
"0.52722895",
"0.52709895",
"0.52647835",
"0.5253625",
"0.5242992",
"0.5241041",
"0.52397317",
"0.5235335",
"0.52328336",
"0.5232387",
"0.5216154",
"0.52142006",
"0.5209381",
"0.52021307",
"0.51961315"
] |
0.0
|
-1
|
Adds a new provider to the provider collection.
|
def add extension, provider
providers[extension] = provider
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def register_provider(name, klass)\n @providers[name] = klass\n end",
"def add_provider!(provider, provider_info = {}, access = {})\n Api::Request.new do |request|\n request[:access] = access\n request[:method] = :POST\n request[:path] = \"/mgmt/{{client_id}}/storages/#{provider}\"\n request[:request_body] = provider_info\n end.execute!\n\n end",
"def spAdd\n provider_name = $prompt.ask('Provider Name:')\n provider_phone = $prompt.ask('Provider Phone Number:')\n $all_sp.push(ServiceProvider.new(provider_name, provider_phone, [], {}, []))\n successPrint()\n end",
"def new(*args)\n obj = super\n @provider_instances << obj\n obj\n end",
"def add_official_provider(provider_class, sub_type=nil, access_token: nil)\n raise TypeError, \"Expected OEmbed::Provider instance but was #{provider_class.class}\" \\\n unless provider_class.is_a?(OEmbed::Provider)\n\n @@to_register[sub_type.to_s] ||= []\n @@to_register[sub_type.to_s] << provider_class\n\n if access_token.is_a?(Hash) && access_token[:name] && access_token[:method]\n setter_method = \"#{access_token[:method]}=\"\n raise TypeError, \"Expected OEmbed::Provider instance to respond to the given access_token method #{setter_method}\" \\\n unless provider_class.respond_to?(setter_method)\n\n @@access_token_setters[access_token[:name]] ||= []\n @@access_token_setters[access_token[:name]] << provider_class.method(setter_method)\n end\n end",
"def register(*providers)\n providers.each do |provider|\n provider.urls.each do |url|\n @@urls[url] ||= []\n @@urls[url] << provider\n end\n end\n end",
"def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end",
"def register_provider( name, provider )\n @providers ||= Hash.new\n name = name.to_s\n\n unless provider.respond_to?(:logger)\n raise Polylog::InvalidProvider, \"`logger` method not found for provider #{name.inspect}\"\n end\n\n arity = provider.method(:logger).arity\n unless 1 == arity\n raise Polylog::InvalidProvider, \"`logger` method arity must be 1; arity is #{arity} for provider #{name.inspect}\"\n end\n\n @providers[name] = provider\n end",
"def register_new(provider_data)\n location = Location.find_or_create_by(zip_code: provider_data[:zip_code])\n competencies = provider_data[:competencies].select{|k, v| v == 1}.keys\n provider = location.providers.new(provider_data)\n if provider.save\n competencies.each do |competency|\n assessment = Assessment.find_by(word: competency)\n provider.competencies.create(assessment: assessment)\n end\n end\n end",
"def provider=(name)\n return unless name\n\n set_provider(name)\n copy_provider_keys\n end",
"def try_to_add_provider\n\n prov_id = params[:select_prov]\n\n if prov_id != \"0\"\n @prov = SmsProvider.where(:id => prov_id).first\n @lcr.add_sms_provider(@prov)\n flash[:status] = _('Provider_added')\n else\n flash[:notice] = _('Please_select_provider_from_the_list')\n end\n\n redirect_to :action => 'lcr_providers', :id => @lcr\n end",
"def new\n @provider = Provider.new\n end",
"def provider=(provider)\n @provider = provider\n end",
"def add!(container)\n ### add container's providers ###\n # internally providers are added in reverse order (last one first)\n # so at runtime you it's easy and fast to grab the latest provider\n # so when adding now, we have to reverse the providers to get them in the original order\n container.providers.reverse.each do |definition|\n add_provider(*definition)\n end\n\n ### add container's provides (simple providers) ###\n self.provides(container.provides)\n\n ### fallback provider ###\n @fallback_provider = container.fallback_provider.block if container.fallback_provider\n\n ### add container's data ###\n give!(container.data)\n end",
"def provides(name)\n @providers << name unless @providers.include?(name)\n end",
"def create\n @provider = Provider.new(provider_params)\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render :show, status: :created, location: @provider }\n else\n format.html { render :new }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n flash[:notice] = 'Provider was successfully created.'\n format.html { redirect_to providers_path }\n format.xml { render :xml => @provider, :status => :created, :location => @provider }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @title = t('view.providers.new_title')\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: t('view.providers.correctly_created') }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: 'new' }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @provider = Provider.new(provider_params)\n @provider.user_id = current_user.id\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render :show, status: :created, location: @provider }\n else\n format.html { render :new }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n provider = Manage::Provider.find_by(login: manage_provider_params[:login])\n if provider\n flash_msg('danger', \"此账号已经存在\", 'new')\n else\n manage_provider = Manage::Provider.new(manage_provider_params)\n begin\n if manage_provider.save\n flash_msg('success', '添加供应商成功!', 'index')\n end\n rescue Exception => e\n flash_msg('danger', \"添加供应商失败!#{error_msg(manage_provider)}\", 'new')\n end\n end\n end",
"def create\n @provider = Provider.new(provider_params)\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render action: 'show', status: :created, location: @provider }\n else\n format.html { render action: 'new' }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def provide(oid = :all, &block)\n provider = Provider.new(oid)\n provider.instance_eval(&block)\n\n # Providers are pushed onto the end of the provider queue.\n # When dispatching, this is searched in order for a match.\n # So, like exception handlers, you such specify providers\n # in order of most -> least specific oid. ('1.3.1' comes before '1.3')\n providers << provider\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end",
"def add_dependency(dependency, providers)\r\n if providers.size == 0\r\n # external dependency, skip this\r\n elsif providers.size == 1\r\n # add dependency to this provider\r\n provider = providers[0]\r\n # unless @dependencies[provider].include? dependency\r\n @dependencies[provider] = @dependencies[provider] + [dependency]\r\n ### provider.incoming[self] = provider.incoming[self] + [dependency]\r\n # end\r\n else\r\n warn \"dependency to \\\"#{dependency}\\\" found more than once: #{providers.join(', ')}\"\r\n end\r\n end",
"def create_new_admin\n @provider = Provider.new\n end",
"def create\n @provider = Provider.new(provider_params)\n\n if @provider.save\n render json: @provider, status: :created, location: @provider\n else\n render json: @provider.errors, status: :unprocessable_entity\n end\n end",
"def set_provider\r\n @provider = Provider.find(params[:id])\r\n end",
"def providers\n @providers ||= {}\n end",
"def create\n @provider = current_company.providers.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_provider\n @provider = Provider.friendly.find(params[:id])\n end",
"def create\n @info_provider = Info::Provider.new(info_provider_params)\n\n respond_to do |format|\n if @info_provider.save\n format.html { redirect_to @info_provider, notice: 'Provider was successfully created.' }\n format.json { render :show, status: :created, location: @info_provider }\n else\n format.html { render :new }\n format.json { render json: @info_provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end",
"def provider=(new_provider)\n web3.JS.setProvider(new_provider)\n provider\n end",
"def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend",
"def set_provider\n @provider = Provider.find(params[:id])\n end",
"def set_provider_service\n @provider_service = ProviderService.find(params[:id])\n end",
"def set_provider_provider_type\n @provider_provider_type = Provider::ProviderType.find(params[:id])\n end",
"def provides(provider, opts = {:raise_on_fail => true})\n if cursor = provides?(provider)\n raise ProviderExists.new(\"'#{provider}' is already provided by #{cursor}!\") if opts[:raise_on_fail]\n else\n check_cursor!.provides(provider)\n end\n end",
"def initialize(name, provider)\n @name = name\n @provider = provider\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n ProviderAdmin.create(:member_id =>params[:member_id], :provider_id => @provider.id, :active=>true)\n format.html { redirect_to(@provider, :notice => 'Provider was successfully created.') }\n format.xml { render :xml => @provider, :status => :created, :location => @provider }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @provider = Provider.new(params[:provider])\n @services = Service.all\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to providers_path, notice: 'As informacoes foram salvas com sucesso.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @supplier_provider = Supplier::Provider.new(supplier_provider_params)\n\n respond_to do |format|\n if @supplier_provider.save\n format.html { redirect_to @supplier_provider, notice: 'Provider was successfully created.' }\n format.json { render :show, status: :created, location: @supplier_provider }\n else\n format.html { render :new }\n format.json { render json: @supplier_provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_simple_provider_source\n create_source(PROVIDER_TEMPLATE, provider_path)\n end",
"def create\n @provider = Provider.new(params[:provider])\n @provider.active = true\n\n respond_to do |format|\n if @provider.save\n format.html { redirect_to @provider, notice: 'Provider was successfully created.' }\n format.json { render json: @provider, status: :created, location: @provider }\n else\n format.html { render action: \"new\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n self.default_provider.new\n end",
"def initialize(provider)\n @provider = provider\n end",
"def set_providerservice\n @providerservice = Providerservice.find(params[:id])\n end",
"def provider_name=(value)\n @provider_name = value\n end",
"def provider_id=(value)\n @provider_id = value\n end",
"def new\r\n @provider = Provider.new\r\n render_new\r\n end",
"def providify\n newparam(:provider)\n nil\n end",
"def provider\n use_provider('null') unless defined? @provider\n @provider\n end",
"def provider(name, &block)\n name = name.to_sym\n @__providers[name] ||= []\n @__provider_overrides[name] ||= []\n\n # Add the provider to the ordering list\n @__provider_order << name\n\n if block_given?\n @__providers[name] << block if block_given?\n\n # If this block takes two arguments, then we curry it and store\n # the configuration override for use later.\n if block.arity == 2\n @__provider_overrides[name] << block.curry[Vagrant::Config::V2::DummyConfig.new]\n end\n end\n end",
"def feature_add(name)\n set_add(FeaturesKey, name.to_s)\n end",
"def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end",
"def set_provider\n @provider = Provider.find(params[:id]) if params[:id].present?\n @providers = Goodstype.find(params[:goodstype_id]).providers if params[:goodstype_id].present?\n end",
"def create\n @service_provider = ServiceProvider.new(service_provider_params)\n\n respond_to do |format|\n if @service_provider.save\n format.html { redirect_to @service_provider, notice: \"Service provider was successfully created.\" }\n format.json { render :show, status: :created, location: @service_provider }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @service_provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end",
"def add_consumer(consumer_class)\n find_consumer(consumer_class) do |consumer_instance|\n return consumer_instance\n end\n\n register_consumer(consumer_class) do |_|\n additional_consumers << consumer_class\n end\n end",
"def provider\n @provider\n end",
"def provide(domain, &block)\n @providers[domain] << block\n end",
"def add(adapter)\n adapters << adapter\n end",
"def add_new_player(new_player)\n @players.push(new_player)\n end",
"def provider\n get(PROVIDER)\n end",
"def providers\n @providers ||= load_hash 'config/providers.yml'\n end",
"def providers\n @providers_manager\n end",
"def add(klass)\n @models << klass\n end",
"def providers\n @providers.dup\n end",
"def create\n @provider_provider_type = Provider::ProviderType.new(provider_provider_type_params)\n @provider_provider_type.user_created_id = current_user.id\n respond_to do |format|\n if @provider_provider_type.save\n format.html { redirect_to provider_provider_types_path, notice: I18n.t('provider_types.controller.create') }\n format.json { render :show, status: :created, location: @provider_provider_type }\n else\n format.html { render :new }\n format.json { render json: @provider_provider_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def method_missing(name, *args, &blk)\n provider.send(name, *args)\n end",
"def add_service(serv)\n services << serv\n end",
"def add_user(uid, user_set, provider = \"database\")\n user = ::User.find_by(provider: provider, uid: uid)\n user = create_user(uid, provider) if user.nil?\n user_set << user\n user\n end",
"def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end",
"def set_service_provider\n @service_provider = ServiceProvider.find(params[:id])\n end",
"def method_missing(name, *args, &block)\n if self.provider && provider.respond_to?(name)\n self.provider.send(name, *args, &block)\n else\n super(name, *args, &block)\n end\n end",
"def provider_map\n @provider_map ||= provider_list.inject({}) do |map, klass|\n map[klass.provider_id] = klass unless klass.nil?\n map\n end\n end",
"def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n provider_klass = Vmpooler::PoolManager::Provider\n provider_klass.constants.each do |classname|\n next unless classname.to_s.casecmp(provider_class) == 0\n\n return provider_klass.const_get(classname).new(config, logger, metrics, redis_connection_pool, provider_name, options)\n end\n raise(\"Provider '#{provider_class}' is unknown for pool with provider name '#{provider_name}'\") if provider_klass.nil?\n end",
"def factory(id = nil)\n if id\n OneProvision::Provider.new_with_id(id, @client)\n else\n OneProvision::Provider.new(OneProvision::Provider.build_xml,\n @client)\n end\n end",
"def add_player(new_player)\n @players << new_player\n end",
"def set_supplier_provider\n @supplier_provider = Supplier::Provider.find(params[:id])\n end",
"def add_omniauth(auth)\n self.authentications.find_or_create_by(\n provider: auth['provider'],\n uid: auth['uid'].to_s\n )\n end",
"def add(resource)\n get_resource(resource.type).add(resource.value)\n end",
"def identity_providers=(value)\n @identity_providers = value\n end",
"def identity_providers=(value)\n @identity_providers = value\n end",
"def provider\n providers.first\n end",
"def set_provider_project\n @provider_project = ProviderProject.find(params[:id])\n @h_providers = {}\n Provider.all.map{|p| @h_providers[p.id] = p}\n end",
"def initialize\n provider_builders = read_provider_builders\n @providers = Hash[provider_builders.map do |name, package_hash|\n packages = Hash[package_hash.map do |size, price|\n [size, Package.new(size, price)]\n end]\n [name, Provider.new(name, packages)]\n end]\n end",
"def add username\n @members.add username\n end"
] |
[
"0.6940578",
"0.66328067",
"0.64919317",
"0.6239821",
"0.61185026",
"0.607157",
"0.606617",
"0.60642457",
"0.60566235",
"0.59977895",
"0.5982376",
"0.59495604",
"0.59476715",
"0.59152204",
"0.5864147",
"0.5859157",
"0.5837305",
"0.5832999",
"0.5809659",
"0.5809659",
"0.5809659",
"0.5809659",
"0.577902",
"0.5775374",
"0.576549",
"0.57454145",
"0.5701573",
"0.56828886",
"0.56828886",
"0.56828886",
"0.56828886",
"0.56828886",
"0.56828886",
"0.56828886",
"0.56823856",
"0.56659454",
"0.56653666",
"0.56482106",
"0.5619095",
"0.561648",
"0.5543308",
"0.5537131",
"0.5534623",
"0.55259687",
"0.55036837",
"0.5494518",
"0.5477568",
"0.5462255",
"0.545605",
"0.54044724",
"0.53996146",
"0.538627",
"0.538454",
"0.5359365",
"0.53576416",
"0.53112596",
"0.53026354",
"0.52914643",
"0.5282706",
"0.5264629",
"0.5252869",
"0.52443135",
"0.52433056",
"0.51983047",
"0.51923984",
"0.51874423",
"0.5180203",
"0.51664454",
"0.5147672",
"0.51454854",
"0.51372516",
"0.5120657",
"0.51124156",
"0.5108408",
"0.51079965",
"0.51062584",
"0.50948465",
"0.50891453",
"0.50868016",
"0.50860614",
"0.50854033",
"0.5077046",
"0.5070606",
"0.50606906",
"0.50495666",
"0.50495666",
"0.5046229",
"0.5035311",
"0.5032461",
"0.5016798",
"0.5009497",
"0.5001897",
"0.49793866",
"0.49753252",
"0.49721956",
"0.49721956",
"0.49648178",
"0.49639943",
"0.49622107",
"0.49522635"
] |
0.7386824
|
0
|
List of configured providers.
|
def providers
@providers ||= {}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def providers\n @providers.keys\n end",
"def providers\n @providers ||= load_hash 'config/providers.yml'\n end",
"def providers\n driver(current_driver).providers\n end",
"def providers\n @providers_manager\n end",
"def providers\n providers = YARD::Registry.all(\"puppet_providers_#{name}\".to_sym)\n return providers if providers.empty?\n\n providers.first.children\n end",
"def providers\n url = url_with_api_version(@base_url, 'providers')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def configured_providers\n Rails.configuration.providers.select do |provider|\n Rails.configuration.send(\"omniauth_#{provider}\")\n end\n end",
"def configured_providers\n Rails.configuration.providers.select do |provider|\n Rails.configuration.send(\"omniauth_#{provider}\")\n end\n end",
"def providers\n authentication_strategies.pluck :provider\n end",
"def providers\n @providers.dup\n end",
"def provider_list\n @provider_list ||= subclasses.inject([]) do |list, klass_name|\n klass = klass_name.constantize\n begin\n list << klass.instance\n rescue LoadError => exc\n logger.error \"#{klass} load error: #{exc}\"\n end\n list\n end\n end",
"def suitable_providers\n return @suitable_providers if @suitable_providers\n @suitable_providers = []\n [\n @resource.class.defaultprovider,\n @resource.class.suitableprovider,\n ].flatten.uniq.each do |provider_class|\n if service_provider_enabled? provider_class\n @suitable_providers << provider_class.name\n end\n end\n @suitable_providers\n end",
"def providers(params = {})\n response = default_scope.get('providers/') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end",
"def load_used_providers\n Vmpooler::Providers.load_by_name(used_providers)\n end",
"def get_providers(opts = {})\n data, _status_code, _headers = get_providers_with_http_info(opts)\n data\n end",
"def providers(parameters = {}, invocation_options = {})\n exec(RubyTerraform::Commands::Providers,\n parameters, invocation_options)\n end",
"def providers_get(opts = {})\n data, _status_code, _headers = providers_get_with_http_info(opts)\n data\n end",
"def providers\n ([self] + parent_groups).reverse.inject({}) do |memo, group|\n begin\n memo.merge(group.poise_spec_helpers[:providers] || {})\n rescue NoMethodError\n memo\n end\n end\n end",
"def provided_pools\n list = []\n @config[:pools].each do |pool|\n list << pool['name'] if pool['provider'] == name\n end\n list\n end",
"def omniauth_providers\n @omniauth_providers ||= Account.omniauth_providers.map(&:to_s)\n end",
"def formats\n providers.keys\n end",
"def course_providers_list\n # TODO: Make sure course_providers are not huge. Very unlikely though\n course_providers.active.map do |cp|\n [\"#{ cp.locality } - #{ cp.city } - #{ cp.state }\", cp.id]\n end\n end",
"def identity_providers=(value)\n @identity_providers = value\n end",
"def identity_providers=(value)\n @identity_providers = value\n end",
"def provides\n @provides ||= user_data_as_array('provide')\n @provides\n end",
"def available_service_providers\n @providers = ServiceProvider.order(rating: :desc).order(rating_count: :desc)\n end",
"def identity_providers\n return @identity_providers\n end",
"def identity_providers\n return @identity_providers\n end",
"def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end",
"def providers( url )\n\n\t\t\t@config.each do | name, options |\n\t\t\t\tif ( url =~ options[ :pattern ])\n\t\t\t\t\tyield self._provider( name, options )\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def provider_map\n @provider_map ||= provider_list.inject({}) do |map, klass|\n map[klass.provider_id] = klass unless klass.nil?\n map\n end\n end",
"def providers_get_providers(opts = {})\n data, _status_code, _headers = providers_get_providers_with_http_info(opts)\n return data\n end",
"def load_providers()\n @cookbook_loader.each do |cookbook|\n cookbook.load_providers\n end\n true\n end",
"def providers\n [AssetPipelineProvider, FilesystemProvider]\n end",
"def get_auto_start_providers\n\t\ts = get_admin_section \"system.applicationHost/serviceAutoStartProviders\"\n\t\tIisObjectCollection.new s.Collection, :add, AutoStartProvider\n\tend",
"def providers\n before = ObjectSpace.each_object(Class).to_a\n filter_dir_contents(read_dir_contents).each { |f| require f }\n after = ObjectSpace.each_object(Class).to_a\n classes = (after - before).select { |c| c <= ProviderStrategy }\n @strategies.concat(classes.map(&:new))\n end",
"def list(selection=nil)\n env.load!\n\n env.config.providers.each do |name,provider|\n env.logger.debug(\"Asking provider #{name} to list ip #{selection}\")\n provider.ip_list(selection,options)\n end\n end",
"def get_selected_providers\n params.keys.select do |k|\n k.include? \"provider\"\n end.map do |checkbox|\n checkbox.split(\":\").last\n end\n end",
"def generate_providers(cookbooks_paths)\n providers = []\n cookbooks_paths = [cookbooks_paths] unless cookbooks_paths.is_a?(Array)\n cookbooks_paths.each do |cookbooks_path|\n return [] unless File.directory?(cookbooks_path)\n Dir[File.normalize_path(File.join(cookbooks_path, '*/'))].each do |cookbook_path|\n cookbook_name = File.basename(cookbook_path)\n Dir[File.normalize_path(File.join(cookbook_path, POWERSHELL_PROVIDERS_DIR_NAME, '*/'))].each do |provider_file_path|\n provider_name = filename_to_qualified_string(cookbook_name, provider_file_path)\n provider_class_name = convert_to_class_name(provider_name)\n next if @providers_names.include?(provider_class_name)\n generate_single_provider(provider_class_name, provider_file_path)\n providers << provider_name\n end\n end\n end\n @providers_names += providers\n true\n end",
"def whitelist_providers\n [:new_school_ldap, :twitter, :nyu_shibboleth, :aleph]\n end",
"def available_plugins\n @plugins.keys\n end",
"def available_plugins\n PluginList.availables(@client)\n end",
"def provider\n conf['provider'] || 'defaults'\n end",
"def provides(name)\n @providers << name unless @providers.include?(name)\n end",
"def alternative_names\n auth_providers.map do |ap|\n { provider: ap.provider, name: \"#{ap.uname} (#{ap.provider})\" }\n end\n end",
"def index\n @providers = Provider.all\n end",
"def provider_items\n @provider_items ||= ProviderItem.find(provider_items_ids)\n end",
"def list(selection=nil)\n\n env.config.providers.each do |name,provider|\n env.ui.info(\"Asking provider #{name} to list keystore #{selection}\")\n provider.keystore_list(selection,options)\n end\n end",
"def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end",
"def index\n @service_providers = ServiceProvider.all\n end",
"def [] format\n providers[format]\n end",
"def [](name)\n @providers[name]\n end",
"def service_resource_providers\n service_resource_providers = []\n\n if ::File.exist?(\"/usr/sbin/update-rc.d\")\n service_resource_providers << :debian\n end\n\n if ::File.exist?(\"/usr/sbin/invoke-rc.d\")\n service_resource_providers << :invokercd\n end\n\n if ::File.exist?(\"/sbin/insserv\")\n service_resource_providers << :insserv\n end\n\n # debian >= 6.0 has /etc/init but does not have upstart\n if ::File.exist?(\"/etc/init\") && ::File.exist?(\"/sbin/start\")\n service_resource_providers << :upstart\n end\n\n if ::File.exist?(\"/sbin/chkconfig\")\n service_resource_providers << :redhat\n end\n\n if ::File.exist?(\"/bin/systemctl\")\n # FIXME: look for systemd as init provider\n service_resource_providers << :systemd\n end\n\n service_resource_providers\n end",
"def provides\n sort!\n sources.map {|s| s.provides }.flatten\n end",
"def register(*providers)\n providers.each do |provider|\n provider.urls.each do |url|\n @@urls[url] ||= []\n @@urls[url] << provider\n end\n end\n end",
"def list(selection=nil)\n\n env.config.keypairs.each do |name,provider|\n env.ui.info(\"Keypair name:#{name}\")\n end\n end",
"def index\n config = api.get_config_vars(app).body\n matches = config.keys & REDIS_PROVIDERS\n current = config['REDIS_URL']\n\n selected = REDIS_PROVIDERS.select do |key|\n config[key] == current && !current.nil?\n end\n\n if selected.empty?\n display \"No REDIS instance currently set to REDIS_URL\"\n else\n display \"Currently using #{selected.first}\\n\"\n end\n\n display\n display 'Available REDIS providers'\n matches.each do |match|\n display \" #{match}\"\n end\n end",
"def expiring_providers(expiring_favorites)\n providers = []\n expiring_shows = expiring_favorites.map {|favorite| favorite.show}\n shows_by_provider.each do |provider, show_array|\n shows_in_common = show_array.select do |show|\n expiring_shows.include?(show)\n end\n if !shows_in_common.empty?\n providers << provider \n end \n end \n providers\n end",
"def provider\n get(PROVIDER)\n end",
"def get_provider_overrides(name)\n (@__provider_overrides[name] || []).map do |p|\n [\"2\", p]\n end\n end",
"def transition_from_crypto_providers(value = nil)\n rw_config(\n :transition_from_crypto_providers,\n (!value.nil? && [value].flatten.compact) || value,\n []\n )\n end",
"def index\n @supplier_providers = Supplier::Provider.all\n end",
"def lcr_providers\n\n @page_title = _('Providers_for_LCR') # + \": \" + @lcr.name\n @page_icon = \"provider.png\"\n\n @providers = @lcr.sms_providers(\"asc\")\n @all_providers = SmsProvider.find(:all)\n @other_providers = []\n for prov in @all_providers\n @other_providers << prov if !@providers.include?(prov)\n end\n flash[:notice] = _('No_providers_available') if @all_providers.empty?\n end",
"def providers_get_providers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProvidersApi.providers_get_providers ...\"\n end\n # resource path\n local_var_path = \"/api/Providers\"\n\n # query parameters\n query_params = {}\n query_params[:'$filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'$orderby'] = opts[:'orderby'] if !opts[:'orderby'].nil?\n query_params[:'$top'] = opts[:'top'] if !opts[:'top'].nil?\n query_params[:'$skip'] = opts[:'skip'] if !opts[:'skip'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ProviderListItemPage')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProvidersApi#providers_get_providers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def populate_providers_hash\n # GET A LIST OF ALL PROVIDERS\n Rails.logger.info(\"Retrieving providers list from #{@ingest_providers_list_endpoint}\")\n response = RestClient::Request.execute :method => :get, :url => \"#{@ingest_providers_list_endpoint}\", :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n if (response.code != 200)\n Rails.logger.info(\"ERROR #{response.code} retrieving providers list\")\n # terminate task if we cannot validate the providers names\n exit(status=256)\n else\n list_of_providers_hashes = JSON.parse!(response.body)\n list_of_providers_hashes.each do |hash|\n provider_id = hash['provider-id']\n @all_providers[provider_id] = 'Y'\n end\n Rails.logger.info(\"RETRIEVED A LIST OF ALL PROVIDERS, SIZE: #{list_of_providers_hashes.size}, LOOKUP SIZE: #{@all_providers.size}\")\n end\n end",
"def transition_from_crypto_providers(value = nil)\n config(:transition_from_crypto_providers, (!value.nil? && [value].flatten.compact) || value, [])\n end",
"def provider\n @provider\n end",
"def plugins\n @plugin_list\n end",
"def locate_plugins\r\n configuration.plugin_locators.map do |locator|\r\n locator.new(initializer).plugins\r\n end.flatten\r\n # TODO: sorting based on config.plugins\r\n end",
"def list_known_servers\n connect.servers.all\n end",
"def get_drivers\n return return_all_drivers\n end",
"def get_drivers\n drivers\n end",
"def services\n warn \"DEPRECATED: this is no longer supported by LDAP. This method will always return an empty Array\"\n []\n end",
"def enabled_handlers\n @enabled_handlers ||=\n providers.select do |klass|\n # NB: this is different from resource_resolver which must pass a resource_name\n # FIXME: deprecate this and normalize on passing resource_name here\n klass.provides?(node, resource)\n end.sort {|a,b| a.to_s <=> b.to_s }\n end",
"def search(connector, options={})\n if options.respond_to? :to_str\n return search(connector, :q=>options.to_str)\n end\n json = connector.prepare_and_invoke_api_call(\n 'profiles/v1/search/providers', :method=>:get,\n :auth=>false, :sign=>false, :params=>options)\n\n providers = []\n if json['providers']['provider']\n [json['providers']['provider']].flatten.each do |provider|\n providers << self.new(provider)\n end\n end\n return providers\n end",
"def identity_providers()\n return MicrosoftGraph::IdentityProviders::IdentityProvidersRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def list_config\n configs = store :get, 'configs'\n (configs.error?) ? 'No config vars set yet.' : configs.to_s\n end",
"def get_providers\n @weights.map{|k,v|v.keys}.flatten.uniq\n end",
"def authentication_providers authenticator, account: Conjur.configuration.account\n JSON.parse(url_for(:authentication_providers, account, authenticator, credentials).get)\n end",
"def list\n logger.info \"Retrieving Vagrant plugin list for #{description}\"\n output = instance.execute!(:plugin, \"list\").stdout\n Derelict::Parser::PluginList.new(output).plugins\n end",
"def find_providers_for(attributes)\n plugins = []\n attributes.each do |attribute|\n attrs = select_subtree(@map, attribute)\n raise Ohai::Exceptions::AttributeNotFound, \"No such attribute: \\'#{attribute}\\'\" unless attrs\n raise Ohai::Exceptions::ProviderNotFound, \"Cannot find plugin providing attribute: \\'#{attribute}\\'\" unless attrs[:_plugins]\n\n plugins += attrs[:_plugins]\n end\n plugins.uniq\n end",
"def collaborators(app_env)\n app_setting_list('collaborators', app_env)\n end",
"def collaborators(app_env)\n app_setting_list('collaborators', app_env)\n end",
"def available_service_providers\n ServiceProvider.includes(:provision_services).\n where(:provision_services => {:product_category_id => self.service_request.product_category_id,\n :product_brand_id => self.service_request.product_brand_id }\n ) if self.service_request\n end",
"def list(opts = {})\n search_provider.list(opts)\n end",
"def ciphers\n @ciphers ||= config[:ciphers].collect { |cipher_config| Cipher.from_config(**cipher_config) }\n end",
"def index\n @providerservices = Providerservice.all\n end",
"def registered_plugin_names\r\n configuration.plugins ? configuration.plugins.map(&:to_s) : nil\r\n end",
"def omniauth_provider_groups(&block)\n # Find the most even number of groups\n groups = [5, 4].find { |g| omniauth_providers.count % g == 0 }\n groups ||= 3 # Fall back to 3 per line (yuck)\n\n # Return providers in groups\n omniauth_providers.in_groups_of groups, false, &block\n end",
"def provider\n use_provider('null') unless defined? @provider\n @provider\n end",
"def adaptors\n @adaptors ||= []\n end",
"def initialize\n provider_builders = read_provider_builders\n @providers = Hash[provider_builders.map do |name, package_hash|\n packages = Hash[package_hash.map do |size, price|\n [size, Package.new(size, price)]\n end]\n [name, Provider.new(name, packages)]\n end]\n end",
"def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end",
"def providers\n @title = 'Puppet Provider Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_provider)\n erb(:objects)\nend",
"def plugins\n Refinery::Plugins.registered\n end",
"def engines\r\n @engines ||= plugins.select(&:engine?)\r\n end",
"def all_plugin_specs\n @plugin_specs.values\n end",
"def smb_enumprintproviders\n\t\tresp = smb_enumprinters(8, nil, 1, 0)\n\t\treturn nil if not resp\n\t\trptr, tmp, blen = resp.unpack(\"V*\")\n\n\t\tresp = smb_enumprinters(8, nil, 1, blen)\n\t\treturn nil if not resp\n\n\t\tbcnt,pcnt,stat = resp[-12, 12].unpack(\"VVV\")\n\t\treturn nil if stat != 0\n\t\treturn nil if pcnt == 0\n\t\treturn nil if bcnt > blen\n\t\treturn nil if pcnt < 3\n\n\t\t#\n\t\t# The correct way, which leads to invalid offsets :-(\n\t\t#\n\t\t#providers = []\n\t\t#\n\t\t#0.upto(pcnt-1) do |i|\n\t\t#\tflags,desc_o,name_o,comm_o = resp[8 + (i*16), 16].unpack(\"VVVV\")\n\t\t#\n\t\t#\t#desc = read_unicode(resp,8+desc_o).gsub(\"\\x00\", '')\n\t\t#\t#name = read_unicode(resp,8+name_o).gsub(\"\\x00\", '')\n\t\t#\t#comm = read_unicode(resp,8+comm_o).gsub(\"\\x00\", '')\n\t\t#\t#providers << [flags,desc,name,comm]\n\t\t#end\n\t\t#\n\t\t#providers\n\n\t\treturn resp\n\n\tend",
"def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end"
] |
[
"0.8362594",
"0.8128595",
"0.80782074",
"0.79805493",
"0.7715629",
"0.76403266",
"0.76014507",
"0.76014507",
"0.7413273",
"0.74022377",
"0.7297735",
"0.72866434",
"0.72759145",
"0.6921644",
"0.6845834",
"0.67605525",
"0.6726786",
"0.6722341",
"0.6717966",
"0.67173785",
"0.66678834",
"0.66057026",
"0.65964866",
"0.65964866",
"0.64655167",
"0.6465316",
"0.64194226",
"0.64194226",
"0.6363629",
"0.6316161",
"0.63046044",
"0.6271748",
"0.6201967",
"0.6192679",
"0.612698",
"0.61161506",
"0.61028636",
"0.5988043",
"0.59722495",
"0.59489655",
"0.5942645",
"0.5922165",
"0.5890803",
"0.58628196",
"0.5859237",
"0.5857272",
"0.5848099",
"0.5824592",
"0.5823288",
"0.58214366",
"0.58132195",
"0.5790585",
"0.5784709",
"0.576335",
"0.57632643",
"0.5760873",
"0.5744132",
"0.57137436",
"0.56924087",
"0.5690805",
"0.5690367",
"0.56802547",
"0.5665452",
"0.5660453",
"0.5642701",
"0.5629805",
"0.56274503",
"0.56229705",
"0.5619924",
"0.56078964",
"0.5601635",
"0.55996186",
"0.55962986",
"0.5592092",
"0.55892336",
"0.5584958",
"0.5577129",
"0.55649877",
"0.55573595",
"0.5535382",
"0.55302054",
"0.5525972",
"0.551167",
"0.551167",
"0.54997414",
"0.5488144",
"0.5480247",
"0.5477993",
"0.54710245",
"0.543925",
"0.5420956",
"0.5399393",
"0.539888",
"0.5397744",
"0.5396491",
"0.5394319",
"0.53910923",
"0.5382415",
"0.5376172",
"0.5363149"
] |
0.8151667
|
1
|
Resets the provider collection to the initial values.
|
def reset
providers.clear
configured_providers.each { |k, v| self[k] = v }
self.default = configured_default
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset_provider\n remove_stored_info\n set_default_as_provider\n end",
"def reset\n @collection = []\n end",
"def reset!\n # this should be overridden by concrete adapters\n end",
"def reset_initial_values\n @initial_values.clear if @initial_values\n @missing_initial_values.clear if @missing_initial_values\n end",
"def reset!\n @registered_items = self.initial_state.dup\n end",
"def reset!\n @registered_items = self.initial_state.dup\n end",
"def reset\n # Empty, but subclasses will override this.\n end",
"def reset\n @authorizations = []\n @filters = []\n end",
"def reset_adapters\n @adapters = nil\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def reset\n @exemptions = ExemptionList.from_module(CoreExemptions)\n @global = false\n @trusted_filters = []\n end",
"def reset\n # TODO\n end",
"def reset!\n @cards = load_cards\n end",
"def reset\n reset_adapters\n reset_config\n reset_handlers\n reset_hooks\n end",
"def reset!\n @callers = @default.dup\n self\n end",
"def reset\n @sets = {}\n self\n end",
"def clear\n reset_defaults\n self\n end",
"def reset\n @cards = Card.suits.keys.map do |suit|\n Card.values.map {|i| Card.new(suit, i)}\n end.flatten\n @dealt = []\n self\n end",
"def reset!\n self.cards = CARDS.dup\n end",
"def reset\n probe_sets.each(&:reset)\n end",
"def reset\n @storage = []\n end",
"def reset\n @id = nil\n @strands = []\n @suggested_topic = nil\n end",
"def subscriptions_reset\n self.subscriptions = Subscription.defaults\n end",
"def reset\n configure({})\n end",
"def reset!\n @products = []\n end",
"def reset!\n @products = []\n end",
"def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = nil\n metrics.each_key { |metric| singleton_class.send(:remove_method, metric) if respond_to?(metric) }\n @metrics = nil\n collectors.clear\n configurators.clear\n instance_variable_set(:@configured_by, nil)\n instance_variable_set(:@debug_was_enabled_by, nil)\n end",
"def reset!\n @cached_descriptions = nil\n @nodes = nil\n @cloud_nodes = nil\n end",
"def reset!\n reset_endpoints!\n reset_routes!\n reset_validations!\n end",
"def reset!\n initialize\n end",
"def reset\n each(&:reset)\n self\n end",
"def reset\n keys.each do |key|\n instance_variable_set(:\"@#{key}\", defaults[key])\n self\n end\n end",
"def reset\n cleanup(true)\n end",
"def reset\n self.base_currency = nil\n self.currency_rates = nil\n end",
"def reset\n clear\n load_from(REGISTRY_PATH)\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.consumer_key = DEFAULT_CONSUMER_KEY\n self.consumer_secret = DEFAULT_CONSUMER_SECRET\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n end",
"def __reset\n @registry.clear\n end",
"def clear\n @adapter.clear(collection)\n end",
"def reset!\n self.api_key \t = DEFAULT_API_KEY\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset\n cache.remove(\"#{klass}/#{options}\")\n @records = []\n @loaded = nil\n self\n end",
"def reset\n raise \"Not implemented\"\n end",
"def reset!\n tap { set_defaults }\n end",
"def reset\n [topics, queues, subscriptions].each do |resource|\n resource.values.each(&:delete)\n resource.clear\n end\n end",
"def reset\n set(default_preferences)\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.client_id = DEFAULT_CLIENT_ID\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset!\n @_store = {:default => Configatron::Store.new}\n end",
"def reset\n @id = nil\n @members = []\n @topic = nil\n end",
"def reset\n @grid = empty_grid\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.consumer_key = DEFAULT_CONSUMER_KEY\n self.consumer_secret = DEFAULT_CONSUMER_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.xauth_username = DEFAULT_XAUTH_USERNAME\n self.xauth_password = DEFAULT_XAUTH_PASSWORD\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self.logger = DEFAULT_LOGGER\n self\n end",
"def reset_provider_session!\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n return unless @provider_session\n @provider_session.token = nil\n @provider_session.code = nil\n @provider_session.data = nil\n @provider_session = nil\n end",
"def reset\n @res_features = FEATURES.dup\n @res_feature_types = FEATURE_TYPES.dup\n @res_segments = SEGMENTS.dup\n end",
"def reset\n setup\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset\n end",
"def reset\n end",
"def reset\n\t\tself.clear\n\t\tme = self\n\t\t@default_values.each {|n,v| me[n] = v.is_a?(Class) ? nil : v}\n\tend",
"def reset\n self.api_key = nil\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self.platform_client_id = nil\n self.platform_client_secret = nil\n self\n end",
"def reset\n Vedeu.log(type: :reset,\n message: \"(#{self.class.name}) #{registered.inspect}\".freeze)\n\n @storage = in_memory\n end",
"def clear\n factory_map.clear\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset\n\n end",
"def reset!\n @adapter_registry ||= Lotus::Model::AdapterRegistry.new\n @adapter_registry.reset!\n @mapper = nil\n end",
"def reset\n self\n end",
"def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end",
"def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end",
"def reset\n @discovered_clients = nil\n end",
"def reset\n self.api_key = DEFAULT_API_KEY\n self.api_version = DEFAULT_API_VERSION\n self.endpoint = DEFAULT_ENDPOINT\n self.adapter = DEFAULT_ADAPTER\n end",
"def reset\n invoke_on_reset_callbacks\n self\n end",
"def initvars\n @provider_instances = []\n @needs_flush = false\n @failed = false\n end",
"def reset\n @array = nil\n end",
"def reset\n @artist = nil\n @copyright = nil\n @cameras = []\n end",
"def reset\n\t\t\tself.access_token = DEFAULT_ACCESS_TOKEN\n\t\t\tself.authorization_endpoint = DEFAULT_AUTHORIZATION_ENDPOINT\n\t\t\tself.client_id = DEFAULT_CLIENT_ID\n\t\t\tself.client_secret = DEFAULT_CLIENT_SECRET\n\t\t\tself.endpoint = DEFAULT_ENDPOINT\n\t\t\tself.proxy = DEFAULT_PROXY\n\t\t\tself.user_agent = DEFAULT_USER_AGENT\n\t\tend",
"def clear!\n @adapters = []\n end",
"def reset_cleared_default_fields\n @cleared_default_fields = {}\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.user_login = DEFAULT_USER_LOGIN\n self.user_password = DEFAULT_USER_PASSWORD\n self.endpoint = DEFAULT_ENDPOINT\n self.format = DEFAULT_FORMAT\n self.proxy = DEFAULT_PROXY\n self.cookie = DEFAULT_COOKIE\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset\n @params = initial_params\n self\n end",
"def reset\n @parsers = nil\n @transformer = nil\n @cache = nil\n end",
"def reset\n self.api_key = DEFAULT_API_KEY\n self.user_agent = DEFAULT_USER_AGENT\n self.search_query_defaults = DEFAULT_SEARCH_SETTINGS\n self\n end",
"def reset_filters\n @_filters = []\n end",
"def reset\n\n end",
"def reset!\n @apps = {}\n @default_params = {}\n @basic_auth = nil\n end",
"def reset\n initialize\n setup\n end",
"def reset\n reset_config\n reset_driver\n end",
"def reset\n end",
"def reset\n end",
"def reset!\n @defaults.each do |k, v|\n instance_variable_set(k, v)\n end\n end",
"def reset\n @rows = nil\n end",
"def reset!\n keys.each do |key|\n instance_variable_set(:\"@#{key}\", GogoKit::Default.send(key))\n end\n self\n end",
"def reset\n\t\t\t\tself.clear\n\t\t\t\tme = self\n\t\t\t\t@default_values.each { |n, v| me[n] = v.is_a?(Class) ? nil : v }\n\t\t\tend",
"def reset_metadata\n @topics, @brokers, @consumergroups = nil, nil, nil\n end",
"def reset!\n @loaded_projects = nil\n end",
"def reset_used_factories\n @used_factories = []\n end",
"def reset\n @data = nil\n end",
"def reset\n @registry = {}\n @logging = false\n @line_item_limit = 1000\n end",
"def reset\n @_storage = in_memory\n\n Vedeu::Buffers.reset\n Vedeu::Cursors.reset\n Vedeu::Focus.reset\n Vedeu::Groups.reset\n\n @_storage\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.client_id = DEFAULT_CLIENT_ID\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.authorize_endpoint = DEFAULT_AUTHORIZE_ENDPOINT\n self.token_endpoint = DEFAULT_TOKEN_ENDPOINT\n self.gateway = DEFAULT_GATEWAY\n self.access_token = DEFAULT_ACCESS_TOKEN\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end"
] |
[
"0.7753693",
"0.7116367",
"0.6629752",
"0.6623564",
"0.66110027",
"0.66110027",
"0.6471403",
"0.6417714",
"0.6363478",
"0.63123494",
"0.63123494",
"0.62903196",
"0.624949",
"0.6244952",
"0.6232816",
"0.6227661",
"0.6222696",
"0.62199634",
"0.6205134",
"0.6171895",
"0.61715275",
"0.6170631",
"0.6145557",
"0.61214685",
"0.61164075",
"0.6116247",
"0.6116247",
"0.6112409",
"0.61086696",
"0.61004615",
"0.6090235",
"0.60836184",
"0.60829496",
"0.6066591",
"0.6058331",
"0.6046987",
"0.6045137",
"0.6044198",
"0.6038828",
"0.60344625",
"0.60273784",
"0.6027022",
"0.601518",
"0.6008789",
"0.6003527",
"0.5999692",
"0.59968066",
"0.5996367",
"0.59903103",
"0.5985995",
"0.5979325",
"0.5972554",
"0.59653133",
"0.5964997",
"0.5961382",
"0.5961382",
"0.59529775",
"0.59529644",
"0.5947906",
"0.5947526",
"0.5942725",
"0.5942725",
"0.5942725",
"0.5942725",
"0.59420264",
"0.5935506",
"0.5933501",
"0.5931432",
"0.5931432",
"0.59290993",
"0.5926142",
"0.59245217",
"0.5914535",
"0.591109",
"0.5910218",
"0.5903028",
"0.58948153",
"0.58893216",
"0.58882624",
"0.5884318",
"0.5883324",
"0.5878641",
"0.58769965",
"0.58727026",
"0.5869048",
"0.58664006",
"0.58553505",
"0.5852039",
"0.5852039",
"0.58496785",
"0.5848048",
"0.5847597",
"0.5846896",
"0.58439237",
"0.58434284",
"0.5839299",
"0.5835243",
"0.58351225",
"0.58239084",
"0.5818594"
] |
0.7555268
|
1
|
Get provider corresponding to a given format.
|
def formats
providers.keys
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [] format\n providers[format]\n end",
"def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end",
"def provider_for(file)\n ext = File.extname(file)\n case ext\n when '.ini'\n IniProvider\n when '.yaml', '.yml'\n YamlProvider\n else\n raise UnsupportedConfigFormatError.new(ext)\n end\n end",
"def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end",
"def parser_class(format)\n supported_parsers.detect { |p| p.parses? format }\n end",
"def provider\n providers.first\n end",
"def format\n lookup_val = Integer(@rf['format'])\n @_format ||= format_proxy.lookup_format_name(lookup_val)\n rescue\n @rf['format']\n end",
"def load_format(format)\n case format.to_s\n when /(md|mkdn?|mdown|markdown)$/i\n :markdown\n when /(textile)$/i\n :textile\n when /(rdoc)$/i\n :rdoc\n when /(org)$/i\n :org\n when /(creole)$/i\n :creole\n when /(re?st(\\.txt)?)$/i\n :rest\n when /(asciidoc)$/i\n :asciidoc\n when /(pod)$/i\n :pod\n when /(\\d)$/i\n :roff\n when /(media)?wiki$/i\n :mediawiki\n else\n nil\n end\n end",
"def provider\n get(PROVIDER)\n end",
"def provider\n use_provider('null') unless defined? @provider\n @provider\n end",
"def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end",
"def fetch_format(token, property)\n if FORMATS.key?(token)\n FORMATS[token][property]\n else\n raise ArgumentError, \"Unknown format token `:#{token}`\"\n end\n end",
"def provider\n @provider\n end",
"def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end",
"def format\n @format ||= File.extname(@full_path)[1..-1].intern\n end",
"def read_format(format)\n format ||= 'html'\n format.gsub('.', '').to_sym\n end",
"def format_renderer(format)\n renderer_name = format.to_s.capitalize + \"Renderer\"\n\n begin\n renderer_class = Object.const_get(renderer_name)\n rescue\n Logging.logger.warn(\"Renderer #{renderer_name} not found. Falling back to plaintext.\")\n renderer_class = Object.const_get(\"PlaintextRenderer\")\n end\n\n renderer_class.new(verbose, group)\n end",
"def get_credentials_provider\n @providers.each { |p|\n begin\n # if token is assigned, that's the provider we want.\n # providers must throw NoValueError so that we can fall to the next provider if necessary\n CerberusUtils::get_credentials_from_provider(p)\n return p\n\n rescue Cerberus::Exception::NoValueError\n next\n end\n }\n\n # we should have found and returned a valid provider above, else there's a problem\n CerberusUtils::Log.instance.error(\"Could not find a valid provider\")\n raise Cerberus::Exception::NoValidProviders.new\n end",
"def provider\n begin\n @provider ||= eval(\"MusicProviders::#{source}\").new\n rescue\n @provider = MusicProviders::DefaultProvider.new\n end\n end",
"def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end",
"def provides(*args)\n self.formats = args\n end",
"def format idx\n case idx\n when Integer\n @formats[idx] || @default_format || Format.new\n when String\n @formats.find do |fmt| fmt.name == idx end\n end\n end",
"def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end",
"def file_for(provider)\n if cursor = provides?(provider)\n cursor.file.to_s\n else\n raise ProviderNotFound.new(\"The file for provider '#{provider}' is not found.\")\n end\n end",
"def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end",
"def use_format(format)\n reader_file = File.join(File.dirname(__FILE__), \"sf1-driver\", \"readers\", \"#{format}-reader\")\n writer_file = File.join(File.dirname(__FILE__), \"sf1-driver\", \"writers\", \"#{format}-writer\")\n require reader_file\n require writer_file\n\n eval \"extend #{Helper.camel(format)}Reader\"\n eval \"extend #{Helper.camel(format)}Writer\"\n end",
"def format2type(format)\n if FORMATS.has_key? format\n FORMATS[format]\n elsif @user_defined_formats.has_key? format\n @user_defined_formats[format]\n else\n # Previously, just return :float here...\n # Instead, updating to correctly identify percents, dates/times from numeric formats\n # Step 1, remove all quoted (i.e., displayed as non-replaced static text) sections\n\t # \t\tAND all color and language bracket marker sections\n adj_format = format.gsub(/\\\".*?\\\"/, \"\").gsub(/\\[.*?\\]/, \"\")\n # Step 2, check if a percent, s date, a datetime, or a time\n\t if adj_format.include?(\"%\")\n\t\t:percentage\n elsif (adj_format.include?(\"y\") || adj_format.include?(\"d\") || adj_format.include?(\"m\")) && !(adj_format.include?(\"h\") || adj_format.include?(\"s\"))\n :date\n elsif (adj_format.include?(\"y\") || adj_format.include?(\"d\") || adj_format.include?(\"mmm\")) && (adj_format.include?(\"h\") || adj_format.include?(\"s\"))\n :datetime\n elsif !(adj_format.include?(\"y\") || adj_format.include?(\"d\") || adj_format.include?(\"mmm\")) && (adj_format.include?(\"h\") || adj_format.include?(\"s\"))\n :time\n else\n :float\n end\n end\n end",
"def format\n @spec[:format]\n end",
"def register(format)\n @@registered_formats << format\n end",
"def my_provider\n self.class.my_provider\n end",
"def to_format\n @format ||= lookup.last \n end",
"def provider\n conf['provider'] || 'defaults'\n end",
"def provider\n system.provider\n end",
"def format\n @format ||= (\n if read\n fmt = self.class.supported_formats.find{ |fm| fm.match?(path, read) }\n raise IOError, \"Version file matches no known format.\"\n else\n PlainFormat\n end\n )\n end",
"def require_formatter(format)\n case format.to_s\n when 'yaml'\n require 'yaml'\n when 'json'\n require 'json'\n end\n end",
"def request_format(scope)\n format = format_from_params(scope)\n format ||= format_from_request(scope)\n return format if (format && self.respond_to?(\"to_#{format}\"))\n DEFAULT_FORMAT\n end",
"def first_provider(provider)\n @first_provider ||= authentications.each { |a| return a if a.provider == provider }\n end",
"def provider\n @provider or raise \"No provider set via space.use_provider\"\n end",
"def create_renderer(format)\n case format.to_s\n when \"pdf\"\n HtmlConverter::Renderer::PDF.new\n when \"ps\"\n HtmlConverter::Renderer::PS.new\n else\n raise StandardError, \"Uknown format: #{format}\"\n end\n end",
"def [](name)\n @providers[name]\n end",
"def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end",
"def choose_archiver(format)\n begin\n archiver_class = GlacierArchive.const_get(self.class.derive_name(format))\n rescue NameError => e\n raise \"No archiver for #{format} has been written yet\"\n end\n archiver_class.new\n end",
"def format\n @format ||= self._format_default\n end",
"def format_to_use(request)\n unless header = accept_header(request)\n raise ArgumentError, \"An Accept header must be provided to pick the right format\"\n end\n\n format = nil\n header.split(/,\\s*/).each do |name|\n next unless format = Puppet::Network::FormatHandler.format(name)\n next unless format.suitable?\n return format\n end\n\n raise \"No specified acceptable formats (#{header}) are functional on this machine\"\n end",
"def formats\n formats = online_resource?(record) ? online_format : physical_format\n any_found?(formats) ? Array(formats[0]) : nil\n end",
"def provider\n EmailAddress::Config.providers.each do |name, defn|\n return name if EmailAddress::DomainMatcher.matches?(@host_name, defn[:domains])\n end\n nil\n end",
"def provider_name\n return @provider_name\n end",
"def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend",
"def create_or_find_format_by name, variant = :default\n fs = @formats[name]\n fs = @formats[name] = {} if fs.nil?\n f = fs[variant]\n if f.nil?\n f = Workbook::Format.new\n if (variant != :default) && fs[:default]\n f = fs[:default].clone\n end\n @formats[name][variant] = f\n end\n @formats[name][variant]\n end",
"def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end",
"def resolve_ext(file_name)\n SUPPORTED_TEMPLATE_FORMATS.find { |ext| File.exists?(\"#{file_name}.#{ext}\") }\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def provider_path\n provider_directory + \"#{@provider}.rb\"\n end",
"def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n provider_klass = Vmpooler::PoolManager::Provider\n provider_klass.constants.each do |classname|\n next unless classname.to_s.casecmp(provider_class) == 0\n\n return provider_klass.const_get(classname).new(config, logger, metrics, redis_connection_pool, provider_name, options)\n end\n raise(\"Provider '#{provider_class}' is unknown for pool with provider name '#{provider_name}'\") if provider_klass.nil?\n end",
"def maybe_explicit_provider(resource)\n return nil unless resource.provider\n resource.provider\n end",
"def format\n return @format if [:json, :yaml].include?(@format)\n secrets.input_format\n end",
"def resolve_provider\n attributes.fetch(:resolveProvider)\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def formats\n self.class::FORMATS\n end",
"def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end",
"def provider_class\n self.class\n end",
"def provider_class\n self.class\n end",
"def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end",
"def format(format_name)\n valid_for 'string'\n assert_string format_name\n set format: format_name\n end",
"def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end",
"def getFormatInfo(dbName, formatName)\n printDebugMessage('getFormatInfo', 'Begin', 11)\n formatInfo = nil\n dbInfo = getDatabaseInfo(dbName)\n dbInfo.each_element('formatInfoList/formatInfo') { |tmpFormatInfo|\n if tmpFormatInfo.elements['name'].text == formatName\n formatInfo = tmpFormatInfo\n else\n tmpFormatInfo.each_element('aliases/alias') { |value|\n if value.text == formatName\n formatInfo = tmpFormatInfo\n end\n }\n end\n }\n printDebugMessage('getFormatInfo', 'End', 11)\n return formatInfo\n end",
"def with_format(format)\n old_formats = formats\n self.formats = [format]\n yield\n self.formats = old_formats\n nil\n end",
"def format\n @format ||= properties.format.new self\n end",
"def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def load_exfmt(format, attrs, opts = {})\n respond_to? \"load_exfmt_#{format}\" or\n raise ArgumentError, \"Exchange format #{format} is not supported\"\n __send__ \"load_exfmt_#{format}\", attrs, opts\n end",
"def provider_name\n @json['profile']['providerName'] rescue nil\n end",
"def [](key)\n if key == \"provider\"\n return @provider\n end\n @hash[key]\n end",
"def name\n @provider[:name]\n end",
"def with_format(format, &block)\n old_formats = formats\n begin\n self.formats = [format]\n return block.call\n ensure\n self.formats = old_formats\n end\n end",
"def format\n { 'print' => :pdf, 'zpass' => :csv }[kind]\n end",
"def format=(format)\n format = format.to_sym\n raise _(\"unsupported format '%{format}'.\") % { format: format } unless self.class.supported_format?(format)\n @format = format\n end",
"def retrieve\n provider.send(self.class.name)\n end",
"def provider_name\n object.provider_id.titleize\n end",
"def format\n image_format = FFI::MemoryPointer::new( ImageFormat )\n error = OpenCL.clGetImageInfo( self, FORMAT, image_format.size, image_format, nil)\n error_check(error)\n return ImageFormat::from_pointer( image_format )\n end",
"def mappings_provider(provider_name, is_legacy = false)\n return nil if provider_name.nil?\n provider = nil\n module_name = is_legacy ? 'Highlander': 'Cfhighlander'\n begin\n providers = Object.const_get(module_name).const_get('MapProviders')\n providers.const_get(provider_name)\n rescue NameError => e\n if e.to_s.include? \"uninitialized constant\"\n return mappings_provider(provider_name, true) unless is_legacy\n return nil\n end\n STDERR.puts(e.to_s)\n raise e\n end\nend",
"def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end",
"def provider_name(provider)\n Account.provider_name(provider)\n end",
"def format\n if ImageFormatService.include? geo_mime_type\n ImageFormatService.code(geo_mime_type)\n elsif RasterFormatService.include? geo_mime_type\n RasterFormatService.code(geo_mime_type)\n elsif VectorFormatService.include? geo_mime_type\n VectorFormatService.code(geo_mime_type)\n end\n end",
"def format_from_mimetype(mimetype)\n return nil if mimetype.nil?\n AllowedFormats.each { |k, v| return v if mimetype.include?(k) }\n end",
"def formats\n format\n end",
"def st_format(f)\n if self.class.st_config[:formats].respond_to?(:call)\n self.class.st_config[:formats].call(f.to_sym)\n else\n if self.class.st_config[:formats][f].is_a?(Symbol)\n self.send(self.class.st_config[:formats][f])\n else\n self.class.st_config[:formats][f]\n end\n end\n end",
"def provides(*types)\n @_use_format = true\n provides_format(*types)\n end",
"def provider\n @fog_wrapper.provider\n end",
"def format(_view_path = nil)\n formats.first || Mime::NullType.instance\n end",
"def format\n @format\n end",
"def implementation_provider\n attributes.fetch(:implementationProvider)\n end",
"def format\n params.fetch(:format, default_format)\n end",
"def register_format(ext, mime)\n FORMATS[ext.to_s] = mime\n end",
"def findProvider(policy)\n if( @provider === \"OpenStack\" )\n @governance = policy.os_governance\n elsif (@provider === \"AWS\")\n @governance = policy.aws_governance\n end\n @cloud_enabled = @governance[\"enabled_cloud\"]\n end",
"def registered_formats\n @@registered_formats\n end",
"def parse_format(format)\n format = format.to_s\n format.chomp! # remove carriage return\n format.strip! # remove leading and trailing space\n format.gsub!(/[ \\t]+/, ' ') # replace tabulations or spaces with a space\n\n strip_quotes = proc { |string| string.gsub(/^\\\\\"/, '').gsub(/\\\\\"$/, '') }\n find_quotes = proc { |string| string =~ /^\\\\\"/ } \n find_percent = proc { |string| string =~ /^%.*t$/ }\n find_referrer_or_useragent = proc { |string| string =~ /Referer|User-Agent/ }\n \n pattern = format.split(' ').map do |element|\n has_quotes = !!find_quotes.call(element)\n element = strip_quotes.call(element) if has_quotes\n \n self.names << rename_this_name(element)\n\n case\n when has_quotes\n if element == '%r' or find_referrer_or_useragent.call(element)\n /\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"/\n else\n '\\\"([^\\\"]*)\\\"'\n end\n when find_percent.call(element)\n '(\\[[^\\]]+\\])'\n when element == '%U'\n '(.+?)'\n else\n '(\\S*)'\n end\n end.join(' ')\n\n @regexp = Regexp.new(\"^#{pattern}$\")\n format\n end"
] |
[
"0.6890807",
"0.6637845",
"0.6144279",
"0.612312",
"0.59931195",
"0.59456164",
"0.59246707",
"0.5909754",
"0.57798964",
"0.5763829",
"0.5706053",
"0.5702132",
"0.5696122",
"0.56224453",
"0.5619345",
"0.56161296",
"0.5578824",
"0.5563391",
"0.55528134",
"0.551311",
"0.5490883",
"0.54825276",
"0.5482259",
"0.54178923",
"0.53976345",
"0.53822434",
"0.537498",
"0.535882",
"0.5325746",
"0.529941",
"0.52966017",
"0.52936584",
"0.52678293",
"0.5261703",
"0.5251777",
"0.5245052",
"0.52407694",
"0.5195628",
"0.5187952",
"0.5184895",
"0.51829284",
"0.51787543",
"0.51619416",
"0.5150705",
"0.51426655",
"0.5139406",
"0.5135725",
"0.51154625",
"0.5115209",
"0.51038444",
"0.5094036",
"0.50849855",
"0.5078676",
"0.5078676",
"0.5078676",
"0.50511986",
"0.50494725",
"0.504094",
"0.50311273",
"0.50298876",
"0.5021529",
"0.5021529",
"0.5014608",
"0.501392",
"0.50097895",
"0.50097895",
"0.49866372",
"0.4985545",
"0.49837765",
"0.49824935",
"0.49792036",
"0.4978484",
"0.49782687",
"0.49679777",
"0.49666184",
"0.49608293",
"0.49599996",
"0.49499953",
"0.49356994",
"0.4919848",
"0.49186978",
"0.49135342",
"0.49113092",
"0.49057955",
"0.48960552",
"0.489391",
"0.48865944",
"0.48821676",
"0.48780203",
"0.4871455",
"0.4868524",
"0.48645642",
"0.4857134",
"0.48510852",
"0.48443547",
"0.48414722",
"0.4826341",
"0.481893",
"0.4810093",
"0.4808777"
] |
0.6160864
|
2
|
Get provider corresponding to a given format.
|
def [] format
providers[format]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end",
"def formats\n providers.keys\n end",
"def provider_for(file)\n ext = File.extname(file)\n case ext\n when '.ini'\n IniProvider\n when '.yaml', '.yml'\n YamlProvider\n else\n raise UnsupportedConfigFormatError.new(ext)\n end\n end",
"def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end",
"def parser_class(format)\n supported_parsers.detect { |p| p.parses? format }\n end",
"def provider\n providers.first\n end",
"def format\n lookup_val = Integer(@rf['format'])\n @_format ||= format_proxy.lookup_format_name(lookup_val)\n rescue\n @rf['format']\n end",
"def load_format(format)\n case format.to_s\n when /(md|mkdn?|mdown|markdown)$/i\n :markdown\n when /(textile)$/i\n :textile\n when /(rdoc)$/i\n :rdoc\n when /(org)$/i\n :org\n when /(creole)$/i\n :creole\n when /(re?st(\\.txt)?)$/i\n :rest\n when /(asciidoc)$/i\n :asciidoc\n when /(pod)$/i\n :pod\n when /(\\d)$/i\n :roff\n when /(media)?wiki$/i\n :mediawiki\n else\n nil\n end\n end",
"def provider\n get(PROVIDER)\n end",
"def provider\n use_provider('null') unless defined? @provider\n @provider\n end",
"def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end",
"def fetch_format(token, property)\n if FORMATS.key?(token)\n FORMATS[token][property]\n else\n raise ArgumentError, \"Unknown format token `:#{token}`\"\n end\n end",
"def provider\n @provider\n end",
"def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end",
"def format\n @format ||= File.extname(@full_path)[1..-1].intern\n end",
"def read_format(format)\n format ||= 'html'\n format.gsub('.', '').to_sym\n end",
"def format_renderer(format)\n renderer_name = format.to_s.capitalize + \"Renderer\"\n\n begin\n renderer_class = Object.const_get(renderer_name)\n rescue\n Logging.logger.warn(\"Renderer #{renderer_name} not found. Falling back to plaintext.\")\n renderer_class = Object.const_get(\"PlaintextRenderer\")\n end\n\n renderer_class.new(verbose, group)\n end",
"def get_credentials_provider\n @providers.each { |p|\n begin\n # if token is assigned, that's the provider we want.\n # providers must throw NoValueError so that we can fall to the next provider if necessary\n CerberusUtils::get_credentials_from_provider(p)\n return p\n\n rescue Cerberus::Exception::NoValueError\n next\n end\n }\n\n # we should have found and returned a valid provider above, else there's a problem\n CerberusUtils::Log.instance.error(\"Could not find a valid provider\")\n raise Cerberus::Exception::NoValidProviders.new\n end",
"def provider\n begin\n @provider ||= eval(\"MusicProviders::#{source}\").new\n rescue\n @provider = MusicProviders::DefaultProvider.new\n end\n end",
"def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end",
"def provides(*args)\n self.formats = args\n end",
"def format idx\n case idx\n when Integer\n @formats[idx] || @default_format || Format.new\n when String\n @formats.find do |fmt| fmt.name == idx end\n end\n end",
"def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end",
"def file_for(provider)\n if cursor = provides?(provider)\n cursor.file.to_s\n else\n raise ProviderNotFound.new(\"The file for provider '#{provider}' is not found.\")\n end\n end",
"def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end",
"def use_format(format)\n reader_file = File.join(File.dirname(__FILE__), \"sf1-driver\", \"readers\", \"#{format}-reader\")\n writer_file = File.join(File.dirname(__FILE__), \"sf1-driver\", \"writers\", \"#{format}-writer\")\n require reader_file\n require writer_file\n\n eval \"extend #{Helper.camel(format)}Reader\"\n eval \"extend #{Helper.camel(format)}Writer\"\n end",
"def format2type(format)\n if FORMATS.has_key? format\n FORMATS[format]\n elsif @user_defined_formats.has_key? format\n @user_defined_formats[format]\n else\n # Previously, just return :float here...\n # Instead, updating to correctly identify percents, dates/times from numeric formats\n # Step 1, remove all quoted (i.e., displayed as non-replaced static text) sections\n\t # \t\tAND all color and language bracket marker sections\n adj_format = format.gsub(/\\\".*?\\\"/, \"\").gsub(/\\[.*?\\]/, \"\")\n # Step 2, check if a percent, s date, a datetime, or a time\n\t if adj_format.include?(\"%\")\n\t\t:percentage\n elsif (adj_format.include?(\"y\") || adj_format.include?(\"d\") || adj_format.include?(\"m\")) && !(adj_format.include?(\"h\") || adj_format.include?(\"s\"))\n :date\n elsif (adj_format.include?(\"y\") || adj_format.include?(\"d\") || adj_format.include?(\"mmm\")) && (adj_format.include?(\"h\") || adj_format.include?(\"s\"))\n :datetime\n elsif !(adj_format.include?(\"y\") || adj_format.include?(\"d\") || adj_format.include?(\"mmm\")) && (adj_format.include?(\"h\") || adj_format.include?(\"s\"))\n :time\n else\n :float\n end\n end\n end",
"def format\n @spec[:format]\n end",
"def register(format)\n @@registered_formats << format\n end",
"def my_provider\n self.class.my_provider\n end",
"def to_format\n @format ||= lookup.last \n end",
"def provider\n conf['provider'] || 'defaults'\n end",
"def provider\n system.provider\n end",
"def format\n @format ||= (\n if read\n fmt = self.class.supported_formats.find{ |fm| fm.match?(path, read) }\n raise IOError, \"Version file matches no known format.\"\n else\n PlainFormat\n end\n )\n end",
"def require_formatter(format)\n case format.to_s\n when 'yaml'\n require 'yaml'\n when 'json'\n require 'json'\n end\n end",
"def request_format(scope)\n format = format_from_params(scope)\n format ||= format_from_request(scope)\n return format if (format && self.respond_to?(\"to_#{format}\"))\n DEFAULT_FORMAT\n end",
"def first_provider(provider)\n @first_provider ||= authentications.each { |a| return a if a.provider == provider }\n end",
"def provider\n @provider or raise \"No provider set via space.use_provider\"\n end",
"def create_renderer(format)\n case format.to_s\n when \"pdf\"\n HtmlConverter::Renderer::PDF.new\n when \"ps\"\n HtmlConverter::Renderer::PS.new\n else\n raise StandardError, \"Uknown format: #{format}\"\n end\n end",
"def [](name)\n @providers[name]\n end",
"def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end",
"def choose_archiver(format)\n begin\n archiver_class = GlacierArchive.const_get(self.class.derive_name(format))\n rescue NameError => e\n raise \"No archiver for #{format} has been written yet\"\n end\n archiver_class.new\n end",
"def format\n @format ||= self._format_default\n end",
"def format_to_use(request)\n unless header = accept_header(request)\n raise ArgumentError, \"An Accept header must be provided to pick the right format\"\n end\n\n format = nil\n header.split(/,\\s*/).each do |name|\n next unless format = Puppet::Network::FormatHandler.format(name)\n next unless format.suitable?\n return format\n end\n\n raise \"No specified acceptable formats (#{header}) are functional on this machine\"\n end",
"def formats\n formats = online_resource?(record) ? online_format : physical_format\n any_found?(formats) ? Array(formats[0]) : nil\n end",
"def provider\n EmailAddress::Config.providers.each do |name, defn|\n return name if EmailAddress::DomainMatcher.matches?(@host_name, defn[:domains])\n end\n nil\n end",
"def provider_name\n return @provider_name\n end",
"def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend",
"def create_or_find_format_by name, variant = :default\n fs = @formats[name]\n fs = @formats[name] = {} if fs.nil?\n f = fs[variant]\n if f.nil?\n f = Workbook::Format.new\n if (variant != :default) && fs[:default]\n f = fs[:default].clone\n end\n @formats[name][variant] = f\n end\n @formats[name][variant]\n end",
"def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end",
"def resolve_ext(file_name)\n SUPPORTED_TEMPLATE_FORMATS.find { |ext| File.exists?(\"#{file_name}.#{ext}\") }\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def provider_path\n provider_directory + \"#{@provider}.rb\"\n end",
"def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n provider_klass = Vmpooler::PoolManager::Provider\n provider_klass.constants.each do |classname|\n next unless classname.to_s.casecmp(provider_class) == 0\n\n return provider_klass.const_get(classname).new(config, logger, metrics, redis_connection_pool, provider_name, options)\n end\n raise(\"Provider '#{provider_class}' is unknown for pool with provider name '#{provider_name}'\") if provider_klass.nil?\n end",
"def maybe_explicit_provider(resource)\n return nil unless resource.provider\n resource.provider\n end",
"def format\n return @format if [:json, :yaml].include?(@format)\n secrets.input_format\n end",
"def resolve_provider\n attributes.fetch(:resolveProvider)\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def formats\n self.class::FORMATS\n end",
"def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end",
"def provider_class\n self.class\n end",
"def provider_class\n self.class\n end",
"def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end",
"def format(format_name)\n valid_for 'string'\n assert_string format_name\n set format: format_name\n end",
"def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end",
"def getFormatInfo(dbName, formatName)\n printDebugMessage('getFormatInfo', 'Begin', 11)\n formatInfo = nil\n dbInfo = getDatabaseInfo(dbName)\n dbInfo.each_element('formatInfoList/formatInfo') { |tmpFormatInfo|\n if tmpFormatInfo.elements['name'].text == formatName\n formatInfo = tmpFormatInfo\n else\n tmpFormatInfo.each_element('aliases/alias') { |value|\n if value.text == formatName\n formatInfo = tmpFormatInfo\n end\n }\n end\n }\n printDebugMessage('getFormatInfo', 'End', 11)\n return formatInfo\n end",
"def with_format(format)\n old_formats = formats\n self.formats = [format]\n yield\n self.formats = old_formats\n nil\n end",
"def format\n @format ||= properties.format.new self\n end",
"def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def load_exfmt(format, attrs, opts = {})\n respond_to? \"load_exfmt_#{format}\" or\n raise ArgumentError, \"Exchange format #{format} is not supported\"\n __send__ \"load_exfmt_#{format}\", attrs, opts\n end",
"def provider_name\n @json['profile']['providerName'] rescue nil\n end",
"def [](key)\n if key == \"provider\"\n return @provider\n end\n @hash[key]\n end",
"def name\n @provider[:name]\n end",
"def with_format(format, &block)\n old_formats = formats\n begin\n self.formats = [format]\n return block.call\n ensure\n self.formats = old_formats\n end\n end",
"def format\n { 'print' => :pdf, 'zpass' => :csv }[kind]\n end",
"def format=(format)\n format = format.to_sym\n raise _(\"unsupported format '%{format}'.\") % { format: format } unless self.class.supported_format?(format)\n @format = format\n end",
"def retrieve\n provider.send(self.class.name)\n end",
"def provider_name\n object.provider_id.titleize\n end",
"def format\n image_format = FFI::MemoryPointer::new( ImageFormat )\n error = OpenCL.clGetImageInfo( self, FORMAT, image_format.size, image_format, nil)\n error_check(error)\n return ImageFormat::from_pointer( image_format )\n end",
"def mappings_provider(provider_name, is_legacy = false)\n return nil if provider_name.nil?\n provider = nil\n module_name = is_legacy ? 'Highlander': 'Cfhighlander'\n begin\n providers = Object.const_get(module_name).const_get('MapProviders')\n providers.const_get(provider_name)\n rescue NameError => e\n if e.to_s.include? \"uninitialized constant\"\n return mappings_provider(provider_name, true) unless is_legacy\n return nil\n end\n STDERR.puts(e.to_s)\n raise e\n end\nend",
"def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end",
"def provider_name(provider)\n Account.provider_name(provider)\n end",
"def format\n if ImageFormatService.include? geo_mime_type\n ImageFormatService.code(geo_mime_type)\n elsif RasterFormatService.include? geo_mime_type\n RasterFormatService.code(geo_mime_type)\n elsif VectorFormatService.include? geo_mime_type\n VectorFormatService.code(geo_mime_type)\n end\n end",
"def format_from_mimetype(mimetype)\n return nil if mimetype.nil?\n AllowedFormats.each { |k, v| return v if mimetype.include?(k) }\n end",
"def formats\n format\n end",
"def st_format(f)\n if self.class.st_config[:formats].respond_to?(:call)\n self.class.st_config[:formats].call(f.to_sym)\n else\n if self.class.st_config[:formats][f].is_a?(Symbol)\n self.send(self.class.st_config[:formats][f])\n else\n self.class.st_config[:formats][f]\n end\n end\n end",
"def provides(*types)\n @_use_format = true\n provides_format(*types)\n end",
"def provider\n @fog_wrapper.provider\n end",
"def format(_view_path = nil)\n formats.first || Mime::NullType.instance\n end",
"def format\n @format\n end",
"def implementation_provider\n attributes.fetch(:implementationProvider)\n end",
"def format\n params.fetch(:format, default_format)\n end",
"def register_format(ext, mime)\n FORMATS[ext.to_s] = mime\n end",
"def findProvider(policy)\n if( @provider === \"OpenStack\" )\n @governance = policy.os_governance\n elsif (@provider === \"AWS\")\n @governance = policy.aws_governance\n end\n @cloud_enabled = @governance[\"enabled_cloud\"]\n end",
"def registered_formats\n @@registered_formats\n end",
"def parse_format(format)\n format = format.to_s\n format.chomp! # remove carriage return\n format.strip! # remove leading and trailing space\n format.gsub!(/[ \\t]+/, ' ') # replace tabulations or spaces with a space\n\n strip_quotes = proc { |string| string.gsub(/^\\\\\"/, '').gsub(/\\\\\"$/, '') }\n find_quotes = proc { |string| string =~ /^\\\\\"/ } \n find_percent = proc { |string| string =~ /^%.*t$/ }\n find_referrer_or_useragent = proc { |string| string =~ /Referer|User-Agent/ }\n \n pattern = format.split(' ').map do |element|\n has_quotes = !!find_quotes.call(element)\n element = strip_quotes.call(element) if has_quotes\n \n self.names << rename_this_name(element)\n\n case\n when has_quotes\n if element == '%r' or find_referrer_or_useragent.call(element)\n /\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"/\n else\n '\\\"([^\\\"]*)\\\"'\n end\n when find_percent.call(element)\n '(\\[[^\\]]+\\])'\n when element == '%U'\n '(.+?)'\n else\n '(\\S*)'\n end\n end.join(' ')\n\n @regexp = Regexp.new(\"^#{pattern}$\")\n format\n end"
] |
[
"0.6637845",
"0.6160864",
"0.6144279",
"0.612312",
"0.59931195",
"0.59456164",
"0.59246707",
"0.5909754",
"0.57798964",
"0.5763829",
"0.5706053",
"0.5702132",
"0.5696122",
"0.56224453",
"0.5619345",
"0.56161296",
"0.5578824",
"0.5563391",
"0.55528134",
"0.551311",
"0.5490883",
"0.54825276",
"0.5482259",
"0.54178923",
"0.53976345",
"0.53822434",
"0.537498",
"0.535882",
"0.5325746",
"0.529941",
"0.52966017",
"0.52936584",
"0.52678293",
"0.5261703",
"0.5251777",
"0.5245052",
"0.52407694",
"0.5195628",
"0.5187952",
"0.5184895",
"0.51829284",
"0.51787543",
"0.51619416",
"0.5150705",
"0.51426655",
"0.5139406",
"0.5135725",
"0.51154625",
"0.5115209",
"0.51038444",
"0.5094036",
"0.50849855",
"0.5078676",
"0.5078676",
"0.5078676",
"0.50511986",
"0.50494725",
"0.504094",
"0.50311273",
"0.50298876",
"0.5021529",
"0.5021529",
"0.5014608",
"0.501392",
"0.50097895",
"0.50097895",
"0.49866372",
"0.4985545",
"0.49837765",
"0.49824935",
"0.49792036",
"0.4978484",
"0.49782687",
"0.49679777",
"0.49666184",
"0.49608293",
"0.49599996",
"0.49499953",
"0.49356994",
"0.4919848",
"0.49186978",
"0.49135342",
"0.49113092",
"0.49057955",
"0.48960552",
"0.489391",
"0.48865944",
"0.48821676",
"0.48780203",
"0.4871455",
"0.4868524",
"0.48645642",
"0.4857134",
"0.48510852",
"0.48443547",
"0.48414722",
"0.4826341",
"0.481893",
"0.4810093",
"0.4808777"
] |
0.6890807
|
0
|
If any of the 'indicator properties' in the attribute hash are not nil, the boolean property is set to true in the attribute hash. Otherwise it's set to the default (or not set if default=nil). Returns the attribute hash.
|
def infer_boolean bool_property, indicator_properties, atts, default=nil
atts[bool_property] = default unless (atts[bool_property] or default.nil?)
indicator_properties.each do |x|
atts[bool_property] = true unless atts[x].nil?
end
return atts
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def boolean_attributes\n @boolean_attributes\n end",
"def copy_boolean_options_to_attributes(keys)\n keys.each do |k|\n if @opts[k] && !@attr.has_key?(k)\n @attr[k] = k\n end\n end\n end",
"def attributes_nil_hash\n @_attributes_nil_hash ||= {}.tap do |attr_hash|\n registered_properties.each_pair do |k, prop_obj|\n val = prop_obj.default_value\n attr_hash[k.to_s] = val\n end\n end.freeze\n end",
"def write_default_attributes\n self.attribute_defaults.each do |attribute, value|\n write_property_from_db(attribute, Neo4j::TypeConverters.convert(value, attribute, self.class, false)) unless changed_attributes.has_key?(attribute) || _java_entity.has_property?(attribute)\n end\n end",
"def has_booleans(*attrs)\n options = attrs.extract_options!\n attrs.each do |attr|\n\n attr_reader attr\n define_reader_with_options(attr,options) \n define_method(\"#{attr.to_s}=\") do |val|\n instance_variable_set(\"@#{attr}\", val.to_s.to_b)\n attributes[attr] = val\n val\n\n end\n\n define_method (\"#{attr.to_s}?\") do\n send(\"#{attr.to_s}\".to_sym).to_s.to_b\n end\n end\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 patch_policy_booleans_if(hash)\n return hash unless @check_waterfall\n\n hash.transform_values! do |value|\n case value\n when true\n value.define_singleton_method(:dig) { |*_keys| true }\n when false\n value.define_singleton_method(:dig) { |*_keys| false }\n when 'maybe'\n value.define_singleton_method(:dig) { |*_keys| 'maybe' }\n else\n patch_policy_booleans_if(value)\n end\n\n value\n end\n end",
"def write_default_attributes\n attribute_defaults.each do |attribute, value|\n write_attribute(attribute, Neo4j::TypeConverters.convert(value, attribute, self.class)) unless changed_attributes.has_key?(attribute) || _java_node.has_property?(attribute)\n end\n end",
"def default_attributes\n default_attributes = {}\n query.conditions.each do |tuple|\n operator, property, bind_value = *tuple\n\n next unless operator == :eql &&\n property.kind_of?(DataMapper::Property) &&\n ![ Array, Range ].any? { |k| bind_value.kind_of?(k) }\n !model.key(repository.name).include?(property)\n\n default_attributes[property.name] = bind_value\n end\n default_attributes\n end",
"def default_values\n self.organization_active = true if attributes.key?('organization_active') && organization_active.nil?\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 typus_boolean(attribute = :default)\n\n begin\n boolean = Typus::Configuration.config[name]['fields']['options']['booleans'][attribute.to_s]\n rescue\n boolean = 'true, false'\n end\n\n return nil if boolean.nil?\n\n hash = ActiveSupport::OrderedHash.new\n\n mapping = boolean.kind_of?(Array) ? boolean : boolean.extract_settings\n hash[:true], hash[:false] = mapping.first, mapping.last\n hash.map { |k, v| hash[k] = v.humanize }\n\n return hash\n\n end",
"def booleans_hash\n { camelize: camelize, include_root: include_root, include_namespaces: include_namespaces }\n end",
"def attributes_mapping\n common = {\n :hourly_billing_flag => :hourlyBillingFlag,\n :os_code => :operatingSystemReferenceCode,\n :vlan => :primaryNetworkComponent,\n :private_vlan => :primaryBackendNetworkComponent,\n :key_pairs => :sshKeys,\n :private_network_only => :privateNetworkOnlyFlag,\n :user_data => :userData,\n :provision_script => :postInstallScriptUri,\n :network_components => :networkComponents,\n }\n\n conditional = if bare_metal?\n {\n :cpu => :processorCoreAmount,\n :ram => :memoryCapacity,\n :disk => :hardDrives,\n :bare_metal => :bareMetalInstanceFlag\n }\n else\n {\n :cpu => :startCpus,\n :ram => :maxMemory,\n :disk => :blockDevices,\n :image_id => :blockDeviceTemplateGroup,\n :ephemeral_storage => :localDiskFlag,\n }\n end\n common.merge(conditional)\n end",
"def set_default_attrs\n self.state = 'Texas' if self.respond_to? :state\n self.origin = 'hunted' if self.respond_to? :origin\n self.gender = 'male' if self.respond_to? :gender\n if self.respond_to? :parts\n parts = Part::NAMES.map { |part_name| {name: part_name} }\n parts << { other: true }\n self.parts = parts\n end\n if self.respond_to? :taxidermy_parts\n taxidermy_parts = self.class::DEFAULT_TAXIDERMY_PARTS.map { |part_name| {name: part_name} }\n taxidermy_parts << { other: true }\n self.taxidermy_parts = taxidermy_parts\n end\n self\n end",
"def reset_is_default_flags\n if self.is_default == true\n self.time_series.weights.get_all_but(self.id).update_all(is_default: false)\n end\n end",
"def is_default\n data[:is_default]\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 default_attributes\n @default_attributes ||= {}\n end",
"def initialize(attributes = {})\n super(attributes)\n parse_booleans\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 default_attributes(custom = {})\n {}\n end",
"def additional_properties\n @additional_properties.nil? ? true : @additional_properties\n end",
"def default_attributes=(v)\n cfg_set(:default_attributes, v)\n end",
"def customized_properties\n current_resource.info['properties'].select do |_k, v|\n v['is_set'] == true\n end\n end",
"def configure_virtual_attributes(attributes)\n @virtual_attributes = if attributes == true\n VirtualAttributes.new(true)\n elsif attributes.is_a?(Hash)\n VirtualAttributes.new(true, attributes)\n else\n VirtualAttributes.new(false)\n end\n end",
"def merge_attributes(data)\n data.fetch(\"default\", {})\n .merge(data.fetch(\"normal\", {}))\n .merge(data.fetch(\"override\", {}))\n .merge(data.fetch(\"automatic\", {}))\n end",
"def _attributes(overrides)\n # allows us to set a root value\n return @attributes.clone unless @attributes.is_a?(Hash)\n\n if @parent.present?\n att = HashDealer.roll(@parent.to_sym)\n else\n att = HashDealer::Hash.new(self.optional_attributes)\n end\n\n @attributes.each do |k,v|\n att[k] = v.is_a?(Proc) ? v.call(att.merge(overrides)) : v\n end\n # if we have a hash as the first arg, it would override the attributes\n overrides.each_pair do |k,v|\n att[k.to_sym] = v if att.has_key?(k.to_sym)\n end\n att\n end",
"def owner_class_attribute_default_matches?(state); end",
"def default_attributes\n cfg_get(:default_attributes)\n end",
"def default_attributes=(v)\n cfg_set(:default_attributes, v)\n end",
"def default_values\n self.active ||= false\n end",
"def changes_to_default?\n return false unless has_default?\n\n # Cast our value to the actual type; if this is a boolean value, this\n # casts \"f\" to false.\n column = master_class.type_for_attribute(column_name)\n typecasted_value = column.deserialize(value)\n\n typecasted_value == get_default\n end",
"def to_boolean(default = nil)\n return true if ['true', '1', 'yes', 'on', 't'].include? self\n return false if ['false', '0', 'no', 'off', 'f'].include? self\n return default\n end",
"def typus_boolean(attribute = 'default')\n boolean = Typus::Configuration.config[self.name]['fields']['options']['booleans'][attribute] rescue nil\n boolean = \"true, false\" if boolean.nil?\n return { :true => boolean.split(', ').first.humanize, \n :false => boolean.split(', ').last.humanize }\n end",
"def default_X__PROPERTY_BOOL__X\n config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X')\n end",
"def set_default_attributes\n self.attributes = default_attributes\n self.attributes.each do |key, value|\n # Scrub the attributes if there's no value\n attr_clean!(key) unless value\n end\n 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 to_h(persist: false)\n {}.tap do |hash|\n (persist ? properties - foreign_objects : properties).each do |property|\n value = self[property]\n if value == false || value.present?\n hash[property] = value\n end\n end\n end\n end",
"def default_attributes\n cfg_get(:default_attributes)\n end",
"def default_true\n return (@acts[1].nil? ? true : @acts[1])\n end",
"def default_values\n self.contact_active = true if contact_active.nil?\n end",
"def attr_set_boolean(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def add_default_rel_attributes?\n @should_add_noopener = false if should_not_include_noopener?\n\n @should_add_noreferrrer = false if should_not_include_noreferrer?\n end",
"def include_operational_attrs=( new_setting )\n\t\tself.clear_caches\n\t\t@include_operational_attrs = new_setting ? true : false\n\tend",
"def is_preferred\n attributes.fetch(:isPreferred)\n end",
"def email_notification_preferences=(prefs_attributes)\n prefs = self.email_notification_preferences # init the object if it wasn't there\n prefs_attributes.each{|key, val| prefs.send(\"#{key}=\", val==\"true\")}\n write_attribute(:email_notification_preferences, prefs)\n end",
"def attr_bool_writer *symbols\n attr_writer *symbols\n end",
"def boolean_default_true(value)\n value.nil? || value\n end",
"def default_values\n\t\tself.done ||= 'false'\n\t\tself.flag ||= 'false'\n\tend",
"def to_hash\n hash = super\n VnicFcIf.attribute_map.each_pair do |attr, param|\n value = self.send(attr)\n if value.nil?\n is_nullable = VnicFcIf.openapi_nullable.include?(attr)\n next if !is_nullable || (is_nullable && !instance_variable_defined?(:\"@#{attr}\"))\n end\n\n hash[param] = _to_hash(value)\n end\n hash\n end",
"def set_if_nil(hash, key)\n hash[key] = true if hash[key].nil?\n end",
"def valid_attributes_hash( *additional_object_classes )\n\t\tself.log.debug \"Gathering a hash of all valid attributes:\"\n\t\tmust = self.must_attributes_hash( *additional_object_classes )\n\t\tself.log.debug \" MUST attributes: %p\" % [ must ]\n\t\tmay = self.may_attributes_hash( *additional_object_classes )\n\t\tself.log.debug \" MAY attributes: %p\" % [ may ]\n\n\t\treturn may.merge( must )\n\tend",
"def may_attributes_hash( *additional_object_classes )\n\t\tentry = self.entry\n\t\tattrhash = {}\n\n\t\tself.may_attribute_types( *additional_object_classes ).each do |attrtype|\n\t\t\t# self.log.debug \" adding attrtype %p to the MAY attributes hash\" % [ attrtype.named ]\n\n\t\t\tif attrtype.single?\n\t\t\t\tattrhash[ attrtype.name ] = nil\n\t\t\telse\n\t\t\t\tattrhash[ attrtype.name ] = []\n\t\t\tend\n\t\tend\n\n\t\t# :FIXME: Does the resulting hash need the additional objectClasses? objectClass is\n\t\t# MUST via 'top', so it should already exist in that hash when merged with\n\t\t# this one...\n\t\t# attrhash[ :objectClass ] |= additional_object_classes\n\n\t\treturn attrhash\n\tend",
"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 acwake\n return nil unless @property_hash.has_key? 'acwake'\n return nil unless @property_hash['acwake'] == '0' || @property_hash['acwake'] == '1'\n \n @property_hash['acwake'] == '1' ? :true : :false\n end",
"def make_default!\n pics = profile.profile_pics.where(is_default: true)\n pics.each { |pic| pic.update_attribute(:is_default, false) }\n update_attribute(:is_default, true)\n end",
"def bool_attr_accessor(*args)\n options = (args.pop if args.last.is_a?(Hash)) || {}\n\n (args + options.keys).each {|n| class_eval \"def #{n}=(x); @#{n} = x; end\" }\n\n args.each {|n| class_eval \"def #{n}?; @#{n}; end\" }\n\n options.keys.each do |n|\n class_eval %(def #{n}?\n if !defined? @#{n}\n @#{n} = #{options[n] ? 'true' : 'false'}\n else\n @#{n}\n end\n end)\n set_field_type(n => TrueClass) if respond_to?(:set_field_type)\n end\n end",
"def reset_nil_attributes_to_default\n nil_attributes = self.class.non_nil_attributes.find_all do |name|\n !instance_variable_defined?(\"@#{name}\") || instance_variable_get(\"@#{name}\").nil?\n end\n\n nil_attributes.each do |attribute|\n default = self.default_value attribute\n\n value = case default\n when Time, Numeric, Symbol, true, false, nil then default\n else default.dup\n end\n\n instance_variable_set \"@#{attribute}\", value\n end\n\n @installed_by_version ||= nil\n end",
"def convert_boolean(key)\n @params[key] = _boolinze(@params[key]) if _is_bool?(get_default(key))\n end",
"def scaffold_set_attributes(object, attributes)\n attributes.each do |k,v|\n v = nil if v.empty? and scaffold_table_column_type(k) == :boolean\n object.send(\"#{k}=\", v)\n end \n end",
"def all_base_attributes_present?\n BASE_ATTRIBUTES.all? { |attribute| self.send(\"#{attribute}?\") }\n end",
"def set_defaults\n self.active = self.active.nil? ? true : self.active\n self.show_in_dashboard = self.show_in_dashboard.nil? ? true : self.show_in_dashboard\n self.system_activity = self.system_activity.nil? ? false : self.system_activity\n self.frequency_quantity ||= 1\n end",
"def default_attributes\n {}\n end",
"def attr_get_boolean(attr_type, strict = true)\n #This is a stub, used for indexing\n end",
"def attributes_hash\n attributes = @serializable.attributes\n if options[:only].any?\n attributes.slice(*options[:only])\n elsif options[:except].any?\n attributes.except(*options[:except])\n else\n attributes\n end\n end",
"def lookup_boolean_attribute (attname, workitem, default=false)\n\n result = lookup_downcase_attribute(attname, workitem)\n return default if result == nil\n\n (result == 'true')\n end",
"def prepare_attribute!(_element, options)\n if options[:attribute].is_a?(FalseClass)\n options.except!(:attribute)\n elsif !options.key?(:attribute)\n options[:attribute] = true\n end\n end",
"def attributes(class_id, obj_ref, *attributes_hashes)\n attributes = class_id\n\n attributes_hashes.each do |hash|\n attributes.update hash\n end\n\n result = attributes.collect do |attr, value|\n if value == true\n next \" #{attr}\"\n elsif value == false\n next\n else\n \" #{attr}='#{value}'\"\n end\n end\n\n result.join\n end",
"def typus_boolean(attribute = :default)\n options = read_model_config['fields']['options']\n\n boolean = if options && options['booleans'] && boolean = options['booleans'][attribute.to_s]\n boolean.is_a?(String) ? boolean.extract_settings : boolean\n else\n [\"True\", \"False\"]\n end\n\n [[boolean.first, \"true\"], [boolean.last, \"false\"]]\n end",
"def custom_attributes\n base = {}.with_indifferent_access\n\n CUSTOM_MAP_ATTRIBUTES.inject(base) do |hash, attribute|\n value = send(attribute)\n\n # Using #blank? as coordinates might be an empty array.\n hash[attribute] = value unless value.blank?\n\n hash\n end\n end",
"def initialize_attributes()\n @attributes ||= {}\n merged_attributes = {}\n defaults = self.class.schema.defaults(self)\n\n # Merge the defaults in where attributes don't have a value defined.\n defaults.each do |name, value|\n merged_attributes[name] = attributes[name] || value\n end\n @attributes = merged_attributes\n end",
"def load_attributes!\n fetch_data unless data_fetched?\n # master & value attributes\n raw_attributes = Ken::Util.convert_hash(@data[\"/type/reflect/any_master\"])\n raw_attributes.merge!(Ken::Util.convert_hash(@data[\"/type/reflect/any_value\"])) \n @attributes = {}\n raw_attributes.each_pair do |a, d|\n properties.select { |p| p.id == a}.each do |p|\n @attributes[p.id] = Ken::Attribute.create(d, p)\n end\n end\n # reverse properties\n raw_attributes = Ken::Util.convert_hash(@data[\"/type/reflect/any_reverse\"])\n raw_attributes.each_pair do |a, d|\n properties.select { |p| p.master_property == a}.each do |p|\n @attributes[p.id] = Ken::Attribute.create(d, p)\n end\n end\n @attributes_loaded = true\n end",
"def default_values\n\t\tself.status = false\n\tend",
"def cached_attributes\n @cached_attributes ||=\n property_types.select{|k,v| attribute_types_cached_by_default.include?(v)}.map{|e| e.first.to_s}.to_set\n end",
"def default_value(attributes)\n exists = attributes['id'].present?\n obsolete = attributes['access_level'].to_i == RightManager::Right::NO\n attributes[:_destroy] = 1 if exists && obsolete # destroy FALSE Rights\n return (!exists && obsolete) # reject FALSE Right\n end",
"def set_defaults\n self.active = self.active.nil? ? true : self.active\n end",
"def set_defaults\n self.active = self.active.nil? ? true : self.active\n end",
"def set_defaults\n self.active = self.active.nil? ? true : self.active\n end",
"def to_hash(attribute_map = self.class.attribute_map, openapi_nullable = Set.new([]))\n hash = {}\n attribute_map.each_pair do |attr, param|\n value = self.send(attr)\n if value.nil?\n is_nullable = openapi_nullable.include?(attr)\n next if !is_nullable || (is_nullable && !instance_variable_defined?(:\"@#{attr}\"))\n end\n \n hash[param] = _to_hash(value)\n end\n hash\n end",
"def to_hash(attribute_map = self.class.attribute_map, openapi_nullable = Set.new([]))\n hash = {}\n attribute_map.each_pair do |attr, param|\n value = self.send(attr)\n if value.nil?\n is_nullable = openapi_nullable.include?(attr)\n next if !is_nullable || (is_nullable && !instance_variable_defined?(:\"@#{attr}\"))\n end\n \n hash[param] = _to_hash(value)\n end\n hash\n end",
"def to_hash(attribute_map = self.class.attribute_map, openapi_nullable = Set.new([]))\n hash = {}\n attribute_map.each_pair do |attr, param|\n value = self.send(attr)\n if value.nil?\n is_nullable = openapi_nullable.include?(attr)\n next if !is_nullable || (is_nullable && !instance_variable_defined?(:\"@#{attr}\"))\n end\n \n hash[param] = _to_hash(value)\n end\n hash\n end",
"def to_hash(attribute_map = self.class.attribute_map, openapi_nullable = Set.new([]))\n hash = {}\n attribute_map.each_pair do |attr, param|\n value = self.send(attr)\n if value.nil?\n is_nullable = openapi_nullable.include?(attr)\n next if !is_nullable || (is_nullable && !instance_variable_defined?(:\"@#{attr}\"))\n end\n \n hash[param] = _to_hash(value)\n end\n hash\n end",
"def airtable_formatted(hash)\n h = hash.dup\n h.each{|k,v|\n if v == [\"\"]\n h[k] = []\n elsif v == \"\"\n h[k] = nil\n elsif v == \"true\"\n h[k] = true\n elsif v == \"false\"\n h[k] = false\n end\n }\n end",
"def set_defaults\n set_nil_default( :archived, false )\n end",
"def boolean_pair(outcomes, spec_config)\n return false if spec_config['default']\n\n if [TrueClass, FalseClass].include?(outcomes.first.class)\n return { outcomes.first => !outcomes.first }\n end\n\n return unless %w[true false].include?(outcomes.first)\n\n { outcomes.first => (outcomes.first != 'true').to_s }\n end",
"def set_defaults\n self.active = self.active.nil? ? true : self.active\n end",
"def is_default?\n @rule_details.is_default == true\n end",
"def attributes\n @attributes ||= begin\n attrs = {}\n self.class.key_attrs.values.each { |a| attrs[a.name] = a.initial_value }\n self.class.other_attrs.values.each { |a| attrs[a.name] = a.initial_value }\n attrs\n end\n end",
"def output_value(key)\n if self.class.boolean_attributes.include?(key)\n (@attributes[key] ? \"yes\" : \"no\")\n else\n @attributes[key]\n end\n end",
"def set_defaults\n unless persisted? \n self.active ||= false\n self.complete ||= false\n self.start_on ||= Date.today\n self.finished_on ||= Date.today + 1\n end\n end",
"def create_boolean_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil)\n path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'\n .gsub('{databaseId}', database_id)\n .gsub('{collectionId}', collection_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if collection_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"collectionId\"')\n end\n\n if key.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"key\"')\n end\n\n if required.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"required\"')\n end\n\n params = {\n key: key,\n required: required,\n default: default,\n array: array,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'POST',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::AttributeBoolean\n )\n end",
"def feature_flags_with_defaults\n flag_names = FeatureFlag.pluck(:name).sort\n FeatureFlag.default_flag_hash.merge(feature_flags_for(*flag_names)).with_indifferent_access\n end",
"def assign_boolean_param_if_used(attr_name, value)\n\t\tsend \"#{attr_name}=\", value.present? if value\n\tend",
"def defaults\n hash = {}\n\n hash[:heating] = nil\n hash[:cooling] = nil\n hash[:interior_lighting] = nil\n hash[:exterior_lighting] = nil\n hash[:interior_equipment] = nil\n hash[:exterior_equipment] = nil\n hash[:electric_vehicles] = nil\n hash[:fans] = nil\n hash[:pumps] = nil\n hash[:heat_rejection] = nil\n hash[:humidification] = nil\n hash[:heat_recovery] = nil\n hash[:water_systems] = nil\n hash[:refrigeration] = nil\n hash[:generators] = nil\n\n return hash\n end",
"def enabled\n if @property_hash[:enabled].nil?\n :absent\n else\n @property_hash[:enabled]\n end\n end",
"def boolean(key, default=false)\n\t\tvalue = self.fetch(key.downcase, nil)\n\t\tif value\n\t\t\tif value.strip =~ /^(true|t|yes|y|on|1|enable|enabled|positive|pro|allow|active|activate|accept|trust)$/i\n\t\t\t\treturn true\n\t\t\tend\n\t\t\tif value.strip =~ /^(false|f|no|n|off|0|disable|disabled|negative|con|deny|inactive|deactivate|reject|distrust|mistrust)$/i\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn default\n\tend",
"def lessbright\n return nil unless @property_hash.has_key? 'lessbright'\n return nil unless @property_hash['lessbright'] == '0' || @property_hash['lessbright'] == '1'\n \n @property_hash['lessbright'] == '1' ? :true : :false\n end",
"def default_values\n self.isAdmin ||= false\n end",
"def use_defaults\n self.search_attr_values = {}\n\n search_attributes_config.each do |k, v|\n search_attr_values[k.to_sym] = FieldDefaults.calculate_default(self, v.default, v.type)\n end\n search_attr_values\n end"
] |
[
"0.5871165",
"0.58479124",
"0.5739904",
"0.563485",
"0.5597352",
"0.5594985",
"0.55411273",
"0.5538196",
"0.552452",
"0.5505258",
"0.5490311",
"0.5428838",
"0.53585804",
"0.52806413",
"0.5279203",
"0.5273315",
"0.52719796",
"0.52068394",
"0.51994675",
"0.5199269",
"0.5197765",
"0.5196846",
"0.5171446",
"0.5156922",
"0.51489437",
"0.51393133",
"0.51057535",
"0.51027775",
"0.5097858",
"0.50967896",
"0.50953585",
"0.50909394",
"0.5087364",
"0.5083245",
"0.5081012",
"0.50793856",
"0.5071577",
"0.50703883",
"0.505153",
"0.5049311",
"0.5048912",
"0.50421786",
"0.5041086",
"0.50348574",
"0.50230837",
"0.5019195",
"0.5003402",
"0.49948275",
"0.49920422",
"0.4970235",
"0.49664772",
"0.49626604",
"0.49536568",
"0.49445358",
"0.49380866",
"0.49256727",
"0.49242464",
"0.4924154",
"0.49162066",
"0.49146894",
"0.4914642",
"0.49031162",
"0.4902415",
"0.48999158",
"0.4898955",
"0.48928764",
"0.48858804",
"0.48652107",
"0.48629615",
"0.48515868",
"0.48491025",
"0.48398995",
"0.48378024",
"0.48284483",
"0.48275518",
"0.48274165",
"0.48233953",
"0.48233953",
"0.48233953",
"0.4814557",
"0.4814557",
"0.4814557",
"0.4814557",
"0.4814545",
"0.48140416",
"0.48100722",
"0.48077303",
"0.48073643",
"0.4804276",
"0.4795317",
"0.47924048",
"0.4780222",
"0.47800583",
"0.47663468",
"0.4764644",
"0.47585136",
"0.47583896",
"0.47554073",
"0.47543028",
"0.47535264"
] |
0.7186898
|
0
|
Cleans a list of Boolean values to be either true or false
|
def clean_bool dirty_vals
vals = []
array = separate(dirty_vals)
array.each { |dirty_val|
val = get_b(dirty_val)
#if val.nil? and (!dirty_val.nil? and dirty_val.strip!='')
# val = dirty_val.match(/(not applicable|n\/a|not available)/i).nil?
#end
vals << val
}
if vals.empty? or vals.uniq == [nil]
return nil
elsif vals.include? true
return true
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove_falsy_values(list)\n list.select {|element| !!element}\nend",
"def remove_falsy_values list\n list.select { |item| !!item }\nend",
"def munge_boolean(value)\n case value\n when true, 'true', :true\n 'true'\n when false, 'false', :false\n 'false'\n else\n raise \"Invalid value for munge_boolean #{value}\"\n end\n end",
"def clean_up_boolean(_, q_val)\n %w(t true).include? q_val\n end",
"def remove_falsy_values(list)\n list.delete_if { |el| !el }\n end",
"def convert_booleans(value)\n if [\"true\", \"false\"].include?(value)\n value = (value == \"true\")\n else\n value\n end\n end",
"def coerce_str_to_bool(*keys)\n coerce(*keys){ |str_bool| (str_bool == 'on' || str_bool == 'true')}\n end",
"def remove_nils_and_false_from_array(array)\n array.select {|i| i != nil && i != false }\nend",
"def only_true(array)\n array.reject{|element| element == false || element == nil}\nend",
"def boolify(val)\n\nend",
"def booleans!\n @boolean_params.each do |param|\n key = (param.is_a?(Array) ? param.first : param)\n verify_boolean_param(key)\n end\n end",
"def remove_falsy_values list\n\n list.compact!\n\n list.each do |x|\n if x == false\n y = list.find_index(x)\n list.slice!(y)\n end\n end\n\nend",
"def remove_nils_and_false_from_array(arr)\n arr.reject { |n| n.nil? || n == false }\nend",
"def remove_nils_and_false_from_array(array)\n array.reject!{ | word | word == nil || word == false }\nend",
"def remove_nils_and_false_from_array(array)\n array.reject{|element|!element}\nend",
"def create_boolean_collection(options) #:nodoc:\n options[:true] ||= ::Formtastic::I18n.t(:yes)\n options[:false] ||= ::Formtastic::I18n.t(:no)\n options[:value_as_class] = true unless options.key?(:value_as_class)\n\n [ [ options.delete(:true), true], [ options.delete(:false), false ] ]\n end",
"def create_boolean_collection(options) #:nodoc:\n options[:true] ||= ::I18n.t(:yes)\n options[:false] ||= ::I18n.t(:no)\n options[:value_as_class] = true unless options.key?(:value_as_class)\n\n [ [ options.delete(:true), true], [ options.delete(:false), false ] ]\n end",
"def reduce_to_all_true(array)\n if array.include? false\n false\n elsif array.each.include? true\n true\n end\nend",
"def remove_falsy_values(list)\n list.select{|element| element}\nend",
"def convert_boolean_strings\n %i{ambiguous_ref_bases use_all_contigs include_low_hmes polyploidy}.each do | symbol |\n if @options.key?(symbol)\n @options[symbol] = @options[symbol] == 'false' ? false : true\n end\n end\n end",
"def remove_nils_and_false_from_array(array)\n\tn = ['a', 'b', nil, nil, false, 'c', nil]\n\tn.keep_if { |letter| letter != nil && letter != false }\nend",
"def remove_falsy_values(arr)\n arr.reject { |e| !e } # OR arr.reject { |e| !!e }\nend",
"def booleanish_to_boolean(arguments, ddl)\n arguments.keys.each do |key|\n if ddl[:input].keys.include?(key)\n if ddl[:input][key][:type] == :boolean\n arguments[key] = true if arguments[key] == \"true\"\n arguments[key] = true if arguments[key] == \"yes\"\n arguments[key] = true if arguments[key] == \"1\"\n arguments[key] = false if arguments[key] == \"false\"\n arguments[key] = false if arguments[key] == \"no\"\n arguments[key] = false if arguments[key] == \"0\"\n end\n end\n end\n rescue\n true\n end",
"def to_bool(value)\n ! FALSE_VALUES.include?(value)\n end",
"def remove_nils_and_false_from_array(array)\n array.select{|x| x}\nend",
"def unsafe_munge(value)\n # downcase strings\n if value.respond_to? :downcase\n value = value.downcase\n end\n\n case value\n when *BooleanProperty.values_for_true\n :true\n when *BooleanProperty.values_for_false\n :false\n else\n fail \"expected a boolean value, got #{value.inspect}\"\n end\n end",
"def areAllTrue(boolean_array)\r\n\tboolean_array.each do |x|\r\n\t\tif !x \r\n\t\t\treturn false\r\n\t\tend\r\n\tend\r\n\treturn true\r\nend",
"def value_to_boolean(value)\n if value.is_a?(String) && value.empty?\n nil\n else\n TRUE_VALUES.include?(value)\n end\n end",
"def coerce_booleans(val)\n return 1 if [true, \"TRUE\", \"1\", \"true\", \"YES\", \"yes\"].include?(val)\n return 0 if [false, \"FALSE\", \"0\", \"false\", \"NO\", \"no\"].include?(val)\n\n val\n end",
"def coerce_boolean(value, options = {})\n return if options[:allow_nil] && (value.nil? || value == \"\")\n return false if value.to_s.strip == \"false\"\n !!value && !coerce_string(value, :allow_nil => false).strip.empty?\n end",
"def boolean(**props)\n transform(type: :boolean, **props) do |value|\n !!value\n end\n end",
"def coerce_booleans(config, *names)\n names.each { |name| config[name] = [true, 'true'].include?(config[name]) }\n end",
"def convert_string_to_bool(value)\n case value\n when \"true\"\n true\n when \"false\"\n false\n when Array\n value.map { |elem| convert_string_to_bool(elem) }\n when Hash\n value.each do |key, elem|\n value[key] = convert_string_to_bool(elem)\n end\n value\n else\n value\n end\n end",
"def remove_falsy_values(foo)\n foo.select { |bar| !!bar }\n end",
"def coerce_bool(value)\n case value\n when nil, false then false\n when Numeric then !value.zero?\n else\n true\n end\n end",
"def value_to_boolean(value)\n if value.is_a?(String) && value.blank?\n nil\n else\n TRUE_VALUES.include?(value)\n end\n end",
"def false_values\n [false, 'false', :false, :no, 'no', :undef, nil, :absent]\n end",
"def normalize(boolean_str)\n\t\t\tTrue.include?(boolean_str) ? (:true) : (:false)\n\t\tend",
"def fix_booleans\n Post.where.not(published: 't').update_all(\"published = 'f'\")\n end",
"def collapse_boolean_literals(node)\n map node do |n|\n case n\n when And\n if n.children.any? do |c|\n False === c\n end\n puts \"Collapsing and(false)\"\n False.new\n else\n n.children.delete_if do |c|\n True === c\n end\n n\n end\n when Or\n if n.children.any? do |c|\n True === c\n end\n puts \"Collapsing or(true)\"\n True.new\n else\n n.children.delete_if do |c|\n False === c\n end\n n\n end\n else\n n\n end\n end\n end",
"def remove_nils_and_false_from_array(arr)\n reformed_array = []\n index = 0\n arr.each do |entry|\n if entry != nil && entry != false\n reformed_array.insert(index, entry)\n index += 1\n end\n end \n return reformed_array\nend",
"def post_process_boolean( val )\n\t\t\treturn TRUE_VALUES.include?( val.to_s.downcase )\n\t\tend",
"def convert_to_boolean(val)\n return val if val.is_a?(TrueClass) || val.is_a?(FalseClass)\n val = val.to_s.clean\n return nil if val.blank?\n if val.match?(/\\A(false|f|n|no)\\z/i)\n false\n elsif val.match?(/\\A(true|t|y|yes)\\z/i)\n true\n end\n end",
"def c_textify_bool_list_result(list,name_list)\n list.each_index do |i|\n if name_list.include?(list[i]['key'])\n list[i]['value'].each do |item|\n list.push({'key'=>item['name'],'value'=>item['value']})\n end\n list.delete_at(i)\n # continue at same index because we delete current one\n redo\n end\n end\n end",
"def bool_conv(value)\n value == HEX_FALSE ? false : true\n end",
"def to_boolean(val)\n val && (val.to_s.match(/(true|t|yes|y|1)$/i) != nil)\n end",
"def fix_boolean(node)\n node.children.map! do |child|\n if child.is_a?(AST::Node) &&\n child.type == :coerce_b\n child.children.first\n else\n child\n end\n end\n end",
"def test_string_should_convert_into_boolean\n ['true', 'True', 'TRUE', '1'].each do |x|\n assert x.to_boolean\n end\n assert !\"false\".to_boolean \n end",
"def exercise_1111 (bool_values)\n end",
"def booleans(*values)\n @optional_params.concat(values)\n @boolean_params = values\n end",
"def coerce_boolean(value, options = {})\n return nil if options[:allow_nil] && value.nil?\n !!value && !coerce_string(value).empty?\n end",
"def to_bool(value)\n value.to_s.downcase == 'true' ? true : false\n end",
"def parse_boolean_value(value)\n value.to_s.downcase == 'true'\n end",
"def value_to_boolean(value)\n return value if value==true || value==false\n case value.to_s.downcase\n when \"true\", \"t\", \"1\" then true\n else false\n end\n end",
"def clone_symptoms_negate_bool_values\n new_symptoms = symptoms.to_a.deep_dup\n new_symptoms.each do |symptom|\n if symptom.type == 'BoolSymptom'\n symptom.negate\n else\n symptom.value = nil\n end\n end\n end",
"def flip_flop(trueValue, falseValue)\n map! do |truth|\n truth ? trueValue : falseValue\n end\n end",
"def coerce_boolean(value, options = {})\n value = value =~ options[:pattern] if options.has_key?(:pattern)\n !!value\n end",
"def parse_bool() false end",
"def parse_bool() false end",
"def to_bool\n return true if ['true', '1', 'yes', 'on', 't'].include? self\n return false if ['false', '0', 'no', 'off', 'f'].include? self\n return false\n end",
"def to_boolean(value)\n case value\n when :true, 'true'\n true\n else\n false\n end\n end",
"def to_boolean(str)\n !(str == 'false' || str == '0')\nend",
"def clean_filter(value)\n value = @filters[value] if value.is_a? Symbol\n ActiveRecord::Type::Boolean.new.cast(value)\n end",
"def to_boolean(value)\n [\"true\", \"1\", \"yes\"].include?(value.to_s) ? true : false\n end",
"def _boolinze(val)\n return true if ['true', '1'].include?(val)\n return false if ['false', '0'].include?(val)\n val\n end",
"def to_bool\n dc = to_s.downcase\n\n if TRUE_WORDS.include?(dc)\n true\n elsif FALSE_WORDS.include?(dc)\n false\n end\n end",
"def match_maker setter, *args\n pairs = []\n args.to_a.each_slice(2) do |a,b|\n a = !!a#this will set show if the value is true or false. Nil is false.\n b = !!b\n if a == b\n pairs << true\n else\n pairs << false\n end\n end\n if setter == true#reverse the result if true\n pairs.map! do |i|\n i = !i\n end\n end\n p pairs\nend",
"def to_boolean(value)\n [\"true\", \"1\", \"yes\"].include?(value.to_s) ? true : false\n end",
"def parse_from_human(boolean_pattern)\n self[0...length] = [] #remove the last pattern if it existed\n boolean_pattern.each_char do |char|\n if char == '1'\n push true\n elsif char == '0'\n push false\n elsif char == '-'\n push nil\n else\n raise \"Unexpected pattern character: #{char}\"\n end\n end\n end",
"def typecast_value_boolean(value)\n case value\n when false, 0, \"0\", /\\Af(alse)?\\z/i, /\\Ano?\\z/i\n false\n else\n blank_object?(value) ? nil : true\n end\n end",
"def normalize_bool(default = :and)\n case self\n when /(and|all)/i\n :and\n when /(any|or)/i\n :or\n when /(not|none)/i\n :not\n when /^p/i\n :pattern\n else\n default.is_a?(Symbol) ? default : default.normalize_bool\n end\n end",
"def parse_to_true_false_string(only_yes = false)\n raise MissingValueError.new(var: var) if vals.empty?\n raise TooManyValuesError.new(var: var) if vals.length > 1\n\n val = vals.first\n return \"TRUE\" if /^(1|yes|true)$/i.match?(val)\n return \"FALSE\" if /^(0|no|false)$/i.match?(val) && !only_yes\n raise BadYesError.new(var: var, val: val) if only_yes\n\n raise BadBooleanError.new(var: var, val: val)\n end",
"def infer_boolean bool_property, indicator_properties, atts, default=nil\n atts[bool_property] = default unless (atts[bool_property] or default.nil?)\n indicator_properties.each do |x|\n atts[bool_property] = true unless atts[x].nil?\n end\n return atts\n end",
"def parse_bool(bool_param)\n bool_param.try(:to_bool) || (bool_param.try(:to_i) == 1)\n end",
"def parse_to_true_false_string(only_yes = false)\n raise MissingValueError.new(var: var) if vals.empty?\n raise TooManyValuesError.new(var: var) if vals.length > 1\n val = vals.first\n return \"TRUE\" if /^(1|yes|true)$/i.match?(val)\n return \"FALSE\" if /^(0|no|false)$/i.match?(val) && !only_yes\n raise BadYesError.new(var: var, val: val) if only_yes\n raise BadBooleanError.new(var: var, val: val)\n end",
"def apply_validations_for_boolean\n value_set = [ true, false ]\n value_set << nil unless not_nullable?\n flex_column_class.validates field_name, :inclusion => { :in => value_set }\n end",
"def is_bool input\n !!input == input\nend",
"def normalize_ifs(ifs)\n case ifs\n when NilClass\n nil\n when Array\n ifs.map do |iff|\n lambda { val = variables.value_of(iff.to_s); !val.nil? && !val.kind_of?(FalseClass) && val != 'false' }\n end\n when Hash\n ifs.each_with_object([]) do |(k, v), arr|\n arr << lambda { variables.value_of(k.to_s) == v }\n end\n when String, Symbol\n [lambda { val = variables.value_of(ifs.to_s); !val.nil? && !val.kind_of?(FalseClass) && val != 'false' }]\n else\n raise TypeError, \"Invalid syntax for if: #{ifs.inspect}\"\n end\n end",
"def convert_to_boolean(value)\n value != 'no'\n end",
"def value_to_boolean_with_negative_ones(value)\n return true if TRUE_VALUES_WITH_NEGATIVE_ONES.include?(value)\n value_to_boolean_without_negative_ones(value)\n end",
"def has_booleans(*attrs)\n options = attrs.extract_options!\n attrs.each do |attr|\n\n attr_reader attr\n define_reader_with_options(attr,options) \n define_method(\"#{attr.to_s}=\") do |val|\n instance_variable_set(\"@#{attr}\", val.to_s.to_b)\n attributes[attr] = val\n val\n\n end\n\n define_method (\"#{attr.to_s}?\") do\n send(\"#{attr.to_s}\".to_sym).to_s.to_b\n end\n end\n end",
"def analisados(analisados)\n analisados.each do |_n, value|\n return true if value == false\n end\n false\n end",
"def booleans cols\n decode_values :boolean, cols, true\n end",
"def boolean cols\n decode_values :boolean, cols\n end",
"def boolean_pair(outcomes, spec_config)\n return false if spec_config['default']\n\n if [TrueClass, FalseClass].include?(outcomes.first.class)\n return { outcomes.first => !outcomes.first }\n end\n\n return unless %w[true false].include?(outcomes.first)\n\n { outcomes.first => (outcomes.first != 'true').to_s }\n end",
"def to_boolean\n # SECURE: BNS 2012-10-09: But may behave oddly for multi-line input\n return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)\n return false if self == false || self.nil? || self =~ (/^(false|f|no|n|0)$/i)\n fail ArgumentError, \"invalid value for Boolean: \\\"#{self}\\\"\"\n end",
"def parse_bool() true end",
"def to_bool(value)\n ActiveModel::Type::Boolean.new.cast(value.to_s.strip)\n end",
"def preconditions arr\n arr.each {|i|\n if (i.is_bool? && i==false) || (i.is_a?(Proc) && (i.call==false))\n return false\n end\n }\n return true\nend",
"def typecast_value_boolean(opts={});true;end",
"def convert(value)\n case value.to_s\n when /^(yes|y|t(rue)?|1)$/i\n return true\n when /^(no|n|f(alse)?|0)$/i\n return false\n else\n fail TypeError, \"Expected boolean type, got #{value}\"\n end\n end",
"def set_boolean!(value)\n @objects = nil\n @memory = nil\n\n self[:type] = :boolean\n self[:values][:boolean] = if value\n 1\n else\n 0\n end\n end",
"def truthy?\n case strip.downcase\n when \"1\", \"true\", \"yes\", \"on\", \"enabled\", \"affirmative\"\n true\n else\n false\n end\n end",
"def cast_to_boolean(input)\n ActiveRecord::Type::Boolean.new.type_cast_from_user(input)\n end",
"def is_bool(value) #method\n if value == 'verdadero' || value == 'falso'\n true\n else\n false\n end\n end",
"def f_all\n C.curry.(\n ->(f, xs) {\n !any.(->(x) { x == false }, map.(f, xs))\n }\n )\n end",
"def false_true\n alternatives false, true\n end",
"def boolean_to_binary(arr)\n result = ''\n i = 0\n while i < arr.length\n result << '1' if arr[i]\n result << '0' if !arr[i]\n i += 1\n end\n return result\nend",
"def as_booleans(row)\n fail ValueError unless row =~ /\\A\\|[ *]+\\|\\z/\n row[1..-2].each_char.map { |c| c == '*' }\n end",
"def nullify(bool)\n bool ? bool : nil\n end"
] |
[
"0.67963964",
"0.677568",
"0.66777885",
"0.664705",
"0.6532966",
"0.6388392",
"0.63500625",
"0.6339539",
"0.6331791",
"0.6289312",
"0.62826055",
"0.6270334",
"0.6262669",
"0.6237597",
"0.6234937",
"0.62102747",
"0.61962754",
"0.6169771",
"0.61552",
"0.6148134",
"0.6104385",
"0.6094068",
"0.608712",
"0.60771215",
"0.60718423",
"0.6048915",
"0.60327005",
"0.60127133",
"0.60009146",
"0.5962674",
"0.59360796",
"0.5912989",
"0.59095377",
"0.58928066",
"0.5878371",
"0.58646244",
"0.5863339",
"0.5850105",
"0.5815771",
"0.5802855",
"0.5799348",
"0.57834387",
"0.5739472",
"0.5737307",
"0.57342345",
"0.5718452",
"0.57114625",
"0.57054776",
"0.5702722",
"0.5696191",
"0.5694636",
"0.5688207",
"0.5684353",
"0.5654028",
"0.5644967",
"0.56399345",
"0.5626947",
"0.5557012",
"0.5557012",
"0.55367684",
"0.5525461",
"0.5521827",
"0.54982007",
"0.5498166",
"0.5488687",
"0.5474504",
"0.5461597",
"0.545734",
"0.5456997",
"0.5444193",
"0.54008937",
"0.53875023",
"0.5381802",
"0.5373664",
"0.53735125",
"0.5366792",
"0.53615147",
"0.5356597",
"0.5351735",
"0.5350917",
"0.53301257",
"0.5308335",
"0.53050876",
"0.53045",
"0.5297935",
"0.529228",
"0.528545",
"0.5279188",
"0.527665",
"0.526652",
"0.52653146",
"0.52540517",
"0.52537775",
"0.5235121",
"0.52263",
"0.5212584",
"0.51925147",
"0.5170844",
"0.51706177",
"0.51671654"
] |
0.7573842
|
0
|
Easy access to the current connection context.
|
def connection
settings.connection
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def connection #:nodoc:\n Thread.current['connection'] ||= retrieve_connection\n Thread.current['connection']\n end",
"def context\n Context.instance\n end",
"def connection\n retrieve_connection\n end",
"def context\n @context ||= Context.new(self)\n end",
"def context\n Thread.current[:ctx] ||= {}\n Thread.current[:ctx]\n end",
"def context\n @context ||= Context.new(self)\n end",
"def connection\n @@connection\n end",
"def context\n unless @instance_context\n @instance_context = ChannelContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def current\n all_contexts[Thread.current.object_id]\n end",
"def context\n init\n @context\n end",
"def connection\n self.class.connection\n end",
"def connection\n self.class.connection\n end",
"def connection\n self.class.connection\n end",
"def connection\n self.class.connection\n end",
"def connection\n self.class.connection\n end",
"def connection\n @connection\n end",
"def context\n\n self\n end",
"def context\n unless @instance_context\n @instance_context = CurrentCallContext.new(@version, )\n end\n @instance_context\n end",
"def context\n self.current_custom_context || self.default_context\n end",
"def this_context\n self\n end",
"def connection\n @connection\n end",
"def context\n unless @instance_context\n @instance_context = CpsContext.new(@version, )\n end\n @instance_context\n end",
"def connection\n @connection_class.connection\n end",
"def connection\n self.session.connection\n end",
"def connection\n raise ConnectionNotEstablished unless @@connection\n return @@connection\n end",
"def context\n @context ||= {}\n end",
"def context\n @context ||= {}\n end",
"def context\n unless @instance_context\n @instance_context = InteractionChannelContext.new(\n @version,\n @params['interaction_sid'],\n @params['sid'],\n )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ChannelContext.new(@version , @params['service_sid'], @params['sid'])\n end\n @instance_context\n end",
"def connection\n @connection\n end",
"def client_context\n return @client_context\n end",
"def client_context\n return @client_context\n end",
"def connection\n self.server[self.database][self.layout]\n end",
"def connection\n @@connection_proxy\n end",
"def connection\n @@connection_proxy\n end",
"def connection\n if defined?(@active_connection_name) && (conn = active_connections[@active_connection_name])\n conn\n else\n # retrieve_connection sets the cache key.\n conn = retrieve_connection\n active_connections[@active_connection_name] = conn\n end\n end",
"def execution_context\n @context\n end",
"def context\n unless @instance_context\n @instance_context = ConfigurationContext.new(@version , @params['chat_service_sid'])\n end\n @instance_context\n end",
"def connection\n adapter.connection\n end",
"def context\n unless @instance_context\n @instance_context = CallContext.new(@version, @params['account_sid'], @params['sid'],)\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CallContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CallContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def connection\n @connection ||= build_connection\n end",
"def message_context_session\n session\n end",
"def connection\n return nil unless has_connection?\n ActiveRecord::Base.connection\n end",
"def context\n @parent&.context\n end",
"def context\n @context_stack.last\n end",
"def context\n @context || (parent.context if parent)\n end",
"def conn\n\t\treturn @conn ||= self.connect\n\tend",
"def context\n Byebug.current_context\n end",
"def active_connection\n super\n end",
"def connection\n @connection ||= make_connection\n end",
"def connection(env); end",
"def current!\n fail 'No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db' unless current\n current\n end",
"def context\n unless @instance_context\n @instance_context = CompositionContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def contextify\n self.class.monadic_context.new self\n end",
"def context\n @context ||= ::ZMQ::Context.new\n end",
"def connection\n @pg\n end",
"def context\n unless @instance_context\n @instance_context = ApplicationContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n @_context ||= begin\n ptr = MemoryPointer::new( Context )\n error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)\n error_check(error)\n Context::new( ptr.read_pointer )\n end\n end",
"def connection\n ActiveRecord::Base.connection\n end",
"def interface\n Context.interface\n 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 context(name = current_context)\n named_context(name)&.context\n end",
"def context\n nil\n end",
"def context\n Thread.current[NAME] ||= Hash.new\n end",
"def context\n attributes.fetch(:context)\n end",
"def connection\n ActiveRecord::Base.connection\n end",
"def get_context\n @context_hash ||= {}\n end",
"def raw_connection\n @connection\n end",
"def connection\n CryptKeeper::Connection.http_instance\n end",
"def connection\n @connection_pool\n end",
"def get(context = Context.current)\n context[self]\n end",
"def connection\n @db = Connection.client\nend",
"def context\n unless @instance_context\n @instance_context = InteractionContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def irb_context\n IRB.CurrentContext\n end",
"def connection\n self.field('Connection')\n end",
"def mainContext\n # return Context.find( context )\n return context\n end",
"def proxy_context\n @context\n end"
] |
[
"0.70869696",
"0.70253927",
"0.69178975",
"0.68982804",
"0.68723774",
"0.685649",
"0.68383914",
"0.6618575",
"0.66181654",
"0.6615057",
"0.6594858",
"0.6594858",
"0.6594858",
"0.6594858",
"0.6594585",
"0.65898645",
"0.65778315",
"0.655838",
"0.6519816",
"0.6503987",
"0.6499308",
"0.6498855",
"0.649698",
"0.64949465",
"0.6492638",
"0.6489125",
"0.6489125",
"0.6486776",
"0.6481776",
"0.6470914",
"0.64590555",
"0.64571357",
"0.6394478",
"0.63612145",
"0.63612145",
"0.63580793",
"0.63578886",
"0.63469195",
"0.6329381",
"0.63039744",
"0.6298928",
"0.62734985",
"0.62538046",
"0.62118626",
"0.620245",
"0.62019855",
"0.61920613",
"0.61872226",
"0.618577",
"0.6175823",
"0.6156706",
"0.61563414",
"0.6151211",
"0.6145599",
"0.61300737",
"0.6128947",
"0.61228323",
"0.61223453",
"0.6113123",
"0.6112719",
"0.61067075",
"0.61055166",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.60887814",
"0.6087091",
"0.6087045",
"0.6085341",
"0.6078389",
"0.6067731",
"0.60582256",
"0.6056432",
"0.60527694",
"0.60512227",
"0.60425156",
"0.6038965",
"0.6037517",
"0.60206133",
"0.6008282",
"0.6008155",
"0.59953046"
] |
0.6254622
|
42
|
Function for initializing the Driver instance.
|
def initialize()
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize driver\n @driver = driver\n end",
"def initialize(driver)\n\t\tsuper\n\n\t\tself.driver = driver\n\tend",
"def initialize(driver)\r\n @@driver = driver\r\n end",
"def driver_initialize\n\t\t#Driver initialization happens here.\n\t\tdriver = Driver::new\n\t\tdriver.seed = rand(100)\n\t\tdriver.my_initialize\n\t\tdriver\n\tend",
"def initialize(driver)\r\n begin\r\n $driver = driver\r\n rescue Exception => e\r\n raise e.message\r\n raise e.backtrace.inspect\r\n end\r\n end",
"def initialize_driver\n if ENV['browser'] == \"\"\n browser_sym = @config.browser.downcase.to_sym\n else\n browser_sym = ENV['browser'].downcase.to_sym\n end\n\n client = Selenium::WebDriver::Remote::Http::Default.new\n client.timeout = 40 # seconds\n exec_mode = @config.execution_mode.to_s.downcase\n if exec_mode == \"local\"\n Selenium::WebDriver::Chrome.driver_path=\"#{File.dirname(__FILE__)}/drivers/chromedriver.exe\"\n $driver = Selenium::WebDriver.for(browser_sym, :http_client => client)\n elsif exec_mode == \"remote\"\n initializing_remote_web_driver browser_sym, client\n end\n end",
"def initialize(driver, api)\n @driver = driver\n @api = api\n end",
"def initialize(driver, api)\n @driver = driver\n @api = api\n end",
"def initialize(driver, api)\n @driver = driver\n @api = api\n end",
"def initialize(driver, api)\n @driver = driver\n @api = api\n end",
"def initialize(driver, api)\n @driver = driver\n @api = api\n end",
"def initialize(driver, api)\n @driver = driver\n @api = api\n end",
"def initialize(options = {})\n options = { :logger => Jamie.logger }.merge(options)\n validate_options(options)\n logger = options[:logger]\n\n @suite = options[:suite]\n @platform = options[:platform]\n @driver = options[:driver]\n @jr = options[:jr]\n @logger = logger.is_a?(Proc) ? logger.call(name) : logger\n\n @driver.instance = self\n setup_driver_mutex\n end",
"def initialize(options = {})\n self.browser = options.fetch(:browser, :chrome)\n self.install_dir = options.fetch(:install_dir, './webdrivers/')\n self.locale = options.fetch(:locale, :en)\n self.headless = options.fetch(:headless, false)\n self.window_size = options.fetch(:window_size, '1280,720')\n self.screen_dir = options.fetch(:screen_dir, './screens/')\n self.log_prefix = options.fetch(:log_prefix, ' - ')\n self.verbose = options.fetch(:verbose, false)\n self.silent = options.fetch(:silent, false)\n self.auth_username = options.fetch(:auth_username, '')\n self.auth_password = options.fetch(:auth_password, '')\n self.main_label = caller_locations(2, 1).first.label\n\n initialize_driver\n\n self.timeout = options.fetch(:timeout, 30)\n end",
"def initialize\n # Create temporary data directory\n create_data_dir\n\n # Init connection to ADS\n init_ads\n\n # Initialize Data science toolkit\n init_dstk\n\n # Init connection to SQLite\n # init_sqlite3\n end",
"def initialize(driver, baseurl='/')\n super(driver, baseurl)\n end",
"def initialize(driver)\n @driver = driver\n @utills = WebDriverUtils.new(@driver)\n end",
"def initialize\n init\n end",
"def initialize()\n @sel = Capybara::Session.new(:selenium)\n end",
"def initialize(options) # @todo: Refactor using factory method Connection.build_producer\n super # takes declared attributes only, skipping brokers and client_id\n brokers = options.fetch(:brokers)\n client = options.fetch(:client_id)\n @connection = DRIVER.new(brokers, client, attributes)\n @mutex = Mutex.new\n end",
"def driver\n # DATPages::Driver.instance\n @driver ||= DATPages::DriverConnection.initialize_driver\n end",
"def driver; end",
"def initialize\n set_config\n end",
"def start_driver\n @driver.start_driver\n end",
"def initialize(params = nil)\n set_params(params)\n set_simulation\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize(config = nil)\n @config = config\n setup\n end",
"def initialize(conf = {})\n super(conf) ;\n setup() ;\n end",
"def initialize(node)\n require 'chef/provisioning/aws_driver'\n\n Server::Helpers.check_attribute?(\n node['provisioning'][driver],\n \"node['provisioning']['#{driver}']\"\n )\n @node = node\n @driver_hash = @node['provisioning'][driver]\n\n @driver_hash.each do |attr, value|\n singleton_class.class_eval { attr_accessor attr }\n instance_variable_set(\"@#{attr}\", value)\n end\n end",
"def initialize_drivers\n\t\tself.drivers = []\n\t\ttdrivers = %W{ postgresql mysql sqlite3 }\n\t\ttdrivers.each do |driver|\n\t\t\tbegin\n\t\t\t\tActiveRecord::Base.default_timezone = :utc\n\t\t\t\tActiveRecord::Base.establish_connection(:adapter => driver)\n\t\t\t\tif(self.respond_to?(\"driver_check_#{driver}\"))\n\t\t\t\t\tself.send(\"driver_check_#{driver}\")\n\t\t\t\tend\n\t\t\t\tActiveRecord::Base.remove_connection\n\t\t\t\tself.drivers << driver\n\t\t\trescue ::Exception\n\t\t\tend\n\t\tend\n\n\t\tif(not self.drivers.empty?)\n\t\t\tself.driver = self.drivers[0]\n\t\tend\n\n\t\t# Database drivers can reset our KCODE, do not let them\n\t\t$KCODE = 'NONE' if RUBY_VERSION =~ /^1\\.8\\./\n\tend",
"def initialize(*args, &blk)\n setup(*args, &blk)\n end",
"def create_driver(_conf = APPLICATION_DEFAULT_CONFIG, _tag = 'test')\n _undefined\n end",
"def initialize( buffers, driver )\n @buffers = buffers\n @driver = driver\n end",
"def driver\n\t\t\t_load_driver unless @driver\n\t\t\t@driver\n\t\tend",
"def initialize(selenium_webdriver: (::Selenium::WebDriver.for DEFAULT_BROWSER, options: default_options))\n require \"selenium-webdriver\"\n @driver = selenium_webdriver\n end",
"def initialize\n super\n\n @component_name = @component_name.snakecase\n @component_type = Automation::Component::DatabaseType\n @connected = false\n\n # Database details from the configuration.\n @database_id = @config_manager[\"database.#{@component_name}.database_id\"]\n @adapter = db_config('adapter', default: false)\n raise ConfigurationError.new(\"No adapter defined for database '#{@component_name}.#{@database_id}'\") unless @adapter\n # Get the adapter specific connection specification and establish the connection on all required models.\n @connection_config = db_connection_config\n end",
"def setup\n # Create Object from CPBI Library (cpbi_lib.rb)\n @cpbi_backend = CPBI_lib.new\n @driver = @cpbi_backend.driver\n @wait = @cpbi_backend.wait\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize(driver, element)\n super(element)\n\n @driver = driver\n end",
"def initialize(config)\n @config = config\n setup\n end",
"def initialize()\n end",
"def initialize(name)\n @name = name\n @@all << self\n #here we set our drivers name and shovel them into our mass collection of drivers\n end",
"def initialize(opts = {})\n opts[:timeout] = 120 unless opts[:timeout]\n @wait = Selenium::WebDriver::Wait.new(:timeout=>opts[:timeout])\n TelluriumDriver.wait_for_document_ready=true;\n\n opts[:caps] ||= {}\n opts[:caps][:browserName] ||= opts[:browser]\n opts[:caps][:version] ||= opts[:version]\n\n is_local = !opts[:hub_ip] and !opts[:hub_url]\n \n if is_local\n @driver = Selenium::WebDriver.for(opts[:browser].to_sym,:desired_capabilities=>opts[:caps])\n else\n @driver = Selenium::WebDriver.for(:remote,:desired_capabilities=>opts[:caps],:url=> \"http://#{opts[:hub_ip]}:4444/wd/hub\")\n end\n end",
"def initialize(options = {})\n init(options)\n end",
"def driver\n unless @driver\n # require here so minimum loading is done before {start} is called.\n require 'msf/ui'\n\n @driver = Msf::Ui::Console::Driver.new(\n Msf::Ui::Console::Driver::DefaultPrompt,\n Msf::Ui::Console::Driver::DefaultPromptChar,\n driver_options\n )\n end\n\n @driver\n end",
"def initialize\n set_defaults\n end",
"def initialize\n set_defaults\n end",
"def initialize\n # Create an instance of the selenium driver.\n client = Selenium::WebDriver::Remote::Http::Default.new\n client.timeout = 60 # default seconds to wait for responses from web requests to the application server\n @driver = Selenium::WebDriver.for(:chrome, :http_client => client, :listener => DemoSeleniumEventListener.new)\n end",
"def initialize device_name, *args\n begin\n @driver = device_driver(device_name)\n rescue Selenium::WebDriver::Error::UnknownError => e\n raise DeviceError, \"Invalid device name: '#{device_name}'\"\n end\n @device_name = device_name\n @browser = Watir::Browser.new driver\n end",
"def driver\n @driver ||= self.class.default_driver\n end",
"def initialize(...)\n super()\n configure(...)\n end",
"def initialize(options)\n\t\t\t@options = options\n\t\t\t@driver_name = (options[:driver] || :firefox).to_sym\n\t\t\t@variables = {\n\t\t\t\t'__TIMEOUT__' => (options[:timeout] || 10).to_i,\n\t\t\t\t'__DEBUG__' => false,\n\t\t\t\t'__SELECTOR__' => options[:selector] || 'sid',\n\t\t\t\t'__OUTPUT__' => options[:output],\n\t\t\t\t'__DIR__' => File.absolute_path(Dir.pwd)\n\t\t\t}\n\t\t\t@aliases = {}\n\t\t\t@tests = []\n\n\t\t\tclient = Selenium::WebDriver::Remote::Http::Default.new\n\t\t\tclient.timeout = (@options[:open_timeout] || 60).to_i\n\t\t\t@options[:driver_opt] = {} unless @options[:driver_opt]\n\t\t\t@options[:driver_opt][:http_client] = client\n\n\t\t\t_load_extensions(options[:extensions] || [])\n\n\t\t\t@logger = Context::load_logger(options[:logger], options[:logger_opt])\n\n\t\t\t@parser = Parser.new(self)\n\t\tend",
"def initialize(options={})\n @config = DEFAULTS.merge! options\n @config[:console_id] = CONSOLE_MAP[@config[:console]] if CONSOLE_MAP.has_key? @config[:console]\n\n setup_connection\n setup_resources\n end",
"def setup_capybara\n @poltergeist_driver = nil\n\n # Capybara will not re-run the block if the driver name already exists, so the driver name\n # will have a time integer appended to ensure uniqueness.\n driver_name = \"poltergeist_crawler_#{Time.now.to_f}\".to_sym\n Grell.logger.info \"GRELL Registering poltergeist driver with name '#{driver_name}'\"\n\n Capybara.register_driver driver_name do |app|\n @poltergeist_driver = Capybara::Poltergeist::Driver.new(app,\n js_errors: false,\n inspector: false,\n phantomjs_logger: FakePoltergeistLogger,\n phantomjs_options: ['--debug=no', '--load-images=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1.2'])\n end\n\n Capybara.default_max_wait_time = 3\n Capybara.run_server = false\n Capybara.default_driver = driver_name\n Capybara.current_session.driver.headers = { # The driver gets initialized when modified here\n \"DNT\" => 1,\n \"User-Agent\" => USER_AGENT\n }\n\n raise 'Poltergeist Driver could not be properly initialized' unless @poltergeist_driver\n\n @poltergeist_driver\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(options = {}, &blk)\n init(options, &blk)\n end",
"def initialize(options = {}, &blk)\n init(options, &blk)\n end",
"def initialize\n @drivers = Array.new\n end",
"def init\n raise NotImplementedError\n end",
"def initialize\n\t\t\n\t\t@dao = DAO.new 'rpg'\n\n\tend",
"def initialize\n # Define instance variables\n @log = nil\n @config = nil\n @robot = nil\n @socket = nil\n # Initialize those that should be done now.\n parse_arguments()\n setup_logger()\n # Call the block if necessary.\n yield(self) if block_given?\n end",
"def init\n\n end",
"def initialize(args = {})\n @driver = args.fetch(:driver)\n @instrumenter = args[:instrumenter] || Instrumenters::Noop\n @argument_generators = args.fetch(:argument_generators, DefaultArgumentGenerators)\n @result_transformers = args.fetch(:result_transformers, DefaultResultTransformers)\n @retry_strategy = args[:retry_strategy] || DefaultRetryStrategy\n @command_runners = args.fetch(:command_runners, DefaultCommandRunners)\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",
"def initialize(devtype,param)\n setupDevice(devtype,param) ;\n end",
"def initialize\n end",
"def initialize\n OperaWatir.compatibility! unless OperaWatir.api >= 3\n\n self.driver = OperaDriver.new(self.class.desired_capabilities)\n self.active_window = OperaWatir::Window.new(self)\n self.preferences = OperaWatir::Preferences.new(self)\n self.keys = OperaWatir::Keys.new(self)\n self.spatnav = OperaWatir::Spatnav.new(self)\n self.utils = OperaWatir::Utils.new(self)\n end",
"def initialize\n @drivers = []\n end",
"def initialize()\n\t\tend",
"def initialize() end",
"def initialize config\n connect config\n create_table_if_not_exists!\n end",
"def initialize(file_path: file_path, name: name, index: index, dataset: dataset)\n @gdal_driver_handle = if file_path\n GDALIdentifyDriver(::File.expand_path(file_path), nil)\n elsif name\n GDALGetDriverByName(name)\n elsif index\n count = self.class.driver_count\n raise \"index must be between 0 and #{count - 1}.\" if index > count\n\n GDALGetDriver(index)\n elsif dataset\n GDALGetDatasetDriver(dataset)\n end\n end",
"def initialize(driver, user, price, route)\r\n\t\t@driver = driver\r\n\t\t@user = user\r\n\t\t@price = price\r\n\t\t@route = route\r\n\tend",
"def adapter_initialize\n end",
"def initialize\n define_os\n define_path\n read_settings\n end",
"def initialize_configuration\n\n #Pulse the Program pin via JTAG.\n self.instruction = :jprogram\n\n #Put the device into configuration mode, and give it 14,000 cycles to start up.\n self.instruction = :cfg_in\n run_test(ConfigurationStartup)\n\n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def setup_driver\n return if $driver\n caps = Appium.load_appium_txt file: File.join(Dir.pwd, 'appium.txt')\n $driver = Appium::Driver.new caps\n # debug \"setting up driver using #{caps.to_yaml}\"\nend",
"def driver\n start_app_if_needed\n @driver\n end",
"def initialize\r\n\r\n end",
"def initialize(browser = :chrome)\n @driver = Selenium::WebDriver.for browser\n end",
"def initialize(framework, opts)\n\t\tsuper\n\t\tadd_console_dispatcher(OpenVASCommandDispatcher)\n\t\tprint_status(\"Welcome to OpenVAS integration by kost and averagesecurityguy.\")\n\t\tprint_status\n\t\tprint_status(\"OpenVAS integration requires a database connection. Once the \")\n\t\tprint_status(\"database is ready, connect to the OpenVAS server using openvas_connect.\")\n\t\tprint_status(\"For additional commands use openvas_help.\")\n\t\tprint_status\n\t\t@ov = nil\n\t\t@formats = nil\n\tend",
"def define_driver\n { 'name' => 'solusvm',\n 'privileged' => 'true'\n }\n end"
] |
[
"0.8146847",
"0.80160236",
"0.7998658",
"0.7858474",
"0.731117",
"0.71061283",
"0.70538735",
"0.70538735",
"0.70538735",
"0.70538735",
"0.70538735",
"0.70538735",
"0.69862056",
"0.6961147",
"0.6790253",
"0.6639914",
"0.6595987",
"0.6524962",
"0.65206426",
"0.6503429",
"0.6492743",
"0.6488773",
"0.64621717",
"0.64607316",
"0.64469194",
"0.6432869",
"0.6432869",
"0.6419442",
"0.6375659",
"0.63614726",
"0.6353484",
"0.63352007",
"0.63005733",
"0.6291275",
"0.628577",
"0.62785786",
"0.62630534",
"0.6259684",
"0.6259308",
"0.6259308",
"0.6259308",
"0.62346894",
"0.6222267",
"0.62149274",
"0.6209144",
"0.6182337",
"0.6181307",
"0.61631316",
"0.61579794",
"0.61579794",
"0.61539215",
"0.6151966",
"0.6147615",
"0.61473286",
"0.61432016",
"0.6125699",
"0.61254835",
"0.6099375",
"0.6099375",
"0.6099375",
"0.6099375",
"0.6099375",
"0.6099375",
"0.60778135",
"0.60778135",
"0.6063087",
"0.60613185",
"0.605911",
"0.60411906",
"0.60352826",
"0.6025814",
"0.6023975",
"0.6023975",
"0.6023975",
"0.6023975",
"0.6023975",
"0.6023975",
"0.6023975",
"0.6023975",
"0.60202545",
"0.601558",
"0.60130143",
"0.60104316",
"0.6007215",
"0.600012",
"0.59975916",
"0.5996425",
"0.5995849",
"0.5995306",
"0.5988539",
"0.5986959",
"0.5984621",
"0.5984621",
"0.5984621",
"0.5984621",
"0.59804237",
"0.5979794",
"0.595482",
"0.59466326",
"0.59441555",
"0.59406143"
] |
0.0
|
-1
|
Function for navigating to passed URL and creating browser instance.
|
def navigateTo(browser_instance,url)
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
# $worldMap = Hash.new
$session = Capybara::Session.new(:selenium)
$session.visit 'https://staging-bbva.everfiapps-dev.net/cportal/ccdee586/login'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def goto_page(browser_handle, url)\n browser_handle.goto(url)\nend",
"def navigate_to(url)\n self.visit url\n end",
"def navigate_to(url)\n self.visit url\n end",
"def go_to_page(url)\n Logbook.step(\"Open start page #{url} :)\")\n @browser.get url\n sleep 2\n\n @browser\n end",
"def go_to(url)\n @browser.navigate.to url\n end",
"def goto_url(url)\r\n @browser.navigate.to url\r\n end",
"def go_to_url (url)\n\t\t@browser.goto (url)\n\tend",
"def open(url = @url)\n @browser.goto(url)\n wait_for_page_to_load\n end",
"def go_to(url)\n @browser.goto(url)\n end",
"def start_browser(url, browser = 'firefox')\n self.open_browser browser\n @browser.goto url\n return @browser\n end",
"def goto_url(url)\r\n @web_browser.goto_url url\r\n end",
"def goto_url(url)\n @web_browser.goto_url url\n end",
"def visit\n @browser.goto(URL)\n end",
"def openBrowser(step)\n browserName = @envConfig['Browser']\n browserDriver = \"#{$ROOT}/../webDriver/#{browserName}driver.exe\"\n case browserName\n when 'chrome'\n Selenium::WebDriver::Chrome.driver_path = browserDriver\n # @browser = Watir::Browser.new(:chrome, :switches => %w[--start-maximized])\n @browser = Watir::Browser.new(:chrome)\n when 'firefox'\n Selenium::WebDriver::Firefox.driver_path = browserDriver\n # @browser = Watir::Browser.new(:firefox, :switches => %w[--start-maximized])\n @browser = Watir::Browser.new(:firefox)\n end\n Watir.default_timeout = @envConfig['DefaultWaitTime'].to_s.to_i\n pageObject = PageObject.new\n @actionObjects = pageObject.initializePageObject(@browser, @pageObjects)\n end",
"def go()\n\t@selenium.open @url\n end",
"def goto(url)\r\n #set_defaults()\r\n get_window_number()\r\n set_browser_document()\r\n # Load the given url.\r\n $jssh_socket.send(\"#{BROWSER_VAR}.loadURI(\\\"#{url}\\\");\\n\" , 0)\r\n read_socket()\r\n\r\n wait()\r\n end",
"def browse url\n @@headless = Headless.new\n @@headless.start\n @@browser = Watir::Browser.start url\n end",
"def go_to(url)\n driver.get url\n end",
"def load_browser_tab(url:)\n @browser.execute_script('window.open()')\n @browser.windows.last.use\n @browser.goto(url)\n end",
"def open_browser(base_url = nil, options = {})\n base_url ||= $ITEST2_PROJECT_BASE_URL\n base_url ||= $BASE_URL\n raise \"base_url must be set\" if base_url.nil?\n\n default_options = {:speed => \"fast\",\n :visible => true,\n :highlight_colour => 'yellow',\n :close_others => true,\n :start_new => false, \t# start a new browser always\n :go => true}\n\n options = default_options.merge options\n options[:firefox] = true if \"Firefox\" == $ITEST2_BROWSER || \"Firefox\" == $BROWSER\n ($ITEST2_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false\n\n if base_url =~ /^file:/\n uri_base = base_url\n else\n uri = URI.parse(base_url)\n uri_base = \"#{uri.scheme}://#{uri.host}:#{uri.port}\"\n end\n\n if options[:start_new]\n @web_browser = WebBrowser.new(uri_base, nil, options)\n else\n @web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser\n end\n\n if base_url =~ /^file:/\n goto_url(base_url) # for files, no base url\n else\n (uri.path.length == 0) ? begin_at(\"/\") : begin_at(uri.path) if options[:go]\n end\n\n return @web_browser\n end",
"def open_new_page(url)\n $verbose ? puts(\"opening new page: #{url}\") : nil\n @driver.execute_script('window.open()')\n @driver.switch_to.window(@driver.window_handles.last)\n sleep(1)\n @driver.get(url)\n end",
"def setup_browser(url)\n browser = Watir::Browser.new :firefox, headless: true\n browser.goto url\n return browser\nend",
"def open_browser_with_search(url)\n Launchy.open(url)\nend",
"def goto_base_url\n @browser.goto base_url\n end",
"def initialize_browser\n if @browser\n @leave_open = true\n else\n @browser = Browser.create(config)\n end\n @browser.goto origin\n bring_to_front_if_appropriate\n @leave_open ||= config[:leave_open]\n end",
"def open_home_page\n open(configuration.browser_url)\n end",
"def visit_page(url)\n logger.info { \"visit #{url}\" }\n WebPage.new(url, web[url.to_s])\n end",
"def openURL(step)\n url = @step['Parameter1']\n @browser.goto(url)\n end",
"def goto(url = \"\")\n active_window.url = url\n sleep(1)\n end",
"def open_home_page\n selenium.open(context.browser_url)\n wait_for_page_to_load\n end",
"def visit_page \n visit URL \n end",
"def visit(url)\n begin\n @browser.goto url\n rescue Errno::ECONNREFUSED\n puts \"Webdriver reconnecting...\"\n @browser = Watir::Browser.new $driver.to_sym\n login\n @browser.goto url\n end\n end",
"def browse(url)\n if RUBY_PLATFORM =~ /darwin/\n `open #{url}`\n elsif RUBY_PLATFORM =~ /linux/\n `#{ENV['BROWSER']} #{url}`\n elsif ENV['OS'] == 'Windows_NT' or\n RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw|wince/i\n `start \"\" \"#{url}\"`\n end\n end",
"def open_page(name)\n name_link(name).click \n wait_for_ajax\n self.window(:title=>\"rSmart | Content Profile\").use\n ContentDetailsPage.new @browser\n end",
"def browser\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = BrowserFactory.build(session: session, url_options: url_options)\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"rv = #{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def open(url)\n driver.get(url)\n end",
"def open_page(name)\n name_link(name).click\n self.wait_for_ajax\n self.window(:title=>\"rSmart | Content Profile\").use\n ContentDetailsPage.new @browser\n end",
"def navigate_to(link)\n $driver.get link\nend",
"def browser(params, &proc)\n raise \"Session::browser requires a code block to be executed\" unless proc\n\n destination = create_destination(params)\n b = nil\n if params[:selector]\n b = create_browser(destination, params[:selector])\n else\n b = create_browser(destination)\n end\n\n if proc\n begin\n proc.call(b)\n ensure\n b.close\n b = nil\n end\n end\n b\n end",
"def visit_url(path)\n unless path.include? \"://\"\n path = @base_url.to_s + path\n end\n @selenium_driver.navigate.to(path)\n# @driver.switch_to_default_context\n end",
"def goto_page(path)\r\n @browser.navigate.to(site_url + path)\r\n end",
"def initialize(url = BASE_URL)\n @agent = Mechanize.new\n @current_page = @agent.get url\n end",
"def open_in_browser\n puts url\n `#{open} #{url}`\n end",
"def get_url(browser_handle)\n browser_handle.url\nend",
"def get(url)\n navigate.to(url)\n end",
"def goto(url)\n fname = getFunctionName()\n log fname + \" Starting. Going to url: #{url}\" if $debuglevel >=0\n @ie.navigate(url)\n sleep 2\n return waitForIE()\n end",
"def launch_browser(url)\n case RUBY_PLATFORM\n when /darwin/\n system \"open\", url\n when /mswin|mingw|cygwin/\n system \"start\", url\n else\n system \"xdg-open\", url\n end\n end",
"def goto_next_page(browser_handle)\n browser_handle.forward\nend",
"def visit_page(urlparameter)\n\n visit(urlparameter)\n\n end",
"def url=(url)\n driver.navigate.to(url)\n end",
"def navigate_to(link)\n\t $driver.get link\nend",
"def open_browser(base_url, options = {})\n default_options = {:resynchronize => false, :firefox => false } \n options = default_options.merge(options)\n options[:firefox] ||= (ENV['LOADWISE_PREVIEW'] || $LOADWISE_PREVIEW)\n RWebSpec::WebBrowser.new(base_url, nil, options)\n end",
"def go\n require 'pashua'\n pagetmp = wikipage_selector(\"Jump to which page?\")\n exit unless pagetmp\n @chrome.windows[1].get.tabs[@chrome.windows[1].get.active_tab_index.get].get.URL.set(\"http://localhost/wiki/#{pagetmp}\")\nend",
"def on page_class, visit=false, &block\n $current_page = page_class.new @browser, visit\n block.call $current_page if block\n $current_page\n end",
"def open_browser_by_watir(options = {})\r\n\r\n begin\r\n support_unicode\r\n rescue => e\r\n puts \"Unicode may not work in IE, #{e}\"\r\n end\r\n\r\n\t\t\tif options && options.class == String\r\n\t\t\t options = {:base_url => options.to_s }\r\n\t\t\tend\r\n\t\t\t \r\n\t\t\tif options && options.class == Hash && options[:base_url]\r\n \tbase_url ||= options[:base_url]\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tbase_url = options[:base_url] rescue nil \r\n\t\t\tbase_url ||= $TESTWISE_PROJECT_BASE_URL\t\t\t\r\n base_url ||= $BASE_URL\r\n \r\n raise \"base_url must be set\" if base_url.nil?\r\n\r\n default_options = {:speed => \"fast\",\r\n :visible => true,\r\n :highlight_colour => 'yellow',\r\n :close_others => true,\r\n :start_new => false, # start a new browser always\r\n :go => true}\r\n\r\n options = default_options.merge options\r\n ($TESTWISE_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false\r\n\r\n if base_url =~ /^file:/\r\n uri_base = base_url\r\n else\r\n uri = URI.parse(base_url)\r\n uri_base = \"#{uri.scheme}://#{uri.host}:#{uri.port}\"\r\n end\r\n\r\n if options[:start_new]\r\n @web_browser = WebBrowser.new(uri_base, nil, options)\r\n else\r\n @web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser\r\n end\r\n\r\n if base_url =~ /^file:/\r\n goto_url(base_url) # for files, no base url\r\n else\r\n (uri.path.length == 0) ? begin_at(\"/\") : begin_at(uri.path) if options[:go]\r\n end\r\n\r\n return @web_browser\r\n end",
"def page_for_url(url)\n @mechanize_instance.get(url)\n end",
"def navigateToAppRoot()\r\n @@driver.get(@@configuration['configuration']['url'])\r\n @@driver.manage().delete_all_cookies()\r\n $stderr.puts(\"It's open the browser and navigate to the url\")\r\n return HomePage.new(@@driver)\r\n end",
"def go(location)\n browser.location = location\n browser.response\n end",
"def initialize(params = {}, &block)\n @module_name = self.class.parent.to_s\n @class_name = self.class.to_s.split(\"::\").last\n define_site_pages\n define_flows\n config = Settings.config(@class_name).merge(params)\n browser_name = config[:browser] || 'chrome'\n browser_driver = config[:driver] || 'watir' \n browser_params = config[browser_name] || {}\n @browser = Browser.create(browser_name, browser_driver, browser_params)\n goto(config[:url]) if config[:url]\n execute_block_and_close_browser(browser, &block) if block_given?\n end",
"def go_to_url(base_url)\r\n\t\t\tputs \"Going to: #{base_url}\" \r\n\t\t\t@driver.get(base_url)\r\n\t\t\t@driver.manage.timeouts.implicit_wait = 10\r\n\t\tend",
"def crawler_page\n open(crawler_url)\n end",
"def visit\n Capybara.visit(@url)\n self\n end",
"def visit\n Capybara.visit(@url)\n self\n end",
"def url\n @browser.url\n end",
"def browser\n if @browser.nil?\n # puts '[BrowserOperator] Create Internet Explorer'\n @browser = Watir::Browser.new\n @browser.activate\n end\n @browser\n end",
"def begin_at(url)\r\n dump_caller_stack\r\n @web_browser.begin_at(url)\r\n end",
"def initialize browser\n @browser = browser\n end",
"def CreateBrowser()\r\n ret = @dispatch._invoke(1610743828, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def request_for_url\n driver.request_for_url\n end",
"def get_browser(scenario)\n if ENV['LOCAL']\n return get_local_browser(scenario)\n end\n get_zalenium_browser(scenario)\nend",
"def begin_at(url)\n dump_caller_stack\n @web_browser.begin_at(url)\n end",
"def uses_page page # only works with IE\n new_url = self.class.html_root + page\n browser.goto new_url unless browser.url == new_url\n end",
"def goto newPage\n unless friends[newPage.to_sym].nil?\n uri = friends[newPage.to_sym].uri\n end\n uri ||= newPage\n uri = @page.uri+uri unless uri.to_s =~ /^http/u\n @page = @agent.get uri\n @page\n end",
"def new_page(options={})\n close_page\n open_page(options)\n end",
"def setup_browser\n @browser = Browser.new(self)\n end",
"def url_home\n\tvisit url_visit\n end",
"def url\n @browser.url\n end",
"def browse(url)\n if RUBY_PLATFORM =~ /darwin/\n `open #{url}`\n elsif ENV['OS'] == 'Windows_NT' or\n RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw|wince/i\n `start \"\" \"#{url}\"`\n end\n end",
"def CreateBrowser()\r\n ret = _invoke(1610743828, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def load_page\n @mechanize_instance.get(@url)\n end",
"def open_url(url)\n url = url.is_a?(NSURL) ? url : NSURL.URLWithString(url)\n request = NSURLRequest.requestWithURL(url, cachePolicy: NSURLRequestUseProtocolCachePolicy, timeoutInterval: 20)\n web.loadRequest request\n end",
"def browser(*args)\n b = Runtime.instance.set_if(self, :browser) do\n # Add LL to the arguments for the browser\n LapisLazuli::Browser.set_world(self)\n\n # Create & return a new browser object\n brow = LapisLazuli::Browser.new(*args)\n\n metadata = Runtime.instance.get(:metadata)\n if metadata\n metadata.set(\n \"browser\",\n {\n \"name\" => brow.driver.capabilities[:browser_name],\n \"version\" => brow.driver.capabilities[:browser_version] || brow.driver.capabilities[:version],\n \"platform\" => brow.driver.capabilities[:platform_name] || brow.driver.capabilities[:platform],\n }\n )\n end\n\n sessionid = brow.driver.capabilities[\"webdriver.remote.sessionid\"]\n\n if !sessionid.nil?\n metadata.set(\"sessionid\", sessionid)\n end\n\n brow\n end\n\n if not b.is_open?\n b.start\n end\n\n return b\n end",
"def on(page_class, browser = @browser)\n page = page_class.new(browser)\n yield page if block_given?\n page\n end",
"def open\n @browser.goto @@site_url + \"/login.php\"\n\tWatir::Wait.until { self.loaded? LoginPage.title}\n self\n end",
"def load_page\n @page ||= @mechanize.get(url)\n end",
"def url\n @browser.current_url\n end",
"def browse(number)\n request = get_request_by_number(number)\n Launchy.open(request.html_url)\n end",
"def go_to_url(url)\n visit(\"https://#{url}\")\n end",
"def navigate_to_product_page(product_permalink)\r\n selenium.open selenium.get_location + \"/#{product_permalink}\"\r\n end",
"def test_url_generation\n page = new_page()\n assert_equal page.url, '/test'\n end",
"def visit(address, page = nil, &block)\n Browser::Session.new(address, page).perform(&block)\n end",
"def url_in_new_window\n if handles = page.driver.browser.window_handles rescue nil\n new_window = handles.last\n page.within_window(new_window) do\n return without_trailing_slash(current_url)\n end\n end\n end",
"def navigate_to_review_page(review_permalink)\r\n selenium.open selenium.get_location + \"/#{review_permalink}\"\r\n end",
"def initialize(url)\n @url = url\n # Create our mechanized instance\n @mechanize_instance = SharedMechanize.instance\n end",
"def load_page\n page.visit('')\n end",
"def open url\r\n command 'open', url_arg(url)\r\n end",
"def open url\r\n command 'open', url_arg(url)\r\n end",
"def CurrentPage\r\n\r\n puts \"I'm now on \" + $browser.url\r\n puts $newline\r\n\r\nend",
"def goto relative_url\n destination = File.join(@site.origin, relative_url) \n @browser.goto destination\n end",
"def goto_page(page)\r\n perform_operation {\r\n @web_browser.goto_page(page) if @web_browser\r\n }\r\n end"
] |
[
"0.7511774",
"0.7470131",
"0.73721313",
"0.734198",
"0.7321395",
"0.72917706",
"0.7285907",
"0.7269727",
"0.71324486",
"0.7122379",
"0.7053053",
"0.7036144",
"0.69951206",
"0.69078857",
"0.6897082",
"0.6839892",
"0.68358505",
"0.6785373",
"0.6753554",
"0.6702242",
"0.667388",
"0.664867",
"0.6617297",
"0.6615431",
"0.65898204",
"0.6570148",
"0.65307516",
"0.65197986",
"0.6519766",
"0.6510139",
"0.6472088",
"0.6433892",
"0.6416214",
"0.6402227",
"0.6397577",
"0.6387118",
"0.63799566",
"0.6376467",
"0.63473725",
"0.6325788",
"0.6315677",
"0.63069224",
"0.6305742",
"0.6278986",
"0.62722343",
"0.62657446",
"0.6251173",
"0.6248674",
"0.6239914",
"0.619267",
"0.6171919",
"0.61469114",
"0.61452156",
"0.6090429",
"0.60840696",
"0.6080537",
"0.6052117",
"0.60140306",
"0.60100925",
"0.59923387",
"0.5972135",
"0.59570706",
"0.59570706",
"0.5956117",
"0.59291726",
"0.59118533",
"0.5910802",
"0.58882356",
"0.588527",
"0.58840007",
"0.58819234",
"0.5877249",
"0.58746547",
"0.5843543",
"0.58415747",
"0.58363044",
"0.5819758",
"0.5818798",
"0.5812978",
"0.58029276",
"0.5801914",
"0.57992303",
"0.57855093",
"0.5783419",
"0.5773372",
"0.57724375",
"0.57666004",
"0.57620317",
"0.57562137",
"0.5747911",
"0.5727285",
"0.57241935",
"0.5720408",
"0.5719425",
"0.57062083",
"0.57045245",
"0.57045245",
"0.57037437",
"0.5701994",
"0.57006574"
] |
0.6266028
|
45
|
Function for navigating to passed URL and creating browser instance. def navigateTo(browser_instance,url) $browser = Watir::Browser.new browser_instance $browser.cookies.clear $browser.goto(url) end Function for closing all the opened browser instances.
|
def close_multiple_browsers(browser_instance)
# if browser_instance == "ie"
# Sys::ProcTable.ps.each{|ps|
# if ps.name.downcase==browser_instance+"xplore.exe"
# Process.kill('KILL',ps.pid)
# end}
# end
# if browser_instance != "ie"
$browser.close
# end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def go_to(url)\n @browser.navigate.to url\n end",
"def goto_page(browser_handle, url)\n browser_handle.goto(url)\nend",
"def navigateTo(browser_instance,url)\n Capybara.default_driver = :selenium\n\n \n Capybara.register_driver :selenium do |app|\n Capybara::Selenium::Driver.new(app, :browser => :chrome)\n end\n# $worldMap = Hash.new\n $session = Capybara::Session.new(:selenium)\n $session.visit 'https://staging-bbva.everfiapps-dev.net/cportal/ccdee586/login'\n end",
"def go_to_url (url)\n\t\t@browser.goto (url)\n\tend",
"def openBrowser(step)\n browserName = @envConfig['Browser']\n browserDriver = \"#{$ROOT}/../webDriver/#{browserName}driver.exe\"\n case browserName\n when 'chrome'\n Selenium::WebDriver::Chrome.driver_path = browserDriver\n # @browser = Watir::Browser.new(:chrome, :switches => %w[--start-maximized])\n @browser = Watir::Browser.new(:chrome)\n when 'firefox'\n Selenium::WebDriver::Firefox.driver_path = browserDriver\n # @browser = Watir::Browser.new(:firefox, :switches => %w[--start-maximized])\n @browser = Watir::Browser.new(:firefox)\n end\n Watir.default_timeout = @envConfig['DefaultWaitTime'].to_s.to_i\n pageObject = PageObject.new\n @actionObjects = pageObject.initializePageObject(@browser, @pageObjects)\n end",
"def go_to(url)\n @browser.goto(url)\n end",
"def go()\n\t@selenium.open @url\n end",
"def goto_url(url)\r\n @browser.navigate.to url\r\n end",
"def go_to_page(url)\n Logbook.step(\"Open start page #{url} :)\")\n @browser.get url\n sleep 2\n\n @browser\n end",
"def goto_next_page(browser_handle)\n browser_handle.forward\nend",
"def setup_browser(url)\n browser = Watir::Browser.new :firefox, headless: true\n browser.goto url\n return browser\nend",
"def visit\n @browser.goto(URL)\n end",
"def closeBrowser(step)\n @browser.quit\n end",
"def navigate_to(url)\n self.visit url\n end",
"def close_browser\n @browser.close # Same for watir-webdriver and selenium-webdriver.\n end",
"def quit\n @browser.close\n end",
"def visit(url)\n begin\n @browser.goto url\n rescue Errno::ECONNREFUSED\n puts \"Webdriver reconnecting...\"\n @browser = Watir::Browser.new $driver.to_sym\n login\n @browser.goto url\n end\n end",
"def navigate_to(url)\n self.visit url\n end",
"def move_between_tabs\n window = page.driver.browser.window_handles\n\n if window.size > 1\n page.driver.browser.switch_to.window(window.last)\n page.driver.browser.close\n page.driver.browser.switch_to.window(window.first)\n end\n\n # example of moving between tabs in browser\n\n # open_new_window :tab\n # tab = page.driver.browser.window_handles\n # page.driver.browser.switch_to.window(tab.last)\n # visit href\n # style_code = page.driver.browser.page_source\n # page.driver.browser.close\n # page.driver.browser.switch_to.window(tab.first)\nend",
"def close_browser\n\t\t@browser.close\n\tend",
"def goto(url)\r\n #set_defaults()\r\n get_window_number()\r\n set_browser_document()\r\n # Load the given url.\r\n $jssh_socket.send(\"#{BROWSER_VAR}.loadURI(\\\"#{url}\\\");\\n\" , 0)\r\n read_socket()\r\n\r\n wait()\r\n end",
"def close_browser b\n begin\n Moose.msg.info(\"Closing Watir browser!\")\n b.close\n rescue => e\n Moose.msg.error(\"Unable to close browser using Watir browser.close! - #{e.message}\")\n begin\n b.quit\n rescue Errno::ESRCH => e\n Moose.msg.error(\"Unable to kill browser using Process.kill!\")\n else\n Moose.msg.info(\"Killed browser!\")\n end\n else\n Moose.msg.info(\"Closed browser!\")\n end\n end",
"def close_browser\r\n @browser.quit\r\n sleep 1\r\n end",
"def open_browser (ele)\n\n but_ref=$array2[\"#{ele}\"]\n if but_ref == \"firefox\"\n $log.info \"Firefox browser is going to open\"\n $browser = Watir::Browser.new :firefox\n elsif but_ref== \"ie\"\n $log.info \"Internet browser is going to open\"\n $browser = Watir::Browser.new :ie\n elsif but_ref == \"chrome\"\n $log.info \"Chrome browser is going to open\"\n profile = Selenium::WebDriver::Chrome::Profile.new\n profile['download.prompt_for_download'] = false\n profile['download.default_directory'] = \"D:\\\\CCL -naz\\\\configuration\"\n $browser = Watir::Browser.new :chrome, :profile => profile\n\telse\n\tfail_screenshot\n\t $log.info \"failed to open the #{ele} browser\"\n raise(\"failed to open the #{ele} browser\") \n end\n $browser.window.resize_to(1616,876)\nend",
"def ensure_only_one_browser_window_open\n $tracer.trace(\"PowerUpRewardsDSL : #{__method__}, Line : #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n if(browser_count > 1)\n for i in (browser_count - 1) .. 1\n browser(i).close\n end\n end\n\n browser(0)\n end",
"def open_browser_by_watir(options = {})\r\n\r\n begin\r\n support_unicode\r\n rescue => e\r\n puts \"Unicode may not work in IE, #{e}\"\r\n end\r\n\r\n\t\t\tif options && options.class == String\r\n\t\t\t options = {:base_url => options.to_s }\r\n\t\t\tend\r\n\t\t\t \r\n\t\t\tif options && options.class == Hash && options[:base_url]\r\n \tbase_url ||= options[:base_url]\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tbase_url = options[:base_url] rescue nil \r\n\t\t\tbase_url ||= $TESTWISE_PROJECT_BASE_URL\t\t\t\r\n base_url ||= $BASE_URL\r\n \r\n raise \"base_url must be set\" if base_url.nil?\r\n\r\n default_options = {:speed => \"fast\",\r\n :visible => true,\r\n :highlight_colour => 'yellow',\r\n :close_others => true,\r\n :start_new => false, # start a new browser always\r\n :go => true}\r\n\r\n options = default_options.merge options\r\n ($TESTWISE_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false\r\n\r\n if base_url =~ /^file:/\r\n uri_base = base_url\r\n else\r\n uri = URI.parse(base_url)\r\n uri_base = \"#{uri.scheme}://#{uri.host}:#{uri.port}\"\r\n end\r\n\r\n if options[:start_new]\r\n @web_browser = WebBrowser.new(uri_base, nil, options)\r\n else\r\n @web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser\r\n end\r\n\r\n if base_url =~ /^file:/\r\n goto_url(base_url) # for files, no base url\r\n else\r\n (uri.path.length == 0) ? begin_at(\"/\") : begin_at(uri.path) if options[:go]\r\n end\r\n\r\n return @web_browser\r\n end",
"def quitbrowser\n @browser.quit\n end",
"def close_browser\r\n if @web_browser\r\n # Old TestWise version\r\n # @web_browser.close_browser unless $TESTWISE_LEAVE_BROWSER_OPEN_AFTER_RUN\r\n @web_browser.close_browser\r\n else\r\n\t\t\t\tclose_all_browsers\r\n end\r\n end",
"def close_new_window\n $driver.close\nend",
"def close_browser\n $LOG.info \"Inside close browser method\"\n begin\n $driver.quit\n rescue Exception => e\n $LOG.error \"Error in quiting browser and ending session\" + e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Error in quiting browser and ending session \\n Error Message ::\" + e.message\n end\n end",
"def navigate_to(link)\n $driver.get link\nend",
"def switch_next_window\n cur_window = browser.window_handle\n browser.close\n browser.window_handles.each do |window|\n next if window.eql?(cur_window)\n\n browser.switch_to.window(window)\n break\n end\n end",
"def go_to(url)\n driver.get url\n end",
"def load_browser_tab(url:)\n @browser.execute_script('window.open()')\n @browser.windows.last.use\n @browser.goto(url)\n end",
"def stopBrowser()\n\t\n\t#@browser.close_current_browser_session()\n\t@browser.stop\n\t\nend",
"def goto_url(url)\r\n @web_browser.goto_url url\r\n end",
"def goto_url(url)\n @web_browser.goto_url url\n end",
"def open(url = @url)\n @browser.goto(url)\n wait_for_page_to_load\n end",
"def close_other_windows\n cur_window = browser.window_handle\n browser.window_handles.each do |window|\n next if window.eql?(cur_window)\n\n browser.switch_to.window(window)\n browser.close\n end\n browser.switch_to.window(cur_window)\n end",
"def goto(url = \"\")\n active_window.url = url\n sleep(1)\n end",
"def start_browser(url, browser = 'firefox')\n self.open_browser browser\n @browser.goto url\n return @browser\n end",
"def reset_browser\n # clear cookies\n Testing.browser.cookies.clear\n\n # open homepage\n unless Testing.browser.url == \"#{Testing.base_url}/\"\n Testing.browser.goto(Testing.base_url)\n end\n\n Testing.browser\n end",
"def ensure_only_one_browser_window_open\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n if (browser_count > 1)\n for i in (browser_count - 1) .. 1\n browser(i).close\n end\n end\n\n browser(0)\n end",
"def open_new_page(url)\n $verbose ? puts(\"opening new page: #{url}\") : nil\n @driver.execute_script('window.open()')\n @driver.switch_to.window(@driver.window_handles.last)\n sleep(1)\n @driver.get(url)\n end",
"def switch_to_new_window\n $previous_window = $driver.window_handle\n $driver.switch_to.window($driver.window_handles.last)\nend",
"def close_attached_browser(browser_handle)\n close_browser(browser_handle)\nend",
"def Close\r\n\r\n # Close browser\r\n $browser.close\r\n $headless.destroy\r\n\r\nend",
"def browser\n if @browser.nil?\n # puts '[BrowserOperator] Create Internet Explorer'\n @browser = Watir::Browser.new\n @browser.activate\n end\n @browser\n end",
"def navigateToAppRoot()\r\n @@driver.get(@@configuration['configuration']['url'])\r\n @@driver.manage().delete_all_cookies()\r\n $stderr.puts(\"It's open the browser and navigate to the url\")\r\n return HomePage.new(@@driver)\r\n end",
"def quit_browser\n @browser.quit\n end",
"def goto_base_url\n @browser.goto base_url\n end",
"def stopBrowser()\n\t\n\t$browser.stop\n\t\nend",
"def stopBrowser()\n\t\n\t$browser.stop\n\t\nend",
"def stopBrowser()\n\t\n\t$browser.stop\n\t\nend",
"def initialize_browser\n if @browser\n @leave_open = true\n else\n @browser = Browser.create(config)\n end\n @browser.goto origin\n bring_to_front_if_appropriate\n @leave_open ||= config[:leave_open]\n end",
"def navigate_to(link)\n\t $driver.get link\nend",
"def close_browser\n Logbook.step('Stop webdriver. The End of a test:)')\n @browser.quit\n Logbook.publish_results\n end",
"def close_browser\n if @web_browser\n # Old iTest2 version\n # @web_browser.close_browser unless $ITEST2_LEAVE_BROWSER_OPEN_AFTER_RUN\n @web_browser.close_browser\n else\n WebBrowser.close_all_browsers\n end\n end",
"def open_browser(base_url = nil, options = {})\n base_url ||= $ITEST2_PROJECT_BASE_URL\n base_url ||= $BASE_URL\n raise \"base_url must be set\" if base_url.nil?\n\n default_options = {:speed => \"fast\",\n :visible => true,\n :highlight_colour => 'yellow',\n :close_others => true,\n :start_new => false, \t# start a new browser always\n :go => true}\n\n options = default_options.merge options\n options[:firefox] = true if \"Firefox\" == $ITEST2_BROWSER || \"Firefox\" == $BROWSER\n ($ITEST2_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false\n\n if base_url =~ /^file:/\n uri_base = base_url\n else\n uri = URI.parse(base_url)\n uri_base = \"#{uri.scheme}://#{uri.host}:#{uri.port}\"\n end\n\n if options[:start_new]\n @web_browser = WebBrowser.new(uri_base, nil, options)\n else\n @web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser\n end\n\n if base_url =~ /^file:/\n goto_url(base_url) # for files, no base url\n else\n (uri.path.length == 0) ? begin_at(\"/\") : begin_at(uri.path) if options[:go]\n end\n\n return @web_browser\n end",
"def browser(params, &proc)\n raise \"Session::browser requires a code block to be executed\" unless proc\n\n destination = create_destination(params)\n b = nil\n if params[:selector]\n b = create_browser(destination, params[:selector])\n else\n b = create_browser(destination)\n end\n\n if proc\n begin\n proc.call(b)\n ensure\n b.close\n b = nil\n end\n end\n b\n end",
"def goto_previous_page(browser_handle)\n browser_handle.back\nend",
"def get_browser\n client = Selenium::WebDriver::Remote::Http::Default.new\n client.open_timeout = TIMEOUT # seconds – default is 30\n browser = Watir::Browser.new DRIVER.to_sym, :http_client => client\n return browser\nend",
"def goto_page(path)\r\n @browser.navigate.to(site_url + path)\r\n end",
"def open_home_page\n selenium.open(context.browser_url)\n wait_for_page_to_load\n end",
"def clean_up\n @browser.close if @browser && @browser.exists?\n quit \"Later, noobs\"\n end",
"def goto(url)\n fname = getFunctionName()\n log fname + \" Starting. Going to url: #{url}\" if $debuglevel >=0\n @ie.navigate(url)\n sleep 2\n return waitForIE()\n end",
"def initialize_browser\n puts \"\\n>Initializing Firefox browser\"\n @browser = Watir::Browser.new :firefox\n @browser.send_keys :f11\n @homepage = Homepage.new(@browser)\n return @homepage\nend",
"def open\n @browser.goto @@site_url + \"/login.php\"\n\tWatir::Wait.until { self.loaded? LoginPage.title}\n self\n end",
"def refresh\n url=$driver.current_url\n $driver.navigate.to 'http://www.google.com/'\n quiesce\n $driver.navigate.to url\n quiesce\n $driver.current_url.should == url\n end",
"def go\n require 'pashua'\n pagetmp = wikipage_selector(\"Jump to which page?\")\n exit unless pagetmp\n @chrome.windows[1].get.tabs[@chrome.windows[1].get.active_tab_index.get].get.URL.set(\"http://localhost/wiki/#{pagetmp}\")\nend",
"def cookies_from_selenium\n driver = Selenium::WebDriver.for :firefox\n driver.navigate.to \"https://min.e-boks.dk/logon.aspx?logontype=oces\"\n\n loop do\n break if driver.title =~ %r(^e-Boks )\n sleep 1\n end\n\n cookies = driver.manage.all_cookies\n driver.quit\n cookies\nend",
"def createBorwser(url,browser)\n begin\n driver=Watir::Browser.new browser.to_sym \n driver.goto url\n timer(driver) { |driver|\n if driver.input(:id=>$elementIdTextBox).present?\n driver.input(:id=>$elementIdTextBox).send_keys(\"watir webdriver\")\n driver.input(:id=>$elementIdTextBox).send_keys :enter\n Watir::Wait.until(timeout:10) { driver.element(:id=>/#{$elementIdResultMain}/).element(:visible_text=>/#{$elementIdResult}/).present? }\n end\n }\n rescue Exception => e\n puts e.to_s.red\n ensure\n driver.close\n end\n \nend",
"def go_to_url(base_url)\r\n\t\t\tputs \"Going to: #{base_url}\" \r\n\t\t\t@driver.get(base_url)\r\n\t\t\t@driver.manage.timeouts.implicit_wait = 10\r\n\t\tend",
"def click\n\tbegin\n\t @selenium.click(@locator)\n\trescue => e\n\t sleep(3)\n\t @selenium.click(@locator)\n\tend\n\n\tbegin\n\t @selenium.wait_for_page_to_load\n\trescue => e\n\t sleep(2)\n\t @selenium.wait_for_condition(\"selenium.browserbot.getCurrentWindow()\", TIMEOUT)\n\tend\n\t\n end",
"def teardown\n @browser.close\n end",
"def close_page\n Logbook.message('Closing browser page >>')\n\n if @browser.nil?\n Logbook.error('Page is already closed')\n else\n @browser.close\n Logbook.message('Done! Page closed')\n end\n end",
"def teardown\n $browser.close\nend",
"def move_last_tab\n window = page.driver.browser.window_handles\n\n if window.size > 1\n page.driver.browser.switch_to.window(window.first)\n page.driver.browser.close\n page.driver.browser.switch_to.window(window.last)\n end\nend",
"def muda_aba\n window = page.driver.browser.window_handles\n if window.size > 1 \n page.driver.browser.switch_to.window(window.first)\n page.driver.browser.close\n page.driver.browser.switch_to.window(window.last) \n end\n end",
"def visit_url(path)\n unless path.include? \"://\"\n path = @base_url.to_s + path\n end\n @selenium_driver.navigate.to(path)\n# @driver.switch_to_default_context\n end",
"def forward\n $LOG.info \"Browser navigating forward method\"\n begin\n $driver.navigate.forward\n rescue Exception => e\n $LOG.error \"Browser navigating forward error \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Browser navigating forward error \\n Error Message :: \"+e.message\n end\n end",
"def close_window(close_loc = :current, active_loc = nil)\n if @browser.windows.count == 1\n # doesn't matter what they enter, bc closing the only window of a browser\n # instance causes the browser to crash\n @browser.close\n end\n\n\n if close_loc == :current\n # if the current window is being closed, we have to move to another before closing it\n if active_loc.nil?\n # if new active window is unspecified, make the previous window the new active one\n self.switch_to_previous_window\n else\n self.switch_to_window(active_loc)\n end\n else\n # a specific window to be closed has been specified (though it may still be the active one)\n if close_loc[0..3] == 'url=' or close_loc[0..5] == 'title='\n if @browser.window(parse_location(close_loc)).current?\n # if the current window is being closed, we have to move to another before closing it\n if active_loc.nil?\n # if new active window is unspecified, make the previous window the new active one\n self.switch_to_previous_window\n else\n self.switch_to_window(active_loc)\n end\n end\n @browser.window(parse_location(close_loc)).close\n else\n # assume close_loc is an integer\n # since Robot Framework sends all args as text, the above check for\n # \"url=\" and \"title=\" is the best we can do to ensure argument correctness\n close_loc = close_loc.to_i\n # the number of the window\n # user-facing numbers are 1-based, internal we use 0-based because @browser.windows\n # is a Ruby array, so minus 1\n window_id = close_loc - 1\n if window_id == -1\n # either the user has been too smart for his/her own good and thinks the windows are 0-based,\n # or they've entered text that doesn't match 'url=' or 'title=', in which case\n # the above loc.to_i will make loc equal 0\n raise(ArgumentError, \"You must provide the url or title of the window in the format 'url=' or 'title=', or you must provide the number of the window, starting with 1 for the first window opened.\")\n end\n \n if @browser.windows[window_id].current?\n # if the current window is being closed, we have to move to another before closing it\n if active_loc.nil?\n # if new active window is unspecified, make the previous window the new active one\n self.switch_to_previous_window\n else\n self.switch_to_window(active_loc)\n end\n end\n # this will throw its own error if the index is out of range\n @browser.windows[window_id].close\n end\n end\n end",
"def switch_to_main_window\n $previous_window = $driver.window_handle\n $driver.switch_to.window($driver.window_handles.first)\nend",
"def test_24_stopbrowser()\n\t\t\n\t\t$workBook.Save\n\t\t$workBook.Close\n\t\t$excel.Quit\n\t\tstopBrowser()\n\t\t\n\tend",
"def switch_to_previous_window\n $driver.switch_to.window $previous_window\nend",
"def SwitchTab\n page.driver.browser.switch_to.window (page.driver.browser.window_handles.last)\n end",
"def switch_to_new_window(window)\t\r\n\t\t\t# Switch to new window\r\n\t\t\t#new_window = @driver.window_handles.last\r\n\t\t\t@driver.switch_to.window(window)\r\n\t\tend",
"def browse url\n @@headless = Headless.new\n @@headless.start\n @@browser = Watir::Browser.start url\n end",
"def close_browsers_and_delete_cookies\n $tracer.trace(\"PowerUpRewardsDSL : #{__method__}, Line : #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n close_all\n m = $options.silent_mode\n $options.silent_mode = true\n if (os_name == \"mswin32\")\n ie\n mozilla\n elsif (os_name == \"darwin\")\n safari\n end\n for i in 0..(browser_count - 1)\n browser(i).cookie.all.delete\n end\n close_all\n $options.silent_mode = m\n end",
"def logout\n\n\t$browser.click \"link=Log out\"\n\tputs \"Logout Successfully!!\"\n\t$browser.wait_for_page_to_load\n\t# Stop the browser session.\n\t$browser.close_current_browser_session\n\n end",
"def url_in_new_window\n if handles = page.driver.browser.window_handles rescue nil\n new_window = handles.last\n page.within_window(new_window) do\n return without_trailing_slash(current_url)\n end\n end\n end",
"def close_all_browsers\r\n\t\t\t@web_browser.close_all_browsers\r\n end",
"def on page_class, visit=false, &block\n $current_page = page_class.new @browser, visit\n block.call $current_page if block\n $current_page\n end",
"def forward\n driver.navigate.forward\n end",
"def forward\n driver.navigate.forward\n end",
"def browser\n return @browser if @browser\n\n @appium_driver = Appium::Driver.new @options, false\n # browser is the standard selenium driver without any appium methods\n @browser = @appium_driver.start_driver\n\n main = Process.pid\n at_exit do\n # Store the exit status of the test run since it goes away after calling the at_exit proc...\n @exit_status = $ERROR_INFO.status if $ERROR_INFO.is_a?(SystemExit)\n quit if Process.pid == main\n exit @exit_status if @exit_status # Force exit with stored status\n end\n @browser\n end",
"def open_home_page\n open(configuration.browser_url)\n end",
"def XOclose\n\t\tsleep TIMETICK\n\n\t\tbegin\n\t\t\t@wwBrws.close\n\t\trescue\n#\t\t\t::Process.kill('KILL', browser_pid)\n\t\tend\n\t\t$alog.lwrite('Browser closed!', 'DEBG')\n\t\treturn retControl(OK)\n\tend",
"def browser\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = BrowserFactory.build(session: session, url_options: url_options)\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"rv = #{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end",
"def abrirNavegador()\n\tbrowser = Watir::Browser.new :firefox\n\n\tbrowser\nend"
] |
[
"0.6979972",
"0.6943354",
"0.68233675",
"0.6781023",
"0.67809355",
"0.6634658",
"0.65798134",
"0.65744716",
"0.6571664",
"0.64872974",
"0.6408356",
"0.63914335",
"0.6351872",
"0.63504416",
"0.63236266",
"0.63182306",
"0.6294872",
"0.6257424",
"0.6248659",
"0.6220599",
"0.62162805",
"0.62069154",
"0.61897016",
"0.6171043",
"0.6168151",
"0.61556876",
"0.61528933",
"0.6149637",
"0.6135029",
"0.61099124",
"0.6100974",
"0.60703856",
"0.6059595",
"0.60513073",
"0.60454303",
"0.6038692",
"0.6031026",
"0.60245484",
"0.6016113",
"0.5999783",
"0.59901947",
"0.59680986",
"0.59567904",
"0.595609",
"0.59514487",
"0.5941758",
"0.5938333",
"0.5928513",
"0.5907165",
"0.59019405",
"0.5896202",
"0.58892995",
"0.58892995",
"0.58892995",
"0.58705115",
"0.58456534",
"0.5843292",
"0.58162326",
"0.5807495",
"0.58047396",
"0.5801916",
"0.5789077",
"0.57888997",
"0.5780322",
"0.57723117",
"0.5771518",
"0.57692283",
"0.5766308",
"0.57467085",
"0.57354903",
"0.57243687",
"0.56793296",
"0.56717706",
"0.5669423",
"0.56620365",
"0.5657273",
"0.56401706",
"0.5634618",
"0.5629216",
"0.56202793",
"0.56186855",
"0.5616732",
"0.5615967",
"0.5608357",
"0.5599539",
"0.5584473",
"0.55842423",
"0.55815977",
"0.5575375",
"0.55647045",
"0.5537428",
"0.5531756",
"0.5530296",
"0.5526824",
"0.5526824",
"0.552448",
"0.55230105",
"0.5519435",
"0.55131334",
"0.55096525"
] |
0.6636261
|
5
|
After the depthfirst search is done we can find any vertice connected to "node" in constant time [O(1)] and find a path to this node in linear time [O(n)].
|
def path_to(node)
return unless has_path_to?(node)
path = []
current_node = node
while(current_node != @source_node) do
path.unshift(current_node)
current_node = @edge_to[current_node]
end
path.unshift(@source_node)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def depth_first_search(node)\n return if node.nil?\n node.visit\n node.connections.each do |conn|\n depth_first_search(conn) unless conn.visited\n end\nend",
"def path_to(node)\n return unless @visited.include?(node)\n path = []\n while(node != @node) do\n path.unshift(node) \n node = @edge_to[node]\n end\n path.unshift(@node)\n end",
"def paths_to(node)\n find_paths do\n find { |n| n == node }\n end\n end",
"def dfs_traversal(source_vertex)\n\n @visited[source_vertex] = true;\n\n @adjacent_list[source_vertex].each do |i|\n dfs_traversal(i) if !@visited[i]\n end\n\n end",
"def route?(graph, node)\n graph.depth_first_search(graph.starting_vertex, node)\nend",
"def find_path\n current_node = @cells_visited.last\n while current_node.parent != nil do\n @solved_path << current_node.cell\n current_node = current_node.parent\n end\n @solved_path << current_node.cell\n end",
"def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n\t# record node path {node => previous_node}\n\tnodes_path = {start_node => nil} \n\t\n\twhile !open_nodes.empty?\n # node = choose_node(reachable)\n\t\tnode = open_nodes.sample # random node in open_nodes\n\t\t\n\t\treturn build_path(goal_node, nodes_path) if node==goal_node # STOP if reached goal! \n \n # Don't repeat ourselves.\n reachable.delete(node) # remove current node from reachable\n explored.push(node) # add node to explored\n \n # What nodes are now open from this node?\n # Adjacent, not in explored, and valid (not an obstacle and in maze)\n new_reachable = (get_adjacent_nodes(node) - explored) & valid\n\t\t# ADD new nodes to reachable\n new_reachable.each do |adj_node|\n if !reachable.include?(adj_node)\n # adjacent.previous = node # Remember how we got there.\n nodes_path[adj_node] = node # {[0,3] => [0,2]}\n reachable << adj_node\n end\n end\n \n\t\t# REFRESH OPEN NODES\n open_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n \n end\n \n\treturn nil # open_nodes empty - no path found\nend",
"def shortest_path_to(node)\n return nil if @previous_nodes[node].nil?\n\n nodes = [node]\n while previous_node = @previous_nodes[nodes[0]] do\n nodes.unshift(previous_node)\n end\n\n nodes\n end",
"def seek_from_node(starting_node)\n puts \"seek started from node #{starting_node.inspect}...\"\n \n # -- PART I -- (starting from one node for now...) \n visited_nodes = grow_basic_path([ starting_node ])\n \n puts \"got basic path of length #{visited_nodes.length}, moving on to IIa)...\"\n \n # -- PART II a) --\n if visited_nodes.length < nodes.length\n target_nodes = extract_target_nodes_from_path(visited_nodes)\n \n while target_nodes.length > 0\n puts \"TNL: #{target_nodes.length}\"\n visited_nodes = restructure_path(visited_nodes, target_nodes)\n target_nodes = extract_target_nodes_from_path(visited_nodes)\n end\n end\n \n puts \"...done, moving on to IIb)...\"\n \n # -- PART II b) --\n if visited_nodes.length < nodes.length\n visited_nodes = trim_and_extend_path(visited_nodes)\n end\n \n puts \"...done, moving on to IIc)...\"\n \n # -- PART II c) --\n if visited_nodes.length < nodes.length\n visited_nodes = trim_and_extend_path(visited_nodes.reverse)\n end\n \n # -- PART III --\n results = {}\n \n if visited_nodes.length < nodes.length \n results[:path] = visited_nodes\n else\n results[:tour] = visited_nodes\n \n cycle_starts = connected_to(visited_nodes.first).map do |node|\n visited_nodes[visited_nodes.index(node) - 1]\n end\n cycle_ends = connected_to(visited_nodes.last)\n \n (cycle_starts & cycle_ends).each do |node|\n index = visited_nodes.index(node)\n \n circuit = visited_nodes[0..index] + [ visited_nodes.last ]\n circuit += visited_nodes[(index + 1 - visited_nodes.length)..-2].reverse\n \n results[:cycles] ||= []\n results[:cycles] << circuit\n end\n end\n \n results\n end",
"def find_neighbors(node)\n nbrs = []\n self.edges.each do |e|\n nbrs.push(e.target) if e.source == node\n nbrs.push(e.source) if e.target == node\n end\n nbrs\n end",
"def find_path(start, target)\n node = build_path(start, target)\n path = [node]\n until node.next_node.nil? do\n node = node.next_node\n path.push(node)\n end\n path = path.reverse\n puts \"You made it in #{path.length} moves. Here is your path: \"\n path.each do |node|\n puts \"[#{node.x}], [#{node.y}]\"\n end\nend",
"def dfs\n visited = {}\n vertexes.keys.each {|v| visited[v] = false}\n unvisited = find_first_unvisited visited\n search_results = []\n until unvisited.is_nothing?\n #find a depth first search tree and hash containing the order that each node is visited\n dpst = explore(unvisited.from_just)\n if dpst.is_nothing?\n return Nothing.new\n else\n dpst = dpst.from_just\n end\n if search_results.empty?\n search_results.push dpst\n else\n search_results.each_with_index do |result, i|\n tree = dpst[:tree]\n found = false\n result.each do |v|\n if tree[v] and result.length < tree.keys.length\n results[i] = dpst\n found = true\n break\n end\n end\n break if found\n end\n end\n # Mark each point in the path as visited\n dpst[:visit_order].each do |k|\n visited[k] = true\n end\n unvisited = find_first_unvisited visited\n end\n search_results\n end",
"def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend",
"def find_paths(current_node, target_node, current_path=[])\n \tcurrent_path.push(current_node)\n \tif current_node == target_node\n \t\t@found_paths.push(current_path.dup)\n \telse\n \t\t@adjacency_list[current_node].each do |child|\n \t\t\tfind_paths(child, target_node, current_path)\n \t\tend\n \tend\n \tcurrent_path.pop\n end",
"def dfs(start_node)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend",
"def path_finder \n until queue.empty? \n current_node = queue.shift()\n generate_neighbours(current_node)\n current_node.neighbour_nodes.each do |neighbour|\n track_visited(current_node, neighbour)\n correct_node?(neighbour) ? (return neighbour.visited) : (queue << neighbour)\n end\n end\n end",
"def depth_first_search!(node)\n node.marked = true\n node.type = \"M\"\n node.adj.each do |n|\n if n.marked == false\n depth_first_search(n)\n end\n end\n end",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def build_path(start, end_pos)\n node = Node.new(start[0], start[1])\n target = Node.new(end_pos[0], end_pos[1])\n visited_nodes = []\n next_moves = [node]\n until next_moves.empty? do\n node = next_moves.shift\n puts \"Current node: #{node.x}, #{node.y}\"\n if node.x == target.x && node.y == target.y \n return node\n end\n visited_nodes.push(node)\n node.moves = get_moves(node)\n node.moves.reject do |square|\n visited_nodes.include?(square)\n end\n node.moves.each do |move| \n next_moves.push(move)\n end\n end\n return node\nend",
"def find_shortest_path(rolling_node)\n\n @backtrack = []\n @backtrack << @goal_node\n\n # iterate until we arrive at the start node\n while rolling_node[:prev] != nil do\n temp_node = @node_list.find { |hash| hash[:id] == rolling_node[:prev] }\n @backtrack << temp_node[:id]\n rolling_node = temp_node\n end\n\n # create a table with the 1d and the 2d array node values\n @shortest_path = []\n\n @backtrack.each do |p|\n @shortest_path << [p, @table_convert[p]]\n @shortest_path_coords << @table_convert[p][1]\n end\n end",
"def depth_first_traversal(vertex)\n return if @visited_verts.include? vertex\n\n @visited_verts << vertex\n\n if VERT_MAP.has_key? vertex\n VERT_MAP[vertex].each do |dest_vertex|\n depth_first_traversal(dest_vertex)\n end\n end\n\n @sorted_verts << vertex\n end",
"def dfs_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if dfs_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def visit(node, target, visited = [], path = [node.data])\n # Terminal states:\n if node.data == target\n # 1. If node.data is equal to target return the path\n return path\n else\n # If the node hasn't been visited then\n if !visited.include? node\n # Push the node in visited (so it wont be visited again)\n visited.push(node)\n # Traverse through each node in the node's connections\n node.connections.each do |connection|\n # Push to path the corresponding data\n path.push(connection.data)\n # Return a recursive call to the method with this particular connection as 1st argument\n # target as 2nd and then current versions of visited and path as 3rd an fourth args\n return visit(connection, target, visited, path)\n end\n end\n end\nend",
"def extract_target_nodes_from_path(visited_nodes)\n connected_to(visited_nodes.last).select do |node|\n i = visited_nodes.index(node) \n i && (unvisited_neighbours_of(visited_nodes[i + 1], visited_nodes).length > 0)\n end\n end",
"def path_to(v)\n return nil unless @visited.include?(v)\n\n path = []\n cur_node = v\n while (cur_node != source_node)\n path << cur_node\n cur_node = @edge_to[cur_node]\n end\n path << source_node\n path.reverse\n end",
"def search(node)\n longest_path = 0\n if (@paths[node])\n @paths[node].each_index do |next_idx|\n next_node = @paths[node][next_idx]\n @paths[node].delete_at(next_idx)\n tmp = 1 + search(next_node)\n @paths[node].insert(next_idx,next_node)\n if (longest_path < tmp)\n longest_path = tmp\n end\n end\n end\n return longest_path\n end",
"def search(node)\n longest_path = 0\n if (@paths[node])\n @paths[node].each_index do |next_idx|\n next_node = @paths[node][next_idx]\n @paths[node].delete_at(next_idx)\n tmp = 1 + search(next_node)\n @paths[node].insert(next_idx,next_node)\n if (longest_path < tmp)\n longest_path = tmp\n end\n end\n end\n return longest_path\n end",
"def dfs(node, visited, component = [])\n visited << node\n component << node.object\n\n node.adjacents.each do |adjacent_node|\n dfs(adjacent_node, visited, component) unless visited.include?(adjacent_node)\n end\n end",
"def shortest_path(from_x, from_y, to_x, to_y)\n @visited = Array.new(@matrix.size) { Array.new(@matrix.first.size) { false } }\n @farthest_node = nil\n queue = Queue.new\n queue << Node.new(from_x, from_y, 0)\n\n while !queue.empty? do\n node = queue.pop\n\n if !@farthest_node || node.dist > @farthest_node.dist\n @farthest_node =node\n end\n\n if node.x == to_x && node.y == to_y\n # We pathed to the target\n target_node = node\n break\n end\n [[-1,0],[1,0],[0,1],[0,-1]].each do |dir|\n x = node.x + dir[0]\n y = node.y + dir[1]\n if is_valid?(x, y)\n @visited[y][x] = true\n queue.push(Node.new(x, y, node.dist + 1, node))\n end\n end\n end\n\n # We didn't find a path to the target\n return nil unless target_node\n\n # Trace back the journey\n journey = []\n journey.push [node.x,node.y]\n while !node.parent.nil? do\n node = node.parent\n journey.push [node.x,node.y]\n end\n journey.reverse.drop(1)\n end",
"def traverse_maze(maze)\n def get_path(maze, row, col, current_path)\n return false if row.negative? || row >= maze.length || col.negative? || col >= maze[0].length # out of bounds\n return false if maze[row][col] == 1 # impassable\n\n current_path << Point.new(row, col)\n at_end = row == maze.length - 1 && col == maze[0].length - 1\n if at_end || get_path(maze, row, col += 1, current_path) || get_path(maze, row += 1, col, current_path)\n @viable_path = current_path\n return true\n end\n false\n end\n @viable_path = nil\n return nil if maze.nil? || maze.empty?\n\n get_path(maze, 0, 0, [])\n return false if @viable_path.nil?\n\n @viable_path.map { |p| [p.row, p.col].join(',') }.join(' -> ')\nend",
"def search(node = @root)\n if node.position == @target\n @target_node = node\n return\n else\n node.connected_knights.each { |knight| search(knight) }\n end\n end",
"def build_path(start, finish)\n path = [finish]\n loop do\n vertex = path.last\n d = graph[*vertex]\n neighbours = get_neighbours(*vertex)\n next_vertex = neighbours.select{|n_vert| graph[*n_vert] == d - 1}.first\n path << next_vertex if next_vertex\n break if vertex == start\n end\n path\n end",
"def adjacent_nodes(node)\n h = @pathway.graph[node]\n h ? h.keys : []\n end",
"def dfs\n visited = Hash.new(false)\n @v.each do |vertex| \n visited.merge(explore(vertex)) if !visited[vertex]\n end\n return visited\n end",
"def depth_first(node, visited = Set.new())\n return nil if visited.include?(node.val)\n\n puts node.val\n visited.add(node.val)\n\n node.neighbors.each do |neighbor|\n depth_first(neighbor, visited);\n end\nend",
"def has_path_to(node)\n\t\t@visited.include?(node)\n\tend",
"def dfs(node)\n preorder, visited = [], []\n dfs_visit(node, visited, preorder)\n preorder\nend",
"def search_dfs(node, target, visited)\n return if visited[node] == true\n return node if node == target\n visited[node] = true\n res = nil\n @graph[node].each do |nabe|\n if !visited[nabe]\n if (res = search_dfs(nabe, target, visited)) == target\n break\n end\n end\n end\n res\n end",
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end",
"def shortest_path(start_node, end_node, graph)\n adjacent_edges = graph.select{ | edge | edge[NODES].include?(start_node) }\n remaining_edges = graph - adjacent_edges\n shortest_path = Path.new\n adjacent_edges.each do | edge |\n path = Path.new [edge]\n neighbor_node = (edge[NODES] - [start_node])[0] # ['A', 'B'] - ['A'] => ['B']\n unless neighbor_node == end_node\n path_ahead = shortest_path(neighbor_node, end_node, remaining_edges)\n (path_ahead.empty?)? path.clear : path.concat(path_ahead)\n end \n shortest_path = path if path.distance < shortest_path.distance\n end\n shortest_path\n end",
"def find_knight_moves graph, init_vertice\n found_path, moves = traverse_vertice(graph, init_vertice, [])\n return moves if found_path\n nil\nend",
"def find_path(end_pos)\n node = root_node.dfs(end_pos)\n\n self.trace_path_back(node)\n end",
"def dfs(list)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend",
"def dfs(start_vertex, &block)\n start_vertex.gray!\n @time += 1\n start_vertex.discovery = @time\n start_vertex.get_connections.each do |next_vertex|\n if next_vertex.white?\n next_vertex.predecessor = start_vertex\n dfs(next_vertex, &block)\n end\n end\n start_vertex.black!\n @time += 1\n start_vertex.finish = @time\n yield start_vertex if block_given?\n end",
"def find_path()\n visited = Array.new(8) {Array.new(8)}\n return [] if @destination == @currentPosition\n paths = [[@currentPosition]]\n visited[@currentPosition[0]][@currentPosition[1]] = true\n\n until paths.empty?\n new_paths = []\n paths.each do |path|\n next_positions = possibleMoves(path.last, visited)\n next_positions.each do |move|\n newpath = path.dup << move\n if move == @destination #if we reached our destination stop and return the path\n return newpath\n end\n visited[move[0]][move[1]] = true\n new_paths.push(newpath)\n end\n end\n paths = new_paths\n end\n end",
"def solve_dijkstra\n\n unvisited_set = @unvisited_set.dup\n\n # create a queue for nodes to check\n @queue = []\n current_node = @start_node\n @queue << current_node\n\n # Stop If there are no unvisited nodes or the queue is empty\n while unvisited_set.size > 0 && @queue.size > 0 do\n\n # set the current node as visited and remove it from the unvisited set\n current_node = @queue.shift\n\n # remove visited node from the list of unvisited nodes\n unvisited_set.delete(current_node)\n\n # find the current node's neighbours and add them to the queue\n rolling_node = @node_list.find { |hash| hash[:id] == current_node }\n rolling_node[:neighs].each do |p|\n # only add them if they are unvisited and they are not in the queue\n if unvisited_set.index(p) && !@queue.include?(p)\n @queue << p\n # set the previous node as the current for its neighbours\n change_node = @node_list.find { |hash| hash[:id] == p }\n change_node[:prev] = current_node\n # increase the distance of each node visited\n change_node[:dist] = rolling_node[:dist] + @step\n end\n end\n\n if current_node == @goal_node\n find_shortest_path(rolling_node)\n break\n end\n end\n return @shortest_path_coords\n end",
"def path(from, to)\n prev = bfs(from)[0]\n return nil unless prev[to]\n rev_path = []\n current_vertex = to\n while current_vertex\n rev_path << current_vertex\n current_vertex = prev[current_vertex]\n end\n rev_path.reverse\n end",
"def dfs_helper(start_node)\n\n ret_list = [start_node.value]\n # Your code here\n start_node.visited = true\n start_node.edges.each do |edge|\n unless edge.node_to.visited\n ret_list += dfs_helper(edge.node_to)\n end\n end\n return ret_list\n end",
"def find_any_path_between_vertices(source_vertex, destination_vertex)\n validate_integer(source_vertex, destination_vertex)\n return nil if @vertices[source_vertex].nil? || @vertices[destination_vertex].nil?\n return path_between_vertices(source_vertex, destination_vertex)\n end",
"def path?(from_id, to_id)\n from = find_vert(from_id)\n to = find_vert(to_id)\n visted = []\n letters = ''\n return dfs_search(from, to, visted, letters)\n end",
"def search(path, final_point)\n\n current = path.first\n puts \"current.center = #{current.center}\"\n puts \"final_point.center = #{final_point.center}\"\n puts \"path.size = #{path.size}\"\n puts \"path = #{path.map{ |p| [p.center,p.wp_visited?].flatten }}\"\n puts \"current.wp_visited? = #{current.wp_visited?}\"\n\nbinding.pry # => debugger\n\n if wp_distance2(current, final_point) < 1.0\n puts \"found\"\n return path.reverse\n end\n\n wp_adjacents = sort_and_filter(current.wp_adjacents, final_point)\n\n wp_adjacents.each do |wp|\n search(path.unshift(wp), final_point)\nbinding.pry # => debugger\n wp.wp_mark\n end\n end",
"def find_shortest_path(initial_node, final_node)\n\t\tunless @nodes.include?(initial_node) && @nodes.include?(final_node)\n\t\t raise(\"Either of the nodes not found in the Graph\") \n\t\tend\n\t\tdistance = {}\n\t previous = {}\n\t\tdistance[initial_node] = 0 # Distance from initial_node to initial_node\n\t previous[initial_node] = nil\n\t\tnodes_counted = @nodes\n\t\t\t\n\t\tnodes_counted.each do |n|\n\t\t if n != initial_node \n\t\t\t distance[n] = Float::INFINITY # Unknown distance function from initial_node to final_node\n\t\t\t previous[n] = nil \t # Previous node in optimal path from initial_node\n\t\t\tend\n\t\tend\n\n\t\tuntil nodes_counted.empty? \n\t\t\n\t\t\tu = distance.select{|k,v| nodes_counted.include?(k)}.min_by{|k,v| v}.first # Source node in first case\n\t\t\tbreak if (distance[u] == Float::INFINITY)\n\t\t\tnodes_counted.delete(u)\n\t\t\t\n\t\t\t@paths[u].keys.each do |v|\n\t\t\t\talt = distance[u] + @paths[u][v]\n\t\t\t\tif alt < distance[v] # A shorter path to v has been found\n\t\t\t\t\tdistance[v] = alt\n\t\t\t\t\tprevious[v] = u\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t \n\t\tpath = []\n\t\tcurrent = final_node\n\t\twhile current\n\t\t\tpath.unshift(current)\n\t\t\tcurrent = previous[current]\n\t\tend\n \n\t\treturn distance[final_node], path\n\n\tend",
"def find_moves(start, target)\n visited = breadth_first_search(start, target)\n moves = []\n find_coordinate = target\n visited.reverse.each do |vertex|\n vertex.neighbors.each do |coordinate|\n if coordinate == find_coordinate\n moves << vertex.key\n find_coordinate = vertex.key\n end\n end\n end\n moves.reverse << target\n end",
"def find_path(end_pos)\n # self.dfs(target)\n end_node = root_node.bfs(end_pos)\n trace_path_back(end_node).map { |node| node.value }.reverse!\n end",
"def find_path(goal = @maze.find_end)\n path = [goal]\n spot = goal\n until @branching_paths[spot] == nil\n path << @branching_paths[spot]\n spot = @branching_paths[spot]\n end\n path\n end",
"def fill(node)\n filled_so_far = Array.new\n nodes_hash = Hash.new\n already_seen = Hash.new\n queue = [node]\n while (not queue.empty?)\n next_node = queue.shift\n next if already_seen[next_node]\n already_seen[next_node] = true\n @paths[next_node].each do |next_next_node|\n if (next_next_node == next_node)\n # special case. we consider a node connected to itself to be strongly connected\n nodes_hash[next_node] = true\n elsif (find(next_next_node,next_node)) \n # make sure there is a reverse path\n queue << next_next_node\n nodes_hash[next_node] = true\n nodes_hash[next_next_node] = true\n end\n end\n end\n nodes = nodes_hash.keys\n @paths.each do |k,v|\n if nodes.include?(k)\n v.each do |v|\n if nodes.include?(v)\n filled_so_far << [k,v]\n end\n end\n end\n end\n return filled_so_far\n end",
"def fill(node)\n filled_so_far = Array.new\n nodes_hash = Hash.new\n already_seen = Hash.new\n queue = [node]\n while (not queue.empty?)\n next_node = queue.shift\n next if already_seen[next_node]\n already_seen[next_node] = true\n @paths[next_node].each do |next_next_node|\n if (next_next_node == next_node)\n # special case. we consider a node connected to itself to be strongly connected\n nodes_hash[next_node] = true\n elsif (find(next_next_node,next_node)) \n # make sure there is a reverse path\n queue << next_next_node\n nodes_hash[next_node] = true\n nodes_hash[next_next_node] = true\n end\n end\n end\n nodes = nodes_hash.keys\n @paths.each do |k,v|\n if nodes.include?(k)\n v.each do |v|\n if nodes.include?(v)\n filled_so_far << [k,v]\n end\n end\n end\n end\n return filled_so_far\n end",
"def find_path(target)\n queue = [root_node]\n until queue.empty?\n p current_node = queue.shift\n p queue\n return current_node if current_node.value == target\n current_node.children.each do |child|\n queue << child\n end\n end\n nil\nend",
"def ids_recursive(vertex, goal_vertex, depth, max_depth)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @stack.pop() && return if depth == max_depth\n @explored[vertex.label] = true # Mark vertex as being explored\n depth = depth + 1\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if ids_recursive(edge, goal_vertex, depth, max_depth) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def dijkstra\n # Intialise the algorithom if first run\n init_dijkstra if empty_path?\n\n # Stop the execution if all the nides have been reached\n return path if completed_path?\n\n # Make sure that all the weights are updated\n current_node[:node].adjacent_nodes.values.each do |node|\n @pool << node.merge(\n from: current_node[:node],\n weight: node[:weight] + current_node[:weight]\n )\n end\n\n # Sort the pool of nodes/edges by weight so to be able to grab the smallest\n # weight.\n pool.sort_by! { |edge| edge[:weight] }\n\n # Pick the next untouched node by shifting the nodes in the pool starting\n # from the smallest to the greatest.\n next_node = nil\n loop do\n next_node = pool.shift\n break unless values_in_path.include?(next_node[:node].value)\n end\n\n # Push the next step (from -> to) in the path\n @path << \"#{next_node[:from].value} ==> #{next_node[:node].value}\"\n\n # Track the node as seen\n @values_in_path += [next_node[:node].value, current_node[:node].value]\n\n # Update the current node\n @current_node = next_node\n\n # Keep the execution going\n dijkstra\n end",
"def neighbours_into_start(node)\n # Find all arcs that include this node in the right place\n passable_nodes = []\n @arcs.get_arcs_by_node_id(node.node_id).each do |arc|\n if arc.end_node_id == node.node_id and arc.end_node_direction\n passable_nodes.push nodes[arc.begin_node_id]\n elsif arc.begin_node_id == node.node_id and !arc.begin_node_direction\n passable_nodes.push nodes[arc.end_node_id]\n end\n end\n return passable_nodes.uniq\n end",
"def find_shortest_path(start_node, end_node)\n\n\t\tif (!start_node || !end_node)\n\t\t\traise \"start and end nodes must be specified\"\n\t\tend\n\n\t\tqueue = Hash[@edges.keys.map { |k| [k, nil] }]\n\t\tqueue[start_node] = 0\n\n\t\tdistances = queue.dup\n\t\tcrumbs = {}\n\n\t\twhile queue.size > 0\n\n\t\t\texpanded_node = get_min(queue)\n\n\t\t\t# Check if the current path to each neighbor of the expanded_node\n\t\t\t# is shorter than the path currently stored on the distances hash\n\t\t\t@edges[expanded_node].each do |node, edge|\n\n\t\t\t\tif distances[expanded_node]\n\t\t\t\t\n\t\t\t\t\tcurrent_path_distance = distances[expanded_node] + edge.weight\n\n\t\t\t\t\t# The distance to node is shorter via the current path or the distance to node hasn't yet been computed.\n\t\t\t\t\t# Either way, the distance from start_node->node is updated with the current distance (since it is shorter)\n\t\t\t\t\tif (!distances[node] || current_path_distance < distances[node])\n\t\t\t\t\t\tdistances[node], queue[node] = current_path_distance, current_path_distance\n\t\t\t\t\t\tcrumbs[node] = expanded_node\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\tqueue.delete(expanded_node)\n\n\t\tend\n\n\t\t# List of edges representing the shortest path from start_node to end_node\n\t\tshortest_path = []\n\t\tcurrent_node = end_node\n\n\t\twhile (current_node && current_node != start_node && crumbs.size > 0)\n\t\t\tprevious_node = crumbs[current_node]\n\t\t\tif (previous_node)\n\t\t\t\tshortest_path << @edges[previous_node][current_node]\n\t\t\t\tcrumbs.delete(current_node)\n\t\t\tend\n\t\t\tcurrent_node = previous_node\n\t\tend\n\n\t\treturn shortest_path.reverse\n\n\tend",
"def depth_first_search_recursive(source)\n visited.add(source)\n\n source.neighbors.each do |neighbor|\n unless visited.include?(neighbor)\n depth_first_search_recursive(neighbor)\n meta[neighbor] = source\n end\n end\n end",
"def non_deterministic_search(goal_vertex)\n @explored = {}\n @stack = [] #\n non_deterministic_recursive(self, goal_vertex)\n @stack\n end",
"def depth_first_graph(node, visited = [])\n if !visited.include? node\n visited.push(node)\n output = node.data.to_s + \" \"\n output += node.connections.map do |connection|\n depth_first_graph(connection, visited)\n end.join(\"\")\n end\n output\nend",
"def has_path_to?(node)\n @visited.include?(node)\n end",
"def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend",
"def prev_node_finder(n_s, i)\n path_line = $dijkstra_result.select{ |line| line =~ /^#{n_s}/}\n path_line_array = []\n if (path_line[0] == nil)\n return\n else\n path_line_array = path_line[0].split(',')\n end\n prev_node = path_line_array[2]\n $path[i].push(prev_node)\n prev_node_finder(prev_node,i)\n #puts \"Previous node of #{n_d} is #{prev_node}\"\nend",
"def path(x, y)\r\n\t\t# If x or y are on the edge, meaning they have only one path, return 1\r\n\t\tif (x == 0 || y == 0)\r\n\t\t\treturn 1\r\n\t\r\n\t\t# If in the middle of the square, check to see if sum of paths for node already calculated?\r\n\t\telse\r\n\t\t\t# If so, return calculated sum of paths for node\r\n\t\t\tif @node[x][y] != 0\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\t\t\r\n\t\t\t# Otherwise, set node[x][y] to sum of paths for connected nodes through recursion\r\n\t\t\t# Return newly calculated node[x][y]\r\n\t\t\telse\r\n\t\t\t\t@node[x][y] = path(x-1, y) + path(x, y-1)\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\tend\r\n\t\tend\t\r\n\tend",
"def find_path(char)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # use request\n request = @request[char]\n # if no nodes to test\n if request.open.size == 0\n # abort testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # stop execution\n return []\n end\n # found\n found = false\n # find minimal key\n key = request.open.keys.min {|a, b|\n Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>\n Math.hypot(b[0] - request.tx, b[1] - request.ty)}\n # this node is now logged as checked\n request.closed[key[0], key[1]] = request.open[key]\n # remove this node from the pending array\n request.open.delete(key)\n # iterate through all possible directions with relative offsets\n Cache::PathDirs.each {|dir|\n # coordinates of new position\n kx, ky = key[0] + dir[0], key[1] + dir[1]\n # if new coordinates are destination\n if kx == request.tx && ky == request.ty\n # the new node was checked\n request.closed[kx, ky] = dir[2]\n # path was found\n found = true\n # stop checking\n break\n # if new node not checked yet and coordinates are passable\n elsif request.closed[kx, ky] == 0 &&\n char.passable?(key[0] * pix, key[1] * pix, dir[2])\n # add new node to be checked\n request.open[[kx, ky]] = dir[2]\n end}\n # stop execution except if found path\n return nil unless found\n # backtrack the path\n result = request.backtrack\n # finish testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # return movement command array\n return result\n end",
"def knight_moves(initial, final)\n @board.check_impossible_move(initial, final)\n\n search_queue = [Vertex.new(initial)]\n\n until search_queue.empty?\n test_vertex = search_queue.shift\n\n return show_path(make_path(test_vertex)) if test_vertex.value == final\n \n @board.possible_moves(test_vertex.value).each do |move|\n new_vertex = Vertex.new(move)\n new_vertex.parent = test_vertex\n test_vertex.children << move\n search_queue << new_vertex\n end \n\n end\n \"No path was found :(\"\n end",
"def solve\n graph = Graph.create(words, WordNode)\n graph.connect_nodes(:one_char_diff)\n\n end_node = graph.nodes_hash[end_word]\n start_node = graph.nodes_hash[start_word]\n start_node.cost = 0\n\n heap = Containers::Heap.new { |a, b| (a.cost <=> b.cost) == -1 }\n graph.nodes_hash.each do |k, v|\n heap.push v\n end\n\n puts heap.size\n # puts \"is empty?#{heap.empty?}\"\n until heap.empty? do\n current_node = heap.pop\n puts current_node.value, current_node.cost\n # puts current_node == end_node\n # puts current_node.value, end_node.value\n return graph.path(end_node) if current_node == end_node\n\n current_node.connected_nodes.each do |node|\n\n # puts node.visited\n unless node.visited\n cost = current_node.cost + 1\n if cost < node.cost\n node.cost = cost\n node.parent = current_node\n # puts \"changed parent\"\n # puts node.parent\n end\n end\n end\n\n current_node.visited = true\n end\n end",
"def non_deterministic_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.shuffle!.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if non_deterministic_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def traverse_road(next_field,vt=Set.new,solution)\n @visited_tiles = vt\n avail_pos = available_ways_to_go_to(next_field,solution).to_set - @visited_tiles\n\n @visited_tiles << next_field\n avail_pos.each do |nf|\n if ((solution[nf[0],nf[1]] == 0) && (!@visited_tiles.include? nf))\n # print_board create_solution_board @visited_tiles\n traverse_road(nf,@visited_tiles,solution)\n end\n end\n @visited_tiles\n end",
"def explore(vertex)\n #binding.pry if vertexes.size == 4\n vertex = self[vertex]\n visited = Set.new\n visit_order = []\n tree = {}\n stack = []\n if vertex.is_nothing?\n return Nothing.new\n else\n vertex = vertex.from_just\n end\n # we will build a depth first search tree with backedges\n # A backedge will occur if a tree is discovered with an edge that is on a higher level in the tree\n stack.push vertex\n visit_order.push vertex.key\n visited.add vertex.key\n tree[vertex.key] = {:children => []}\n until stack.empty?\n candidate = stack.pop\n candidate.neighbours.each do |dest| # iterate through the neighbours of the vertex\n if !visited.member? dest.key # if the destination has not been visited\n visited.add dest.key\n visit_order.push dest.key # add destination to visitation path\n # Set the destinations parent to the candidate\n tree[dest.key] = {:parent => candidate.key, :children => []}\n # Add the destination key to the list of children of the canditate\n tree[candidate.key][:children].push dest.key\n #add the candidate and destination to the top of the stack so that we can return to them later in the algorithm\n stack.push candidate \n stack.push dest\n break # leave the loop, this only runs once\n end\n end\n end\n return Just.new({ tree: tree, visit_order: visit_order })\n end",
"def dfs_search(source, destination, visted, letters)\n return false if visted.include? source.id\n\n visted << source.id\n return true if source == destination\n\n source.neighbors.each do |id|\n neighbor = find_vert(id)\n if dfs_search(neighbor, destination, visted, letters)\n letters << neighbor.data\n return true, letters\n end\n end\n false\n end",
"def breadth_first_search(start, target)\n queue = [ @vertices[start] ]\n visited = []\n until queue.empty?\n vertex = queue.shift\n break if vertex.key == target\n visited << vertex\n vertex.neighbors.each { |key| queue << @vertices[key] unless visited.include?(@vertices[key])}\n end\n visited\n end",
"def depth_first_search_winston(goal_vertex)\n return [self] if self == goal_vertex\n @stack = [], @explored = {}\n @stack << [self]\n @explored[self.label] = true\n while @stack\n path = @stack.pop\n path.last.edges.reverse_each { |edge|\n unless @explored.has_key? edge.label\n @explored[edge.label] = true\n new_path = path.dup.push(edge)\n edge == goal_vertex ? (return new_path) : @stack << new_path\n end\n }\n end\n end",
"def get_allpaths(source, dest, visited, path)\n # mark visited\n visited[source] = 1\n path << source\n\n if source.eql? dest\n @paths << path.dup\n else\n # recurse for all neighboring nodes\n @nnmap[source].each do |n|\n get_allpaths(n, dest, visited, path) if visited[n].eql? 0\n end\n end\n\n path.pop\n visited[source] = 0\n end",
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end",
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n dfs_visit = Proc.new { |from|\n\tvisited[from] = true\n\ttimestamp[from] = [count += 1]\n\t@graph[from].each_key do |to|\n\t if visited[to]\n\t if timestamp[to].size > 1\n\t if timestamp[from].first < timestamp[to].first\n\t\t# forward edge (black)\n\t\tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n\t\tforward_edges[from] = to\n\t else\n\t\t# cross edge (black)\n\t\tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n\t\tcross_edges[from] = to\n\t end\n\t else\n\t # back edge (gray)\n\t p \"#{from} -> #{to} : back edge\" if $DEBUG\n\t back_edges[from] = to\n\t end\n\t else\n\t # tree edge (white)\n\t p \"#{from} -> #{to} : tree edge\" if $DEBUG\n\t tree_edges[to] = from\n\t dfs_visit.call(to)\n\t end\n\tend\n\ttimestamp[from].push(count += 1)\n }\n\n @graph.each_key do |node|\n\tunless visited[node]\n\t dfs_visit.call(node)\n\tend\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end",
"def findShortestPathsFromNode(root)\n # Clear graph for search\n @nodes.each do |node|\n node.setVisited false\n end\n\n # But (of course) we start with a node, so let's say it's been visited\n\n root.setVisited true\n\n # Set up the root of the tree\n treeRoot = TElement.new(root, nil)\n # Set up parents vector (just treeRoot) and leaves (empty)\n parents = []\n parents.push treeRoot\n leaves = []\n # indicates whether to keep going\n continuing = true\n # todo: this is going to look rather different in Ruby! double-check w/ original java\n while (continuing)\n children = []\n continuing = false\n parents.each do |parent| \n parentNode = parent.node\n puts \"Doing parent: #{parentNode} \" \n parentNode.getEdges.each do |edge|\n puts \"Doing edge(s): #{edge} \" \n childNode = edge.getOtherNode parentNode\n if childNode.notVisited\n \t childNode.setVisited true \n puts \"visited: #{childNode}\"\n child = TElement.new (childNode, parent, edge)\n leaves.push child\n children.push child\n continuing = true\n end\n\t parents = children\n\tend\n end\n end\n #puts \"returning: #{leaves}\"\n return leaves \n end",
"def dfs(target)\n return self if self.value == target\n # debugger\n self.children.each do |node|\n dfs(node)\n # if node.value == target\n # return node\n # else\n # node.dfs(target)\n # end\n end\n return nil if self.children.empty?\n p new_arr\n end",
"def get_path(s, e, maze)\n if maze[s[0]][s[1]] == 1 || # found a wall or visited area\n s[0] < 0 || s[1] < 0 || # top or left edge\n s[0] >= maze.length || s[1] >= maze[0].length # bottom or right edge\n\n path = nil\n\n elsif s[0] == e[0] && s[1] == e[1] # exit spot\n\n path = [s]\n\n else\n\n maze[s[0]][s[1]] = 1 # visit current node\n path =\n get_path([s[0] - 1, s[1]], e, maze) ||\n get_path([s[0], s[1] + 1], e, maze) ||\n get_path([s[0], s[1] - 1], e, maze) ||\n get_path([s[0] + 1, s[1]], e, maze)\n\n path << s unless path.nil?\n\n end\n \n return path\nend",
"def shortest_path_to_all_nodes(initial)\n initial.distance = 0\n\n current = initial\n loop do\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return graph.vertices if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n end",
"def find_path(end_pos)\n end_node = root_node.dfs(end_pos)\n trace_path_back(end_node)\n .reverse\n .map(&:value)\n end",
"def select_possible_path(possible_paths)\n vertex, data = possible_paths.min_by do |vertex, data|\n data[:cost]\n end\n vertex\nend",
"def shortest_path(nodes, starting, ending)\n queue = [starting]\n previous = {}\n previous[starting] = nil\n while !queue.empty?\n p queue\n last_node = queue.pop\n if last_node == ending\n path = []\n while previous[last_node]\n path.unshift(last_node)\n last_node = previous[last_node]\n end\n path.unshift(starting)\n return path\n end\n if neighbors = nodes[last_node]\n neighbors.each do |neighbor|\n unless previous.has_key?(neighbor)\n queue.unshift(neighbor) \n previous[neighbor] = last_node\n end\n end\n end\n end\nend",
"def shortest_path_to(dest_node)\n return unless has_path_to?(dest_node)\n path = []\n while (dest_node != @node) do\n path.unshift(dest_node)\n dest_node = @edge_to[dest_node]\n end\n path.unshift(@node)\n end",
"def search(start, goal)\n openset = Set.new\n closedset = Set.new\n current = start\n\n if @maximize_cost # serves to invert the comparison\n openset_min_max = openset.method(:max_by)\n flip = -1\n else\n openset_min_max = openset.method(:min_by)\n flip = 1\n end\n\n openset.add(current)\n while not openset.empty?\n current = openset_min_max.call{|o| o.g + o.h }\n if current == goal\n path = []\n while current.parent\n path << current\n current = current.parent\n end\n path << current\n return path.reverse\n end\n openset.delete(current)\n closedset.add(current)\n @graph[current].each do |node|\n next if closedset.include? node\n\n if openset.include? node\n new_g = current.g + current.move_cost(node)\n if (node.g - new_g) * flip > 0\n node.g = new_g\n node.parent = current\n end\n else\n node.g = current.g + current.move_cost(node)\n node.h = heuristic(node, start, goal)\n node.parent = current\n openset.add(node)\n end\n end\n end\n return nil\n end",
"def isRoute (nodeA, nodeB, visited)\n visited[nodeA.value] = true\n isRoute = false\n if nodaA.value == nodeB.value\n isRoute = true\n end\n if nodeA.nodes == nil\n isRoute = false\n else\n if !isRoute\n nodeA.nodes.each do |node|\n if node.value == nodeB.value\n isRoute = true\n break\n end\n end\n if !isRoute\n nodeA.nodes.each do |node|\n visited[node] = true\n isRoute(node, nodeB, visited) if visited[node] == false\n end\n end\n end\n end\n isRoute\nend",
"def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend",
"def shortest_paths(source)\n level = 0\n nextlevel = [source]\n seen = { source => level }\n pred = { source => [] }\n until nextlevel.empty?\n level += 1\n thislevel = nextlevel\n nextlevel = []\n thislevel.each do |v|\n neighbors_of(v).each do |w|\n next if (seen.keys.include? w) && (seen[w] != level)\n unless seen.keys.include? w\n pred[w] = []\n seen[w] = level\n nextlevel << w\n end\n pred[w] << v\n end\n end\n end\n [pred, seen]\n end",
"def dfs(root, target)\n return root if root.value == target\n root.children.each do |child|\n search_result = dfs(child, target)\n return search_result unless search_result.nil?\n end\n\n nil\nend",
"def reachable_cells(x, y, world)\n visited = []\n queue = [[x, y]]\n\n while !queue.empty?\n start = queue.pop\n neighbors = DIRECTIONS.values.\n map {|d| [start[0] + d[:x], start[1] + d[:y]]}.\n select {|x,y| world[y][x] == '.' }\n new_cells = neighbors - visited\n queue = queue + new_cells\n visited.push(start)\n end\n\n visited\nend",
"def create_path(node)\n path = []\n until node == nil\n path << node.data\n node = node.parent\n end\n path.reverse\n end",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def depth_first_search(adj_matrix, source_index, end_index)\n node_stack = [source_index]\n # The code uses a forever loop and then breaks when we encounter certain conditions.\n loop do\n curr_node = node_stack.pop\n return false if curr_node == nil\n return true if curr_node == end_index\n\n # Out of the adjacency matrix, pick the “children” of curr_node by checking the 1’s in the adjacency matrix\n children = (0..adj_matrix.length-1).to_a.select do |i| \n adj_matrix[curr_node][i] == 1\n end\n \n # Take those nodes and push them onto the end of the stack\n node_stack = node_stack + children\n end\n end"
] |
[
"0.6875687",
"0.6873869",
"0.67981875",
"0.6794501",
"0.67521584",
"0.67380077",
"0.6705711",
"0.66593736",
"0.66064054",
"0.6573044",
"0.65468067",
"0.65302616",
"0.64828247",
"0.645809",
"0.6415288",
"0.63948447",
"0.63936937",
"0.6379044",
"0.63639575",
"0.6360958",
"0.63576174",
"0.6336854",
"0.633664",
"0.63341236",
"0.6321637",
"0.63162875",
"0.63100326",
"0.63100326",
"0.63023967",
"0.62791955",
"0.6271582",
"0.6235469",
"0.62328964",
"0.62309647",
"0.62227875",
"0.6219848",
"0.62053895",
"0.6165069",
"0.6163553",
"0.61629283",
"0.61572987",
"0.61571145",
"0.614764",
"0.6138251",
"0.6133563",
"0.61201096",
"0.61084914",
"0.61068636",
"0.61023504",
"0.6079997",
"0.60712403",
"0.60638016",
"0.60556495",
"0.6054093",
"0.60538256",
"0.6053466",
"0.60416687",
"0.60416687",
"0.6040992",
"0.6039511",
"0.6033717",
"0.60112774",
"0.60007006",
"0.600004",
"0.5999289",
"0.5989096",
"0.59859365",
"0.5982015",
"0.59740525",
"0.59628016",
"0.5958733",
"0.595428",
"0.5945195",
"0.59392446",
"0.5937857",
"0.592796",
"0.5904982",
"0.5902799",
"0.59016204",
"0.58944637",
"0.5893926",
"0.5884086",
"0.5881067",
"0.58701646",
"0.5867422",
"0.5855389",
"0.5847732",
"0.5842889",
"0.5829438",
"0.5828734",
"0.58281887",
"0.5818252",
"0.58175987",
"0.5815658",
"0.58155394",
"0.58074045",
"0.5784616",
"0.57808",
"0.57757545"
] |
0.637559
|
19
|
GET /companies GET /companies.json
|
def index
if request.format.to_sym == :html
@companies = Company.page(params[:page]).order("LOWER(name)")
else
@companies = Company.all
end
respond_with(@companies)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def companies\n render \"company/companies.json.jbuilder\", status: :ok\n end",
"def index\n @companies = Company.all\n if @companies\n render json: {\n companies: @companies\n }\n else\n render json: {\n status: 500,\n errors: ['No companies']\n }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = companies_scope\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n @com_info = Company.last\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n respond_to do |format|\n format.html {}\n format.json {render json: {message: @companies}, status: 200}\n end\n end",
"def all_companies_information\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_company_info'])\n\t\t url_params = {}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend",
"def index\n @company_authorities = CompanyAuthority.all\n\n render json: @company_authorities\n end",
"def show\n render json: [*@company]\n end",
"def all\n endpoint = 'Companies'\n response = JSON.parse(@client.get(endpoint).body)\n companies = response.key?('Items') ? response['Items'] : []\n companies.map { |attributes| Unleashed::Company.new(@client, attributes) }\n end",
"def show\n render json: @company\n end",
"def index\n @companies = NasdaqCompany.all_companies\n respond_with(@companies)\n end",
"def index\n @companies = ClientCompany.all\n end",
"def index\n @companies = Company.all\n @cities = City.all\n #render json: @companies\n render json: { :companies => @companies, :cities => @cities }\n end",
"def index\n @companies = Company.all\n #result\n\n if @companies.count>0\n render :json => @companies.to_json(:include =>[:confidenceLevel,:nda,:country,:region,:state,:city,:company_type,:company_investors]), :status=>:ok\n else\n render :json => \"No companies found.\".to_json\n end\n end",
"def show\n render json: Company.find(params[\"id\"])\n end",
"def index\n\t\tif current_user.user_role.code == 'admin'\n\t\t\t@companies = Company.all\n\t\telse\n\t\t\t@companies = current_user.created_companies\n\t\tend\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @companies }\n\t\tend\n\tend",
"def index\n add_breadcrumb \"all\", nil, \"glyphicon-list\"\n\n @companies = current_user.account.companies || []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def byId\n @company = Company.find(company_params[:id])\n\n render json: @company\n end",
"def index\n @intelcompanies = IntelCompany.all\n render json: @intelcompanies.to_json(include: [:intel, :company])\n end",
"def index\r\n # Get all companies alphabetized\r\n #@companies = Company.order(\"LOWER(name)\")\r\n @companies = Company.order(\"LOWER(name)\").paginate(:page =>params[:page], :per_page =>10)\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @companies }\r\n end\r\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def getbyId\n begin\n @company = Company.find(params[:id])\n render :json => @company.to_json(:include =>[:confidenceLevel,:nda,:country,:region,:state,:city,:company_type,:companyInvestors,:classifications,:companyGeos,:companyRevenues,:companyGrowths]), :status=>:ok\n rescue\n render :json=>\"No company found\"\n end\n end",
"def get_expense_companies\n res = {\n :total => nil,\n :success => true,\n :data => []\n }\n entities = OrderEntity.find_all_by_order_id(params[:id], :include => [:company])\n entities.each do |e|\n res[:data].push([e.id, e.company.name])\n end\n\n render :json => res.to_json, :layout => false\n\n end",
"def index\n @company_types = CompanyType.all\n\n render json: @company_types\n end",
"def index\n @companies = Company.all\n\n end",
"def index\n\t\t@companies = Company.all\n\tend",
"def index\n\t\t@companies = Company.all\n\tend",
"def show\n @companies = Company.all\n end",
"def get_information_all_companies()\n\t\tpage = 275\n\t\tbegin\n\t\t\turl = create_url(\"organizations\",\"\",page)\n\t\t\tputs \"Reading #{url}\"\n\t\t\tresult = read_url(url)\n\t\t\t#save_json(result, [\"organizations\"])\n\n\t\t\tadd_organization_info(result,\"name\")\n\t\t\tadd_organization_info(result,\"path\")\n\t\t\t\n\t\t\tnext_url = result['data']['paging']['next_page_url']\n\t\t\tpage = page + 1\n\t\tend while next_url != nil\n\t\tcreate_permalink(@paths)\n\t\tsave_json(\"\", [\"names\", \"paths\", \"permalinks\"])\n\tend",
"def companies\n signed_get(COMPANIES_PATH)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companions = Companion.all\n end",
"def index\n @company = Company.find(params[:company_id])\n @roles = Role.where(:company_id => @company.id)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles }\n end\n end",
"def new\n @company.name = params[:name]\n @companies = []\n @linkedin_companies = []\n \n if (!@company.name.blank?)\n @companies = Company.find_all_by_name(params[:name])\n @linkedin_companies = current_user.linkedin_client.search({:keywords => params[:name]}, \"company\").companies.all\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n company = Company.find_by_id(params[:id])\n if company.blank?\n render(\n json: {\n error: {\n code: 404,\n message: \"Company not found\",\n errors: {\n message: \"Company not found\"\n }\n }\n })\n return\n end\n\n render json: {\n data: {\n kind: Company.name,\n id: company.id,\n company: company.as_json(include: :industry)\n }\n }\n end",
"def index\n @companies = @person.companies\n\n respond_to do |format|\n format.html # index.html.haml\n format.xml { render :xml => @companies }\n end\n end",
"def companies\n companies = Driver.find(params[:id]).company\n if companies.size == 0\n companies = Array.new\n end\n respond_with companies\n rescue ActiveRecord::RecordNotFound\n respond_with ActiveRecord::RecordNotFound\n end",
"def index\n @business_companies = Business::Company.all\n end",
"def company\n response = JSON.parse(@client.get(\"users/#{send(:id)}/companies\").body)\n Promisepay::Company.new(@client, response['companies'])\n rescue Promisepay::NotFound\n nil\n end",
"def show\n @biz_company = BizCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @biz_company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n employees_and_bio_signals\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company =Company.find_by(user_id: params[:user_id])\n render json:\n @company\n \n end",
"def show\n\t begin\n\t\t if params[:id].to_i != 0\n\t\t\t # id given\n\t\t @company = Company.find(params[:id])\n\t\t else\n\t\t\t # name given\n\t\t\t @company = Company.find_by_name(params[:id])\n\t\t end\n\t rescue Exception => e\n\t\t @company = nil\n\t\tend\n\n\t if @company.nil?\n\t\t redirect_to root_path, alert: \"This company does not exist.\"\n\t\t return\n\t end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end",
"def show\n\t\t@company = Company.find(params[:id])\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @company }\n\t\tend\n\tend",
"def index\n @companies = current_user.companies.all\n flash[:notice] = t('flash.actions.index.notice') if @companies.empty?\n respond_with(@companies)\n end",
"def index\n\t\t\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies_info = Company.display_information\n end",
"def show\n response_hash = @company.get_company_detail\n respond_to do |format|\n format.html {}\n format.json {render json: {message: response_hash}, status: 200}\n end\n end",
"def show\n @crunch_company = CrunchCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crunch_company }\n end\n end",
"def index\n @contact_companies = ContactCompany.all\n end",
"def show\n @breadcrumb = 'read'\n @company = Company.find(params[:id])\n @offices = @company.offices.paginate(:page => params[:page], :per_page => per_page).order(:office_code)\n @notifications = @company.company_notifications.paginate(:page => params[:page], :per_page => per_page).order('id')\n @accounts = @company.company_bank_accounts.paginate(:page => params[:page], :per_page => per_page).order(:id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @hiring_companies = HiringCompany.all\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n format.ext_json { render :json => find_companies.to_ext_json(:class => :company, :count => Company.count) }\n end\n end",
"def index\n @account_companies = Account::Company.all\n end",
"def show\n render json: @company_authority\n end",
"def index\n @production_companies = ProductionCompany.all\n end",
"def find_company\n @company = Company.exists?(params[:id])\n if @company\n @company = Company.find(params[:id])\n else\n render json: { description: \"Company not found\", code: 404 }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @customer_companies = CustomerCompany.all\n end",
"def get_company_by_company_part\n @parts = CompaniesController::CompanyService.get_company_by_company_part(params[:param_part])\n if !@parts.nil?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend",
"def index\n @companies = Company.order(:name).page(params[:page]).per(10)\n end",
"def index\n @customers = Customer.where(:company_id => current_user.company.id).paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end",
"def index\n\t\t@companies = []\n if params[:query].nil?\n @products = []\n else\n @products = Product.search params[:query]\n @products.each do |product|\n product.companies.each do |company|\n if !@companies.include? company\n @companies << company\n end\n end\n end\n end\n\tend",
"def show\n @ins_company = InsCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ins_company }\n end\n end",
"def index\n @company_clients = CompanyClient.where(company: params[:company]).first\n end",
"def index\n if current_user.is_student?\n @companies = Company.where(:reg_status => [2,3])\n respond_with @companies.as_json({:student_id => current_user.id})\n elsif\n respond_with Company.all\n end\n end",
"def company_information(params)\n get('company-information',params)\n end",
"def show\n @company = Company.find(params[:id])\n respond_with @company\n end",
"def companies\n\t\tEmpresa.all\n\tend",
"def index\n @compania = Companium.all\n end",
"def byState\n @companies = Company.where(\"state_id = ?\", company_params[:state_id])\n\n render json: @companies\n end",
"def show\n @company = current_user.companies.find(params[:company_id])\n @report = @company.labors.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def index\n @companies = NewCompany.where(user: current_user)\n end",
"def index\n @companies = Company.all\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all.page params[:page]\n end",
"def index\n @invoced_companies = InvocedCompany.all\n end",
"def index\n @incomes = current_company.incomes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incomes }\n end\n end",
"def index\n @companies = Company.paginate(page: params[:page]).per_page(10) # pagination (gem 'will_paginate')\n end",
"def index\n @company = Company.all\n end",
"def index\n @companies = Company.alphabetical.all\n end",
"def show\n @company_account = CompanyAccount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @company_account }\n end\n end"
] |
[
"0.79014075",
"0.78579754",
"0.77734107",
"0.77734107",
"0.77734107",
"0.77734107",
"0.7593946",
"0.751332",
"0.7442931",
"0.74332345",
"0.7311373",
"0.72778213",
"0.72639275",
"0.7246536",
"0.72437197",
"0.7199838",
"0.715509",
"0.7150789",
"0.7148859",
"0.7133268",
"0.71272314",
"0.71258575",
"0.7123089",
"0.7066309",
"0.7051794",
"0.7051794",
"0.7051794",
"0.7051794",
"0.7051794",
"0.7051794",
"0.70310616",
"0.70310616",
"0.70310616",
"0.70310616",
"0.70310616",
"0.70310616",
"0.70172393",
"0.7007792",
"0.6988248",
"0.6976108",
"0.6964599",
"0.6964599",
"0.6964393",
"0.6895719",
"0.6894558",
"0.68774647",
"0.68558383",
"0.68554455",
"0.6806947",
"0.6790711",
"0.6763976",
"0.6744131",
"0.674357",
"0.67414737",
"0.67293864",
"0.67269176",
"0.67230266",
"0.668748",
"0.6686193",
"0.6679619",
"0.6665783",
"0.6650285",
"0.66425717",
"0.66375715",
"0.66323495",
"0.6617597",
"0.6614661",
"0.6613959",
"0.6596495",
"0.6590445",
"0.6588993",
"0.6581117",
"0.6560748",
"0.6542597",
"0.6542597",
"0.6542597",
"0.6542597",
"0.65402174",
"0.65195715",
"0.6514687",
"0.64793634",
"0.6479359",
"0.64754206",
"0.64695513",
"0.6461685",
"0.6456526",
"0.6424883",
"0.6424401",
"0.64242476",
"0.64218605",
"0.6421076",
"0.6419071",
"0.64180416",
"0.6407562",
"0.6402702",
"0.64017045",
"0.6397166",
"0.63935524",
"0.6389377",
"0.6370225"
] |
0.70137346
|
37
|
GET /companies/1 GET /companies/1.json
|
def show
@company = Company.find(params[:id])
@company_offers = @company.offers.order(:close_date)
@company_deals = @company.deals.order(:close_date)
respond_with(@company)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @companies = Company.all\n @com_info = Company.last\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def companies\n render \"company/companies.json.jbuilder\", status: :ok\n end",
"def index\n @companies = Company.all\n if @companies\n render json: {\n companies: @companies\n }\n else\n render json: {\n status: 500,\n errors: ['No companies']\n }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def byId\n @company = Company.find(company_params[:id])\n\n render json: @company\n end",
"def show\n render json: Company.find(params[\"id\"])\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companies = companies_scope\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def show\n render json: @company\n end",
"def show\n render json: [*@company]\n end",
"def index\n @companies = Company.all\n respond_to do |format|\n format.html {}\n format.json {render json: {message: @companies}, status: 200}\n end\n end",
"def getbyId\n begin\n @company = Company.find(params[:id])\n render :json => @company.to_json(:include =>[:confidenceLevel,:nda,:country,:region,:state,:city,:company_type,:companyInvestors,:classifications,:companyGeos,:companyRevenues,:companyGrowths]), :status=>:ok\n rescue\n render :json=>\"No company found\"\n end\n end",
"def show\n @crunch_company = CrunchCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crunch_company }\n end\n end",
"def index\n @companies = ClientCompany.all\n end",
"def all_companies_information\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_company_info'])\n\t\t url_params = {}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend",
"def show\n\t begin\n\t\t if params[:id].to_i != 0\n\t\t\t # id given\n\t\t @company = Company.find(params[:id])\n\t\t else\n\t\t\t # name given\n\t\t\t @company = Company.find_by_name(params[:id])\n\t\t end\n\t rescue Exception => e\n\t\t @company = nil\n\t\tend\n\n\t if @company.nil?\n\t\t redirect_to root_path, alert: \"This company does not exist.\"\n\t\t return\n\t end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def show\n @biz_company = BizCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @biz_company }\n end\n end",
"def show\n company = Company.find_by_id(params[:id])\n if company.blank?\n render(\n json: {\n error: {\n code: 404,\n message: \"Company not found\",\n errors: {\n message: \"Company not found\"\n }\n }\n })\n return\n end\n\n render json: {\n data: {\n kind: Company.name,\n id: company.id,\n company: company.as_json(include: :industry)\n }\n }\n end",
"def index\n @company_authorities = CompanyAuthority.all\n\n render json: @company_authorities\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companies = Company.all\n #result\n\n if @companies.count>0\n render :json => @companies.to_json(:include =>[:confidenceLevel,:nda,:country,:region,:state,:city,:company_type,:company_investors]), :status=>:ok\n else\n render :json => \"No companies found.\".to_json\n end\n end",
"def find_company\n @company = Company.exists?(params[:id])\n if @company\n @company = Company.find(params[:id])\n else\n render json: { description: \"Company not found\", code: 404 }\n end\n end",
"def index\n @companies = NasdaqCompany.all_companies\n respond_with(@companies)\n end",
"def show\n\t\t@company = Company.find(params[:id])\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @company }\n\t\tend\n\tend",
"def index\n add_breadcrumb \"all\", nil, \"glyphicon-list\"\n\n @companies = current_user.account.companies || []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @company_clients = CompanyClient.where(company: params[:company]).first\n end",
"def show\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n\n end",
"def index\r\n # Get all companies alphabetized\r\n #@companies = Company.order(\"LOWER(name)\")\r\n @companies = Company.order(\"LOWER(name)\").paginate(:page =>params[:page], :per_page =>10)\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @companies }\r\n end\r\n end",
"def new\n @company.name = params[:name]\n @companies = []\n @linkedin_companies = []\n \n if (!@company.name.blank?)\n @companies = Company.find_all_by_name(params[:name])\n @linkedin_companies = current_user.linkedin_client.search({:keywords => params[:name]}, \"company\").companies.all\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companies = Company.all\n @cities = City.all\n #render json: @companies\n render json: { :companies => @companies, :cities => @cities }\n end",
"def show\n @company = Company.find(params[:id])\n employees_and_bio_signals\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @company_types = CompanyType.all\n\n render json: @company_types\n end",
"def index\n @intelcompanies = IntelCompany.all\n render json: @intelcompanies.to_json(include: [:intel, :company])\n end",
"def index\n\t\t@companies = Company.all\n\tend",
"def index\n\t\t@companies = Company.all\n\tend",
"def get_company\n @company = Company.find(params[:company_id])\n end",
"def show\n @company =Company.find_by(user_id: params[:user_id])\n render json:\n @company\n \n end",
"def show\n @ins_company = InsCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ins_company }\n end\n end",
"def show\n @company = Company.find(params[:id])\n respond_with @company\n end",
"def index\n if request.format.to_sym == :html\n @companies = Company.page(params[:page]).order(\"LOWER(name)\")\n else\n @companies = Company.all\n end\n respond_with(@companies)\n end",
"def show\n add_breadcrumb \"all\", nil, \"glyphicon-screenshot\"\n\n @company = Company.find(id_from_params)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def company\n response = JSON.parse(@client.get(\"users/#{send(:id)}/companies\").body)\n Promisepay::Company.new(@client, response['companies'])\n rescue Promisepay::NotFound\n nil\n end",
"def show\n @breadcrumb = 'read'\n @company = Company.find(params[:id])\n @offices = @company.offices.paginate(:page => params[:page], :per_page => per_page).order(:office_code)\n @notifications = @company.company_notifications.paginate(:page => params[:page], :per_page => per_page).order('id')\n @accounts = @company.company_bank_accounts.paginate(:page => params[:page], :per_page => per_page).order(:id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companies = @person.companies\n\n respond_to do |format|\n format.html # index.html.haml\n format.xml { render :xml => @companies }\n end\n end",
"def show\n response_hash = @company.get_company_detail\n respond_to do |format|\n format.html {}\n format.json {render json: {message: response_hash}, status: 200}\n end\n end",
"def show\n\n \tbegin\n \t@company = Company.find(COMPANY_ID)\n rescue ActiveRecord::RecordNotFound\n \t@company = Company.create({:description => ''})\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end \n end",
"def show\n @company_account = CompanyAccount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @company_account }\n end\n end",
"def index\n @companions = Companion.all\n end",
"def index\n\t\tif current_user.user_role.code == 'admin'\n\t\t\t@companies = Company.all\n\t\telse\n\t\t\t@companies = current_user.created_companies\n\t\tend\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @companies }\n\t\tend\n\tend",
"def get_expense_companies\n res = {\n :total => nil,\n :success => true,\n :data => []\n }\n entities = OrderEntity.find_all_by_order_id(params[:id], :include => [:company])\n entities.each do |e|\n res[:data].push([e.id, e.company.name])\n end\n\n render :json => res.to_json, :layout => false\n\n end",
"def companies\n companies = Driver.find(params[:id]).company\n if companies.size == 0\n companies = Array.new\n end\n respond_with companies\n rescue ActiveRecord::RecordNotFound\n respond_with ActiveRecord::RecordNotFound\n end",
"def show\n @company = current_user.companies.find(params[:company_id])\n @report = @company.labors.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def show\n render json: @company_authority\n end",
"def index\n @companies_info = Company.display_information\n end",
"def all\n endpoint = 'Companies'\n response = JSON.parse(@client.get(endpoint).body)\n companies = response.key?('Items') ? response['Items'] : []\n companies.map { |attributes| Unleashed::Company.new(@client, attributes) }\n end",
"def show\n @company = Company.find(params[:id])\n @status_updates = @company.status_updates\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n format.ext_json { render :json => find_companies.to_ext_json(:class => :company, :count => Company.count) }\n end\n end",
"def show\n @complaint = Complaint.find(params[:id])\n\n render json: @complaint\n end",
"def new\n add_breadcrumb \"add\", nil, \"glyphicon-plus-sign\"\n @companies = Company.all\n\n if current_user.account.companies.empty?\n @company = @companies.first\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @companies }\n end\n else\n @company = current_user.account.companies.last\n respond_to do |format|\n format.html { redirect_to edit_dashboard_company_path(@company), notice: 'Please update your company listing' }\n format.json { render json: current_user.accounts.companies.last }\n end\n end\n end",
"def index\n @business_companies = Business::Company.all\n end",
"def show\n render json: @company_type\n end",
"def index\n\t\t\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def new\n\n @crunch_company = CrunchCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @crunch_company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @company = Company.find(params[:company_id])\n @roles = Role.where(:company_id => @company.id)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles }\n end\n end",
"def new\r\n @company = Company.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @company }\r\n end\r\n end",
"def index\n @companies = Company.all.first(50000)\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end",
"def get_company_by_company_part\n @parts = CompaniesController::CompanyService.get_company_by_company_part(params[:param_part])\n if !@parts.nil?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend",
"def set_api_v1_company\n @api_v1_company = Api::V1::Company.find(params[:id])\n end",
"def index\n @contact_companies = ContactCompany.all\n end",
"def find_company(company_id)\n company = Company.find_by_id(company_id)\n halt 404 unless company\n\n company\n end",
"def show\n @company = Company.find(params[:company_id])\n end"
] |
[
"0.78097886",
"0.76837516",
"0.7651147",
"0.7642482",
"0.7642482",
"0.7642482",
"0.7642482",
"0.75732714",
"0.7532066",
"0.7413212",
"0.7413212",
"0.7413212",
"0.7413212",
"0.7413212",
"0.7413212",
"0.73368204",
"0.73075074",
"0.7303594",
"0.7290155",
"0.72426957",
"0.7118147",
"0.7111091",
"0.70965475",
"0.70867604",
"0.70810765",
"0.70656693",
"0.7052176",
"0.7000734",
"0.6963407",
"0.6960072",
"0.69575477",
"0.69532585",
"0.6927844",
"0.6927419",
"0.6927419",
"0.6927419",
"0.6927419",
"0.6927419",
"0.6927419",
"0.69032013",
"0.6897803",
"0.68879116",
"0.6879356",
"0.6877898",
"0.687622",
"0.68680865",
"0.6856112",
"0.68378663",
"0.6828717",
"0.6828717",
"0.68158394",
"0.6809855",
"0.67926496",
"0.6779328",
"0.677829",
"0.67764425",
"0.67701894",
"0.6760065",
"0.67575294",
"0.6754415",
"0.67542326",
"0.67391247",
"0.67386585",
"0.67039347",
"0.6696699",
"0.6667635",
"0.6661587",
"0.6638375",
"0.66342527",
"0.66246134",
"0.66244125",
"0.65966284",
"0.65808916",
"0.65739304",
"0.6572423",
"0.65707076",
"0.6552754",
"0.6542993",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.6542381",
"0.65413773",
"0.65394485",
"0.65391165",
"0.6525989",
"0.6525989",
"0.6525989",
"0.6525989",
"0.6490184",
"0.6484607",
"0.6483002",
"0.64771754",
"0.6474981",
"0.64734375"
] |
0.0
|
-1
|
GET /companies/new GET /companies/new.json
|
def new
@company = Company.new
respond_with(@company)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\r\n @company = Company.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @company }\r\n end\r\n end",
"def new\n\t\t@company = Company.new\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @company }\n\t\tend\n\tend",
"def new\n @project = Project.new :company_id => params[:company_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n return unless representsCompany?\n\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @biz_company = BizCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @biz_company }\n end\n end",
"def new\n add_breadcrumb \"add\", nil, \"glyphicon-plus-sign\"\n\n if current_user.account.companies.empty?\n respond_to do |format|\n format.html { redirect_to new_dashboard_company_url, status: 302, notice: 'You need to pick a company first.' }\n end\n else\n @companies_sites = current_user.account.companies.zip( current_user.account.sites )\n @current_company = @companies_sites.last.first\n @current_company_sites = @current_company.sites\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: [ @companies_sites, @current_company, @current_company_sites ] }\n end\n end\n end",
"def new\n @ins_company = InsCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ins_company }\n end\n end",
"def new\n add_breadcrumb \"add\", nil, \"glyphicon-plus-sign\"\n @companies = Company.all\n\n if current_user.account.companies.empty?\n @company = @companies.first\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @companies }\n end\n else\n @company = current_user.account.companies.last\n respond_to do |format|\n format.html { redirect_to edit_dashboard_company_path(@company), notice: 'Please update your company listing' }\n format.json { render json: current_user.accounts.companies.last }\n end\n end\n end",
"def create\n render json: Company.create(params[\"company\"])\n end",
"def new\n @company_account = CompanyAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company_account }\n end\n end",
"def new\n @company = Company.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company.name = params[:name]\n @companies = []\n @linkedin_companies = []\n \n if (!@company.name.blank?)\n @companies = Company.find_all_by_name(params[:name])\n @linkedin_companies = current_user.linkedin_client.search({:keywords => params[:name]}, \"company\").companies.all\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n\n @crunch_company = CrunchCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @crunch_company }\n end\n end",
"def new\n @company = Company.new\n respond_with @company\n end",
"def new\n @part_company = PartCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @part_company }\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, :notice => 'Company was successfully created.' }\n format.json { render :json => @company, :status => :created, :location => @company }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@company = Company.new\n\tend",
"def new\n @company = Company.new\n end",
"def new\n @title = \"New Company\"\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.js # new.js.erb --> You don't have to explicity specify it.. its just\n # that you need to specify\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @person = Person.new\n @companies = Company.pluck(:name)\n\n authorize! :create, Person\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @company = Company.new\n end",
"def new\n @company = companies_scope.new\n @company.build_location\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html {\n redirect_to @company, notice: 'Company was successfully created.'\n }\n format.json {\n render json: @company, status: :created, location: @company\n }\n else\n format.html { render action: \"new\" }\n format.json {\n render json: @company.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def new\n load_data\n @company = Company.new\n @contactinfo = Contactinfo.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @company_country = CompanyCountry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company_country }\n end\n end",
"def create\r\n @company = Company.new(params[:company])\r\n respond_to do |format|\r\n if @company.save\r\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\r\n format.json { render json: @company, status: :created, location: @company }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @company.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def new\n @company_financial = CompanyFinancial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company_financial }\n end\n end",
"def new\n @provider = current_company.providers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if @company = Company.find(entity_id_from_params(:company))\n respond_to do |format|\n current_user.account.companies << @company\n format.html { redirect_to root_path, notice: 'Company was successfully created.' }\n format.json\n end\n end\n end",
"def create\n begin\n \n detail = @@data_util.hash_data_to_upper_case( params[:company], ['description'])\n\n detail[:mypclient_id] = session[:client_id]\n detail[:createdby] = session[:username]\n detail[:isactive] = 1\n\n @company = Company.new(detail)\n if @company.save\n @@request_result[:success] = true\n @@request_result[:notice] = 'New company successfully created.'\n else\n @@request_result[:errormsg] = @company.errors.full_messages[0]\n end\n rescue Exception => e\n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def new\n @news_company = NewsCompany.new\n @news_companies=Array.new(Company.all.count){NewsCompany.new}\n @companies=Company.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_company }\n end\n end",
"def create\n \n @company = Company.new(params[:company])\n \n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Empresa foi criada com sucesso.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@company = Company.new(params[:company].merge({:by_user_id => current_user.id}))\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tif @company.save\n\t\t\t\tformat.html { redirect_to @company, notice: t('app.companies.created') }\n\t\t\t\tformat.json { render json: @company, status: :created, location: @company }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @company.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def new\n @company = Company.find_or_create_by(name: 'New Company')\n begin\n @company.save!\n rescue\n flash[:error] = \"Company NOT be found or was not created.\"\n nil\n end\n @address = @company.addresses.find_or_create_by( {addressable_type: 'Company', addressable_id: @company.id} )\n @address.save!\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render action: 'show', status: :created, location: @company }\n else\n format.html { render action: 'new' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @company = Company.find(params[:company_id])\n @role = Role.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end",
"def new\n @company = Company.new\n @regios = Regio.find(:all)\n @sectors = Sector.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def new\n @breadcrumb = 'create'\n @company = Company.new\n @notifications = notifications_dropdown\n @users = users_dropdown\n @classes = bank_account_classes_dropdown\n @zipcodes = zipcodes_dropdown\n @towns = towns_dropdown\n @provinces = provinces_dropdown\n # @countries = countries_dropdown\n # @banks = banks_dropdown\n # @offices = bank_offices_dropdown\n $attachment = Attachment.new\n destroy_attachment\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @company }\n end\n end",
"def create\n @company = Company.new(company_params)\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html {redirect_to @company, notice: 'Company was successfully created.'}\n format.json {render :show, status: :created, location: @company}\n else\n format.html {render :new}\n format.json {render json: @company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html {redirect_to @company, notice: 'Company was successfully created.'}\n format.json {render :show, status: :created, location: @company}\n else\n format.html {render :new}\n format.json {render json: @company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @complaint = Complaint.new\n\n render json: @complaint\n end",
"def new\n @corporation = Corporation.new\n @page_header = \"Добавление новой Корпорации\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corporation }\n end\n end",
"def new\n @global_company = GlobalCompany.new\n @global_company.global_company_profiles.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @global_company }\n end\n end",
"def new\n\n return unless representsCompany?\n\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @person = Person.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @carpool = Carpool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carpool }\n end\n end",
"def new\n @admin_company_detail = Admin::CompanyDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @admin_company_detail }\n end\n end",
"def new\n\n \t\n @companydocument = Companydocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @companydocument }\n end\n\n end",
"def new\n @stuff = Stuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stuff }\n end\n end",
"def create\n @company = Company.new(company_params)\n respond_to do |format|\n if @company.save\n #format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n #format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n authorize!(:new,current_user) unless current_user.role?:lawfirm_admin or current_user.role?:livia_admin\n @companies = Company.getcompanylist(current_user.company_id)\n end",
"def new\n @clinic = Clinic.new\n @packages = Package.all\n @pageType = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clinic }\n end\n end",
"def new\n @business = Business.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @business }\n end\n end",
"def new\n @onecompany_product = Onecompany::Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onecompany_product }\n end\n end",
"def new\n @business = Business.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @business }\n end\n end",
"def create\n @company = @community.companies.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n company = Company.create(company_params)\n if company\n render json:{\n status: :created,\n company: company\n }\n else\n render json: { status: 500 }\n end\n\n \n \n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @project = Project.new\n @services = Service.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @clonet = Clonet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clonet }\n end\n end"
] |
[
"0.8215413",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.80940586",
"0.77714676",
"0.76540494",
"0.7585538",
"0.754403",
"0.7481533",
"0.7471644",
"0.7469828",
"0.7415118",
"0.7412604",
"0.74114054",
"0.7345653",
"0.7308854",
"0.7292187",
"0.7288994",
"0.72550327",
"0.725494",
"0.7229438",
"0.7229061",
"0.72283983",
"0.72106993",
"0.72106993",
"0.72106993",
"0.72106993",
"0.72106993",
"0.72106993",
"0.72106993",
"0.7202171",
"0.71992993",
"0.71987677",
"0.7173707",
"0.71731675",
"0.71731675",
"0.71731675",
"0.71731675",
"0.71633524",
"0.7145005",
"0.71198887",
"0.7104432",
"0.70965236",
"0.70923287",
"0.7084526",
"0.708052",
"0.7072309",
"0.7066408",
"0.7056198",
"0.70539725",
"0.7028171",
"0.70128715",
"0.70095634",
"0.70016116",
"0.697529",
"0.69475186",
"0.69475186",
"0.69475186",
"0.69475186",
"0.69475186",
"0.6944067",
"0.69399124",
"0.6937518",
"0.6937518",
"0.69356614",
"0.69246805",
"0.6917507",
"0.69156456",
"0.689821",
"0.6898025",
"0.6890958",
"0.68861294",
"0.68838286",
"0.6877228",
"0.68369454",
"0.68270683",
"0.6827031",
"0.6826669",
"0.68264216",
"0.6818137",
"0.68179977",
"0.6816077",
"0.6815213",
"0.6815213",
"0.6815213",
"0.6815213",
"0.6815213",
"0.6815213",
"0.6815213",
"0.68058217",
"0.6801579"
] |
0.7397445
|
23
|
POST /companies POST /companies.json
|
def create
# binding.pry
@company = Company.new(params[:company])
if @company.save
UpdateMailer.update_email(@company, current_user, action_name).deliver
flash[:notice] = 'Company was successfully created.'
end
respond_with(@company)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n render json: Company.create(params[\"company\"])\n end",
"def create\n if @company = Company.find(entity_id_from_params(:company))\n respond_to do |format|\n current_user.account.companies << @company\n format.html { redirect_to root_path, notice: 'Company was successfully created.' }\n format.json\n end\n end\n end",
"def companies\n render \"company/companies.json.jbuilder\", status: :ok\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, :notice => 'Company was successfully created.' }\n format.json { render :json => @company, :status => :created, :location => @company }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html {\n redirect_to @company, notice: 'Company was successfully created.'\n }\n format.json {\n render json: @company, status: :created, location: @company\n }\n else\n format.html { render action: \"new\" }\n format.json {\n render json: @company.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @company = Company.new(params[:company])\n \n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Empresa foi criada com sucesso.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @company = Company.new(params[:company])\r\n respond_to do |format|\r\n if @company.save\r\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\r\n format.json { render json: @company, status: :created, location: @company }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @company.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render action: 'show', status: :created, location: @company }\n else\n format.html { render action: 'new' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = @community.companies.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params[:company])\n @companyAuthority = @company.company_authority.new(company_params[:company_authority])\n\n if (!company_params[:lobs].blank?)\n company_params[:lobs].each do |lob|\n @companyAuthority.lob.new(lob)\n end\n end\n\n if @company.save\n render json: @company, status: :created, location: @company\n else\n render json: ErrorSerializer.serialize(@company.errors), status: :unprocessable_entity\n end\n end",
"def create\n @company = Company.new(company_params)\n respond_to do |format|\n if @company.save\n #format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n #format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(nested_params)\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n company = Company.create(company_params)\n if company\n render json:{\n status: :created,\n company: company\n }\n else\n render json: { status: 500 }\n end\n\n \n \n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html {redirect_to @company, notice: 'Company was successfully created.'}\n format.json {render :show, status: :created, location: @company}\n else\n format.html {render :new}\n format.json {render json: @company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html {redirect_to @company, notice: 'Company was successfully created.'}\n format.json {render :show, status: :created, location: @company}\n else\n format.html {render :new}\n format.json {render json: @company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @intelcompany = IntelCompany.new(intelcompany_params)\n\n if @intelcompany.save\n render json: @intelcompany, status: :created, location: @intelcompany\n else\n render json: @intelcompany.errors, status: :unprocessable_entity\n end\n\n end",
"def create\n begin\n \n detail = @@data_util.hash_data_to_upper_case( params[:company], ['description'])\n\n detail[:mypclient_id] = session[:client_id]\n detail[:createdby] = session[:username]\n detail[:isactive] = 1\n\n @company = Company.new(detail)\n if @company.save\n @@request_result[:success] = true\n @@request_result[:notice] = 'New company successfully created.'\n else\n @@request_result[:errormsg] = @company.errors.full_messages[0]\n end\n rescue Exception => e\n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def create\n @account_company = Account::Company.new(account_company_params)\n\n respond_to do |format|\n if @account_company.save\n format.html { redirect_to @account_company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @account_company }\n else\n format.html { render :new }\n format.json { render json: @account_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n\n if @company.save\n respond_with @company, status: :created, location: @company\n else\n respond_with @company, status: :unprocessable_entity\n end\n end",
"def create\n Rails.logger.info \"\\n*****\\nParams Company: #{params[:company]} ********\\n\"\n\n @company = Company.new(params[:company])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.js\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tyc_company = Tyc::Company.new(tyc_company_params)\n\n respond_to do |format|\n if @tyc_company.save\n format.html { redirect_to @tyc_company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @tyc_company }\n else\n format.html { render :new }\n format.json { render json: @tyc_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@company = Company.new(params[:company].merge({:by_user_id => current_user.id}))\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tif @company.save\n\t\t\t\tformat.html { redirect_to @company, notice: t('app.companies.created') }\n\t\t\t\tformat.json { render json: @company, status: :created, location: @company }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @company.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create_new_companies\n params[:new_companies].each do |name|\n c = Company.new\n c.name = CGI.unescape(name)\n c.save\n @movie.production_companies << ProductionCompany.new( :company => c )\n end\n end",
"def index\n @companies = Company.all\n if @companies\n render json: {\n companies: @companies\n }\n else\n render json: {\n status: 500,\n errors: ['No companies']\n }\n end\n end",
"def create\n @company = Company.create!(company_params)\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Bar criado com sucesso.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.json { render :show, status: :created, location: @company }\n SignUpNotifier.registrated(@company).deliver\n else\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n company = Company.new(company_params)\n if company.save \n render json: CompanySerializer.new(company)\n else\n render json: {error: \"Couldnt be saved\"}\n end\nend",
"def create\n @company_type = CompanyType.new(company_type_params)\n\n if @company_type.save\n render json: @company_type, status: :created, location: @company_type\n else\n render json: @company_type.errors, status: :unprocessable_entity\n end\n end",
"def create\n @project = Project.new(project_params)\n @companies = Array.new\n @project.name = @project.name.upcase\n Company.all.each do |comp|\n @companies << [comp.name, comp.id]\n end\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Proyecto registrado exitosamente.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n @data = return_all_details(company_params[:places_id])\n respond_to do |format|\n if @company.save\n @company.update(rating: @data[\"result\"][\"rating\"])\n @company.update(phone_number: @data[\"result\"][\"formatted_phone_number\"])\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n if @company.save\n redirect_to @company, notice: \"Company was successfully created.\"\n else\n render :new, status: :unprocessable_entity\n end\n end",
"def create\n @company = Company.new(company_params)\n @company.tipo = '01'\n if @company.save \n render json: { status: :created }\n else\n render json: @company.errors, status: :unprocessable_entity\n end\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n # result = self.add()\n # # @company = result[:company]\n # format.html { redirect_to result[:company], notice: 'Company was successfully created.' }\n # format.json { render :show, status: :created, location: result[:company] }\n end",
"def create\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @listed_company = ListedCompany.new(listed_company_params)\n\n respond_to do |format|\n if @listed_company.save\n format.html { redirect_to listed_companies_path, notice: 'Listed company was successfully created.' }\n format.json { render :show, status: :created, location: @listed_company }\n else\n format.html { render :new }\n format.json { render json: @listed_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:company][:founded_on] = params[:company][:founded_on].blank? ? Date.today : params[:company][:founded_on].to_date\n @company = Company.new(company_params)\n\n respond_to do |format|\n if @company.save\n response_hash = @company.get_company_detail\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json {render json: {message: response_hash}, status: 200}\n else\n format.html { render :new }\n error = @company.errors.keys[0].to_s.capitalize+\" \"+@company.errors.values[0][0].to_s\n format.json { render json: {message: error}, status: 400 }\n end\n end\n end",
"def new\n @company.name = params[:name]\n @companies = []\n @linkedin_companies = []\n \n if (!@company.name.blank?)\n @companies = Company.find_all_by_name(params[:name])\n @linkedin_companies = current_user.linkedin_client.search({:keywords => params[:name]}, \"company\").companies.all\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def create\n @company = Company.new(company_params)\n if current_user\n current_user.companies << @company\n end\n @company.save\n flash[:safe] = %Q[#{t(\"company_created\")} #{view_context.link_to(t(\"create_new_open_jobs\"), administration_company_path(@company))}.]\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :internal_server_error }\n end\n end\n end",
"def create\n @company_authority = CompanyAuthority.new(company_authority_params)\n\n if @company_authority.save\n render json: @company_authority, status: :created, location: @company_authority\n else\n render json: @company_authority.errors, status: :unprocessable_entity\n end\n end",
"def create\n @ins_company = InsCompany.new(params[:ins_company])\n\n respond_to do |format|\n if @ins_company.save\n format.html { redirect_to @ins_company, notice: 'Ins company was successfully created.' }\n format.json { render json: @ins_company, status: :created, location: @ins_company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ins_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company_account = CompanyAccount.new(params[:company_account])\n\n respond_to do |format|\n if @company_account.save\n format.html { redirect_to @company_account, :notice => 'Company account was successfully created.' }\n format.json { render :json => {:data => @company_account , :success => true }, :status => :created, :location => @company_account }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => {:msg => @company_account.errors, :status => :unprocessable_entity} }\n end\n end\n end",
"def create\n @company = current_user.companies.build(params[:company])\n flash[:notice] = t('flash.actions.create.notice', :resource_name => Company.model_name.human) if @company.save\n respond_with(@company, :location => companies_path)\n end",
"def create\n @company = Company.new(company_params)\n\n render status: \\\n current_user.save_company(@company) ? :created : :unprocessable_entity\n end",
"def create\n @contact_company = ContactCompany.new(contact_company_params)\n\n respond_to do |format|\n if @contact_company.save\n format.html { redirect_to @contact_company, notice: 'Contact company was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact_company }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(params[:company])\n @company.owner = User.find(session[:user_id])\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @company = current_profile.companies.build(company_params)\n\n @company.companytype_id = params[:company_id]\n\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @global_company = GlobalCompany.new(params[:global_company])\n\n respond_to do |format|\n if @global_company.save\n format.html { redirect_to @global_company, notice: 'Global company was successfully created.' }\n format.json { render json: @global_company, status: :created, location: @global_company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @global_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createWithStaff\n created_location = Company.create(params[\"company\"])\n if params[\"id\"]\n updated_person = Person.setCompany(params[\"id\"], created_location)\n end\n render json: created_location\n end",
"def create\n @production_company = ProductionCompany.new(production_company_params)\n\n respond_to do |format|\n if @production_company.save\n format.html { redirect_to @production_company, notice: 'Production company was successfully created.' }\n format.json { render :show, status: :created, location: @production_company }\n else\n format.html { render :new }\n format.json { render json: @production_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def create\n @new_company = NewCompany.new(new_company_params)\n @new_company.user = current_user\n\n respond_to do |format|\n if @new_company.save\n format.html { redirect_to new_requesit_path, notice: 'Вы успешно добавили компанию!' }\n format.json { render :show, status: :created, location: @new_company }\n else\n format.html { render :new }\n format.json { render json: @new_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n\n \n if @company.save\n redirect_to companies_path, notice: 'Company was successfully created.' \n else\n format.html { render :new }\n end\n end",
"def create\n @company = Company.new(company_params)\n @company.user = current_user\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to companies_path, notice: 'Компания успешно создана' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n company = Company.find_by_id(params[:company_id])\n company_logo = company.image_logo\n company_name = company.name \n\n \n @company_order = CompanyOrder.new(company_order_params)\n\n if @company_order.save\n render json: @company_order, status: :created, location: @company_order\n else\n render json: @company_order.errors, status: :unprocessable_entity\n end\n end",
"def create\n @company = Company.new(params[:company])\n @company.create_default_infos\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company successfully created.' }\n format.json { render json: @company, status: :created, location: @company }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @visit_company = VisitCompany.new(visit_company_params)\n\n respond_to do |format|\n if @visit_company.save\n format.html { redirect_to @visit_company, notice: 'Visit company was successfully created.' }\n format.json { render :show, status: :created, location: @visit_company }\n else\n format.html { render :new }\n format.json { render json: @visit_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @customer_company = CustomerCompany.new(customer_company_params)\n @customer_company.created_user_id = current_user.id\n respond_to do |format|\n if @customer_company.save\n format.html { redirect_to @customer_company, notice: t(\"controllers.create_success\") }\n format.json { render :show, status: :created, location: @customer_company }\n else\n @customer_companies_options = CustomerCompany.where(active: true, consortium: true).map{|m| [ m.company_customer , m.id ] }\n format.html { render :new }\n format.json { render json: @customer_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @companyreg = Companyreg.new(companyreg_params)\n\n respond_to do |format|\n if @companyreg.save\n format.html { redirect_to @companyreg, notice: 'Companyreg was successfully created.' }\n format.json { render :show, status: :created, location: @companyreg }\n else\n format.html { render :new }\n format.json { render json: @companyreg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\r\n @company = Company.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @company }\r\n end\r\n end",
"def create\n\t the_params = company_params\n\t the_params[:rating] = 0\n\t the_params[:number_of_votes] = 0\n @company = Company.new(the_params)\n\n respond_to do |format|\n if @company.save\n format.html { redirect_to @company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @company }\n else\n format.html { render :new }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company_name = CompanyName.new(company_name_params)\n\n respond_to do |format|\n if @company_name.save\n format.html { redirect_to @company_name, notice: 'Company name was successfully created.' }\n format.json { render :show, status: :created, location: @company_name }\n else\n format.html { render :new }\n format.json { render json: @company_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n respond_to do |format|\n if @company_business.save\n format.html { redirect_to @company_business, notice: 'Company business was successfully created.' }\n format.json { render json: @company_business, status: :created, location: @company_business }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company_business.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invoced_company = InvocedCompany.new(invoced_company_params)\n\n respond_to do |format|\n if @invoced_company.save\n format.html { redirect_to @invoced_company, notice: t(:successfully_updated_invoced_company) }\n format.json { render action: 'show', status: :created, location: @invoced_company }\n else\n format.html { render action: 'new' }\n format.json { render json: @invoced_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = current_user.companies.build(company_params)\n\n if @company.save\n flash[:success] = \"Saved!\"\n redirect_to companies_path\n else\n render 'new'\n end\n end",
"def update_companies\n current_companies = @movie.companies.collect { |c| c.id.to_s }\n\n delete_production_companies( current_companies )\n add_production_companies( current_companies ) unless params[:companies].nil?\n create_new_companies unless params[:new_companies].nil?\n end",
"def create\n @rail_company = RailCompany.new(rail_company_params)\n\n respond_to do |format|\n if @rail_company.save\n format.html { redirect_to @rail_company, notice: 'Rail company was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rail_company }\n else\n format.html { render action: 'new' }\n format.json { render json: @rail_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hiring_company = HiringCompany.new(hiring_company_params)\n\n respond_to do |format|\n if @hiring_company.save\n format.html { redirect_to @hiring_company, notice: 'Hiring company was successfully created.' }\n format.json { render :show, status: :created, location: @hiring_company }\n else\n format.html { render :new }\n format.json { render json: @hiring_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @credit_company = CreditCompany.new(credit_company_params)\n\n respond_to do |format|\n if @credit_company.save\n format.html { redirect_to @credit_company, notice: t('credit_company.created') }\n format.json { render :show, status: :created, location: @credit_company }\n else\n format.html { render :new }\n format.json { render json: @credit_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = companies_scope.new(company_params)\n\n respond_to do |format|\n if @company.save\n CompanyRegisterMailer.send_request(@company.id).deliver\n\n flash.now[:notice] = I18n.t('commons.successfully_created')\n format.html { render action: \"show\" }\n format.json { render json: @company, status: :created, location: @company.location }\n format.js #\n else\n format.html { render action: \"new\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n format.js #\n end\n end\n end",
"def create\n @type_company = TypeCompany.new(type_company_params)\n\n respond_to do |format|\n if @type_company.save\n format.html { redirect_to @type_company, notice: 'Type company was successfully created.' }\n format.json { render :show, status: :created, location: @type_company }\n else\n format.html { render :new }\n format.json { render json: @type_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company = Company.new(company_params)\n if @company.save\n flash[:success] = \"Company was successfully created.\"\n redirect_to companies_url\n else\n flash[:error] = @company.errors.full_messages.join(\" and \")\n redirect_to new_company_url(@company)\n end\n end",
"def byId\n @company = Company.find(company_params[:id])\n\n render json: @company\n end",
"def index\n @companies = companies_scope\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def create\n @client_company = ClientCompany.new(company_params)\n @client_company.poc_country = @client_company.country_name\n respond_to do |format|\n if @client_company.save\n format.html {redirect_to client_companies_url, notice: 'Company is successfully created.'}\n format.json {render :show, status: :created, location: @client_company}\n else\n format.html {render :new}\n format.json {render json: @client_company.errors, status: :unprocessable_entity}\n end\n end\n end"
] |
[
"0.75086176",
"0.7454409",
"0.7148216",
"0.7067736",
"0.69924504",
"0.6992177",
"0.6991816",
"0.6991816",
"0.6991816",
"0.6991816",
"0.692276",
"0.69189334",
"0.69189334",
"0.69189334",
"0.69189334",
"0.69189334",
"0.69163394",
"0.690428",
"0.6899169",
"0.68933874",
"0.68476266",
"0.6843674",
"0.6816974",
"0.680992",
"0.6766317",
"0.67590636",
"0.67399466",
"0.67399466",
"0.67340183",
"0.67319125",
"0.6682637",
"0.66712207",
"0.66020507",
"0.65840894",
"0.653913",
"0.6523938",
"0.65214026",
"0.6506829",
"0.64884746",
"0.64878446",
"0.6484541",
"0.6479742",
"0.64617956",
"0.6461615",
"0.6441333",
"0.6414747",
"0.63979465",
"0.6391498",
"0.6389729",
"0.6383826",
"0.63828164",
"0.6380915",
"0.6373825",
"0.6361652",
"0.6359336",
"0.63522136",
"0.6341897",
"0.63354236",
"0.63145095",
"0.63130844",
"0.63078475",
"0.63063234",
"0.6296106",
"0.6277097",
"0.6277097",
"0.6277097",
"0.6277097",
"0.62514484",
"0.62510884",
"0.62496394",
"0.6249196",
"0.62437177",
"0.62345177",
"0.62340087",
"0.622988",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.622188",
"0.6211162",
"0.61999255",
"0.61908126",
"0.61877143",
"0.61806846",
"0.61720884",
"0.61657625",
"0.616334",
"0.6153597",
"0.61462766",
"0.61452097",
"0.61353976",
"0.6134431",
"0.6123663",
"0.61188495",
"0.6117755"
] |
0.0
|
-1
|
PUT /companies/1 PUT /companies/1.json
|
def update
@company = Company.find(params[:id])
if @company.update_attributes(params[:company])
UpdateMailer.update_email(@company, current_user, action_name).deliver
flash[:notice] = 'Company was successfully updated.'
end
respond_with(@company)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n @company = Company.find(company_params[:id])\n\n if @company.update(company_params)\n head :no_content\n else\n render json: @company.errors, status: :unprocessable_entity\n end\n end",
"def update\n @company = Company.find(params[:id])\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to companies_path, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n Rails.logger.info \"******\\n\\n\\nCompany: #{params[:company]}***********\\n\\n\\n\"\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_companies\n current_companies = @movie.companies.collect { |c| c.id.to_s }\n\n delete_production_companies( current_companies )\n add_production_companies( current_companies ) unless params[:companies].nil?\n create_new_companies unless params[:new_companies].nil?\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.json { render :show, status: :ok, location: @company }\n else\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html {\n redirect_to @company, notice: 'Company was successfully updated.'\n }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json {\n render json: @company.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, :notice => 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to companies_url, notice: @company.name + ' was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @company = Company.find(params[:id])\r\n \r\n respond_to do |format|\r\n if @company.update_attributes(params[:company])\r\n format.html { redirect_to @company, notice: 'Company 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: @company.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @company = Company.find(params[:id])\n\n if @company.update_attributes(params[:company])\n respond_with @company\n else\n respond_with @company, status: :unprocessable_entity\n end\n end",
"def update\n @company = Company.find(COMPANY_ID)\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to administration_company_path(@company), notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Empresa foi atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render action: 'show', status: :ok, location: @company }\n else\n format.html { render action: 'edit' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_company\n @api_v1_company = Api::V1::Company.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n #format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n #format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(id_from_params)\n\n respond_to do |format|\n if @company.accounts.exists? current_user.account.id\n @company.accounts.delete(current_user.account)\n @company.accounts << current_user.account\n\n format.html { redirect_to root_path, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n @company.accounts << current_user.account\n format.html { redirect_to root_path, notice: 'Company was successfully updated.' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @companies = Array.new\n Company.all.each do |comp|\n @companies << [comp.name, comp.id]\n end\n @project.name = @project.name.upcase\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Proyecto actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n @company.infos.each do |i|\n\t i.value = params[i.key]\n\t i.save\n end\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to @company, notice: 'Company successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@company = Company.find(params[:id])\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tif @company.update_attributes(params[:company])\n\t\t\t\tformat.html { redirect_to @company, notice: t('app.companies.updated') }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @company.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html {redirect_to action: :index, notice: 'Company was successfully updated.'}\n format.json {render :show, status: :ok, location: @company}\n else\n format.html {render :edit}\n format.json {render json: @company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: t(\"updated\") }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to companies_path, notice: 'Общая информация о компании успешно отредактирована' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html {redirect_to @company, notice: 'Company was successfully updated.'}\n format.json {render :show, status: :ok, location: @company}\n else\n format.html {render :edit}\n format.json {render json: @company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n begin\n @company = Company.find(params[:id])\n detail = @@data_util.hash_data_to_upper_case(params[:company], ['description'])\n detail[:lastupdateby] = session[:username]\n\n @@request_result[:data] = detail \n @@request_result[:type] = params[:company].class \n if @company.update_attributes(detail)\n @@request_result[:success] = true\n @@request_result[:notice] = 'Company successfully updated.'\n else\n @@request_result[:errormsg] = @company.errors.full_messages[0]\n end\n rescue Exception => e\n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def update\n @company_type = CompanyType.find(params[:id])\n\n if @company_type.update(company_type_params)\n head :no_content\n else\n render json: @company_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.friendly.find(params[:id])\n\n @company.companytype_id = params[:companytype_id]\n\n\n\n respond_to do |format|\n\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.update(company_params)\n # $redis.publish('companies.update', @company.to_json)\n # render :action => 'show'\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to(@company, :notice => 'Company was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Configurações da empresa alteradas com sucesso!' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # authorize @company\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to admin_company_path(@company), notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = current_user.companies.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n flash[:notice] = 'Company was successfully updated.'\n format.html { redirect_to(@company) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to(@company, :notice => 'Company was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to(@company, :notice => 'Company was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client_company.update(company_params)\n format.html {redirect_to @client_company, notice: 'Company was successfully updated.'}\n format.json {render :show, status: :ok, location: @client_company}\n else\n format.html {render :edit}\n format.json {render json: @client_company.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n @ins_company = InsCompany.find(params[:id])\n\n respond_to do |format|\n if @ins_company.update_attributes(params[:ins_company])\n format.html { redirect_to @ins_company, notice: 'Ins company was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ins_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@company = Company.find(params[:id])\n\t\t@company.update(company_params)\n\t\tredirect_to company_path(@company)\n\tend",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Bar atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n add_to_log(t('Company updated log') + @company.name,\"companies\",\"update\")\n flash[:notice] = t('Company updated')\n format.html { redirect_to(@company) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @company.update(company_params)\n flash[:success] = \"Company updated!\"\n redirect_to @company\n end\n end",
"def update\n @title = \"Update Company\"\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n flash[:notice] = 'Company was successfully updated.'\n format.html { redirect_to(@company) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_company\n id = params[:company_id] ? params[:company_id] : params[:id]\n @company = Company.find(id)\n end",
"def update\n respond_to do |format|\n if @company.update(company_params)\n format.html { redirect_to @company, notice: 'Cliente actualizado con exito' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n respond_to do |format|\n if @company.update!(nested_params)\n format.html { redirect_to @company, notice: \"#{@company.name} Company has been updated.\" }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(params[:company])\n flash[:notice] = 'Company was successfully updated.'\n format.html { redirect_to(@company) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @target_company.update(target_company_params)\n @target_company = TargetCompany.new\n @target_companies = TargetCompany.all\n\n end",
"def update\n if @company.update(company_params)\n redirect_to @company, notice: \"Company was successfully updated.\"\n else\n render :edit, status: :unprocessable_entity\n end\n end",
"def update\n @company_authority = CompanyAuthority.find(params[:id])\n\n if @company_authority.update(company_authority_params)\n head :no_content\n else\n render json: @company_authority.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @new_company.update(new_company_params)\n format.html { redirect_to @new_company, notice: 'Вы успешно отредактировали компанию' }\n format.json { render :show, status: :ok, location: @new_company }\n else\n format.html { render :edit }\n format.json { render json: @new_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:person][:company_name]\n params[:person][:company] = Company.find_or_create_by_name(params[:person][:company_name])\n params[:person].delete(:company_name)\n end\n @person = Person.find(params[:id])\n\n authorize! :edit, @person\n \n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_company()\n # Parameters for the API call\n\n campaign_model = CampaignModel.new()\n campaign_model.utm_source = \"Adwords\"\n campaign_model.utm_medium = \"Twitter\"\n\n company_model = CompanyModel.new()\n company_model.modified_time = Time.now.utc.iso8601\n company_model.company_id = \"12345\"\n company_model.campaign = campaign_model\n\n # Perform the API call through the SDK function\n self.class.controller.update_company(company_model)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 201)\n end",
"def byId\n @company = Company.find(company_params[:id])\n\n render json: @company\n end",
"def companies\n render \"company/companies.json.jbuilder\", status: :ok\n end",
"def update\n respond_to do |format|\n if @account_company.update(account_company_params)\n format.html { redirect_to @account_company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @account_company }\n else\n format.html { render :edit }\n format.json { render json: @account_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company_name.update(company_name_params)\n format.html { redirect_to @company_name, notice: 'Company name was successfully updated.' }\n format.json { render :show, status: :ok, location: @company_name }\n else\n format.html { render :edit }\n format.json { render json: @company_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if @company = Company.find(entity_id_from_params(:company))\n respond_to do |format|\n current_user.account.companies << @company\n format.html { redirect_to root_path, notice: 'Company was successfully created.' }\n format.json\n end\n end\n end",
"def update_contact(companyId, id, model) path = \"/api/v2/companies/#{companyId}/contacts/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end",
"def update\n @company = Company.find(params[:id])\n params[:company][:category_ids] ||= []\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to(@company, :notice => 'Company was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @data = return_all_details(company_params[:places_id])\n respond_to do |format|\n if @company.update(company_params)\n @company.update(rating: @data[\"result\"][\"rating\"])\n @company.update(phone_number: @data[\"result\"][\"formatted_phone_number\"])\n format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @companies = Company.all\n respond_to do |format|\n if @house.update(house_params)\n format.html { redirect_to @house, notice: 'House was successfully updated.' }\n format.json { render :show, status: :ok, location: @house }\n else\n format.html { render :edit }\n format.json { render json: @house.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_company\n @company = Company.find(params[:company])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def update\n @crunch_company = CrunchCompany.find(params[:id])\n @fetch_crunch = Crunchbase::Company.get(@crunch_company.company_name)\n @fetch_crunch_posts = @fetch_crunch.ipo\n\n respond_to do |format|\n if @crunch_company.update_attributes(params[:crunch_company])\n @crunch_company.update_attribute(:posts, @fetch_crunch_posts)\n format.html { redirect_to @crunch_company, notice: 'Crunch company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crunch_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_company\n if /^0*[1-9]\\d*$/.match(params[:id])\n find_company\n else\n render json: { description: \"Invalid ID supplied\", code: 400 }\n end\n end",
"def update\n @company = companies_scope.find(params[:id])\n\n respond_to do |format|\n if @company.update_attributes(company_params)\n format.html { redirect_to @company, notice: I18n.t('commons.successfully_updated') }\n format.json { head :no_content }\n format.js #\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company_account = CompanyAccount.find(params[:id])\n\n respond_to do |format|\n if @company_account.update_attributes(params[:company_account])\n format.html { redirect_to @company_account, :notice => 'Company account was successfully updated.' }\n # format.json { head :ok }\n format.json {render :json => {:data => @company_account , :success => true } }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @company_account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_company_detail = Admin::CompanyDetail.find(params[:id])\n\n respond_to do |format|\n if @admin_company_detail.update_attributes(params[:admin_company_detail])\n format.html { redirect_to @admin_company_detail, :notice => 'Company detail was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @admin_company_detail.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end",
"def set_company\n @company = Company.find(params[:id])\n end"
] |
[
"0.76533496",
"0.7175312",
"0.704681",
"0.6998336",
"0.6969464",
"0.6967971",
"0.69584334",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69481844",
"0.6931405",
"0.69090986",
"0.6901196",
"0.675459",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.6741089",
"0.67236507",
"0.67187583",
"0.6704831",
"0.67004687",
"0.6691469",
"0.66912645",
"0.6684297",
"0.6684297",
"0.66615814",
"0.66466796",
"0.66446376",
"0.66383815",
"0.6638012",
"0.66041064",
"0.6603429",
"0.6568971",
"0.6566898",
"0.65317833",
"0.6522284",
"0.65189725",
"0.6511289",
"0.6510976",
"0.6506683",
"0.6499083",
"0.6481128",
"0.6481128",
"0.6475365",
"0.6466472",
"0.64453065",
"0.6443182",
"0.64384514",
"0.643039",
"0.6424394",
"0.6423008",
"0.641825",
"0.641567",
"0.6407646",
"0.6400383",
"0.6393572",
"0.63901025",
"0.6383814",
"0.6378212",
"0.63716674",
"0.6362062",
"0.6353997",
"0.633194",
"0.6330059",
"0.6314423",
"0.63130057",
"0.6308908",
"0.6307864",
"0.62947047",
"0.6294565",
"0.6288234",
"0.6288234",
"0.6288234",
"0.6288234",
"0.6288234",
"0.6288234",
"0.6288234",
"0.6288234",
"0.6287366",
"0.62811977",
"0.6276071",
"0.62486523",
"0.624662",
"0.6240086",
"0.6240086",
"0.6240086",
"0.6240086",
"0.6240086"
] |
0.0
|
-1
|
DELETE /companies/1 DELETE /companies/1.json
|
def destroy
@company = Company.find(params[:id])
@company.destroy
UpdateMailer.update_email(@company, current_user, action_name).deliver
flash[:notice] = 'Company was successfully deleted.'
respond_with(@company)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @company = Company.find(params[:id])\r\n @company.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to companies_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @crunch_company = CrunchCompany.find(params[:id])\n @crunch_company.destroy\n\n respond_to do |format|\n format.html { redirect_to crunch_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = set_company\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_path, notice: \"#{@company.name} has been deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @biz_company = BizCompany.find(params[:id])\n @biz_company.destroy\n\n respond_to do |format|\n format.html { redirect_to biz_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_path, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ins_company = InsCompany.find(params[:id])\n @ins_company.destroy\n\n respond_to do |format|\n format.html { redirect_to ins_companies_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @company.destroy\n @companies = Company.all\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json {render json: {message: @companies}, status: 200}\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: t(\"company_destroyed\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rail_company.destroy\n respond_to do |format|\n format.html { redirect_to rail_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n #format.html { redirect_to companys_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@company = Company.find_by_slug(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n\n head :no_content\n end",
"def destroy\n @company = Company.find(id_from_params)\n @company.accounts.delete(current_user.account)\n #current_user.companies.delete(@company)\n #@company.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html {redirect_to companies_url, notice: 'Company was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @global_company = GlobalCompany.find(params[:id])\n @global_company.destroy\n\n respond_to do |format|\n format.html { redirect_to global_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html {redirect_to companies_url, notice: 'Company was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @contact_company.destroy\n respond_to do |format|\n format.html { redirect_to contact_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n flash[:notice] = \"company deleted\" \n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t\t@company = Company.find(params[:id])\n\t\t@company.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to companies_url }\n\t\t\tformat.json { head :ok }\n\t\tend\n\tend",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Cliente eliminado con exito' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @guarantee_company.destroy\n respond_to do |format|\n format.html { redirect_to guarantee_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @visit_company.destroy\n respond_to do |format|\n format.html { redirect_to visit_companies_url, notice: 'Visit company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @new_company.destroy\n respond_to do |format|\n format.html { redirect_to new_companies_url, notice: 'New company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Bar Deletado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Person was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @title = \"Destroy Company\"\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_company_detail = Admin::CompanyDetail.find(params[:id])\n @admin_company_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_company_details_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n\n respond_to do |format|\n if @company.destroy\n format.html { redirect_to companies_url,\n notice: (crud_notice('destroyed', @company) + \"#{undo_link(@company)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { redirect_to companies_url, alert: \"#{@company.errors[:base].to_s}\".gsub('[\"', '').gsub('\"]', '') }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @company = current_user.companies.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n add_to_log(t('Company destroy log') + @company.name,\"companies\",\"destroy\")\n\n respond_to do |format|\n format.html { redirect_to(companies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @business_company.destroy\n respond_to do |format|\n format.html { redirect_to business_companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @customer_company.destroy\n respond_to do |format|\n format.html { redirect_to customer_companies_url, notice: t(\"controllers.destroy_success\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @account_company.destroy\n respond_to do |format|\n format.html { redirect_to account_companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Company.transaction do\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @tyc_company.destroy\n respond_to do |format|\n format.html { redirect_to tyc_companies_url, notice: 'Company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_account = CompanyAccount.find(params[:id])\n @company_account.destroy\n\n respond_to do |format|\n format.html { redirect_to company_accounts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @hiring_company.destroy\n respond_to do |format|\n format.html { redirect_to hiring_companies_url, notice: 'Hiring company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @credit_company.destroy\n respond_to do |format|\n format.html { redirect_to credit_companies_url, notice: t('credit_company.destroyed') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company.destroy\n redirect_to(companies_url)\n end",
"def destroy\n @companium.destroy\n respond_to do |format|\n format.html { redirect_to compania_url, notice: 'Companium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.html { redirect_to companies_url }\n format.js\n format.json { head :no_content }\n end\n end",
"def destroy\n @production_company.destroy\n respond_to do |format|\n format.html { redirect_to production_companies_url, notice: 'Production company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n flash[:success] = \"Company was successfully deleted.\"\n redirect_to crm_path\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.html { redirect_to companies_url, notice: 'Компания успешно удалена' }\n format.json { head :no_content }\n end\n end",
"def destroy\n company = @moot.company\n @moot.destroy\n respond_to do |format|\n format.html { redirect_to [company], notice: 'Moot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @company.destroy()\n render json: { :message => \"Success!\" }\n else\n render json: { :message => \"La zona no pudo ser eliminada\" }\n end\n end",
"def destroy\n @events_company = EventsCompany.find(params[:id])\n @events_company.destroy\n\n respond_to do |format|\n format.html { redirect_to events_companies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @company = Company.find(params[:id])\n if @company.destroy\n @@request_result[:success] = true\n @@request_result[:notice] = 'Operation ended successfully.'\n else\n @@request_result[:errormsg] = @company.errors.full_messages[0]\n end\n rescue Exception => e\n @@request_result[:errormsg] = e.message\n @@request_result[:errorcode] = e.code\n end\n render json: @@request_result\n end",
"def destroy\n @listed_company.destroy\n respond_to do |format|\n format.html { redirect_to listed_companies_url, notice: 'Listed company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_vacancy.destroy\n respond_to do |format|\n format.html { redirect_to company_vacancies_url, notice: 'Company vacancy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @part_company = PartCompany.find(params[:id])\n @part_company.destroy\n\n respond_to do |format|\n format.html { redirect_to part_companies_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @company_name.destroy\n respond_to do |format|\n format.html { redirect_to company_names_url, notice: 'Company name was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sp_company_info = SpCompanyInfo.find(params[:id])\n @sp_company_info.destroy\n\n respond_to do |format|\n format.html { redirect_to sp_company_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @company = Company.find(params[:id])\r\n @company.destroy\r\n respond_to do |format|\r\n format.html { redirect_to(admincompany_manage_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @companyreg.destroy\n respond_to do |format|\n format.html { redirect_to companyregs_url, notice: 'Companyreg was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @main_company.destroy\n respond_to do |format|\n format.html { redirect_to main_companies_url, notice: 'Main company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_type.destroy\n\n head :no_content\n end",
"def destroy\n @company_owner.destroy\n respond_to do |format|\n format.html { redirect_to company_owners_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_investor.destroy\n respond_to do |format|\n format.html { redirect_to company_investors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @companycreation.destroy\n respond_to do |format|\n format.html { redirect_to companycreations_url, notice: 'Companycreation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n respond_to do |format|\n if @invoced_company.destroy\n format.html { redirect_to invoced_companies_url}\n format.json { head :no_content }\n else\n format.html { redirect_to invoced_companies_url, :alert => t(:error_destroy_invoiced_company) }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @type_company.destroy\n respond_to do |format|\n format.html { redirect_to type_companies_url, notice: 'Type company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gas_company.destroy\n respond_to do |format|\n format.html { redirect_to admins_gas_companies_url, notice: 'Gas company was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news_company = NewsCompany.find(params[:id])\n @news_company.destroy\n\n respond_to do |format|\n format.html { redirect_to news_companies_url }\n format.json { head :ok }\n end\n end"
] |
[
"0.8018972",
"0.7861743",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7642027",
"0.76235217",
"0.76215345",
"0.76215345",
"0.76215345",
"0.7568788",
"0.7547548",
"0.75399697",
"0.74384123",
"0.7433052",
"0.74231863",
"0.7419068",
"0.74140304",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74086016",
"0.74076587",
"0.74039793",
"0.7403959",
"0.7401683",
"0.7363115",
"0.73630214",
"0.7362838",
"0.7342468",
"0.73364216",
"0.73334366",
"0.7330846",
"0.7329251",
"0.7329251",
"0.7329251",
"0.7329251",
"0.7329251",
"0.7329251",
"0.7329251",
"0.73279244",
"0.73157084",
"0.73101336",
"0.73050505",
"0.72866726",
"0.72704464",
"0.72489464",
"0.7248534",
"0.7246279",
"0.7243713",
"0.7240261",
"0.7237352",
"0.72359806",
"0.72359395",
"0.7229435",
"0.7169927",
"0.7167861",
"0.71323454",
"0.7124109",
"0.71210724",
"0.71018136",
"0.70942634",
"0.70891",
"0.70890296",
"0.70818543",
"0.70656323",
"0.7056755",
"0.70490617",
"0.70454234",
"0.703329",
"0.70256793",
"0.70178384",
"0.70143986",
"0.7001467",
"0.6995481",
"0.69918984",
"0.6973496",
"0.6972658",
"0.69721603",
"0.6972062",
"0.69719017",
"0.69708323",
"0.69704217",
"0.6966308",
"0.6947178"
] |
0.0
|
-1
|
private return all the other Response objects for the same Question. exclude yourself private
|
def sibling_responses
# exclude yourself
# load questions, then load responses
question.responses.where.not(id: id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def responses\n object.questions.map do |q|\n Embedded::ResponseSerializer.new(q.filtered_responses.first,root: false)\n end\n end",
"def sibling_responses\n question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end",
"def answers\n extracted_answers = []\n\n unless self.qp_values.nil?\n self.qp_values.each do |answer| \n extracted_answers.push(ResponseAnswer.new(answer))\n end \n end\n\n return extracted_answers \n end",
"def responses\n @responses ||= api::BatchResponse.new(responses: responses_by_request.values.uniq)\n end",
"def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend",
"def sibling_responses\n if !Response.exists?(self) #checks if instance is stored in database\n question.responses #even if instance class = Reponse, returns false if not in database\n else\n self.question.responses\n .where(\"responses.user_id != ?\", respondent.id)\n end\n\n end",
"def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.success?\n data = Request.manage_response(response)\n end\n data.each do |question|\n questions << Question.new(question)\n end\n questions\nend",
"def sibling_responses\n ac = {answer_choice_id: self.answer_choice_id, id: self.id}\n Response.find_by_sql([<<-SQL, ac])\n SELECT\n\t\t\t\t\trespones.*\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tquestions.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tquestions\n\t\t\t\t\t\t\tJOIN answer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tanswer_choices.id = :answer_choice_id\n\t\t\t\t\t) AS quest\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tanswer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tresponses ON responses.answer_choice_id = answer_choices.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(responses.id != :id)\n\t\t\t\tSQL\n end",
"def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end",
"def responses\n participants.flat_map(&:responses)\n end",
"def sibling_responses\n if self.id\n self.question.responses.where(\"responses.id != ?\", self.id)\n else\n self.question.responses\n end\n end",
"def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end",
"def unanswered_questions\n Question.all.reject do |question|\n responsers_id = question.responses.pluck(:user_id)\n responsers_id.include?(self.id)\n end\n end",
"def sibling_responses\n if persisted?\n return self.question.responses\n elsif self.question.responses.includes(self)\n return self.question.responses.where(\"responses.id <> ?\", self.id)\n end\n end",
"def uniq\n return :responses\n end",
"def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend",
"def responses\n @responses\n end",
"def get_responses(entries)\n responses = entries.map do |entry|\n entry.responses\n end\n responses.flatten.compact\n end",
"def questions\n object.questions.map do |question|\n QuestionSerializer.new(question)\n end\n end",
"def sibling_responses\n # self.question.responses.where(\"responses.id != ?\", self.id)\n self.question.responses.where.not(id: self.id)\n end",
"def get_valid_responses(form_name, question_id)\n resp = get_form(form_name)[:questions][question_id][:valid_responses]\n if resp.is_a? Symbol and !FormValidation::RESPONSE_TYPES.include?(resp)\n resp = self.send(resp)\n end\n return resp\n end",
"def index\n \n # if the current user is a teacher or admin, display all responses submitted\n # otherwise current user is a student, and may only view his/her own responses\n @responses = current_user.top_role.id < 3 ? Response.all : Response.user_responses(current_user.id)\n\n @question_groups = QuestionGroup.all\n\n respond_with(@responses)\n end",
"def questions\n extracted_questions = []\n\n unless self.qp_questions.nil?\n self.qp_questions.each do |question| \n extracted_questions.push(Question.new(question))\n end \n end\n\n return extracted_questions\t\t\t\n\t\tend",
"def questions\n results = CONNECTION.execute(\"SELECT * FROM questions WHERE student_id = #{@id};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << Question.new(result_hash[\"id\"], result_hash[\"student_id\"], result_hash[\"content\"])\n end\n \n return results_as_objects\n end",
"def index\n @responses = @survey.responses\n @questions = Question.all\n end",
"def all_answers_for(question)\n answers.select {|a| a.question == question}\n end",
"def index\n @survey_question_responses = SurveyQuestionResponse.all\n end",
"def specials\n @specials = response[\"specials\"]\n @specials[\"items\"].map!{|item| Foursquared::Response::Special.new(client, item)} if @specials\n @specials\n end",
"def show\n if current_user == nil\n redirect_to home_login_url\n else\n @question = Question.where(:id => params[:id])[0]\n @user = User.where(:id => @question.user_id).first\n if @user == nil\n @user = User.where(:id => 15).first\n end\n @categories = @question.categories\n \n @sample = Question.all.pop\n @samples = @sample.kludgy_related_similar()\n @different_samples = sample.kludgy_related_other()\n\n # @followed = current_user.followed_questions.where(:question_id => params[:id]).size != 0\n #@followed_user = current_user.followed_users.where(:followed_user_id => @question.user_id).size != 0\n\n # @num_events = 0\n # @question.challenges.each { |challenge|\n # @num_events += challenge.events.length\n # }\n puts 'do we play by the same rules brah?'\n @q = @question\n if @q.nil?\n @resp_id = nil\n else\n @resp_id = @q.id\n @responses = ResponseTemplate.where(:item_id => @q.producible_id).where(:parent_id => nil)\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end\n end",
"def question_details\n result = []\n entities.each do |entity|\n group = entity.meta_attribute_entity_group\n result.push({\n :questions=>questions_for_entity(entity).map{|q|q.attribute_name},\n :table=>entity.entity_type,\n :year=>entity.reference_year,\n :group=>group.group_name,\n :parent_table=>group.parent_table,\n :link_to=>(group.parent_group.nil? ? nil : group.parent_group.parent_table)\n })\n end\n result\n end",
"def questions_with_qr(key)\n hashed_questionnaires[key].map do |quest|\n { id: quest.resource.id, title: quest.resource.title, questionnaire_response: {} }\n end\n end",
"def results_from(response)\n response.data.collect do |obj|\n case resource\n when RedboothRuby::Client\n next unless resource_form_hash(obj.merge(session: session))\n resource_form_hash(obj.merge(session: session))\n else\n resource.new(obj.merge(session: session))\n end\n end.compact\n end",
"def getResponse(surveyId, questionId)\n return survey_responses.where({:survey_id => surveyId, :survey_question_id => questionId}).first\n end",
"def responses\n {\n 'multiple_choice_answers' => self.multiple_choice_answers,\n 'open_response_answers' => self.open_response_answers,\n 'image_question_answers' => self.image_question_answers,\n 'external_links' => self.interactive_run_states\n }\n end",
"def questions\n @_questions ||= fetch_questions\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def response_set\n if defined?(@response_set)\n return @response_set unless wipe_response_set?\n end\n @wipe_response_set = false\n @response_set = LimeExt::ResponseLoaders.responses_for self\n return @response_set\n end",
"def appt_questionnaires\n base_qm[:questionnaire].each_with_object({}) do |quest, acc|\n questionnaire_id = quest['id']\n acc[questionnaire_id] = quest\n end\n end",
"def load_responses(parameters, survey_id)\n Question.all.each do |question|\n response = Response.new(survey_id: survey_id, question_id: question.id, choice_id: parameters[:\"#{question.id}\"])\n response.save\n end\n end",
"def replies\n Reply.find_by_question_id(self.id)\n end",
"def items\n # [obj_or_array].flatten makes this always be an array (lastfm gives\n # the single object when it's not an array)\n [main_result[response_type]].flatten.compact rescue []\n end",
"def answers_for_question(question)\n @answers_for_question ||= {}\n @answers_for_question[question] ||= Answer.first_level_only\n .joins(:form_item)\n .where(response_id: responses.map(&:id))\n .where(\"form_items.question_id\" => question.id)\n .index_by(&:response_id)\n end",
"def get_questionnaire_responses\n @get_questionnaire_responses ||=\n questionnaire_response_service.search(\n source: user.icn,\n authored: [date_ge_one_month_ago, date_le_two_weeks_from_now],\n _count: '100'\n )\n end",
"def get_next_set\n hash,url = perform_next_page_request\n Questions.new hash,url\n end",
"def questions\r\n return @questions \r\nend",
"def questions\n @pages.collect { |p| p.questions }.flatten\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def getResponses(surveyId)\n return survey_responses.where({:survey_id => surveyId})\n end",
"def to_response\n []\n end",
"def questions\n return @questions\n end",
"def questions\n result = []\n 1.upto(@@max_questions) { |i| result << question(i) }\n result.select { |q| !q.empty? }\n end",
"def qr_responses\n hashed_qr[appt_id]\n end",
"def response_elements\n RESPONSE_ELEMENTS\n end",
"def questions_list \n #render json: {status: 200, questions: Quiz.all, msg: \"Success.\"}\n render json: {status: 200, questions: Quiz.all.map{|que| [id: que.id, question: que.question, options: [que.opt1,que.opt2,que.opt3,que.opt4], answer: que.answer]}.flatten, msg: \"Success.\"}\n end",
"def update_responses(responses)\n\n ui_hash = []\n\n responses.each do |key, value|\n question = survey.question(key)\n response = response(key)\n\n next if value.nil? || question.nil?\n\n if question.type == :none || question.type == :repeater\n answer = question.answers.first\n ui_hash.push(HashWithIndifferentAccess.new(\n question_id: question.id.to_s,\n api_id: response ? response.api_id : Surveyor::Common.generate_api_id,\n answer_id: answer.id.to_s,\n answer.value_key => value.to_s,\n autocompleted: true\n ))\n end\n\n if question.type == :one\n ui_hash.push(HashWithIndifferentAccess.new(\n question_id: question.id.to_s,\n api_id: response ? response.api_id : Surveyor::Common.generate_api_id,\n answer_id: question.answer(value).id.to_s,\n autocompleted: true\n ))\n end\n\n if question.type == :any\n value.each do |item|\n ui_hash.push(HashWithIndifferentAccess.new(\n question_id: question.id.to_s,\n api_id: response ? response.api_id : Surveyor::Common.generate_api_id,\n answer_id: question.answer(item).id.to_s,\n autocompleted: true\n ))\n end\n end\n end\n\n update_from_ui_hash(Hash[ui_hash.map.with_index { |value, i| [i.to_s, value] }])\n end",
"def answers\n return Answer.where(question_id: self.id) \n end",
"def get_questionnaires\n @get_questionnaires ||= questionnaire_service.search('context-type-value': get_use_context)\n end",
"def batch_responses\n return [@result] unless @batch_response\n # if batch response, generate array based on the response hash.\n @result.map do |r|\n next r unless r.is_a?(Hash)\n hash = r[SUCCESS] || r[ERROR]\n Parse::Response.new hash\n end\n end",
"def index\n \t @responses = Response.all\n end",
"def quiz_questions\n @questions = set_quiz.questions\n end",
"def questions\n qs = []\n qs |= self.class.questions if self.class.respond_to? :questions\n qs |= (@_questions||=[])\n qs.map{|q| q.for_instance(self) }\n end",
"def replies\n Reply.find_by_question_id(@id)\n end",
"def not_duplicate_response\n if respondent_already_answered?\n errors[:user_id] << 'this user has already answered this question'\n end\n # unless sibling_responses.where(user_id: user_id).empty?\n end",
"def new\n @response = Response.new\n @questions = Question.all\n @answers = Answer.all\n @question_groups = QuestionGroup.all\n \n respond_to do |format|\n \n # detect for ajax get request, render all questions within \n # the requested question_group and answers for all multiple choice questions\n if request.xhr?\n \n # if the selected question group is empty (user selects no question group)\n if !params[:question_group_id].empty?\n \n # create question_group_questions instance object which stores\n # for each question in question group an array containing the question object\n # and the answers for that question if it is a multiple choice question.\n @question_group_questions = QuestionGroupQuestion.where(\n \"question_group_id\" => params[:question_group_id]\n ).collect { \n |d| \n question = Question.find(d.question_id)\n [ question, \n question.question_type == 2 ? Answer.find_all_by_questions_id(d.question_id).to_a : nil\n ]\n }\n\n format.html { render :partial => \"question_group_form\", :layout => false, :locals => { \n :question_group_questions => @question_group_questions, \n }\n }\n else\n format.html { render :partial => \"question_answer\", :layout => false, :locals => { :f => @response } }\n end\n else\n # respond to normal request\n format.html # new.html.erb\n format.json { render json: @response }\n end\n end\n end",
"def survey_answers\n survey_questions.map(&:survey_answers).flatten\n end",
"def ordered_subclasses\n [Question]\n end",
"def answerable_questions\n answerable = []\n\n unanswered_questions.each do |question|\n answerable.push(question) if precondition_met(question)\n end\n\n return answerable\n end",
"def my_requests()\n request_array = []\n self.problems.each do |problem|\n Request.where({ problem_id: problem.id}).each do |request|\n request_array.push(request)\n end\n end\n request_array\n end",
"def get_quest\n\t\tget_data\n\n\t\t$finish = false\n\t\tunless $finish == true\n\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\twhile $quiz_arr.include?(@data[$randId]['id'])\n\t\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\tend\n\t\t\t$quiz_arr.push(@data[$randId]['id'])\n\t\t\t$i += 1\n\n\t\t\tif $i == 7\n\t\t\t\t$finish = true\n\t\t\tend\n\n\t\t\t@quest = @data[$randId]['question_name']\n\t\t\t@c_answer = @data[$randId]['c_answer']\n\t\t\t@alt1 = @data[$randId]['alt1']\n\t\t\t@alt2 = @data[$randId]['alt2']\n\t\t\t@alt3 = @data[$randId]['alt3']\n\t\t\t@imgurl = @data[$randId]['imgurl']\n\t\t\t@url = @data[$randId]['news_url']\n\t\t\t@cat = @data[$randId]['category_id']\n\t\t\t@hex = @data[$randId]['category_hex_code']\n\t\t\tget_descriptions(@url)\n\t\t\t@image = @desc_data['image']\n\n\t\t\t$answer_array = Array.new()\n\t \tend\n\tend",
"def convert_responses(responses)\n responses.map do |res|\n matches = res[\"matches\"] || []\n matches.map do |match|\n match[\"ip\"]\n end\n end.flatten.compact.uniq\n end",
"def show\n @problem_set = ProblemSet.find(params[:problem_set_id])\n if session[:user_id].nil?\n session[:redirect_url] = \"/problem_sets/#{@problem_set.id}/questions/\"\n redirect_to(\"/login/\")\n else\n @question = Question.where(:problem_set_id => params[:problem_set_id], :count => params[:id]).first\n if @question.nil?\n flash[:notice] = \"NO SUCH QUESTION!\"\n redirect_to :action=>\"index\"\n else\n @answer = Answer.where(:question_id => @question.id).all\n @response = Response.where(:user_id => session[:user_id], :question_id => @question.id).first\n if @response.nil?\n @response = Response.new\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n end\n end\n end",
"def similar_questions\n\n end",
"def responses\n inline_responses = select { |key, value| key != :table_inputs && key != :timestamp && !is_upload?(key) }\n\n upload_response_keys = select { |key, value| is_upload?(key) }.keys\n upload_responses = {}\n upload_response_keys.each do |key|\n upload_responses[key] = get_upload_response(key)\n end\n\n table_response_keys = self[:table_inputs] ? self[:table_inputs].map { |ti| ti[:key] }.uniq : []\n table_responses = {}\n table_response_keys.each do |key|\n table_responses[key.to_sym] = get_table_responses_column(key)\n end\n\n inline_responses.merge(table_responses).merge(upload_responses)\n end",
"def get_questions\n result = QuizQuestion.includes(:quiz_answers).where(quiz_id: params[:id])\n\n @questions = result.map { |question| QuestionPresenter.new(question) }\n end",
"def index\n @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def all_answered_questions\n self.all_answered_options.map{ |answer| answer.question }\n end",
"def foreach_question\n CollectionWrapper.new(@questions, QuestionWrapper, view_context)\n end",
"def items_from_response\n ids = item_ids\n items = klass.where(:id => ids).group_by(&:id)\n ordered_items(ids, items)\n end",
"def question_response_params\n p = params.require(:question_response).permit(:response, :subject, :responder, :question)\n p[:subject] = Entity.find(p[:subject])\n p[:responder] = Member.find(p[:responder])\n p[:question] = Question.find(p[:question])\n p\n end",
"def remaining_responses\n game.current_round.question.answers - game.current_round.response(self).count\n end",
"def generate_survey_responses_data\n @survey_responses_data = []\n \n CSV.open(@survey_responses_file).map do |line|\n @survey_responses_data << {\n email: line[0],\n employee_id: line[1],\n submitted_at: line[2],\n responses: line[3..-1]\n }\n end\n\n @survey_responses_data\n end",
"def responses_for(data_export_identifier)\n Response.includes([:answer, :question, :response_set]).where(\n \"response_sets.user_id = ? AND questions.data_export_identifier = ?\", self.id, data_export_identifier).\n order(\"responses.created_at\")\n end",
"def count_group_responses(questions)\n questions.map{|q| responses.select{|r| (r.question_id.to_i == q.id.to_i) && !r.response_group.nil?}.group_by(&:response_group).size }.max\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def show\n # @answers = @response.answers\n # @questionnaire_name = @response.questionnaire.name\n # @user = @response.user\n end",
"def most_answers_questions\n\t\tquestions = Question.most_answers_questions\n\t\t#checking questions is present or not.\n\t\tif questions.present?\n \trender :json=> {success: true, \"question\" => questions.as_json(\"question_data\") }\n\t # render json: { success: true, response: @questions.map{ |f| QuestionSerializer.new(f).as_json( root: false ) } }\n\t else\n\t render :json=> { success: false, message: \"Questions are not present\" },:status=> 203\n\t end\n\tend",
"def try_to_convince_other_responders(poll)\n\t\tif poll.expert_user == self\n\t\t\t# Create a hash to remember who will have been convinced\n\t\t\thash = Hash.new()\n\t\t\tpoll.questions.each do |question|\n\t\t\t\tcurrent_array = Array.new()\n\t\t\t\thash.store(question.id, current_array)\n\n\t\t\t\tpoll.participants.each do |participant|\n\t\t\t\t\t# Save current choice in history\n\t\t\t\t\tparticipant.chosen_answer_for_question(question).history_be_chosen_by!(participant)\n\n\t\t\t\t\tunless participant == self\n\t\t\t\t\t\tunless participant.chosen_answer_for_question(question) == self.chosen_answer_for_question(question)\n\t\t\t\t\t\t\tif random_number_is_under(self.influence)\n\t\t\t\t\t\t\t\t# The participant has changed his mind\n\t\t\t\t\t\t\t\tparticipant.chosen_answer_for_question(question).be_not_chosen_by!(participant)\n\t\t\t\t\t\t\t\t# He chooses the answer chosen by the expert\n\t\t\t\t\t\t\t\tself.chosen_answer_for_question(question).be_chosen_by!(participant)\n\t\t\t\t\t\t\t\t# Add the convinced user to the hash\n\t\t\t\t\t\t\t\tcurrent_array.push(participant.first_name + \" \" + participant.name)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# Returns hash\n\t\thash\n\tend",
"def my_questions\n self.questions.map(&:id)\n end",
"def count_question_responses(question)\n Response.count(:conditions => [\"response_set_id =? AND question_id=?\", self.id, question.id])\n end",
"def index\n #show answers for particular survey\n @survey = Survey.find(params[:survey_id])\n @answers = @survey.answers.order(\"question_id, created_at\")\n \n #show answers for specific question\n if (params[:question_id])\n @question = Question.find(params[:question_id])\n @answers = @question.answers.order(\"question_id, created_at\")\n end\n #show answers for specific response\n if (params[:response_id])\n @response = Response.find(params[:response_id])\n @answers = @response.answers.order(\"question_id\")\n end\n end",
"def questions\n return nil unless self.id?\n SurveyQuestion.subclasses.collect do |table|\n table.where(survey: self)\n end.compact.flatten.sort_by(&:sort_index)\n end",
"def not_duplicate_response\n if respondent_already_answered?\n self.errors[:duplicate] << \"You've already answered this question.\"\n end\n end",
"def sub_questions\n @sub_questions ||= lime_group.lime_questions.select{|question|question.parent_qid == qid}\n end"
] |
[
"0.7329625",
"0.6650163",
"0.6506545",
"0.6506545",
"0.64659095",
"0.64549106",
"0.6346589",
"0.6340093",
"0.63355917",
"0.624607",
"0.6175839",
"0.6162994",
"0.6161303",
"0.6161219",
"0.6119024",
"0.60971034",
"0.6080812",
"0.6062206",
"0.60487366",
"0.6040555",
"0.6037918",
"0.60283244",
"0.5986116",
"0.5938805",
"0.5933152",
"0.5879363",
"0.58708644",
"0.5845089",
"0.58297384",
"0.5813852",
"0.5802692",
"0.57877326",
"0.5765472",
"0.57599175",
"0.5736744",
"0.5726133",
"0.57199615",
"0.57096916",
"0.57096916",
"0.56921303",
"0.56866544",
"0.56856555",
"0.56801546",
"0.56768423",
"0.5657509",
"0.5656944",
"0.5644317",
"0.5638781",
"0.5623338",
"0.5588168",
"0.5585137",
"0.5581667",
"0.5581591",
"0.5573746",
"0.5562",
"0.5552199",
"0.5550861",
"0.55465615",
"0.554367",
"0.55078703",
"0.55067587",
"0.5494536",
"0.5479803",
"0.547801",
"0.5475639",
"0.5470463",
"0.5463083",
"0.5433648",
"0.54151404",
"0.5414954",
"0.54148716",
"0.5405061",
"0.54013616",
"0.5395249",
"0.53862435",
"0.53719383",
"0.53623897",
"0.5355969",
"0.5355969",
"0.5355969",
"0.5355969",
"0.5355969",
"0.53556275",
"0.53556144",
"0.5345123",
"0.53435403",
"0.534024",
"0.5335162",
"0.53263164",
"0.53257036",
"0.532301",
"0.53226614",
"0.53209823",
"0.53208625",
"0.5312915",
"0.5310238",
"0.5305412",
"0.5296603",
"0.52950466",
"0.52921647"
] |
0.6531143
|
2
|
see if any sibling response exists with the same respondent_id
|
def respondent_already_answered?
sibling_responses.exists?(user_id: user_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def respondent_already_answered?\n sibling_responses.exists?(responder_id: self.responder_id)\n end",
"def respondent_already_answered?\n sibling_responses.where('user_id = ?', self.user_id).exists?\n end",
"def sibling_responses\n # self.question.responses.where(\"responses.id != ?\", self.id)\n self.question.responses.where.not(id: self.id)\n end",
"def not_duplicate_response\n if respondent_already_answered?\n errors[:user_id] << 'this user has already answered this question'\n end\n # unless sibling_responses.where(user_id: user_id).empty?\n end",
"def sibling_responses\n if !Response.exists?(self) #checks if instance is stored in database\n question.responses #even if instance class = Reponse, returns false if not in database\n else\n self.question.responses\n .where(\"responses.user_id != ?\", respondent.id)\n end\n\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n # exclude yourself\n # load questions, then load responses\n question.responses.where.not(id: id)\n end",
"def sibling_responses\n question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n if self.id\n self.question.responses.where(\"responses.id != ?\", self.id)\n else\n self.question.responses\n end\n end",
"def has_associated_response?\n @associated_responses ||= []\n not @associated_responses.empty?\n end",
"def sibling_responses\n ac = {answer_choice_id: self.answer_choice_id, id: self.id}\n Response.find_by_sql([<<-SQL, ac])\n SELECT\n\t\t\t\t\trespones.*\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tquestions.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tquestions\n\t\t\t\t\t\t\tJOIN answer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tanswer_choices.id = :answer_choice_id\n\t\t\t\t\t) AS quest\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tanswer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tresponses ON responses.answer_choice_id = answer_choices.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(responses.id != :id)\n\t\t\t\tSQL\n end",
"def sibling_responses\n if persisted?\n return self.question.responses\n elsif self.question.responses.includes(self)\n return self.question.responses.where(\"responses.id <> ?\", self.id)\n end\n end",
"def respondent_has_not_already_answered_question\n if sibling_responses.where('user_id != ?', self.user_id).exists?\n errors[:question] << \"You have already answered that question\"\n end\n end",
"def responded_to?(kase)\n !!self.responses.find(:first, :conditions => [\"responses.kase_id = ?\", kase.id])\n end",
"def hasResponses(surveyId)\n return survey_responses.exists?({:survey_id => surveyId})\n end",
"def contains_response_and_soln?() true ; end",
"def expected_duplicate?(id)\n EXPECTED_DUPLICATES.include? id\n end",
"def render_grouped_response? response = @response\n response.grouped?\n end",
"def validate_user_responses(responses)\n failed = false\n puts \"*** VALIDATING USER RESPONSES ***\"\n\n @i = 0\n \n while(@i < responses.length)\n @response = nil\n @index = @i.to_s\n @resp = responses[@index]\n @id = @resp[:id]\n puts \"*** VALIDATING response no. \" + @i.to_s + \", ID=\" + @id + \" ***\" \n \n begin \n @response = Response.find(@id) \n rescue ActiveRecord::RecordNotFound\n puts \"RESPONSE NOT FOUND\"\n failed = true\n break\n end\n\t\n\t\t if (@response.user.id != current_user.id)\n\t\t puts (\"ID MISMATCH: actual: #{current_user.id} expected: #{@response.user.id}\")\n\t\t failed = true\n\t\t break \n\t\t end\n\t\t @i += 1\n\t end\n\t \n return !failed\n end",
"def has_response?\n if @answers.nil? then\n false\n else\n rc = false\n @answers.each do |answer| # loop through Answers\n if !answer.value.blank? then # any response is good enough\n rc = true\n break\n end\n end\n rc\n end\n end",
"def collection_complete?(id)\n responses = self.cache.fetch(id)[:responses]\n return false unless responses.count >= self.nodeUrns.count\n self.nodeUrns.each { |urn| return false unless responses.include? urn }\n return true\n\n end",
"def has_accepted_response?\n self.responses.accepted.any? {|response| response.accepted?}\n end",
"def already_built_response?\n @already_built_response\n end",
"def ocare_child_previously_collected_and_equals_one?(question)\n answer_for(question, ocare_child_response_is_one?)\n end",
"def not_duplicate_response\n if respondent_already_answered?\n self.errors[:duplicate] << \"You've already answered this question.\"\n end\n end",
"def has_responses?\n if is_standard?\n respond_to?(:copy_responses_count_col) ? (copy_responses_count_col || 0) > 0 : copies.any?(&:has_responses?)\n else\n responses_count > 0\n end\n end",
"def duplicate_order?(response)\n response.params.has_key?(:ErrInfo) and response.params[:ErrInfo] == DUPLICATE_ORDER_CODE\n end",
"def find_response(answer_id)\n self.responses.find_by_answer_id(answer_id)\n end",
"def valid_reply?\n # People can send multiple replies to the same message, in which case\n # the recipient is the same as the parent recipient.\n # For most replies, the message recipient should be the parent sender.\n # We use Set to handle both cases uniformly.\n Set.new([sender, recipient]) == Set.new([parent.sender, parent.recipient])\n end",
"def replied_to?\n self.children.length > 0\n end",
"def response_includes?(content)\n @response.body.include?(content)\n end",
"def no_responses\n if self.id && self.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.survey && !survey.template && survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def pending_clarification_requests?\n self.clarification_requests_count > self.clarification_responses_count\n end",
"def pending_clarification_requests?\n self.clarification_requests_count > self.clarification_responses_count\n end",
"def test_relationship_influenced_by_single\r\n response = @rk.relationship_influenced_by(@user_single)\r\n assert_instance_of Hash, response\r\n assert_equal response[\"status\"], 200\r\n end",
"def find_rejected_comments(response)\n decision_ids = Array.new\n post_ids = Array.new\n response['data'].each do |item|\n if item['attributes']['status'] == 'Reject'\n # Get sourceId of post from included section of JSON object\n sourceId = response['included'].find {|i| i['id'] == item['attributes']['commentId']}['attributes']['sourceId']\n decision_ids << item['id']\n post_ids << sourceId\n end\n end\n if decision_ids.any?\n confirm_decisions decision_ids\n reject_posts post_ids\n else\n puts 'No new decisions found.'\n end\n end",
"def following?(other_business_id)\n businesses_in_network.map(&:id).include?(other_business_id)\n end",
"def has_sibling?(peer)\n false\n end",
"def multiple_match?\n acknowledgement_detail = locate_element(@original_body, ACKNOWLEDGEMENT_DETAIL_XPATH)\n return false unless acknowledgement_detail\n\n acknowledgement_detail.nodes.first == MULTIPLE_MATCHES_FOUND\n end",
"def self_reporter_or_proxy?\n responder_id == id\n end",
"def validate_response(response, response_resource_prefix, request_id=nil)\n method = (response_resource_prefix + '_response').to_sym\n response_id = send(method, response[0])\n expect(response_id).to eq(request_id) unless request_id.nil?\nend",
"def has_request_id?(request_id)\n\n self.counts.values.each do |a|\n return true if a[\"requests\"].member?(request_id)\n end\n\n return false\n end",
"def check_duplicates(result, duplicates)\n duplicates.map do |duplicate|\n conflict = duplicate.position_held == result.parent_position_held\n ['Possible clash with parent position held', duplicate] if conflict\n end\n end",
"def has_sibling?(peer); false end",
"def request_sent?(_user_id)\n pending_user_relationships.where(user_id: _user_id).any?\n end",
"def has_response_field?(field, target)\n !!get_response_field(field, target)\n end",
"def no_responses\n #below is code to fix a bizarre bug. When triggered by the \"cut\" function, for some reason survey_id is erased. Have not found reason yet. Temporary fix.\n if !survey_section && self.id\n self.reload\n end\n if self.id && self.survey_section && self.survey_section.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey_section.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.id && !survey_section.survey.template && survey_section.survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def response_to(kase)\n self.responses.find(:first, :conditions => [\"responses.kase_id = ?\", kase.id])\n end",
"def response?\n !!response\n end",
"def siblings?(node_id, other_node_id)\n node_id ^ other_node_id == 1\n end",
"def response?\n !response.nil?\n end",
"def has_answer?(id)\n return @out_answers.key?(id)\n end",
"def no_responses\n if self.id\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if !template && response_sets.count>0\n errors.add(:base,\"Responses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def empty?\n self.responses.empty?\n end",
"def enough_responses?\n game.current_round.response(self).count >= game.current_round.question.answers\n end",
"def div_by_id_exists(id_name)\n return div_by_id(id_name).exist?\nend",
"def replies?\n !replies.empty?\n end",
"def replies?\n !replies.empty?\n end",
"def is_duplicate_request?\n errors.add(:duplicate, \"transfer request.\") if self.class.where(sadhak_profile_id: self.sadhak_profile_id, from_club_id: self.from_club_id, to_club_id: self.to_club_id, status: self.class.statuses['requested']).count > 0\n errors.empty?\n end",
"def reply?\n (!parent.nil? or !parent_id.nil?) and valid_reply?\n end",
"def answered_by?(user)\n replies.exists?(:user_id => user)\n end",
"def message_exists?(response)\n response.respond_to?(:name) && response.name == 'EXISTS'\n end",
"def find_dupes\n @hathi_report_filtered.find_all.with_index do |row, index|\n row if (row['local_id'] == @hathi_report_filtered.at(index + 1)&.[]('local_id')) || (row['local_id'] == @hathi_report_filtered.at(index - 1)['local_id'])\n end.compact\n end",
"def remotely_useful?; self_owned? && remote_siblings.size > 1 end",
"def known?(job_id, interaction_id)\n @requests.include?(key_of(job_id, interaction_id))\n end",
"def resp_pcare_equals_one?(question)\n previous_responses = person.responses_for(\"PARTICIPANT_VERIF.RESP_PCARE\").all\n ri = previous_responses.detect{ |r| r.answer.try(:reference_identifier).to_i == 1 } ? true : false\n answer_for(question, ri)\n end",
"def test_twice_fail\n enter_the_room \"zark\"\n result=enter_the_room \"zark\", {:check_response => false}\n assert last_response.ok?, \"response was:\"+last_response.body\n assert result[\"result\"]==\"duplicate\"\n end",
"def find_if_used_in_calls\n #Call.where(\"did_id = #{self.id}\").first ? false : true\n self.call_count.to_i > 0 ? false : true\n end",
"def has_sibling_on?(peer)\n\t peer == Roby::Distributed || remote_siblings.include?(peer)\n\tend",
"def register_response(response, request)\n\n @active_requests[request.id][:arduino_responses][request.address[:name]] = response \n\n # if reponse is to an info_request then register services\n if request.id < 0 \n register_services request \n\n # else handle response like a normal resource request\n else \n requests = @active_requests[request.id][:arduino_requests].length\n responses = @active_requests[request.id][:arduino_responses].length\n puts \"[Controller:register_response] number of requests #{requests}, and responses #{responses}\"\n if responses >= requests\n puts \"[Controller:register_response] responses received, id: #{request.id}, content: #{@active_requests[request.id]}\"\n # process_response(@active_requests[request.id][:arduino_responses], request.id) \n process_response request.id\n # @active_requests.delete(request.id) \n end\n end\n end",
"def increment_both_no_reply_count\n return true if seen_second_both_no_reply?\n if seen_first_both_no_reply\n self.seen_second_both_no_reply = true\n else\n self.seen_first_both_no_reply = true\n end\n end",
"def friend_request?(id)\n inverse_friendships.where(user_id: id).any?\n end",
"def parse_response(response)\n return [false, nil] if response.body.blank? || response.parsed_response.nil? || response.response.nil?\n return [true, nil] if response.response.is_a?(Net::HTTPNotFound)\n\n Rails.logger.debug { \"Companies house response #{response}\" }\n\n parse_companies_house_response response.parsed_response\n true\n end",
"def no_loops_in_organization_relationship_graph(seen_ids = [])\n return false if seen_ids.include?(id)\n \n seen_ids << id\n\n parent_organizations.each do |parent|\n if parent.no_loops_in_organization_relationship_graph(seen_ids.dup) == false\n errors[:base] << \"Organization parent/child relationships may not form loops in the organization tree graph\"\n return false\n end\n end\n \n return true\n end",
"def invoice_recordexists(h)\n\t\trows = @database.execute(\"SELECT * FROM invoices WHERE number='#{h['number']}';\")\n\t\tline_rows = @database.execute(\"SELECT * FROM invoice_lines WHERE number='#{h['number']}';\")\n\t\tif(rows.length > 0 && line_rows.length > 0) then\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def fetch_response(id)\n res = @responses[id].response\n @responses.delete(id)\n res\n end",
"def answers_using_the_same_sliders\n return false unless question\n @sibling_questions ||= question.question_set.questions.where(['id != ?', question.id])\n @sibling_questions.map(&:answers).flatten.uniq.select do |a|\n (a.slider_keys & self.slider_keys).any?\n end\n end",
"def note_relateds(hashes)\n hashes.each do |hash|\n if !related_hashtags.include?(hash) && self != hash\n r = relateds.create(:related_id => hash.id, :intersection => 1)\n elsif related_hashtags.include?(hash) && self != hash\n r = relateds.where(:related_id => hash.id).first\n r.intersection += 1\n r.save\n end\n end\n end",
"def my_request(request)\n if self.problems.where({ id: request.problem_id }).any?\n true\n else\n false\n end\n end",
"def fetch_response(id)\n res = @responses[id].response\n @responses.delete(id)\n res\n end",
"def any_duplicates?\n return @any_duplicates if defined? @any_duplicates\n\n return @any_duplicates = false if @composition.allow_duplicates?\n\n @any_duplicates = @heroes_by_segment.any? do |map_segment_id, hero_ids|\n hero_ids.uniq.size != hero_ids.size\n end\n end",
"def valid_response_for_answer_sheet?(answers)\n return true if !self.required? \n answer = answers.detect {|a| a.question_id == self.id}\n return answer && answer.value.present?\n # raise answer.inspect \n end",
"def same_children? other\n child_ids = @children.map(&:span_id)\n other_child_ids = other.children.map(&:span_id)\n ::Set.new(child_ids) == ::Set.new(other_child_ids)\n end",
"def participation?(id)\n self.participations.each do | act |\n return true if act.id == id\n end\n return false\n end",
"def complete?\n# self.answers.count == Question.count\n question_set = Question.order(\"order_id asc\").all(:include => :parent_question)\n question_set.reject!{ |q| self.filter_question?(q) }\n\n question_set.each do |q|\n ans = self.answers.find_answer_for_question( q ).first\n if ans.nil?\n return false\n end\n end\n\n return true\n end",
"def notify_response_waiter(response)\n\t\tself.waiters.each() { |waiter|\n\t\t\tif (waiter.waiting_for?(response))\n\t\t\t\twaiter.notify(response)\n\n\t\t\t\tremove_response_waiter(waiter)\n\n\t\t\t\tbreak\n\t\t\tend\n\t\t}\n\tend",
"def has_conflicting_session_with( session )\n has_conflict = false\n\n session.resident_sessions.all.each do |resident_session|\n #puts \">>> finding conflicts with #{resident_session.resident.name}'s session: #{resident_session.session.id} @ #{resident_session.session.time_hhmm}\"\n if has_resident_session_conflict( resident_session )\n has_conflict = true\n end\n end\n\n\n has_conflict\n end",
"def found_error_page_with_same_statuscode_as_we_are_adding(error_pages_to_add, existing_error_page)\n error_pages_to_add.any? do |error_page| \n\t if (!error_page['subStatusCode'].nil?)\n\t error_page['statusCode'] == existing_error_page['statusCode'] && error_page['subStatusCode'] == existing_error_page['subStatusCode']\n\t else\n\t error_page['statusCode'] == existing_error_page['statusCode'] \n\t end\n\tend\n end",
"def response_id\n self['id']\n end",
"def increment_doer_no_reply_count\n return true if seen_second_doer_no_reply?\n if seen_first_doer_no_reply\n self.seen_second_doer_no_reply = true\n else\n self.seen_first_doer_no_reply = true\n end\n end",
"def retweeted?\n retweeted_ids = h.current_user.retweeted_replies.pluck(:id)\n retweeted_ids.include?(self.id)\n end",
"def response_key? key\n self.response_keys.include? key.to_s.strip\n end",
"def wanter_index_and_response token\n found_idx = found_response_code = found = false\n look_lockout do\n current.each do |idx|\n child = @children[idx]\n code = child.look token\n resp = Response[code]\n if (resp.wants?)\n found = true;\n found_idx = idx\n found_response_code = code\n break\n end\n end\n end\n if found\n response = Response[found_response_code]\n [found_idx, response]\n else\n [nil, nil]\n end\n end",
"def employment_duplicated?\n employments = @restaurant.employments.select { | employment | employment.employee == @employment.employee }\n if employments.size > 1\n flash[:error] = \"Employee is already associated with that restaurant\"\n render :new\n else\n return false\n end\n end",
"def has_siblings?\n return call_ancestry_method(:has_siblings?) if use_ancestry?\n\n relationships.any?(&:has_siblings?)\n end",
"def report_match?(other_report, self_report)\n keys_with_expected_diffs = ['receive_time', 'resource_events']\n same_num_elements?(other_report, self_report) && same_contents?(other_report, self_report, keys_with_expected_diffs)\n end",
"def is_sibling_of?(other)\n (other != self) and (other[tree_parent_id_field] == self[tree_parent_id_field])\n end",
"def check_in_all_respond(type, atr, value)\n all_results.map { |result| check_in_result(result, type, atr, value) }.uniq\nend",
"def latest_response\n return nil if self.invite_responses.empty?\n self.invite_responses.first\n end"
] |
[
"0.76925874",
"0.7279114",
"0.6903097",
"0.6882504",
"0.6853014",
"0.6681651",
"0.6681651",
"0.66347",
"0.6610954",
"0.6606145",
"0.65704745",
"0.63962346",
"0.6159311",
"0.61430603",
"0.6081521",
"0.6046843",
"0.5690411",
"0.56268024",
"0.56240535",
"0.5583392",
"0.55649704",
"0.5555849",
"0.550998",
"0.5484042",
"0.54690087",
"0.54183006",
"0.5364194",
"0.53407013",
"0.5337563",
"0.5317798",
"0.5310989",
"0.53036815",
"0.5229826",
"0.52266836",
"0.52266836",
"0.5218901",
"0.5217046",
"0.5199891",
"0.51753336",
"0.51701033",
"0.5169084",
"0.51675063",
"0.5155574",
"0.5150467",
"0.51504356",
"0.5149387",
"0.51434636",
"0.5139842",
"0.5132942",
"0.509804",
"0.5095011",
"0.5082884",
"0.50706226",
"0.5040577",
"0.5039569",
"0.5032149",
"0.5031092",
"0.5006697",
"0.5006697",
"0.4988147",
"0.49706125",
"0.49653372",
"0.49570557",
"0.49545947",
"0.49484116",
"0.49449876",
"0.49332675",
"0.49303368",
"0.49258903",
"0.49172834",
"0.49155957",
"0.49094754",
"0.4902735",
"0.48999923",
"0.489625",
"0.48898375",
"0.4889368",
"0.48890898",
"0.48794183",
"0.48659885",
"0.48654014",
"0.4861621",
"0.48584262",
"0.48567247",
"0.48489895",
"0.4848558",
"0.48449868",
"0.48438728",
"0.4826898",
"0.48235303",
"0.48208874",
"0.48153445",
"0.48117623",
"0.4811144",
"0.48099476",
"0.48061648",
"0.48041692",
"0.48026782",
"0.48026463",
"0.48016468"
] |
0.730623
|
1
|
User Can't Create Multiple Responses To The Same Question
|
def not_duplicate_response
if respondent_already_answered?
errors[:user_id] << 'this user has already answered this question'
end
# unless sibling_responses.where(user_id: user_id).empty?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n \n respond_to do |format|\n \n if !params[:questions].nil? \n params[:questions].each {\n |q| \n type = Question.find_by_id(q[0]).question_type\n answer = (type == 2 ? Answer.find_by_id(q[1]).correct : nil)\n Response.new( \n {\n \"question_id\" => q[0],\n \"answer_id\" => type == 2 ? q[1] : nil,\n \"text\" => type == 1 ? q[1] : nil,\n \"user_id\" => current_user.id,\n \"question_group_id\" => params[:response][:question_group_id],\n \"correct\" => answer\n }\n ).save\n }\n format.html { redirect_to '/responses', notice: 'Your responses were successfully saved.' }\n else\n @response = Response.new(params[:response])\n if @response.save\n format.html { redirect_to @response, notice: 'Response was successfully created.' }\n format.json { render json: @response, status: :created, location: @response }\n end\n end\n end\n end",
"def create_question_responses\n 10.times do\n response = Response.create(content: \"that sucks\", response_context_type: \"Question\", response_context_id: rand(1..12))\n User.find(rand(3)+1).responses << response\n end\nend",
"def not_duplicate_response\n if respondent_already_answered?\n self.errors[:duplicate] << \"You've already answered this question.\"\n end\n end",
"def respondent_has_not_already_answered_question\n if sibling_responses.where('user_id != ?', self.user_id).exists?\n errors[:question] << \"You have already answered that question\"\n end\n end",
"def create\n if not session[:user_id]\n session[:user_id] = params[:user_id]\n redirect_to(problem_set_question_path(session[:prob_id], session[:ques_id])) \n else\n @problem_set = ProblemSet.find(params[:problem_set_id]) \n @question = Question.find(params[:question_id])\n @answer = Answer.find(params[:response])\n @response = Response.new( :answer_id => @answer.id, :result => @answer.correct, :question_id => @question.id, :problem_set_id => @problem_set.id, :user_id => session[:user_id]) \n \n if @problem_set.question_count > @question.count\n next_question = Question.where(:problem_set_id => @problem_set.id, :count => @question.count + 1).first\n result = problem_set_question_path(@problem_set.id, next_question.count)\n else\n result = \"/problem_sets/#{@problem_set.id}/result/\"\n end\n respond_to do |format|\n if @response.save\n format.html { redirect_to(result, :notice => 'Response was successfully created.') }\n format.xml { render :xml => @response, :status => :created, :location => @response }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @response.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def create\n @question = Question.new(params[:question])\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question.problem_set_id = @problem_set.id\n @question.count = @problem_set.question_count + 1\n\n c = false\n ans = false\n\n @ans1 = Answer.new(params[:answer1]) \n @ans2 = Answer.new(params[:answer2]) \n @ans3 = Answer.new(params[:answer3]) \n @ans4 = Answer.new(params[:answer4]) \n\n if @ans1.correct or @ans2.correct or @ans3.correct or @ans4.correct\n c = true\n end\n if params[:answer1][:answer] == \"\"\n @ans1 = nil\n end\n if params[:answer2][:answer] == \"\"\n @ans2 = nil\n end\n if params[:answer3][:answer] == \"\"\n @ans3 = nil\n end\n if params[:answer4][:answer] == \"\"\n @ans4 = nil\n end\n\n if @ans1 or @ans2 or @ans3 or @ans4\n ans = true \n end\n\n respond_to do |format|\n if c and ans \n if @question.save\n @problem_set.question_count += 1\n @problem_set.save \n if @ans1\n @ans1.question_id = @question.id\n @ans1.save\n end\n \n if @ans2\n @ans2.question_id = @question.id\n @ans2.save\n end\n\n if @ans3\n @ans3.question_id = @question.id\n @ans3.save\n end\n \n if @ans4\n @ans4.question_id = @question.id\n @ans4.save\n end\n\n format.html { redirect_to(problem_set_questions_path(@problem_set), :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ans1, :status => :unprocessable_entity }\n end\n end\n end",
"def no_responses\n if self.id && self.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.survey && !survey.template && survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def create\n \n @user_answer = UserAnswer.new(user_answer_params)\n count = 0\n \n #Loop through questions indefinitely\n respond_to do |format|\n if @user_answer.save\n @question = Question.where(id: @user_answer.question_id).first\n @quiz_id = @question.quiz_id\n @questions = Question.where(quiz_id: @quiz_id)\n @numquestions = @questions.count\n @quizzes = Quiz.where(id: @quiz_id)\n @lessonId = @quizzes.first.lesson_id\n\n if @question.questionNum < @numquestions\n @test = @questions.where('id > ?', @question.id).order(id: :asc).first\n\n format.html { redirect_to :controller=>'questions', :id => @test, :action=>'show', notice: 'User answer was successfully created.'}\n else\n #format.html { redirect_to :controller=>'questions', :id=>@questions.shuffle.first.id, :action=>'show' }\n format.html { redirect_to :controller=>'questions', :id=>@questions.first.id, :action=>'show' }\n end\n else\n format.html { render :new }\n format.json { render json: @user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def no_responses\n if self.id\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if !template && response_sets.count>0\n errors.add(:base,\"Responses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def no_responses\n #below is code to fix a bizarre bug. When triggered by the \"cut\" function, for some reason survey_id is erased. Have not found reason yet. Temporary fix.\n if !survey_section && self.id\n self.reload\n end\n if self.id && self.survey_section && self.survey_section.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey_section.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.id && !survey_section.survey.template && survey_section.survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def create_response\n\t\t@response = Response.create(player_id: current_player.id, option_id: params[:option])\n\t\t@question = @response.option.question\n\t\t@total_questions = @question.artist.questions.count\n\t\t@answered = params[:correct].to_i\n\t\tif (@response.option.correct) && (@answered < @total_questions) \n\t\t\t@answered += 1\n\t\t\tredirect_to category_artist_path(last_question: @question.id, correct: @answered,\n\t\t\tcategory_id: @question.artist.category.id, id: @question.artist.id)\n\t\telsif @response.option.correct\n\t\t\tredirect_to category_path(@question.artist.category)\n\t\telse\n\t\t\tartist = @response.option.question.artist\n\t\t\tredirect_to category_path(artist.category), notice: \"Sorry try again!\"\n\t\tend\n\tend",
"def create\n @response = Response.new(params[:response])\n @response.ip_address = request.remote_ip\n @response.survey_id = @survey.id\n @response.user_id = current_user\n \n for param in params do\n if param[0] =~ /^question_id_/\n # handle all question parameters\n # $' represents the value of the question_id\n if param[1].is_a? Hash\n # Valid keys include country, option, year, month, day and numeric option_id\n if param[1].has_key? \"year\" && \"month\" && \"day\"\n # concat year, month and day into one answer\n @response.answers.build(:question_id => $', :answer => Date.new(param[1][\"year\"].to_i, param[1][\"month\"].to_i, param[1][\"day\"].to_i) )\n elsif param[1].has_key? \"option\"\n # look up option id for radio & select questions and build answer\n option_id = Option.find_by_label_and_question_id(param[1][\"option\"], $').id\n @response.answers.build(:question_id => $', :answer => param[1][\"option\"], :option_id => option_id)\n elsif param[1].has_key? \"country\"\n # build country answer\n @response.answers.build(:question_id => $', :answer => param[1][\"country\"])\n else\n # build checkbox and likert answers\n param[1].each do |key, value|\n @response.answers.build(:question_id => $', :answer => value, :option_id => key) unless value == \"0\"\n end\n end\n else\n # build answer without option ie text, textarea\n @response.answers.build(:question_id => $', :answer => param[1] ) #unless param[1].blank?\n end \n end\n if param[0] == 'token'\n @response.survey.update_invitation(param[1])\n end\n end\n\n respond_to do |format|\n if @response.save!\n flash[:notice] = 'Response was successfully created.'\n format.html { redirect_to([@survey, @response]) }\n format.xml { render :xml => @response, :status => :created, :location => @response }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @response.errors, :status => :unprocessable_entity }\n end\n end\n rescue ActiveRecord::RecordInvalid => invalid\n render :action => \"new\"\n end",
"def create\n question_response = QuestionResponse.build_response_essay(current_user, params)\n\n if question_response.try :save\n render json: { message: \"answer saved\" }\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end",
"def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end",
"def create \t\n\t \t# TODO: make sure that there are no duplicates for questions\n\t \t\n\t \tif params[:question].nil?\n\t \t\t@error_message = 'ERROR: no question parameter provided'\n \t\telsif params[:question][:short_name].nil? or params[:question][:short_name].empty?\n \t\t\t@error_message = 'ERROR: no short name provided'\n \t\telsif params[:question][:text].nil? or params[:question][:text].empty?\n \t\t\t@error_message = 'ERROR: no question text provided'\n \t\telsif params[:question][:question_type].nil? or params[:question][:question_type].empty?\n \t\t\t@error_message = 'ERROR: no question type provided'\n\t\telsif params[:question][:domain].nil? or params[:question][:domain].empty?\n\t\t\t@error_message = 'ERROR: no question domain provided'\n\t\telsif not [Question::UNFILED_DOMAIN,Question::PROFILE_DOMAIN,Question::FEEDBACK_DOMAIN].include?(params[:question][:domain].downcase)\n\t\t\t@error_message = 'ERROR: invalid question domain provided'\n \t\telsif not ['Text','Multiple Choice','Multiple Selection'].include?(params[:question][:question_type])\n \t\t\t@error_message = 'ERROR: invalid question type'\n \t\telsif params[:question][:question_type] != 'Text' and (params[:choices].nil? or params[:choices].empty?)\n \t\t\t@error_message = 'ERROR: did not specify choices for a choice question' \t\t\t\n \t\telse\n\t\t \tquestion_type = _condense_question_type(params[:question][:question_type])\n \t\t\t# TODO: make sure that there are no duplicates\n\t\t \t \t\t\t\n\t\t \tif question_type.nil?\n \t\t\t\t@error_message = 'ERROR: could not condense question type properly!'\n \t\t\telse\n\t\t\t \t_create_new_question params[:question][:short_name], params[:question][:text], question_type, params[:question][:domain].downcase, current_user.id, params[:choices]\n\t \t\tend\n \t\tend\n \t\tif @error_message.nil? or @error_message.index('ERROR').nil? # if there is an error, stay on this page; else, allow user to continue\n \t\t\tredirect_to :action => :index\n \t\tend\n\tend",
"def create\n @question = Question.new(question_params)\n link_response_sets(params)\n\n if @question.all_versions.count >= 1\n if @question.not_owned_or_in_group?(current_user) || @question.prev_not_owned_or_in_group?(current_user)\n render(json: @question.errors, status: :unauthorized) && return\n elsif @question.all_versions.last.status == 'draft'\n render(json: @question.errors, status: :unprocessable_entity) && return\n end\n @question.version = @question.most_recent + 1\n end\n assign_author\n if @question.save\n render :show, status: :created, location: @question\n else\n # @categories = Category.all\n render json: @question.errors, status: :unprocessable_entity\n end\n end",
"def create\n if (params[:question]!=nil)\n @question = Question.new(params[:question])\n @question.subject_id=session[:subjectid] \n else\n @question = Question.new\n end \n \n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n \n end\n \n if (params[:A]!=nil)\n @choices = Choice.new()\n @choices.value = params[:A]\n @choices.question_id=@question.id\n @choices.save \n end\n if (params[:B]!=nil)\n @choices = Choice.new()\n @choices.value = params[:B]\n @choices.question_id=@question.id\n @choices.save \n end\n if (params[:C]!=nil)\n @choices = Choice.new()\n @choices.value = params[:C]\n @choices.question_id=@question.id\n @choices.save \n end\n \n @choices = Choice.new()\n @choices.value = @question.answer\n @choices.question_id=@question.id\n @choices.save \n \n end",
"def create\n @survey_answers = []\n @all_values = []\n @collect_values = []\n params[:answers].each do|answer_from_user|\n answer_from_user.each {|key,value|\n @all_values << value\n @survey_answers << Answer.new(:surveyname_id => params[:surveyname_id], :question_id => key.to_i, :description => value, :user_id => current_user.id)\n store_values = validate_all_the_questions(key,value)\n @collect_values << store_values if !store_values.nil?\n }\n end\n if @all_values.length == @collect_values.length\n Answer.transaction do\n @survey_answers.each(&:save)\n end\n end\n \n #save the response to survey from user\n if (!@collect_values.blank? && (@all_values.length == @collect_values.length))\n response = Response.new\n response.user_id = current_user.id\n response.surveyname_id = params[:surveyname_id]\n response.save\n redirect_to surveynames_path, :notice => \"Successfully submitted. Thanks for responding!\"\n else\n redirect_to :back, :notice => \"Submittion Failed. Could be because of wrong inputs (or) blank inputs.\n Please re-enter values and submit again.\"\n end\n\n end",
"def start_questionnaire\n # bypassing the need for the user to select the survey - since we're launching with just one 'legislation'\n # When multiple legislations are available, this value will need to be provided by the form\n access_code = params[:survey_access_code] ||\n current_user.try(:default_jurisdiction) ||\n Survey::DEFAULT_ACCESS_CODE\n\n\n # if a dataset isn't supplied, create one for an authenticated user, or mock one for unauthenticated\n @dataset = Dataset.find_by_id(params[:dataset_id]) || (user_signed_in? ? current_user.datasets.create : Dataset.new)\n authorize! :update, @dataset\n\n # use the most recent survey\n @survey = Survey.where(:access_code => access_code).order(\"survey_version DESC\").first\n\n @response_set = ResponseSet.\n create(:survey => @survey,\n :user_id => current_user.try(:id),\n :dataset_id => @dataset.id\n )\n\n if @survey && @response_set\n session[:response_set_id] = current_user ? nil : @response_set.id\n\n if params[:source_response_set_id]\n source_response_set = ResponseSet.find(params[:source_response_set_id]) # TODO: ensure user has rights to copy the response set answers?\n @response_set.copy_answers_from_response_set!(source_response_set)\n end\n\n # flash[:notice] = t('surveyor.survey_started_success')\n redirect_to(surveyor.edit_my_survey_path(\n :survey_code => @survey.access_code, :response_set_code => @response_set.access_code))\n else\n flash[:notice] = t('surveyor.unable_to_find_that_legislation')\n redirect_to (user_signed_in? ? dashboard_path : root_path)\n end\n end",
"def create\n @question = Question.new(text: \"Default\")\n @answer = @question.answers.build(text: \"Answer1\", color: \"red\", score: 100)\n @answer.save\n @answer = @question.answers.build(text: \"Answer2\", color: \"green\", score: 50)\n @answer.save\n @answer = @question.answers.build(text: \"Answer3\", color: \"blue\", score: 0)\n @answer.save\n #This sets all of the default answers to have a score of 0\n GenPackage.all.each do |package|\n @answer_value = package.answer_values.build(score: 0, question_id: @question.id)\n @answer_value.save\n end\n\n #This qill try and save the question, and if it succeeds, then it alerts the use that the question had been created\n respond_to do |format|\n if @question.save\n format.html { redirect_to :planner, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: :planner }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_present\n if self.question.qtype == 'one_response' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n elsif self.question.qtype == 'likert_scale' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n\n elsif self.question.qtype == 'rank_three' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 3 \n array_wanted = [1, 2, 3]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 3 items are ranked.' )\n return false\n end\n\n elsif self.question.qtype == 'rank_five' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 5 \n array_wanted = [1, 2, 3, 4, 5]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 5 items are ranked.' )\n return false\n end\n end\n end",
"def new\n user_id = session[:user_id]\n quiz_id = Question.find(params[:question_id]).quiz_id\n\n @question = Question.find(params[:question_id])\n @question_answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id, :user_id => current_user.id)\n\n # check if user has already submitted an answer for this question\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def create\n #raise params[:question].inspect\n # \n # @question = Question.new(params[:question].except('url').merge('visitor_identifier' => request.session_options[:id], \n # :ideas => params[:question]['question_ideas']))\n @question = Question.new(params[:question])\n #raise @question.inspect\n @question.validate_me\n unless @question.valid?\n render :action => \"new\" and return\n end\n \n just_registered = true\n unless signed_in?\n logger.info \"not signed in, getting ready to instantiate a new user from params in Questions#create\"\n #try to register the user before adding the question\n @user = ::User.new(:email => params[:question]['email'], \n :password => params[:question]['password'], \n :password_confirmation => params[:question]['password'])\n unless @user.valid?\n flash[:registration_error] = \"Sorry, we couldn't register you.\"\n #redirect_to 'questions/new' and return\n logger.info \"Registration failed, here's the flash: #{flash.inspect}\"\n render :action => \"new\" and return\n end\n if @user.save\n logger.info \"just saved the user in Questions#create\"\n sign_in @user\n just_registered = true\n else\n flash[:notice] = \"Sorry, we couldn't register you.\"\n render :action => \"new\" and return\n #render :template => 'users/new' and return\n end\n end\n #at this point you have a current_user. if you didn't, we would have redirected back with a validation error.\n \n @question_two = Question.new(params[:question].except('url').merge({'local_identifier' => current_user.id, 'visitor_identifier' => request.session_options[:id], :ideas => params[:question]['question_ideas']}))\n logger.info \"question pre-save is #{@question.inspect}\"\n respond_to do |format|\n retryable(:tries => 5) do\n if @question_two.save\n @question = @question_two\n earl = Earl.create(:question_id => @question.id, :name => params[:question]['url'].strip)\n logger.info \"Question was successfully created.\"\n session[:standard_flash] = \"Congratulations. You are about to discover some great ideas.<br/> Send out your URL: #{@question.fq_earl} and watch what happens.\"\n ::ClearanceMailer.deliver_confirmation(current_user, @question.fq_earl) if just_registered\n format.html { redirect_to(@question.earl) }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n logger.info \"Question was not successfully created.\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end",
"def sibling_responses\n if !Response.exists?(self) #checks if instance is stored in database\n question.responses #even if instance class = Reponse, returns false if not in database\n else\n self.question.responses\n .where(\"responses.user_id != ?\", respondent.id)\n end\n\n end",
"def create\n question = current_user.questions.new(question_params)\n question.answers.first.creator = current_user\n question.save\n\n # users get one vote for their own questions by default\n # (so their karma/score improves as they create questions)\n current_user.vote_for(question)\n\n msg = %Q[Your question has been submitted! View it #{view_context.link_to(\"here\", qset_path(question_params[:qset_id]))}].html_safe\n redirect_to new_question_path, notice: msg, flash: { html_safe: true }\n end",
"def make_modification\n cur_resp = ResponseSet.where(:user_id => current_user, :access_code => params[:protocol_id]).first\n mod = ResponseSet.create(:user_id=>current_user.id,\n :survey_id => params[:survey_id])\n mod.parent_id = params[:protocol_id]\n mod.save\n resp_set_id = cur_resp.id\n responses = Response.where(:response_set_id => resp_set_id)\n responses.each do |resp| \n answer_attributes = Answer.find(resp.answer_id).attributes\n answer_attributes.delete(\"id\")\n answer_attributes.delete(\"api_id\")\n answer_attributes.delete(\"created_at\")\n answer_attributes.delete(\"updated_at\")\n new_answer = Answer.new(answer_attributes)\n new_answer.save\n resp_attributes = resp.attributes\n resp_attributes.delete(\"id\")\n resp_attributes.delete(\"api_id\")\n resp_attributes.delete(\"created_at\")\n resp_attributes.delete(\"updated_at\")\n resp_attributes[:answer_id] = new_answer.id\n resp_attributes[:response_set_id] = mod.id\n new_resp = Response.new(resp_attributes)\n new_resp.save\n end\n redirect_to :back\n end",
"def respondent_already_answered?\n sibling_responses.exists?(user_id: user_id)\n end",
"def create\n if current_user.member?\n @answer = Answer.new(answer_params)\n @answer.user_id = current_user.id\n @answer.question_id = params[:questid]\n respond_to do |format|\n if @answer.save\n AnswerMailer.answer_email(@answer.question.user,@answer.user).deliver_now\n format.html { redirect_to '/', notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n\n else\n respond_to do |format|\n format.html { redirect_to '/',notice: 'You are not authorized to answer questions' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def update\n # Using first or create allows users to update their answer (or create it obviously)\n answer = Answer.where(:question_id => params[:question_id], :user_id => current_user.id).first_or_create! do |answer|\n answer.user_id = current_user.id\n answer.survey_id = params[:survey_id]\n answer.group_id = current_user.group.id\n answer.question_id = params[:question_id]\n answer.answer = params[:answer]\n\n @created = true\n\n if answer.save\n q = IQuestion.find_by_id(params[:question_id])\n\n if q.present?\n qdes = q.description\n else\n qdes = \"Orphaned question\"\n end\n\n s = ISurvey.find_by_id(params[:survey_id])\n\n if s.present?\n sdes = s.title\n else\n sdes = \"Orphaned survey\"\n end\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"[#{sdes}] #{qdes}:\", params[:answer])\n\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n if !@created && answer\n answer.answer = params[:answer]\n if answer.save\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"Updated Answer: \", params[:answer])\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n end",
"def create\n respond_to do |format|\n if @question.save\n @question_link = QuizQuestion.create!(:qtype => params[:qtype], :qid => @question.id, :quizid => params[:quizid], :points => params[:points])\n @question_link.save\n @question.update(:questionid => @question_link.id)\n @quiz = Quiz.find_by_id(params[:quizid])\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_answers_if\n if self.type.name == 'satisfaction-100'\n 5.times do |n|\n Answer.create(question: self, value: (n*25).to_s + \"%\")\n end\n end\n if self.type.name == 'free-text'\n Answer.create(question: self, value: \"textarea\")\n end\n end",
"def respondent_already_answered?\n sibling_responses.where('user_id = ?', self.user_id).exists?\n end",
"def create\n @answer = current_user.answers.new(answer_params)\n @answer.question = @question\n @question.update(cant_answers: @question.cant_answers + 1)\n @answer.puntaje = 0\n @answer.best = false;\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer.question, notice: 'Respuesta creada satisfactoriamente' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_user_responses(resp)\n @response = Response.find(resp[:id])\n @question = @response.question\n resp_val_string = Response::EMPTY_RESPONSE_VALUE\n if (@question.question_type == Question::TYPES['short_answer'])\n resp_val_string = resp[:response_value]\n elsif (@question.question_type == Question::TYPES['multiple_choice'] || @question.question_type == Question::TYPES['scale'])\n # look through the multiple choice options and see which one is selected\n # note: for now these are implemented in the same way. in the future, scale may be a slider.\n resp_val_string = resp[:response_value]\n elsif (@question.question_type == Question::TYPES['multiple_select'])\n # look through the multiple select options and see which one(s) are selected\n\t @option_count = 0\n\t @option_arr = []\n\t while(@option_count < @response.question.question_options.length)\n\t\tputs \"** OPTION \" + @option_count.to_s + \" ***\"\n\t\t@index = @option_count.to_s\n\t\tif(resp[\"response_values\"][@index] != \"\")\n\t\t\t@option_arr << resp[\"response_values\"][@index]\n\t\tend\n\t\t@option_count += 1\n\t end\n resp_val_string = @option_arr.join(\",\")\n end\n \n puts \"RESPONSE VALUE STRING: #{resp_val_string}\"\n \n if (resp_val_string == \"\")\n return false\n else\n # update the stuff here\n @response.response_value = resp_val_string\n @response.save!\n return true\n end\n end",
"def for_new_question\n @for_new_question ||= false\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def new\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.where(:problem_set_id => params[:problem_set_id])[params[:question_id].to_i - 1]\n if session[:user_id].nil?\n session[:redirect_url] = \"/problem_sets/#{@problem_set.id}/questions/#{@question.count}/responses/new/\"\n redirect_to(\"/login/\")\n else\n if session[:user_id].to_i != 126126126126126\n flash[:notice] = \"NO PERMISSION!\"\n redirect_to :action => \"index\" \n else\n @response = Response.new\n @answer = Answer.where(:question_id => @question.id)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @response }\n end\n end\n end\n end",
"def create_quiz_questionnaire\n create_questionnaire\n end",
"def auto_add_answers\n\t\tperson_names = %w(john micheal jordan arya tyrion sansa khal joffrey ramsay)\n\t\tanswers = [\"Very likely\",\"Somewhat likely\",\"Neutral\",\"Somewhat unlikely\",\"Very unlikely\",\"Very satisfied\",\"Somewhat satisfied\",\"Neutral\",\"Somewhat dissatisfied\",\"Very dissatisfied\"]\n\n\t\t(1..3).to_a.each do |num|\n\t\t\tperson_name = person_names.shuffle.first\n\t\t\tanswer = answers.shuffle.first\n\t\t\tself.answers.create(person_name: person_name, answer: answer)\n\t\tend\n\tend",
"def create\n @current_user = User.find session[:user_id]\n if @current_user.admin\n pa=question_params\n s=pa[:subgenre]\n b=Subgenre.find s.to_i\n @question= Question.new(question: pa[:question],correct_ans: pa[:a]+pa[:b]+pa[:c]+pa[:d],subgenre_id: s)\n if @question.save && b.genre_id == pa[:genre].to_i\n p @choice1 = Choice.new(text: pa[:option1],correct: pa[:a],question_id: @question.id)\n p @choice2 = Choice.new(text: pa[:option2],correct: pa[:b],question_id: @question.id)\n p @choice3 = Choice.new(text: pa[:option3],correct: pa[:c],question_id: @question.id)\n p @choice4 = Choice.new(text: pa[:option4],correct: pa[:d],question_id: @question.id)\n if @choice1.save && @choice2.save && @choice3.save && @choice4.save\n flash[:notice] = \"Question created\"\n flash[:color] = \"valid\"\n redirect_to questions_path\n else\n @question.destroy\n p @choice1.errors\n flash[:notice] = \"Options Incorrect\"\n flash[:color] = \"invalid\"\n redirect_to new_question_path\n end\n else\n @question.destroy\n flash[:notice] = \"Question not created\"\n flash[:color] = \"invalid\"\n redirect_to new_question_path\n end\n else\n flash[:notice] = \"Acces Denied\"\n flash[:color] = \"invalid\"\n redirect_to home_path\n end\n end",
"def check_ids\n if @answer.question != @question\n raise ActionController::RoutingError.new(\"Answer id and Question id do not match\")\n end\n end",
"def touch_multi_choice_answer\n touch if question_type == \"MultiChoiceQuestion\"\n end",
"def create_questionnaire\n\n @questionnaire = Object.const_get(params[:questionnaire][:type]).new(params[:questionnaire])\n\n if @questionnaire.type == \"QuizQuestionnaire\" #checking if it is a quiz questionnaire\n participant_id = params[:pid] #creating a local variable to send as parameter to submitted content if it is a quiz questionnaire\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n\n @assignment = Assignment.find_by_id(params[:aid])\n if @assignment.team_assignment?\n teams = TeamsUser.find(:all, :conditions => [\"user_id = ?\", session[:user].id])\n for t in teams do\n if team = Team.find(:first, :conditions => [\"id = ? and parent_id = ?\", t.team_id, @assignment.id])\n break\n end\n end\n @questionnaire.instructor_id = team.id #for a team assignment, set the instructor id to the team_id\n else\n @questionnaire.instructor_id = participant_id #for an individual assignment, set the instructor id to the participant_id\n end\n save_questionnaire\n save_choices @questionnaire.id\n flash[:note] = \"Quiz was successfully created\"\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => participant_id\n else\n if (session[:user]).role.name == \"Teaching Assistant\"\n @questionnaire.instructor_id = Ta.get_my_instructor((session[:user]).id)\n end\n save_questionnaire\n\n redirect_to :controller => 'tree_display', :action => 'list'\n end\n end",
"def response_params\n params.require(:response).permit(:user, :questionnaire_id, answers_attributes: [:id, :content, :question_id])\n end",
"def respondent_already_answered?\n sibling_responses.exists?(responder_id: self.responder_id)\n end",
"def create\n @question = Question.new(question_params)\n @question.user_id = @user.id\n if @question.save\n redirect_to set_answer_question_path(@question)\n else\n redirect_to new_question_path\n end\n end",
"def create \n\t\tquestionId = params[:questionId]\n\t\tanswerId = params[:answerId]\n\t\tanswer = params[:answer]\n\t\tnumAnswers = params[:numAnswers].to_i\n\n\t\tbegin\n\t\t\tsuccess = ParseManager.createUserAnswer(answer, answerId, questionId)\n\t\t\tnumAnswers -= 1\n\t\tend until numAnswers == 0\n\n\t\trender json:success\n\tend",
"def after_create\n Stat.increment_counter(:reply_count, self.user.stat.id)\n \n if self.yes?\n Question.increment_counter(:yes_count, question.id)\n else\n Question.increment_counter(:no_count, question.id)\n end\n end",
"def not_author_response\n if author_respondent?\n errors[:author] << 'cannot answer their own poll'\n end\n end",
"def create\n #render :json => params[:quiz_answer]\n #return\n @quiz=Quiz.find(params[:quiz_id])\n\n\n @quiz_answer = QuizAnswer.new(quiz_answer_params)\n\n @question=Question.find(params[:quiz_answer][:question_id])\n #render :json => @quiz.questions\n #return\n\n @next_question = (@quiz.questions.map(&:id) - current_user.quiz_answers.map(&:question_id) - [@question.id])\n #render :json => @quiz.questions\n #return\n\n\n respond_to do |format|\n if @quiz_answer.save\n\n #puts \"check next question #{@next_question}\"\n if @next_question == []\n current_user.current_route = \"/my_dashboard\"\n current_user.save!\n #redirect_to snazzmeup_path,:alert=>\"Successfully given quiz response\"\n redirect_to quiz_review_path(@quiz.id), :alert=>\"Successfully given quiz response\"\n return\n else\n @next_question = @next_question[0]\n current_user.current_route = \"/take_test/#{@quiz.id}/#{@next_question}\"\n current_user.save!\n end\n\n format.html { redirect_to take_test_path(@quiz.id,@next_question)}\n format.json { render action: 'show', status: :created, location: @quiz_answer }\n\n else\n format.html { redirect_to take_test_path(@quiz.id, @question.id), notice: 'Howdy!! You need to select one option.' }\n format.json { render json: @quiz_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question = Question.create!(question_params.merge({user_id: 1}))\n if question_params[:answers]\n question_params[:answers].with_indifferent_access.each do |answer|\n Answer.create!(name: answer[:name], question_id: @question.id)\n end\n end\n @question.prepare\n @question.broadcast\n render json: @question, status: :created\n end",
"def create_a_question\n q = ShortQuestion.create({\n :text => params[:text],\n :belongs_to_topic => params[:topic],\n :by => params[:by] || \"admin\",\n :by_id => params[:by_id]\n })\n params[:answers].each do |ans|\n a = q.short_answers.create({\n :text => ans.text,\n :choice_num => ans.choice \n })\n end\n $r.hset(\"question:#{q.id}:answers\", :num_choices, params[:answers].length)\n # Not setting the value of the answers to 0, as any increment will take care of initializing those keys\n end",
"def perform(user, questions)\n \n end",
"def create\n sleep(rand(1..5)) if Rails.env.development?\n answer = Answer.new(params.require(:answer).permit(:question_uuid, :letter))\n answer.user_slug = current_user_slug\n saved = answer.save\n answers = Answer.where(user_slug: current_user_slug).as_react_json\n\n respond_to do |format|\n if saved\n message = 'Risposta registrata correttamente.'\n # Notify tutor\n ActionCable.server.broadcast \"answers_#{answer.question_uuid}\", answer: answer.as_react_json\n format.html { redirect_to lives_path(@live_lecture), notice: message }\n format.json { render json: { result: :success, message: message, answers: answers } }\n else\n message = answer.errors.full_messages.join('. ')\n format.html { redirect_to lives_path(@live_lecture), alert: message }\n format.json { render json: { result: :error, message: message, answers: answers } }\n end\n end\n rescue ActiveRecord::StatementInvalid, StandardError => e\n answers = Answer.where(user_slug: current_user_slug).as_react_json\n\n respond_to do |format|\n format.html { redirect_to lives_path(@live_lecture), alert: e.message }\n format.json { render json: { result: :error, message: e.message, answers: answers } }\n end\n end",
"def create\n @questionnaire = Questionnaire.new(questionnaire_params)\n @questionnaire.user = @current_user_email\n # flash[:alert] = \"----------> #{@questionnaire.is_name_unique?} <-----------\"\n\n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully created.' }\n format.json { render :show, status: :created, location: @questionnaire }\n else\n format.html { render :new }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = @question.answers.build(answer_params)\n @answer.save\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def create\n\t@question = Question.new(params[:question])\n\t if @question.type.name==\"Matrix Type Question\"\n\t @question.answer=100\n\t end\n\t@questionnaire = Questionnaire.find(params[:questionnaire_id])\n\n\trespond_to do |format|\n\t if @question.save\n\t\t@questionnaire_question = QuestionnaireQuestion.new\n\t\t@questionnaire_question.questionnaire_id=@questionnaire.id\n\t\t@questionnaire_question.question_id=@question.id\n\t\t@questionnaire_question.save\n\n\t\ts=\"True\"\n\t\tif @question.type.name==\"True-False Question\"\n\t\t 2.times do |i|\n\t\t\t@option=Option.new\n\t\t\t@option.name=s\n\t\t\ts=\"False\"\n\t\t\t@option.question_id=@question.id\n\t\t\t@option.option_number=(i+1)\n\t\t\t@option.save\n\n\t\t end\n\t\tend\n\t\tif (@question.type.name==\"Open Ended Question\" || @question.type.name==\"True-False Question\") then\n\t\t format.html { redirect_to new_question_path(:questionnaire_id=>@questionnaire.id), :notice => 'Question was successfully created.' }\n\t\telse\n\t\t if (@question.type.name==\"Matrix Type Question\")\n\n\t\t\tformat.html { redirect_to :controller => :matrix, :action => 'index', :question_id=>@question.id, :notice => 'Question was successfully created.' }\n\t\t end\n\t\t format.html { redirect_to new_option_path(:question_id=>@question.id, :notice => 'Question was successfully created.') }\n\t\tend\n\t else\n\t\tformat.html { redirect_to :action => \"new\" ,:questionnaire_id=>@questionnaire.id}\n\t\tformat.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def create\n passed = true\n count = 0\n if params[:status] == \"listOfAnswers\"\n params[:answers].each do |ans|\n @answer = Answer.new(answers_params(ans))\n if @answer.save\n if @answer.correct\n count = count + 1\n # update_result ans[:user_id], ans[:quiz_id]\n end\n else\n passed = false\n end\n end\n if passed\n create_result params[:answers].first[:user_id], params[:answers].first[:quiz_id], count\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n else\n @answer = Answer.new(answer_params)\n if @answer.save\n if @answer.correct\n update_result\n end\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n\n #user query\n @user = User.find(current_user.id)\n\n #profile query\n @profile = Profile.find_by_user_id(@user.id)\n\n #new quiz object\n @quiz = Quiz.new\n\n @level_name = Level.find(@profile.level_id)\n\n #check quiz type\n if params[:test_type][0] == '1'\n @quiz.title = 'Assesment'\n @quiz.description = 'This is a quiz for '+@profile.user_name.to_s+' at all levels'\n @quiz.is_attempted =false\n @quiz.is_complete = false\n @quiz.num_of_questions = 10\n @quiz.user_id = @user.id\n @quiz.level_id = 0\n @quiz.save\n\n @questions = Question.limit(10).order(\"RANDOM()\")\n @quiz.questions << @questions\n \n\n else\n @quiz.title = 'Quiz '+ @level_name.name.to_s\n @quiz.description = 'This is a quiz for '+@profile.user_name.to_s+' at '+ @level_name.name.to_s+' level'\n @quiz.is_attempted =false\n @quiz.is_complete = false\n @quiz.num_of_questions = 10\n @quiz.user_id = @user.id\n @quiz.level_id = @profile.level_id\n @quiz.save\n\n @questions = Question.where(:level_id => @quiz.level_id).limit(10).order(\"RANDOM()\")\n @quiz.questions << @questions\n end\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend",
"def create_answer\n current_stat_id = nil\n factorIds = []\n badFactors = []\n if params[:form_fields] != nil\n params[:form_fields].each do |field|\n current_stat_id = field[1][:statistic_id].to_i\n af = AnsweredFactor.where(factor_id: field[1][:factor_id],\n statistic_id: current_stat_id,\n month: params[:month],\n year: params[:year],\n user_id: current_user.id).first_or_create\n\n af[:amount] = field[1][:value]\n af.save\n\n if af.amount == nil\n badFactors.push(af)\n af.delete\n else\n factorIds.push([af.id, current_stat_id])\n end\n end\n if badFactors.count == 0\n userFactors = rearrangeFactors(factorIds)\n updateAnswer(userFactors,{:month=>params[:month],:year=>params[:year]})\n current_user.score += Mission.getScore(current_user)\n current_user.effective_score += Mission.getScore(current_user)\n current_user.save\n end\n end\n if badFactors.count == 0 and factorIds.count != 0\n redirect_to statistics_path\n else\n redirect_to emissions_template_path, alert: \"Factor cannot be left blank.\"\n end\n end",
"def create\n @effort = @question.efforts.new(effort_params)\n @effort.question = @question\n @effort.quest = @quest\n\n # if @question.answer.content.downcase == @effort.content.downcase --> Doesn't work !!!\n # @effort.status = \"correct\"\n # else\n # @effort.status = \"wrong\"\n # end\n if @effort.save!\n\n @all_questions = @quest.challenge.questions.to_a\n @answered_questions = @quest.efforts.map(&:question)\n @remaining_questions = @all_questions - @answered_questions\n\n unless @remaining_questions.empty?\n next_question_id = @remaining_questions.first.id\n puts @question.id\n @question = Question.find(next_question_id)\n puts @question.id\n redirect_to student_quest_question_path(@quest, @question)\n else\n # Takes them back to profile if finished\n # TODO - change this to results page or flash message?\n redirect_to student_profile_path\n end\n else\n session[:return_to] ||= request.referer\n end\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(params[:answer])\n @answer.user = current_user\n @answer.score = 0\n @answer.fav = 0\n @user = User.find(@question.user_id)\n\n respond_to do |format|\n if @answer.save\n UserMailer.answer_email(@user).deliver\n format.html { redirect_to @question, notice: 'Respuesta creada correctamente.' }\n format.json { render json: @question, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n questions_arr.each do |i|\n question = Question.new(question_params(i))\n choices_arr(i).each do |j|\n choice = Choice.new(choice_params(j))\n choice.save\n question.choices << choice\n end\n @quiz.questions << question\n end\n\n if @quiz.save\n User.find(params[:user_id]).quizzes << @quiz\n render json: @quiz, status: :created, location: @quiz\n else\n render json: @quiz.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\n\t@exam_answer = ExamAnswer.new(exam_answer_params)\n\tif @exam_answer.exam_id == 999\n\t\t@exam_answer.exam_level = params[:exam_lv]\n\t\t@questions = Question.all.where(level: params[:exam_lv])\n\t\t@exams_questions = @questions.all.where(id: [params[:q1_id], params[:q2_id], params[:q3_id], params[:q4_id], params[:q5_id], params[:q6_id], params[:q7_id], params[:q8_id], params[:q9_id], params[:q10_id]])\n\telse\n\t\t@exam = Exam.find(@exam_answer.exam_id)\n\t\t@exam_answer.exam_level = @exam.level\n\t\t@questions = Question.all.where(level: @exam_answer.exam_level)\n\t\t@exams_questions = @questions.all.where(id: [@exam.question1, @exam.question2, @exam.question3, @exam.question4, @exam.question5, @exam.question6, @exam.question7, @exam.question8, @exam.question9, @exam.question10])\n\tend\n\t\n\t@exam_answer.user_id = current_user.id\n\t@exam_answer.ans1 = params[:q1]\n\t@exam_answer.q1 = (@exam_answer.ans1 == @exams_questions[0].answerR ? true : false)\n\t@exam_answer.ans2 = params[:q2]\n\t@exam_answer.q2 = (@exam_answer.ans2 == @exams_questions[1].answerR ? true : false)\n\t@exam_answer.ans3 = params[:q3]\n\t@exam_answer.q3 = (@exam_answer.ans3 == @exams_questions[2].answerR ? true : false)\n\t@exam_answer.ans4 = params[:q4]\n\t@exam_answer.q4 = (@exam_answer.ans4 == @exams_questions[3].answerR ? true : false)\n\t@exam_answer.ans5 = params[:q5]\n\t@exam_answer.q5 = (@exam_answer.ans5 == @exams_questions[4].answerR ? true : false)\n\t@exam_answer.ans6 = params[:q6]\n\t@exam_answer.q6 = (@exam_answer.ans6 == @exams_questions[5].answerR ? true : false)\n\t@exam_answer.ans7 = params[:q7]\n\t@exam_answer.q7 = (@exam_answer.ans7 == @exams_questions[6].answerR ? true : false)\n\t@exam_answer.ans8 = params[:q8]\n\t@exam_answer.q8 = (@exam_answer.ans8 == @exams_questions[7].answerR ? true : false)\n\t@exam_answer.ans9 = params[:q9]\n\t@exam_answer.q9 = (@exam_answer.ans9 == @exams_questions[8].answerR ? true : false)\n\t@exam_answer.ans10 = params[:q10]\n\t@exam_answer.q10 = (@exam_answer.ans10 == @exams_questions[9].answerR ? true : false)\n\t\n\trec_point = (@exam_answer.q1 ? 1:0) + (@exam_answer.q2 ? 1:0) + (@exam_answer.q3 ? 1:0) + (@exam_answer.q4 ? 1:0) + (@exam_answer.q5 ? 1:0) + (@exam_answer.q6 ? 1:0) + (@exam_answer.q7 ? 1:0) + (@exam_answer.q8 ? 1:0) + (@exam_answer.q9 ? 1:0) + (@exam_answer.q10 ? 1:0)\n\tpoints = rec_point/10.to_f\n\tif @exam_answer.exam_id == 999\n\t\tif params[:exam_lv] == \"Początkujący\"\n\t\t\tpoints2 = points*10.to_i\n\t\telse\n\t\t\tpoints2 = points*20.to_i\n\t\tend\n\telse\n\t\tpoints2 = points*@exam.points.to_i\n\tend\n\t@exam_answer.rec_points = points2\n\n\tif @exam_answer.exam_id == 999\n\t\ttemp = 7/10.to_f\n\t\tif params[:exam_lv] == \"Początkujący\"\n\t\t\t@min = temp*10.to_i\n\t\telse\n\t\t\t@min = temp*20.to_i\n\t\tend\n\telse\n\t\ttemp = 7/10.to_f\n\t\t@min = temp*@exam.points.to_i\n\tend\n\n\tif @exam_answer.rec_points >= @min\n\t\t@user_progress = UserProgress.find_by user_id: current_user.id\n\t\tif @exam_answer.exam_id == 999\n\t\t\tif params[:exam_lv] == \"Początkujący\" && @user_progress.p10?\n\t\t\t\t@user_progress.update(poczatkujacy: true)\n\t\t\telsif params[:exam_lv] == \"Zaawansowany\" && @user_progress.z10?\n\t\t\t\t@user_progress.update(complete_all: true)\n\t\t\t\t@user_progress.update(zaawansowany: true)\n\t\t\tend\n\n\n\t\telse\n\n\t\t\tif @exam.level == \"Początkujący\" && @user_progress.p10?\n\t\t\t\t@user_progress.update(poczatkujacy: true)\n\t\t\telsif @exam.level == \"Zaawansowany\" && @user_progress.z10?\n\t\t\t\t@user_progress.update(complete_all: true)\n\t\t\t\t@user_progress.update(zaawansowany: true)\n\t\t\tend\n\t\tend\n\t\tcurrent_user.increment!(:points, points2)\n\t\trespond_to do |format|\n\t\t if @exam_answer.save\n\t\t format.html { redirect_to @exam_answer, :notice => \"Zdales egzamin!.\" }\n\t\t format.json { render :show, status: :created, location: @exam_answer }\n\t\t else\n\t\t format.html { render :new }\n\t\t format.json { render json: @exam_answer.errors, status: :unprocessable_entity }\n\t\t end\n\t\tend\n\t\t\n\telse\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to exam_list_path , :notice => \"Nie zdales egzaminu, zdobyles za malo punktow, liczba otrzymanych punktow - #{@exam_answer.rec_points} , minimum do zdania - #{@min}\" }\n\t\t format.json { render exam_list_path, status: :unprocessable_entity , location: exam_list }\n\t\tend\n\tend\nend",
"def create\n @reply_answer = ReplyAnswer.new(reply_answer_params)\n\n @answer = Answer.find_by_id(@reply_answer.answer_id)\n @replyer = User.find_by_id(@reply_answer.user_id)\n @answerer = User.find_by_id(@answer.user_id)\n @question = Question.find_by_id(@reply_answer.question_id)\n\n\n # Sends email to original answerer letting them know that a reply has been made.\n UserMailer.reply_to_answer_question(@question, @answerer, @replyer, @answer, @reply_answer).deliver\n\n respond_to do |format|\n if @reply_answer.save\n format.html { redirect_to question_path(@reply_answer.question_id), notice: 'Reply answer was successfully created.' }\n format.json { render :show, status: :created, location: @reply_answer }\n else\n format.html { render :new }\n format.json { render json: @reply_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find_or_create_by_id(params[:participant_id], group: params[:group])\n @response = @user.responses.find_or_create_by_error_and_round_number(params[:response][:id], params[:response][:round_number])\n @response.update_attributes(params[:response])\n\n respond_to do |format|\n if @response.save\n format.js\n format.html { redirect_to(@response, notice: 'Response was successfully created.') }\n format.xml { render xml: @response, status: :created, location: @response }\n\n else\n format.js { render js: \"#{ @response.errors}\" }\n format.html { render action: 'new' }\n format.xml { render xml: @response.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def create_questionnaire_response(data)\n attrs = data.to_h.with_indifferent_access\n response = questionnaire_response_service.create(attrs)\n\n response.tap do |resp|\n if resp.response[:code] == SUCCESS_STATUS\n questionnaire_response.tap do |qr|\n qr.user_uuid = user.uuid\n qr.user_account = user.user_account\n qr.appointment_id = attrs.dig(:appointment, :id)\n qr.questionnaire_response_id = resp.resource.id\n qr.user = user\n qr.questionnaire_response_data = data\n\n qr.save\n end\n end\n end\n end",
"def create\n workout = Workout.find params[:workout_id]\n result = Question.create(workout, { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n @question = result[:question]\n\n respond_to do |format|\n unless @question.persisted?\n format.json { render :json => @question.errors.full_messages, :status => :unprocessable_entity }\n else\n format.json { render :json => @question.as_json({:include => :answers}) }\n end\n \n end\n\n end",
"def valid_response_for_answer_sheet?(answers)\n return true if !self.required? \n answer = answers.detect {|a| a.question_id == self.id}\n return answer && answer.value.present?\n # raise answer.inspect \n end",
"def destroyable?\n self.submitted_answers.empty?\n end",
"def respondent_is_not_author_poll?\n #\n # respondend.id == author.id\n\n if question.poll.author.id == user.id\n errors[:user_id] << 'author should not answer to his/her poll'\n end\n end",
"def send_questionnaire\n @user = current_employee\n success = false\n @vendor_questionnaire = VendorQuestionnaire.new(params[:vendor_questionnaire])\n @vendor_questionnaire.employee_id = @user.id\n if @vendor_questionnaire.save\n params[:approver_id].each do |f|\n @vendor_questionnaire.vendor_questionnaire_groups.new({questionnaire_group_id: f[0],approver_id: f[1]}).save #f[0] questionnaire_group_id f[1] employee_id \n end\n success = true\n else\n success = false\n end \n respond_to do |format|\n if success\n format.html { redirect_to show_question_path(@vendor_questionnaire), notice: 'Sent questionnaire successfully.' }\n format.json { render json: @vendor_questionnaire, status: :created, location: show_question_path(@vendor_questionnaire) } \n else\n format.html { render :action => \"init_questionnaire_workflow\" }\n format.json { render json: @vendor_questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def duplicated_question\n duplicator = Duplicator.new({}, current_course: current_course)\n duplicator.duplicate(@question.specific).acting_as\n end",
"def create_assessment\n @unique_questions = []\n\n questions = QuizQuestion.for_language_course(self, [\"multiple_choice\", \"short_answer\"])\n questions_grouped_by_lesson = questions.group_by(&:lesson_id).values.shuffle\n\n setup_multiple_choice_questions(questions_grouped_by_lesson)\n setup_short_answer_questions(questions_grouped_by_lesson)\n\n @unique_questions\n end",
"def create\n \tsession[:state]= 4\n \t@question = Question.find(session[:qid])\n \t@q_response = QResponse.new(params[:q_response])\n \tif @question.number_response == @q_response.number_response\n \t\tcorrect = 1\n \telsif @q_response.number_response == nil\n \t\tcorrect = -1\t\n \telse\n \t\tcorrect = 0\t\n \tend\n \t\t\n\t@player = Player.find(session[:player_id])\n\t@playground = Playground.find(session[:playground_id])\n\t@playground.q_responses << @q_response\n\t\t\n\t@playground.save\n\t\n\t@player.update_attribute(:number_response, @q_response.number_response)\n\t@player.update_attribute(:time, @q_response.q_time)\n\t@player.update_attribute(:correct, correct)\n\t\n\t@player1 = @playground.game_players[0].player\n\t@player2 = @playground.game_players[1].player\n\t\n\t\n\t#Check for complete response\n\tif @playground.q_responses.count == 2 \n\t\tresult = @player1.correct <=> @player2.correct\n\t\t#both correct\t\n\t\tif result == 0 && @player1.correct == 1\n\t\t\tresult = @player2.time <=> @player1.time\n\t\tend\t\n\t\t\n\t\tif result == -1\n\t\t\t#player 2 wins\n\t\t\t@player1.update_attribute(:winner, 0)\n\t\t\t@player1.update_attribute(:inarow, 0)\n\t\t\t@player2.update_attribute(:winner, 3)\n\t\t\t@player2.update_attribute(:wins, @player2.wins + 1)\n\t\t\t@player2.update_attribute(:inarow, @player2.inarow + 1)\n\t\telsif result == 1\n\t\t\t#player 1 wins\n\t\t\t@player1.update_attribute(:winner, 3)\n\t\t\t@player1.update_attribute(:inarow, @player1.inarow + 1)\n\t\t\t@player1.update_attribute(:wins, @player1.wins + 1)\n\t\t\t@player2.update_attribute(:winner, 0)\n\t\t\t@player2.update_attribute(:inarow, 0)\n\t\telse\n\t\t\t#draw\n\t\t\t@player1.update_attribute(:winner, 1)\n\t\t\t@player2.update_attribute(:winner, 1)\n\t\tend\t\n\t\n\t\t@player1.update_attribute(:games, @player1.games + 1)\n\t\t@player2.update_attribute(:games, @player2.games + 1)\n\t\t\n\t\t@player1.update_attribute(:state, 5)\n\t\t@player2.update_attribute(:state, 5)\n\t\t\n\telse\n\t\t@player.update_attribute(:state, 4)\n\tend\t\n\t\n\trespond_to do |format|\n if @q_response.save\n format.html { redirect_to redirect_to board_url}\n format.js\n format.json { render json: @q_response, status: :created, location: @q_response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @q_response.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_quiz_questionnaire\n valid = valid_quiz\n if valid.eql?(\"valid\")\n create_questionnaire\n else\n flash[:error] = valid.to_s\n redirect_to :back\n end\n end",
"def create\n @question_response = QuestionResponse.new(params[:question_response])\n\n respond_to do |format|\n if @question_response.save\n format.html { redirect_to @question_response, notice: 'Question response was successfully created.' }\n format.json { render json: @question_response, status: :created, location: @question_response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question_response.errors, status: :unprocessable_entity }\n end\n end\n end",
"def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.success?\n data = Request.manage_response(response)\n end\n data.each do |question|\n questions << Question.new(question)\n end\n questions\nend",
"def ask_questions\n if request.post?\n @album = Album.find( params[:answers][:album_id])\n @user = @album.user\n @question = Question.find params[:answers][:question_id]\n Answer.create(question: @question,\n content: params[:answers][:content],\n guest: current_guest)\n logger.info \"GUEST: #{current_guest}\"\n @questions = params[:answers][:questions].gsub('[','').\n gsub(']','').\n split(',').\n map{|id| id.to_i}\n if @questions.any?\n @album_id = @album.id\n @question = Question.find(@questions.first)\n @questions = @questions[1..-1]\n respond_to do |format|\n format.js\n format.html\n end\n else\n #reset_session\n render 'guests/thank_you'\n end\n end\n end",
"def create\n @question_response = QuestionResponse.new(qr_params)\n\n if @question_response.save\n\t\t\t\t@question = @question_response.question\n\t\t\t\trender :action => 'list' \n flash[:notice] = t('questionresponse_created_success') \n else\n render :action => \"new\" \n end\n\t\t\t\n end",
"def create\n @question = Question.new(question_params)\n @question.answers.build(params[:question][:answer])\n\n # Creating associations for themes and levels\n asked_themes = params[:question][:theme_list].reject { |c| c.empty? }\n asked_levels = params[:question][:level_list].reject { |c| c.empty? }\n @question.theme_list.add(asked_themes)\n @question.level_list.add(asked_levels)\n\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to questions_path, notice: 'Question was successfully created.' }\n format.json { render action: 'show', status: :created, location: questions_path }\n else\n format.html { render action: 'new' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quiz\n $game.new_quiz\n @title_page = 'Quiz app'\n\n number_questions = params['question_number'].to_i\n puts number_questions\n $game.player.username = params['username']\n\n if number_questions < 1 or number_questions > 10\n redirect '/start-quiz'\n else\n response = Request.post_request(URL_GET_QUESTIONS, {\n number: number_questions\n })\n\n questions_response = Request.manage_response(response)\n\n questions_response.each do |question|\n $game.quiz.question_answer << question['Answer']\n $game.quiz.questions << Question.new(question)\n end\n @questions = $game.quiz.questions\n\n if @questions.empty?\n redirect '/start-quiz'\n else\n erb :quiz, layout: :template\n end\n end\nend",
"def create_question(question_text,question_bank_id,tenant_id,question_type,explanation,direction_id,passage_id)\n question = Question.new\n question.question_text = question_text\n question.question_bank_id = question_bank_id\n question.tenant_id = tenant_id\n question.explanation = explanation\n question.question_type = question_type\n question.save\n question_attribute = create_question_attribute(question.id,\"\",question_bank_id,\"\",\"\",\"\",direction_id,passage_id,\"\",\"\",tenant_id)\n question_attribute.update_attribute(\"difficulty_id\",get_difficulty(\"not defined\"))\n unless question_type.nil? or question_type.blank?\n question_type = QuestionType.find_by_value(question_type)\n question_attribute.update_attribute(\"question_type_id\",question_type.id)\n end\n return question\n end",
"def generate_questions\n logger.info 'Generating demo question...'\n demo = build_random_question number_of_goods: 3, duration: Question::PUBLIC_TIME_LIMIT\n demo.instruction = Instruction.find_by_number(0)\n demo.save\n\n logger.info 'Assigning demo question to users current_question'\n update_column(:current_question_id, demo.id)\n\n logger.info 'Generating question 1'\n question1 = build_random_question number_of_goods: 3, duration: Question::PUBLIC_TIME_LIMIT\n question1.instruction = Instruction.find_by_number(1)\n question1.save\n\n logger.info 'Generating question 2'\n question2 = build_random_question number_of_goods: 3, duration: Question::PUBLIC_TIME_LIMIT\n question2.instruction = Instruction.find_by_number(1)\n question2.save\n\n logger.info 'Generating question 3'\n question3 = build_random_question number_of_goods: 4, duration: Question::PUBLIC_TIME_LIMIT\n question3.instruction = Instruction.find_by_number(2)\n question3.save\n\n logger.info 'Generating question 4'\n question4 = build_random_question number_of_goods: 4, duration: Question::PUBLIC_TIME_LIMIT\n question4.instruction = Instruction.find_by_number(2)\n question4.save\n\n logger.info 'Generating question 5'\n question5 = build_random_question number_of_goods: 5, duration: Question::PUBLIC_TIME_LIMIT\n question5.instruction = Instruction.find_by_number(3)\n #question3.display_formula = true (taking out the formulas)\n question5.save\n\n logger.info 'Generating question 6'\n question6 = build_random_question number_of_goods: 5, duration: Question::PUBLIC_TIME_LIMIT\n question6.instruction = Instruction.find_by_number(3)\n #question3.display_formula = true (taking out the formulas)\n question6.save\n\n logger.info 'Generating question 7'\n question7 = build_random_question number_of_goods: 3, duration: BetaRandom.get_seconds\n question7.instruction = Instruction.find_by_number(4)\n question7.display_timer = false\n #question4.display_formula = true\n question7.save\n\n logger.info 'Generating question 8'\n question8 = build_random_question number_of_goods: 3, duration: BetaRandom.get_seconds\n question8.instruction = Instruction.find_by_number(4)\n question8.display_timer = false\n #question4.display_formula = true\n question8.save\n\n logger.info 'Generating question 9'\n question9 = build_random_question number_of_goods: 4, duration: BetaRandom.get_seconds\n question9.instruction = Instruction.find_by_number(5)\n question9.display_timer = false\n question9.save\n\n logger.info 'Generating question 10'\n question10 = build_random_question number_of_goods: 4, duration: BetaRandom.get_seconds\n question10.instruction = Instruction.find_by_number(5)\n question10.display_timer = false\n question10.save\n\n logger.info 'Generating question 11'\n question11 = build_random_question number_of_goods: 5, duration: BetaRandom.get_seconds\n question11.instruction = Instruction.find_by_number(6)\n question11.display_timer = false\n question11.save\n\n logger.info 'Generating question 12'\n question12 = build_random_question number_of_goods: 5, duration: BetaRandom.get_seconds\n question12.instruction = Instruction.find_by_number(6)\n question12.display_timer = false\n question12.save\n\n logger.info 'Choosing random question as the question that is judged'\n random_question_id = scorable_questions.sample.id\n update_column :chosen_question_id, random_question_id\n\n shuffle_scorable_questions\n end",
"def answer(data)\n @action = Action.find_by_class_assignment_id_and_user_id(\n @session[:assignment_id], @current_user.id)\n @action_problem = action.action_problems.find_by_problem_id_and_end_time(data[:problem].id, nil)\n @assignment_answer = AssignmentAnswer.create(\n :action_problem_id => @action_problem.id,\n :problem_id => data[:problem].id, \n :answer => data[:correct] || data[:incorrect], \n :correct => data.has_key?(:correct), \n :user_id => @current_user.id, \n :class_assignment_id => @session[:assignment_id], \n :time => Time.now)\n\n #action_problem.incorrect_answers += 1 if data.has_key?(:incorrect)\n #action_problem.first_assignment_answer_id = @assignment_answer.id if action_problem.first_assignment_answer_id.nil?\n #action_problem.save!\n\n if @assignment_answer.first_response? and @assignment_answer.problem.scaffold_id.nil?\n student_id = Student.find_by_user_id(@session[:user]).id\n sa = StudentAssignment.find_or_create_by_student_id_and_class_assignment_id(student_id, @session[:assignment_id])\n sa.increment(:correct_first_answers) if data[:correct] and -1 == @session[:hint_count]\n sa.increment(:all_first_answers)\n sa.save\n end\n # Question level table\n log = QuestionLevelLog.find_by_class_assignment_id_and_user_id_and_problem_id(\n @session[:assignment_id], @current_user.id, data[:problem].id)\n unless log.nil?\n # IF FIRST RESPONSE\n if log.first_action.nil?\n log.first_response_time = @assignment_answer.time\n # if request scaffold\n if @assignment_answer.answer.nil?\n log.first_action = 2\n log.correct = 0\n # if an answer\n else\n log.first_action = 0\n log.attempt_count += 1\n log.correct = @assignment_answer.correct? ? 1:0\n log.answer = @assignment_answer.answer\n if @assignment_answer.answer.class.to_s == \"HashWithIndifferentAccess\"\n log.answer_id = @assignment_answer.answer[:id] unless @assignment_answer.answer[:id].nil?\n log.input_text = @assignment_answer.answer[:body] unless @assignment_answer.answer[:body].nil?\n else\n log.input_text = @assignment_answer.answer\n end\n end\n # NOT THE FIRST RESPONSE\n else\n # if an answer\n unless @assignment_answer.answer.nil?\n log.attempt_count += 1\n end\n end\n log.save\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to @quiz, notice: \"Quiz was successfully created.\" }\n format.json { render :show, status: :created, location: @quiz }\n\t\tmy_array = []\n\t\tmy_array << @quiz.option1\n\t\tmy_array << @quiz.option2\n\t\tmy_array << @quiz.option3\n\t\tmy_array << @quiz.option4\n\t\t\n\t\tcorrect_respo = my_array[@quiz.correct_response.to_i - 1]\n\t\t@quiz.correct_response_text = correct_respo\n\t\t@quiz.save\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n @answer = @question.answers.build(params[:answer])\n @answer.user_id = @current_user.id\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @question, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@errors = {}\n if params[ :quiz_id ] && params[ :user_id ]\n# lead_answer_id = params[ :lqa ]\n# if lead_answer_id.blank? && !params[ :questions ].blank?\n# params[ :questions ].each_pair do |qid,aid|\n# if QuizQuestion.find_by_id( qid ).quiz_phase.position == 0\n# lead_answer_id = aid\n# end\n# end\n# end\n \n @quiz_instance = QuizInstance.create(\n :quiz_id => params[ :quiz_id ],\n :user_id => nil,\n :quiz_instance_uuid => @@uuid_generator.generate( :compact ),\n :lead_answer_id => nil,\n :partner_user_id => params[ :user_id ]\n )\n\n if !params[ :questions ].blank?\n params[ :questions ].each_pair do |qid,aid_list|\n aid_list.split( ',' ).each do |aid|\n answer_text=''\n answer_text = params[ :answer ][aid.to_s] unless params[ :answer ].blank? || params[ :answer ][aid.to_s].blank?\n UserQuizAnswer.create( :quiz_answer_id => aid, :user_id => ( @user ? @user.id : nil ), :quiz_instance_id => @quiz_instance.id, :user_answer_text_response => answer_text )\n end\n end\n end\n\n qiid_cookie_write @quiz_instance.quiz_instance_uuid\n\n if @quiz_instance\n # no more POST / Redirect, so we have to revert to this sort of mess.\n # now we need to set up all the data we'll need to render the first\n # phase of the quiz.\n previous_quiz_phase = QuizPhase.first(:conditions => ['quiz_id = ? and position = 0', @quiz_instance.quiz_id])\n begin\n if params[:lqa]\n next_phase_id = QuizAnswer.find(params[:lqa]).next_quiz_phase_id\n else\n next_phase_id = QuizAnswer.find(params[:questions][previous_quiz_phase.branch_question_id.to_s]).next_quiz_phase_id\n end\n @quiz_phase = QuizPhase.find(next_phase_id)\n rescue\n @quiz_phase = QuizPhase.first(:conditions => ['quiz_id = ? and position = 1', @quiz_instance.quiz_id])\n end\n @quiz = @quiz_instance.quiz\n @quiz_page = 1\n\n # also build the resume URI if we have previous instances of this\n # quiz from this user. resume URI is based on the LAST instanced\n # opened.\n load_previous_quiz_instance\n\n @total_quiz_questions = QuizQuestion.count(\n :conditions => [ 'quizzes.id = ? and quiz_questions.active = 1', @quiz.id ],\n :joins => { :quiz_phase => :quiz }\n )\n\n render :file => 'quiz_instances/show.xml'\n\n else\n @errors[ 'quiz' ] = [\n 'Internal Service Error. Unable to create quiz instance.',\n #'We are unable to start your quiz at this time.',\n 500 ]\n\n end\n else\n if !params[ :quiz_id ]\n @errors[ 'quiz_id' ] = [\n 'Required parameter Quiz ID not provided',\n #'Please select a quiz to continue.',\n 400 ]\n end\n\n if !params[ :user_id ]\n @errors[ 'user_id' ] = [\n 'Required parameter User ID not provided.',\n #'Please select a quiz to continue.',\n 400 ]\n end\n #render :text => \"You must supply a quiz id in order to create an open quiz instance.\", :status => 400\n end\n\n if @errors.size != 0\n #if params[ :format ] = 'xml'\n render 'errors.xml.builder'#, :status => @error_code\n #end\n end\n end",
"def create\n\n @response = Response.find(params[:response_id])\n @request_selection = @response.create_request_selection(params[:request_selection])\n #@reward = @request_selection.create_reward(params[:reward])\n \n respond_to do |format|\n if @request_selection.save\n \n format.html { redirect_to _my_requests_path }\n format.json { render json: @request_selection, status: :created, location: @request_selection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @request_selection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_assignments\n self.assignments.each do |a|\n #want to keep the history of responses even if the question no longer applies.\n #it could be that the question was answered in a prior rotation.\n a.destroy unless a.responded\n end\n assigned_users = User.scoped\n assigned_users =assigned_users.where(:rotation => self.rotation)unless rotation == nil\n assigned_users =assigned_users.where(:year => self.year) unless year == nil\n make_assignments(assigned_users)\n clear_old_assignments\n end",
"def create\n @question_answer_nested = Answer.new(params[:answer])\n next_question = @question_answer_nested.quiz.next_question(@question_answer_nested.question)\n user_id = session[:user_id]\n quiz_id = Question.find(params[:question_id]).quiz_id\n\n respond_to do |format|\n if @question_answer_nested.save\n user_scoring = UserQuiz.find_or_create_by_user_id_and_quiz_id(user_id, quiz_id)\n if next_question\n user_scoring.update_attributes(:status => \"In Progress\")\n format.html { redirect_to new_question_answer_path(next_question.id) }\n else\n user_scoring.update_attributes(\n :total_questions => @question_answer_nested.quiz.approved_questions.count,\n :num_correct => QuizGrader.num_correct(current_user.answers_for_quiz(@question_answer_nested.quiz_id), @question_answer_nested.quiz),\n :status => \"Completed\" \n )\n\n format.html { redirect_to score_path(:id => @question_answer_nested.quiz_id , :user_id => current_user.id), notice: 'Your completed quiz has been recorded.' }\n\n end\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def register_last_answer\n unless self.for_test || self.team_id.nil?\n la = LastAnswer.find_or_create_by(:user_id => self.user_id.to_s, :question_id => self.question_id.to_s)\n\n unless la.answer_id.nil? || la.answer.nil?\n self.try_number = la.answer.try_number + 1\n end\n\n\n\n self.last_answer = la\n la.answer_id = self.id\n\n\t if la.answer.nil?\n\t answers = Answer.where(user_id:la.user_id.to_s, question_id: la.question_id.to_S).desc(:created_at)\n if answers.count > 0\n la.answer_id = answers.first.id\n la.save!\n else\n\t la.delete\n end\n else\n la.save!\n end\n\n self.save\n\n true\n end\n\n #unless self.for_test\n # la = LastAnswer.find_or_create_by(:user_id => self.user.id, :question_id => self.question.id)\n # la.answer = self\n # la.question_id = self.question_id\n # la.user_id = self.user_id\n # la.save!\n #end\n end",
"def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend",
"def question_response_params\n p = params.require(:question_response).permit(:response, :subject, :responder, :question)\n p[:subject] = Entity.find(p[:subject])\n p[:responder] = Member.find(p[:responder])\n p[:question] = Question.find(p[:question])\n p\n end",
"def validate_questions(questions)\n uniq_questions = []\n questions.each do |question|\n qid = question[\"ident\"].to_s\n if (uid_exists?(\"question\", qid))\n if (uniq_questions.include?(question))\n val_warn(\"Duplicate Question Declaration\", qid, \"in Election Definition\")\n else\n val_err(\"Non-Unique Question UID\", qid, \"in Election Definition\")\n end\n else\n uniq_questions.push(question)\n uid_add(\"question\", qid)\n did = question[\"district_ident\"].to_s\n val_err(\"Non-Existent District UID\", did, \"for Question UID\", qid, \"in Question\") unless\n uid_exists?(\"district\", did)\n answers = question[\"answer_list\"].collect {|answer| answer.to_s}\n unless (answers.length == answers.uniq.length)\n val_err(\"Duplicate Answers\", answers.inspect, \"for Question UID\", qid, \"in Question\")\n end\n self.counts_questions[qid] = {\"question_ident\"=>qid,\n \"overvote_count\"=>0,\n \"undervote_count\"=>0,\n \"answer_count_list\"=>answers.collect {|ans| {\"answer\"=> ans,\n \"count\"=> 0}}}\n end\n end\n end",
"def create\n @question = Question.new(params[:question])\n @question.dialogue = 0\n @question.participant = current_user.participant\n @question.status = Question.status_new\n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.71334463",
"0.71333545",
"0.694733",
"0.68908095",
"0.68387",
"0.67739964",
"0.67739964",
"0.67181784",
"0.6646776",
"0.6606174",
"0.6529411",
"0.6510068",
"0.64713866",
"0.6468316",
"0.6412771",
"0.6402794",
"0.63880986",
"0.6382566",
"0.63802475",
"0.63491833",
"0.6296517",
"0.6268113",
"0.62542313",
"0.6229211",
"0.6192088",
"0.6182359",
"0.61729354",
"0.61728",
"0.6166564",
"0.6148484",
"0.6145435",
"0.61213577",
"0.61191046",
"0.6117264",
"0.6112363",
"0.61020315",
"0.60866916",
"0.6066382",
"0.606422",
"0.6053393",
"0.6048531",
"0.6037666",
"0.6018007",
"0.60053",
"0.5996395",
"0.59921473",
"0.5988732",
"0.5988669",
"0.59863865",
"0.5984685",
"0.5983976",
"0.59783715",
"0.5967179",
"0.5961354",
"0.595017",
"0.5948772",
"0.59449786",
"0.594446",
"0.59258986",
"0.5922729",
"0.59200746",
"0.59195966",
"0.59051615",
"0.58944225",
"0.5889525",
"0.58829767",
"0.5882153",
"0.5880949",
"0.58809125",
"0.587502",
"0.58749837",
"0.5870456",
"0.58693993",
"0.5862776",
"0.5859468",
"0.5854255",
"0.5852951",
"0.58517873",
"0.5850613",
"0.584307",
"0.58414257",
"0.5840485",
"0.5834655",
"0.58273494",
"0.5822404",
"0.5816441",
"0.58161265",
"0.58074933",
"0.57956535",
"0.57886755",
"0.5788373",
"0.5787173",
"0.5785577",
"0.57818335",
"0.5780134",
"0.5779912",
"0.577695",
"0.5772083",
"0.5770228",
"0.57610995"
] |
0.7277313
|
0
|
Author Can't Respond To Own Poll The simplest way is to use associations to traverse from a Response object back to the AnswerChoice, to the Question, and finally the Poll. You can then verify whether the poll's author is the same as the respondent_id. This may involve multiple queries, but we will later improve this. Don't spend too much time trying to refactor the method right now. Many students have gone down this deep, dark rabbit hole and you'll have time to explore it later.
|
def respondent_is_not_author_poll?
#
# respondend.id == author.id
if question.poll.author.id == user.id
errors[:user_id] << 'author should not answer to his/her poll'
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_author?\n Response.joins(question: :poll).where(\"polls.user_id = ?\", self.user_id).exists?\n end",
"def not_author_response\n if author_respondent?\n errors[:author] << 'cannot answer their own poll'\n end\n end",
"def poll_author?\n self.answer_choice.question.poll.author_id\n end",
"def questions_author\n self.question.poll.author.id\n end",
"def try_to_convince_other_responders(poll)\n\t\tif poll.expert_user == self\n\t\t\t# Create a hash to remember who will have been convinced\n\t\t\thash = Hash.new()\n\t\t\tpoll.questions.each do |question|\n\t\t\t\tcurrent_array = Array.new()\n\t\t\t\thash.store(question.id, current_array)\n\n\t\t\t\tpoll.participants.each do |participant|\n\t\t\t\t\t# Save current choice in history\n\t\t\t\t\tparticipant.chosen_answer_for_question(question).history_be_chosen_by!(participant)\n\n\t\t\t\t\tunless participant == self\n\t\t\t\t\t\tunless participant.chosen_answer_for_question(question) == self.chosen_answer_for_question(question)\n\t\t\t\t\t\t\tif random_number_is_under(self.influence)\n\t\t\t\t\t\t\t\t# The participant has changed his mind\n\t\t\t\t\t\t\t\tparticipant.chosen_answer_for_question(question).be_not_chosen_by!(participant)\n\t\t\t\t\t\t\t\t# He chooses the answer chosen by the expert\n\t\t\t\t\t\t\t\tself.chosen_answer_for_question(question).be_chosen_by!(participant)\n\t\t\t\t\t\t\t\t# Add the convinced user to the hash\n\t\t\t\t\t\t\t\tcurrent_array.push(participant.first_name + \" \" + participant.name)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# Returns hash\n\t\thash\n\tend",
"def sibling_responses\n if !Response.exists?(self) #checks if instance is stored in database\n question.responses #even if instance class = Reponse, returns false if not in database\n else\n self.question.responses\n .where(\"responses.user_id != ?\", respondent.id)\n end\n\n end",
"def respondent_has_not_already_answered_question\n if sibling_responses.where('user_id != ?', self.user_id).exists?\n errors[:question] << \"You have already answered that question\"\n end\n end",
"def not_duplicate_response\n if respondent_already_answered?\n errors[:user_id] << 'this user has already answered this question'\n end\n # unless sibling_responses.where(user_id: user_id).empty?\n end",
"def respondent_already_answered?\n sibling_responses.exists?(responder_id: self.responder_id)\n end",
"def answered_by\r\n answer_response.answerer\r\n end",
"def respondent_already_answered?\n sibling_responses.where('user_id = ?', self.user_id).exists?\n end",
"def answering_person\n respond_to?(:answerHasAnsweringPerson) ? answerHasAnsweringPerson.first : nil\n end",
"def completed_by? author\n response = responses.find_by(author: author)\n if ::Tasuku.config.update_answers && response && response.is_a?(::Tasuku::Taskables::Question::Answer)\n response.correct?\n else\n !!response\n end\n end",
"def respondent_already_answered?\n sibling_responses.exists?(user_id: user_id)\n end",
"def answered_by?(user)\n replies.exists?(:user_id => user)\n end",
"def update\n def answer_given(question_id)\n return (params[:answer] and params[:answer][question_id.to_s] and\n params[:answer][question_id.to_s].length > 0)\n end\n \n @resp = Response.find(params[:id])\n\n @questionnaire.questions.each do |question|\n if question.kind_of? Questions::Field\n ans = Answer.find_answer(@resp, question)\n if answer_given(question.id)\n if ans.nil?\n ans = Answer.new :question_id => question.id, :response_id => @resp.id\n end\n ans.value = params[:answer][question.id.to_s]\n ans.save\n else\n # No answer provided\n if not ans.nil?\n ans.destroy\n end\n end\n end\n end\n\n respond_to do |format|\n if @resp.update_attributes(params[:response])\n format.html { redirect_to(response_url(@questionnaire, @resp)) }\n format.js { redirect_to(response_url(@questionnaire, @resp, :format => \"js\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => @resp.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def unanswered_questions\n Question.all.reject do |question|\n responsers_id = question.responses.pluck(:user_id)\n responsers_id.include?(self.id)\n end\n end",
"def answer_present\n if self.question.qtype == 'one_response' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n elsif self.question.qtype == 'likert_scale' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n\n elsif self.question.qtype == 'rank_three' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 3 \n array_wanted = [1, 2, 3]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 3 items are ranked.' )\n return false\n end\n\n elsif self.question.qtype == 'rank_five' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 5 \n array_wanted = [1, 2, 3, 4, 5]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 5 items are ranked.' )\n return false\n end\n end\n end",
"def present_survey\n @poll = Poll.find(params[:id])\n if @poll.taken_survey?(current_user)\n flash[:error] = \"You can only answer this survey once\"\n redirect_to poll_path(@poll)\n end\n end",
"def can_vote_on? question\n !question.answers.joins(:votes).where('votes.user_id = ?', id).exists?\n end",
"def has_answered(question)\n return question.responses.find_by(beta_user_id: self.id)\n end",
"def responded_to?(kase)\n !!self.responses.find(:first, :conditions => [\"responses.kase_id = ?\", kase.id])\n end",
"def follow_up_comment_without_response\n if !self.question.nil? && self.question.level > 0 && !self.comments.nil? && self.response.nil? then\n errors.add_to_base \" You may not comment upon a blank response. Use the parent question to add general comments.\" \n end\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def sibling_responses\n ac = {answer_choice_id: self.answer_choice_id, id: self.id}\n Response.find_by_sql([<<-SQL, ac])\n SELECT\n\t\t\t\t\trespones.*\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tquestions.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tquestions\n\t\t\t\t\t\t\tJOIN answer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tanswer_choices.id = :answer_choice_id\n\t\t\t\t\t) AS quest\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tanswer_choices ON answer_choices.question_id = questions.id\n\t\t\t\t\tJOIN\n\t\t\t\t\t\tresponses ON responses.answer_choice_id = answer_choices.id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(responses.id != :id)\n\t\t\t\tSQL\n end",
"def valid_response_for_answer_sheet?(answers)\n return true if !self.required? \n answer = answers.detect {|a| a.question_id == self.id}\n return answer && answer.value.present?\n # raise answer.inspect \n end",
"def participate_in_poll(poll, answer)\n\n # if the user has already participated in this poll\n raise ActiveRecord::RecordInvalid unless PollParticipation.where(user: self, poll: poll).blank?\n\n # create a poll participation model\n poll_participation = PollParticipation.new\n poll_participation.author = poll.author\n poll_participation.poll_answer = answer\n poll_participation.user = self\n poll_participation.poll = poll\n poll_participation.save\n\n # Increment the answer vote count \n poll.cast_vote(answer)\n end",
"def find_response(answer_id)\n self.responses.find_by_answer_id(answer_id)\n end",
"def no_responses\n #below is code to fix a bizarre bug. When triggered by the \"cut\" function, for some reason survey_id is erased. Have not found reason yet. Temporary fix.\n if !survey_section && self.id\n self.reload\n end\n if self.id && self.survey_section && self.survey_section.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey_section.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.id && !survey_section.survey.template && survey_section.survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def question_with_prompt(question_id, visitor_id = \"guest\", prompt_id=nil)\n question = Pairwise::Question.find_with_prompt(question_id, @local_identifier, visitor_id)\n return question #if question.local_identifier == @local_identifier.to_s\n end",
"def sibling_responses\n # exclude yourself\n # load questions, then load responses\n question.responses.where.not(id: id)\n end",
"def must_have_responded_or_sponsored\n @survey = Survey.with_aasm_state(:finished).find(params[:survey_id])\n if (current_organization_or_survey_invitation.participations.find_by_survey_id(@survey.id).nil? &&\n current_organization != @survey.sponsor) \n then\n flash[:notice] = \"The response deadline has passed. You may not view the results unless you have responded to the survey.\"\n \n if logged_in_from_survey_invitation? then\n redirect_to new_account_path\n else\n redirect_to surveys_path\n end\n \n return false\n end\n end",
"def completed_polls\n Poll.find_by_sql([<<-SQL, self.id])\n SELECT\n polls.*\n FROM\n responses\n JOIN\n answer_choices ON responses.answer_choice_id = answer_choices.id\n RIGHT JOIN\n questions ON answer_choices.question_id = questions.id\n JOIN\n polls ON questions.poll_id = polls.id\n WHERE\n responses.user_id = ? OR responses.user_id IS NULL\n GROUP BY\n polls.id\n HAVING\n COUNT(*) = COUNT(answer_choices.id)\n SQL\n end",
"def resp_guard_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.RESP_GUARD\"))\n end",
"def sibling_responses\n # self.question.responses.where(\"responses.id != ?\", self.id)\n self.question.responses.where.not(id: self.id)\n end",
"def getanswerable\n @the_question = Question.find(params[:id])\n @user_id = session[:user_id]\n if @the_question.user.id == @user_id\n render json: [{question: @the_question}]\n end\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end",
"def respond\n\t\t@poll = Poll.find(params[:id])\n\t\t@expert_user = @poll.expert_user\n\t\t@participants = @poll.participants\n\t\t@questions = @poll.questions\n\tend",
"def author_feedback_popup\n @response_id = params[:response_id]\n @reviewee_id = params[:reviewee_id]\n unless @response_id.nil?\n first_question_in_questionnaire = Answer.where(response_id: @response_id).first.question_id\n questionnaire_id = Question.find(first_question_in_questionnaire).questionnaire_id\n questionnaire = Questionnaire.find(questionnaire_id)\n @maxscore = questionnaire.max_question_score\n @scores = Answer.where(response_id: @response_id)\n @response = Response.find(@response_id)\n @total_percentage = @response.get_average_score\n @sum = @response.get_total_score\n @total_possible = @response.get_maximum_score\n end\n\n @maxscore = 5 if @maxscore.nil?\n\n unless @response_id.nil?\n participant = Participant.find(@reviewee_id)\n @user = User.find(participant.user_id)\n end\n end",
"def verified_answer(user_response, list_of_responses)\n if list_of_responses.include? user_response\n user_response\n else\n invalid_return_mm\n end\n end",
"def answer_from(user)\n user.answers.where(question_id: self).first || \n matching_answer_class.new do |answer|\n answer.question = self\n answer.user = user\n end\n end",
"def authored_questions\n Question.find_by_author_id(self.id)\n end",
"def authored_questions\n Question.find_by_author_id(self.id)\n end",
"def auto_accept_response!\n result = false\n if self.active? && self.has_expired? && self.responses_count >= 1 && \n self.offers_reward? && !self.owner_only_offers_reward?\n top = self.responses.active.find(:all, :conditions => [\"responses.up_votes_count >= 2 && responses.votes_sum >= 0\"],\n :order => \"responses.votes_sum ASC, responses.updated_at DESC\", :limit => 2)\n result = top.first.accept! unless top.first.nil?\n self.responses.reload if result\n end\n result\n end",
"def check_user_ownership\n @answer = current_user.answers.find_by(id: params[:id])\n if @answer.nil?\n redirect_to(request.referrer || root_url, flash: { danger: 'You do not have permission to do that.' })\n end\n end",
"def show_explanation\n @room = current_user.room\n @question = @room.question\n return if !@room.show_explanation?\n last_choice = current_user.histories.last.choice if !current_user.histories.empty?\n current_user_choice = (last_choice and last_choice.question_id==@question.id) ? last_choice : nil\n\n puts \"User #{current_user.id} chose #{current_user_choice.id if current_user_choice}\"\n @choices = @question.choices.collect do |choice| {\n data: choice,\n result: if choice.correct\n \"correct\"\n elsif current_user_choice and choice.id==current_user_choice.id\n \"selected\"\n end,\n selected: @room.active_users.all.select {|u| u.histories.last.choice_id == choice.id if !u.histories.empty?}\n }\n end\n messages = {\n correct: \"Congratulations! You got the right answer.\",\n incorrect: \"Sorry, you got the wrong answer. See explanation below.\",\n blank: \"You didn't select an answer. See explanation below.\"\n }\n styles = {\n correct: \"alert alert-success\",\n incorrect: \"alert alert-error\",\n blank: \"alert\"\n }\n # If there's a choice_id (user chose a choice) and that choice is correct\n if current_user.status != 0\n #If user didn't select answer\n if current_user_choice==nil\n @change= current_user.lose_to!(@question)\n @message = messages[:blank]\n @style = styles[:blank]\n #If user chose an incorrect answer\n elsif !current_user_choice.correct?\n @change = current_user.lose_to!(@question)\n @message = messages[:incorrect]\n @style = styles[:incorrect]\n else\n @change = current_user.win_to!(@question)\n @message = messages[:correct]\n @style = styles[:correct]\n end\n end\n render partial: \"show_explanation\"\n end",
"def correct_answers\n correct_answers = self.answers.where(truthiness: true) #for this current user instance (self), gets all the answers where the truthiness is true (set during question/answer creation)\n end",
"def sibling_responses\n question.responses.where.not(id: self.id)\n end",
"def owner_only_offers_reward?\n self.rewards_count == 1 && self.rewards.visible[0].sender == self.person\n end",
"def authored_questions\n Question.find_by_author_id(@id)\n end",
"def sibling_responses\n if self.id\n self.question.responses.where(\"responses.id != ?\", self.id)\n else\n self.question.responses\n end\n end",
"def completed_polls_sql\n Poll.find_by_sql([<<-SQL, self.id])\n SELECT\n polls.*\n FROM\n polls\n JOIN\n questions\n ON\n polls.id = questions.poll_id\n JOIN\n answer_choices\n ON\n answer_choices.question_id = questions.id\n LEFT OUTER JOIN\n (\n SELECT\n *\n FROM\n responses\n WHERE\n responses.user_id = ?\n ) AS responses\n ON\n responses.answer_choice_id = answer_choices.id\n GROUP BY\n polls.id\n HAVING\n COUNT(responses.*) = COUNT(DISTINCT questions.*)\n SQL\n end",
"def validate_allows_response\n if self.kase\n # self.errors.add(:kase, \"is %{status}\".t % {:status => self.kase.current_state_t}) unless self.kase.active?\n # self.errors.add(:kase, \"is not open\".t) unless self.kase.open?\n \n if self.person \n if self.kase.offers_reward?\n\n # only disallow rewarded self answers\n self.errors.add(:base, \"You cannot respond to your own rewarded %{type}\".t % {:type => self.kase.class.human_name}) unless self.person != self.kase.person\n\n end\n end\n end\n end",
"def find_poll_question\n @poll_question = ((@poll) ? @poll.poll_questions : PollQuestion).find(params[:id], include: :poll_options).current_version\n end",
"def question_edit\n reject_user if current_user.questions.where(id: params[:id]).empty?\t\n end",
"def no_responses\n if self.id && self.survey\n #this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.\n self.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}\n end\n if self.survey && !survey.template && survey.response_sets.count>0\n errors.add(:base,\"Reponses have already been collected for this survey, therefore it cannot be modified. Please create a new survey instead.\")\n return false\n end\n end",
"def question\n answer.question\n end",
"def ocare_child_previously_collected_and_equals_one?(question)\n answer_for(question, ocare_child_response_is_one?)\n end",
"def has_associated_response?\n @associated_responses ||= []\n not @associated_responses.empty?\n end",
"def get_question(answer)\n answer.is_a?(Answer) ? answer.question : answer\n end",
"def accepted_answer?(answer)\n answer.id == answer.question.accepted_answer_id\n end",
"def show\n @question = Question.find(params[:id])\n\n @prev_questions = @question.participant.questions.order(\"created_at DESC\").all\n @answers = Answer.find(:all, :conditions=>{:question_id=>params[:id]})\n if @question.participant.user == current_user || !current_user.is_participant?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n else\n raise CanCan::AccessDenied \n end\n end",
"def accepted_receiver\n self.receiver ||= if accepted_response = self.responses.accepted.first\n accepted_response.person\n end\n end",
"def allows_clarification_response?(a_person)\n self.active? && a_person == self.person && self.pending_clarification_requests?\n end",
"def reply_author(reply)\n user_signed_in? && current_user.id == reply.user_id\n end",
"def quiz_owner_user\n unless quiz_owner?(params[:id])\n redirect_to quizzes_path\n flash[:error] = \"Step Off!! You don't own that quiz\"\n end\n end",
"def allows_clarification_response?(a_person)\n self.alive? && self.pending_clarification_requests?\n end",
"def set_answer_respondent\n @answer_respondent = AnswerRespondent.find(params[:id])\n end",
"def is_correct\n return object.question_answers.detect {|element| element.answer_id == object.id}.is_correct\n # object.question_answers.map do |questionAnswer|\n # return questionAnswer.is_correct\n # end\n end",
"def ocare_rel_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.OCARE_REL\"))\n end",
"def is_sole_author_of?(item)\n other_pseuds = item.pseuds.find(:all) - self.pseuds\n self.is_author_of?(item) && other_pseuds.blank?\n end",
"def correct_answer\n self.answers.where(correct: true).first\n end",
"def talks\n @talks ||= Talk.all.select do |t|\n if t.authors.any?\n t.author_id.include?(self.id)\n else\n t.author_id == self.id\n end\n end\n end",
"def respond_to_question(url, token, encrypted_id, resp)\n dputs __method__.to_s\n messages_req = setup_http_request($respond_to_message, @cookie, {:url => url, :arg => [resp, encrypted_id, token]})\n res = @http.request(messages_req)\n body = CGI.unescapeHTML(res.body.force_encoding('utf-8'))\n # Checking...\n if res.code == \"302\"\n found = false\n # Should not be a problem calling public instead private or other way\n get_public_conversations(res['location']).map{|m|\n m[:msgs].map{|c| found = true if c[:msg].include?(resp)}\n if found\n return true\n end\n }\n return false\n end\n raise SendReponseMessageError, \"Cannot received expected 302 code...\"\n end",
"def resp_pcare_equals_one?(question)\n previous_responses = person.responses_for(\"PARTICIPANT_VERIF.RESP_PCARE\").all\n ri = previous_responses.detect{ |r| r.answer.try(:reference_identifier).to_i == 1 } ? true : false\n answer_for(question, ri)\n end",
"def pcare_rel_previously_collected?(question)\n answer_for(question, valid_response_exists?(\"PARTICIPANT_VERIF.PCARE_REL\"))\n end",
"def filter_question?( q )\n return false if q.parent_question_id.blank?\n # if there is parent_question_id, check response value in its answer\n parent_question = q.parent_question\n parent_answer = self.answers.find_answer_for_question( parent_question ).first\n # if question has no answer (e.g. embedded dependency)\n return true if parent_answer.nil?\n\n if parent_answer.get_responses_array.include?( q.parent_response_value )\n return false # don't filter\n else\n return true # filter\n end\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def review\n room = Room.find(params[:room_id])\n publish_async(\"presence-rooms\", \"update_recent_activities\", {\n message: \"#{current_user.name} has left room #{room.title}.\"\n })\n histories = current_user.histories\n .where(room_id: room.id)\n .joins(:choice)\n .includes(:question)\n @questions = histories.collect do |h| {\n id: h.question_id,\n prompt: h.question.prompt,\n paragraph: h.question.paragraph,\n choices: h.question.choices.collect do |c| {\n data: c,\n result: if h.question.correct_choice_ids.include? c.id\n \"correct\"\n elsif c.id==h.choice_id\n \"selected\"\n end\n }\n end\n }\n end\n end",
"def answered?\n\n if answers.length == 0 \n return false\n end\n\n if answers.last.rationale_choices.size > 0\n\n #\n # The last answer is a list containing only one item, and it\n # does not contain a key for :choice_id. This is the answer we\n # generated in the case of unselecting a previous selection.\n # I.e. user is resetting to the default unselected state.\n # {:answer=>\"not answered\"}\n #\n\n return true\n end\n\n return false\n\n end",
"def can_make_decision?\n self.awaiting_decisions? || self.awaiting_replies? || self.all_rejected?\n end",
"def complete?\n# self.answers.count == Question.count\n question_set = Question.order(\"order_id asc\").all(:include => :parent_question)\n question_set.reject!{ |q| self.filter_question?(q) }\n\n question_set.each do |q|\n ans = self.answers.find_answer_for_question( q ).first\n if ans.nil?\n return false\n end\n end\n\n return true\n end",
"def enough_responses?\n game.current_round.response(self).count >= game.current_round.question.answers\n end",
"def allows_response_by(responder)\n self.allows_response?(responder)\n end",
"def politician_question\n first_question_type_loop_politician = true\n while first_question_type_loop_politician\n\t\t\tputs \"Party? Democrat or Republican\"\n party_answer = gets.chomp.downcase\n if party_answer == \"democrat\" && @candidate_counter_demo == 0\n @candidate_counter_demo += 1\n @name = Human.new \"politician\", @name, @party_answer\n\t\t\t@people_list << @name\n elsif party_answer == \"republican\" && @candidate_counter_repub == 0\n @candidate_counter_repub += 1\n @name = Human.new \"politician\", @name, @party_answer\n @people_list << @name\n else\n puts \"You already have politician from that party\"\n end\n\n\t\t\tfirst_question_type_loop_politician = false if @first_question_type_list.include? party_answer\n\n\n end\n\tend",
"def has_no_accepted_response?\n !self.has_accepted_response?\n end",
"def reviewed_by?(reviewer)\n ReviewResponseMap.where('reviewee_id = ? && reviewer_id = ? && reviewed_object_id = ?', id, reviewer.get_reviewer.id, assignment.id).count > 0\n end",
"def find_rejected_comments(response)\n decision_ids = Array.new\n post_ids = Array.new\n response['data'].each do |item|\n if item['attributes']['status'] == 'Reject'\n # Get sourceId of post from included section of JSON object\n sourceId = response['included'].find {|i| i['id'] == item['attributes']['commentId']}['attributes']['sourceId']\n decision_ids << item['id']\n post_ids << sourceId\n end\n end\n if decision_ids.any?\n confirm_decisions decision_ids\n reject_posts post_ids\n else\n puts 'No new decisions found.'\n end\n end",
"def should_show_resp_pcare?(question)\n answer_for(question, !valid_response_exists?(\"PARTICIPANT_VERIF.RESP_PCARE\"))\n end",
"def player_response\n\n if compare_answer\n return puts \"#{@current_asker.name}: YES! You are correct.\"\n end\n\n puts \"#{@current_asker.name}: Seriously? No!\"\n\n end",
"def offerer?(person)\n (share_type.is_offer? && author.eql?(person)) || (share_type.is_request? && !author.eql?(person))\n end",
"def get_answers(company_id)\n self.answers.select {|answer| answer.user.company_id == company_id }\n end",
"def valid_reply?\n # People can send multiple replies to the same message, in which case\n # the recipient is the same as the parent recipient.\n # For most replies, the message recipient should be the parent sender.\n # We use Set to handle both cases uniformly.\n Set.new([sender, recipient]) == Set.new([parent.sender, parent.recipient])\n end",
"def author\n # data = QuestionsDatabase.instance.execute(\"SELECT fname, lname FROM questions\")\n User.find_by_user_id(@author_id)\n\n end",
"def not_duplicate_response\n if respondent_already_answered?\n self.errors[:duplicate] << \"You've already answered this question.\"\n end\n end",
"def answer_for_choice(choice)\n answers.select {|a| a.question == choice.question && a.data == choice.value}.first || answers.build(:question => choice.question, :data => '')\n end",
"def has_accepted_response?\n self.responses.accepted.any? {|response| response.accepted?}\n end",
"def offeror; offeror_id ? User.find(offeror_id) : nil; end"
] |
[
"0.7459119",
"0.74162626",
"0.74114394",
"0.6611128",
"0.65162957",
"0.6469948",
"0.61780465",
"0.60721993",
"0.6028036",
"0.5976189",
"0.5953859",
"0.5941682",
"0.58937144",
"0.5889886",
"0.58878314",
"0.58872795",
"0.58787656",
"0.58635414",
"0.58278686",
"0.58248705",
"0.577402",
"0.5772494",
"0.57522047",
"0.57294774",
"0.57294774",
"0.5705393",
"0.570415",
"0.5683242",
"0.56654656",
"0.5632005",
"0.5626935",
"0.56169623",
"0.56128293",
"0.5609154",
"0.55953246",
"0.55897623",
"0.5580957",
"0.5550898",
"0.5550898",
"0.55498266",
"0.55436367",
"0.5530708",
"0.552763",
"0.55028975",
"0.55028975",
"0.5500468",
"0.54777455",
"0.54754376",
"0.54752463",
"0.544029",
"0.5432142",
"0.54299694",
"0.5411024",
"0.5373186",
"0.5368463",
"0.5350282",
"0.53480625",
"0.5345237",
"0.5334976",
"0.53344005",
"0.5329072",
"0.5327368",
"0.5327149",
"0.5312475",
"0.5308426",
"0.53028053",
"0.52995014",
"0.52987504",
"0.52823645",
"0.52803606",
"0.52714956",
"0.5268648",
"0.5268181",
"0.52573884",
"0.5231356",
"0.52272236",
"0.5201209",
"0.51907295",
"0.51896983",
"0.5183692",
"0.5172986",
"0.5172769",
"0.51557237",
"0.5154055",
"0.51448476",
"0.51384217",
"0.5136353",
"0.51318014",
"0.5131307",
"0.51268786",
"0.5126729",
"0.5126021",
"0.5123085",
"0.5122675",
"0.5112406",
"0.5100273",
"0.50963426",
"0.50954694",
"0.50950843",
"0.5091858"
] |
0.771261
|
0
|
maybe change to bulk add answers, split at "comma"
|
def add_answers
clear
puts "Enter the answers, split by a comma for each"
answers = gets.chomp
answers = answers.gsub(/,\s/,',')
answers = answers.split(",")
answers.each do |answer|
new_answer = Answer.create({:name => answer, :question_id => @current_question.id})
end
puts "Do you want to add another question (y/n)?"
input = gets.chomp
if input == 'y'
add_question
else
admin_menu
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def incorrect_answers\n object.incorrect_answers.split(\", \")\n end",
"def formatAnswerFromArray( answerString )\n answerRows = answerString.split(\"~\")\n answerArr = Array.new()\n answerRows.each { |ans|\n row = \"\"\n ansarr = ans.split(\",\")\n ansarr.each { |a|\n row += a unless a == \",\"\n }\n answerArr.push(row)\n } \n answerArr\n end",
"def answer_split\n arr_of_strings = []\n single_answer = []\n @data.each do |str|\n if str[-1] == '.'\n single_answer << str\n arr_of_strings << single_answer\n single_answer = []\n else\n single_answer << str\n end\n end\n arr_of_strings << single_answer\n @data = arr_of_strings\n end",
"def formatAnswersFromSimple( answerString )\n answerArr = []\n subAnsString = answerString.split( \"~\" )\n subAnsString.each{ |ansStr|\n answerArr.push( ansStr.split( \",\" ))\n }\n answerArr\n end",
"def formatAnswersFromSimple( answerString )\n answerArr = []\n subAnsString = answerString.split( \"~\" )\n subAnsString.each{ |ansStr|\n answerArr.push( ansStr.split( \",\" ))\n }\n answerArr\n end",
"def question_split\n arr_of_strings = []\n single_question = []\n @data.each do |str|\n if str.length == 3 || str.length == 2\n if str[0].numeric? && str[-1] == '.'\n arr_of_strings << single_question\n single_question = []\n single_question << str\n else\n single_question << str\n end\n else\n single_question << str\n end\n end\n arr_of_strings << single_question\n @data = arr_of_strings\n end",
"def multiple_choice_answers\r\n answer.blank? and return []\r\n answer.strip.split(/\\s+/).map(&:to_i).compact\r\n end",
"def formatAnswersToSimple( answerArr )\n resultString = \"\"\n # answerArr.each{ |ansArr|\n# resultString = resultString + ansArr.join( \",\" )\n # resultString = resultString + \"~\"\n # }\n resultString = answerArr.join(\"~\")\nend",
"def answer_join\n strings_joined = @data.map do |answer|\n answer.join(' ')\n end\n strings_joined[0] = strings_joined[0].gsub(\"QUIZ ANSWERS \", '')\n @data = strings_joined\n end",
"def oxford_comma(words)\n if words.length == 1\n words.join\n elsif words.length == 2\n return \"#{words[0]} and #{words[1]}\"\n else words.length > 2\n words[-1].insert(0 , \"and \")\n end\n words.join(\", \") \n end",
"def separate_comma(number)\n num_array = number.to_s.split('').reverse\n comma_array = []\n count = 0\n\n num_array.each do |num| #For refactor, I'm using .each instead of a counter (more efficient).\n if comma_array.length % 4 == 0\n comma_array << \",\"\n comma_array << num\n else\n comma_array << num\n end\nend\n\n\nresult = comma_array # Removes \",\" character at the end of 7 character answers.\n if result[0] == \",\"\n result.shift\n p result.join.reverse\n else\n p result.join.reverse\n end\nend",
"def make_result_list(items)\n items.map do |item|\n {\n 'Question' => item['Question'],\n 'Options' => item['Options'].split(',').collect(&:strip),\n 'Answer' => item['Answer'].to_i,\n }\n end\nend",
"def split_ions\n self.ions.split(',') rescue []\n end",
"def map_exam_required\n # Return list of required exams split by ,\n if self.exam_required\n (self.exam_required.join \", \").gsub(/, $/, '')\n else\n []\n end\n end",
"def separate_comma(random_num)\n\n if random_num >= 1000 && random_num < 10000\n random_num = (random_num.to_s).split(//,2)\n random_num = random_num.join(\",\")\n elsif random_num >= 10000 && random_num < 100000\n random_num = (random_num.to_s).split(//)\n random_num = random_num.insert(2,\",\")\n random_num = random_num.join\n elsif random_num >= 100000 && random_num < 1000000\n random_num = (random_num.to_s).split(//)\n random_num = random_num.insert(3,\",\")\n random_num = random_num.join\n elsif random_num >= 1000000 && random_num < 10000000\n random_num = (random_num.to_s).split(//)\n random_num = random_num.insert(4,\",\")\n random_num = random_num.insert(1,\",\")\n random_num = random_num.join\n elsif random_num >= 10000000 && random_num < 100000000\n random_num = (random_num.to_s).split(//)\n random_num = random_num.insert(5,\",\")\n random_num = random_num.insert(2,\",\")\n random_num = random_num.join\n else random_num < 1000\n random_num\n end\n random_num\nend",
"def separate_comma__Use_refactored_method_below (num)\n strs = String.new\n num.to_s.reverse.each_char.each_slice(3){|chars| strs << \"#{chars.join},\"}\n strs.chomp(',').reverse\nend",
"def question_join\n strings_joined = @data.map do |question|\n question.join(' ')\n end\n @data = strings_joined\n end",
"def separate_comma(num)\n num_array = num.to_s.reverse.split()\n num_array.each_with_index do |item, index|\n if (index+1)%4==0\n num_array.insert(index,\",\")\n end\n end\n return num_array.reverse.join\nend",
"def separate_comma(random_num)\n\t\trandom_num.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(\",\").reverse\n\tend",
"def do_comma s; a = mega_pop(s); String == a.class ? s[:output] << \"#{a}\" : s[:output] << \"#{a.chr}\" end",
"def separate_comma(integer) #running this program gets me an array of each integer.to_s. See below for reconsidered approach\n new_array = []\n integer.to_s.split(//).each{|n| new_array << n} \nend",
"def add_comma(number)\n\tsplit_string = number.to_s.split('')\n\tsplit_string_length = split_string.length\n\n\tif split_string_length > 3\n\t\tsplit_string[0]<< ','\n\t\tsplit_string.join(\"\")\n\t\tp split_string\n\tend\n\nend",
"def for_commas\n each_line! do |line| \n begin\n line.gsub! /,(\\S)/, ', \\1' unless line.match /.*\\\".*,.*\\\".*/ or line.match /','/\n rescue Exception => e\n puts e.message + \", ignored.\"\n end\n end\n end",
"def oxford_comma(array)\n case array.length \nwhen 1\n \"#{array[0]}\"\nwhen 2\n array[0..1].join(\" and \")\nelse \n array[0...-1].join(\", \") << \", and #{array[-1]}\"\nend \nend",
"def oxford_comma(array)\nif array.count == 1 then array.join\nelsif array.count == 2 then array.join(\" and \")\nelsif array.count >= 3\n array[-1].insert(0, \"and \")\n array.join(', ')\nend\nend",
"def oxford_comma(array)\n if array.length == 1\n array.join\n elsif array.length == 2\n array.join(\" and \")\n elsif array.length > 2\n element_storage = array.pop\n new_array = [\"and\"]\n new_array.push(element_storage)\n new_string = new_array.join(\" \")\n array.push(new_string)\n final_array = array.join(\", \")\n end\nend",
"def answers\n [answer_1, answer_2]\n end",
"def wl_single_answer_input input_values\n input_values.map.with_index do |value, i|\n translate_input_value value, i\n end.join(\",\")\n end",
"def separate_comma(num)\nnum = num.to_s\nnums = num.split(\"\")\ndot_nums = []\n\n\n\tfor i in 0 ... nums.size \n\t\tif (i != nums.size-1) && (i-(2*i+1))%3==0 && nums.size >= 4 \n\t\t\tdot_nums << \",\" + nums[i] \n\t\telse\n\t\t\tdot_nums << nums[i]\n\t\tend\n\tend\np dot_nums.join\n\nend",
"def separate_comma(number)\n number = number.to_s\n number = number.split('').reverse!\n array_of_ints = number.each_slice(3).to_a\n array_of_ints.each do |num|\n if num.length == 3\n num.push(',')\n end\n end\n answer = array_of_ints.flatten!.reverse!.join()\n if answer[0] == ','\n answer[0] = ''\n return answer\n end\n return answer\nend",
"def separate_comma_initial(num)\n\t#convert integer to string and reverse it\n\tnum = num.to_s.reverse\n\n\t#initilize answer to empty string\n\tanswer = \"\"\n\n\t#iterate over the indices of the number string\n\t(0...num.length).each do |i|\n\n\t\t#add each number to the answer\n\t\tanswer += num[i]\n\n\t\t#as long as this isn't the last number...\n\t\tunless i == num.length - 1\n\n\t\t\t#add a comma after every three numbers\n\t\t\tanswer += \",\" if (i+1) % 3 == 0\n\t\tend\n\tend\n\n\t#flip the answer and return it\n\treturn answer.reverse\nend",
"def parse_comma_seperated_string(s)\n list = s.split(',')\n end",
"def print_multiple_words\n text = @array_to_split.join(\", \")\n text += \", and #{@lastword}\"\n return text\n end",
"def auto_add_answers\n\t\tperson_names = %w(john micheal jordan arya tyrion sansa khal joffrey ramsay)\n\t\tanswers = [\"Very likely\",\"Somewhat likely\",\"Neutral\",\"Somewhat unlikely\",\"Very unlikely\",\"Very satisfied\",\"Somewhat satisfied\",\"Neutral\",\"Somewhat dissatisfied\",\"Very dissatisfied\"]\n\n\t\t(1..3).to_a.each do |num|\n\t\t\tperson_name = person_names.shuffle.first\n\t\t\tanswer = answers.shuffle.first\n\t\t\tself.answers.create(person_name: person_name, answer: answer)\n\t\tend\n\tend",
"def answers\n %w{Yes No Maybe Ask\\ again\\ later}\nend",
"def comma_breakable\n text ','\n breakable\n end",
"def comma_breakable\n text ','\n breakable\n end",
"def separate_comma(number)\n new_array = number.to_s.reverse.split(\"\")\n count = 0\n new_array.each do |x|\n count += 1\n if count >= 4\n x << \",\" unless count == 3 || count == 5 || count == 6 || count > 7\n end\n end\n new_array.reverse.join\nend",
"def separate_comma(number)\n\tnumber\nend",
"def description_split\n\t\tdescription.split(\", \")\n\tend",
"def map_answers(csv_data, question:)\n print \"Answered #{question.to_s.gsub('_', ' ')}?\\n\"\n print csv_data.group_by{ |row| row[question]&.empty? }[false]&.map{|x| [x.slice(:first_name, :last_name).values.join(' '), x[question]].join(': ') }&.join(\"\\n\")\n print \"\\n\\n\"\n end",
"def separate_comma(num)\n solution = add_commas_every_three(num.to_s.reverse.split(\"\"))\n solution.pop if solution[-1] == ','\n solution.join(\"\").reverse\nend",
"def separate_comma(num)\n\tnum_comma = \"\"\n\tnum.to_s.reverse.split(\"\").each_with_index {|number, index|\n\t\tindex % 3 == 0 && index != 0 ? #here the modulo is \"% 3\" because indexing starts at \"0\". We are placing the comma at index \"3\".\n\t\tnum_comma << \",\" + number \n\t\t: num_comma << number} #using the \"? :\" question-mark-followed-by-a-colon, here is called the ternary-operator.\n\t\t\t\t\t\t\t #I took out the \"if\" statement used in the 1st solution, the \"?\" becomes a \"then\", and the \":\" means \"else\"\n\tnum_comma.reverse\nend",
"def test_for_various_length_inputs_for_mixed_delimiters\n assert_equal 30, @calculator.Add(\"10,10\\n10\")\n assert_equal 30, @calculator.Add(\"5\\n5\\n5,5\\n5,5\")\n assert_equal 30, @calculator.Add(\"5\\n5\\n5,5,5\\n5\")\n end",
"def bracketed_list(values)\n temp=\"\"\n temp += \"[\"\n values.each {|val| temp += \"#{val.to_s}, \"}\n temp += \"]\"\n return temp\nend",
"def parse\n new_emails = emails.delete(\",\")#removes commas\n individual_emails = new_emails.split.uniq #splits emails and deletes repetes\n end",
"def separate_comma(num)\n numarray = num.to_s.chars\n finarray = Array.new\n for i in 0..numarray.length-1\n if i % 3 == 0 && i > 0\n finarray.unshift(numarray.pop + \",\")\n else\n finarray.unshift(numarray.pop)\n end\n end\n return finarray.join\nend",
"def separate_comma(num)\n\tstr = num.to_s.split('')\n\tstr.reverse!\n\tcommas = []\n\tcount = 0\n\tstr.each do |i|\n\t\tif count < 3\n\t\t\tcommas.unshift(i)\n\t\t\tcount += 1\n\t\telsif count == 3 \n\t\t\tcommas.unshift(\",\")\n\t\t\tcommas.unshift(i)\n\t\t\tcount = 1\n\t\tend \n\tend\n\tcommas.join(\"\")\nend",
"def add_data(vals)\n\t\tvals.each_index{|index|\n\t\t\tvalue = vals[index].downcase.strip\n\n unless value.eql?('')\n if value.include?(';')\n @data[@fields[index + 1]].concat(value.split(';'))\n else\n @data[@fields[index + 1]]<<value\n end\n\n @data[@fields[index + 1]].uniq!\n end\n\t\t}\n\tend",
"def shopping_list(ingredients)\n\t\tlist = ingredients.split(/\\n/)\n\tend",
"def separate_comma(num)\n\tnum.to_s.reverse.chars.to_a.each_slice(3).to_a.map {|value|\n\t\tvalue.join(\"\")\n\t}.join(\",\").reverse\nend",
"def separate_comma(num)\n\tnum.to_s.reverse.chars.to_a.each_slice(3).to_a.map {|value|\n\t\tvalue.join(\"\")\n\t}.join(\",\").reverse\nend",
"def separate_comma(num)\n\tarray=num.to_s.chars.to_a.reverse\n\tarray.each_with_index do |x, index|\n\t\tif index % 3 == 0 && index > 0\n\t\t\tarray[index] += ',' \n\t\tend\n\tend\n\n\tnew_array=array.reverse.join('')\n\tnew_array\nend",
"def separate_comma(num)\n #define variables\n rev_array = num.to_s.reverse.split(\"\") #reverse array to count from end of num\n output_array = []\n counter = 0\n #begin .each loop\n rev_array.each do |x|\n if (counter%3) == 0 && output_array != [] #check for 3rd place\n output_array.push \",\"\n end\n output_array.push x\n counter += 1\n end\nreturn output_array.reverse.join\nend",
"def split_and_sub(sep,multi_def,multi)\t\n\t\t\t\tcmd_line = []\n\t\t\t\tmulti.split(sep).each do |sample_name|\n\t\t\t\t\tcmd_line << sub_placeholders(multi_def,self.samples_obj[sample_name])\n\t\t\t\tend\n\t\t\t\tcmd_line.join(sep)\n\t\t\tend",
"def single_numbers\n text, ary = parse_text, [] \n until text.empty?\n top, mid, bot, blank = text.shift(4)\n ary.push(*top.zip(mid, bot).map(&:join)) \n ary.push(\",\") unless text.empty? # add comas when input entered on multiple lines\n end\n ary\n end",
"def parse(list)\n return list if list.is_a?(Array)\n list.include?(',') ? parse_with_commas(list) : parse_with_spaces(list)\n end",
"def question_params\n prm=params.require(:question).permit(:title, :subject_id, :qtype, :description, :options, :difficulty,answer: [])\n prm[:teacher_id]=@logged_teacher.id\n answer=\"\"\n count=0\n prm[:answer].each{ |x|\n unless x.empty?\n answer+=x.to_s.strip+\",\"\n count+=1\n end\n }\n prm[:answer]=answer\n prm[:multiple]=true if count>1\n return prm\n end",
"def split; end",
"def parse \n #splits using regex\n #regex => comma space or space\n email_arr = @emails.split(/,\\s|\\s/)\n print email_arr\n #use set intersection with itself to remove dups\n (email_arr & email_arr)\n\n end",
"def separate_comma(num_to_comma)\n str = num_to_comma.to_s\n count = str.length\n if count < 4\n p str\n elsif (count - 1) % 3 == 0\n while count > 1 do\n count = count - 3\n str.insert(count, \",\")\n end\n elsif (count - 2) % 3 == 0\n while count > 2 do\n count = count - 3\n str.insert(count, \",\")\n end\n elsif (count - 3) % 3 == 0\n while count > 3 do\n count = count - 3\n str.insert(count, \",\")\n end\n end\n p str\nend",
"def separate_comma(number)\n\tnumber = number.to_s.split('')\n\tindex = number.length\n\twhile index > 3 do\n\t\t\tnumber.insert(index-3,\",\")\n\t\tindex-=3\n\tend\n\tnumber.join\nend",
"def separate_comma(num)\n\tnum_s = num.to_s\n\tdigits = num_s.length\n\tif digits <= 3\n\t\tnum_s\n\telsif digits % 3 == 0\n\t\tnum_s.scan(/.../).join(\",\")\n\telse\n\t\ti = digits % 3\n\t\tnum_s[0..i-1] + \",\" + num_s[i..-1].scan(/.../).join(\",\")\n\tend\nend",
"def add_ingredients(*ing)\n ing.join(', ')\nend",
"def getCsvText\r\n sep = \"|\"\r\n t = \"\"\r\n \r\n t << \"Question Number\" + sep \r\n questions.size.times do |i| \r\n t << (i + 1).to_s + sep \r\n end\r\n t << \"Points\"\r\n t << \"\\n\"\r\n \r\n t << \"Correct Answer\" + sep\r\n for question in questions \r\n t << correctAnswerText(question).to_s + sep \r\n end \r\n t << \"\\n\"\r\n \r\n for user in users \r\n t << user.getName + sep\r\n for question in questions \r\n t << answerText(user, question) + sep\r\n end \r\n t << getPoints(user).to_s\r\n t << \"\\n\" \r\n end\r\n return t \r\nend",
"def fields(text) \n p text.split(/[,\\s]+/)\nend",
"def separate_comma(number)\n \n if number == nil\n return nil\n end\n \n arr = number.to_s.reverse.split(//)\n \n \n if arr.length < 7\n j = 0\n \n elsif arr.length % 2 == 0\n j = 1\n else\n j = 2\n end\n \n \n \n if arr.length < 4\n return array.join.reverse.to_s\n \n else\n i = 3\n \n while i < arr.length + j do\n array.insert(i, ',')\n i += 4\n end\n end\n \n return array.join.reverse.to_s\n \nend",
"def separate_comma(number)\n\tif number.to_s.length >= 4 \n\t need_comma=[]\n\t need_comma=number.to_s.split(\"\")\n\t comma_hash={}\n\n\t number.to_s.length.times do |i|\n comma_hash[i+3] = need_comma[i] \n end\n \n \n comma_hash.each do |k, v| \n \t if k%3==0\n \t \tcomma_hash[k]<<\",\"\n \t end\n \tend\n\n\n\t real_number=[]\n\t real_number=comma_hash.values\n\t length=real_number.length\n\t real_number_two=real_number.delete(length)\n\nif real_number.last==\",\"\n\tputs real_number_two \nend\n\n puts real_number.join\n\telse \n\t puts number\n\tend\nend",
"def parse_comma_seperated_string(s)\n s.nil? ? [] : s.split(',')\n end",
"def separate_comma(digits_array)\n\n formatted_digits = digits_array.to_s.split(//)\n #p formatted_digits\n\n reverse_digits = formatted_digits.reverse\n #p reverse_digits\n\n slice_three = []\n reverse_digits.each_slice(3) {|slice| slice_three.push(slice)}\n #p slice_three\n\n join_subarrays = slice_three.map(&:join)\n #p join_subarrays\n\n insert_commas = []\n insert_commas = join_subarrays.join(',')\n #p insert_commas\n\n final = insert_commas.reverse\n p final\n\nend",
"def parse\n csv_emails.split(/,?\\s/).uniq\n end",
"def txt_from_answer\n search_result = QueryForKeywords.new(skills_in_request).call\n answer = search_result.to_array # Here we can decide what output we need\n\n \"\".tap do |str|\n if answer[0].present?\n people = answer[0].map(&:full_name).join(\", \")\n skills = answer[1].map(&:title).join(\", \")\n str << \"Your first choice(s): #{people}. They know about: #{skills}.\"\n end\n\n if answer[2].present?\n people = answer[2].map(&:full_name).join(\", \")\n skills = answer[3].map(&:title).join(\", \")\n str << \"\\nYour second choice(s): #{people}. They know about: #{skills}.\"\n end\n\n if answer[4].present?\n people = answer[4].map(&:full_name).join(\", \")\n skills = answer[5].map(&:title).join(\", \")\n str << \"\\nYour third choice(s): #{people}. They know about: #{skills}.\"\n end\n\n str << \"No results, maybe try another combination of keywords?\" if str.blank?\n end\n end",
"def commas(places = nil)\n group(places, ',')\n end",
"def parse(list)\n list.gsub(/[^\\w\\ ,]+/, '').squeeze(\" \").downcase.split(\",\").map(&:strip).reject { |s| s.blank? }.uniq\n end",
"def separate_comma(number)\n number.to_s.reverse.split(\"\").each_with_index { |x,y| x << \",\" if y == 3 || y == 6 }.reverse.join\nend",
"def separate_comma(user_integer)\n\tif user_integer.to_s.length <= 3\n\t\treturn user_integer.to_s\n\telse\n\t\tfinal_array=[]\n\t\tcounter_comma = (user_integer.to_s.length - 1) / 3\n\t\tuser_integer.to_s.split(\"\").reverse.each_slice(3) do |array|\n\t\t\tarray = array.push(\",\") if counter_comma > 0\n\t\t\tp array\n\t\t\tfinal_array = final_array + array\n\t\t\tcounter_comma -=1\n\t\tend\n\t\treturn final_array.reverse.join\n\tend\nend",
"def separate_comma(input)\n number= input.to_s\n if number.length>9\n number.insert(-4,',')\n number.insert(-8,',')\n number.insert(-12,',') \n elsif number.length>6\n \tnumber.insert(-4,',')\n number.insert(-8,',')\n elsif number.length>3\n \tnumber.insert(-4,',')\n else\n \treturn number\nend\nend",
"def separate_comma(number)\n num = number.to_s\n i = -4\n while i >= (-1 * num.length)\n num.insert(i, ',')\n i -= 4\n end\n p num.to_s\nend",
"def separate_comma(number)\n\n array = number.to_s.reverse.split(//)\n length = array.length\n\n if length<=6\n x = 0\n elsif length%2 == 0\n x = 1\n else \n x = 2\n end\n\n\n\n if length < 4\n return array.join.reverse.to_s \n else\n i = 3\n while i < length+n do\n array.insert(i, ',')\n i += 4\n end\n end\n return array.join.reverse.to_s\nend",
"def prepare_words(words)\n return [''] if words.blank?\n a = words.split(/[,\\s]/).map(&:strip)\n a.any? ? a : ['']\n end",
"def oxford_comma(array)\n\tcase array.count\n\twhen 1\n\t\tarray[0]\n\twhen 2\n\t\tarray.join(\" and \")\n\telse\n\t\tarray[array.count-1]=\"and \"+array.last#Add the and to the front of the least element\n\t\tresult = array.join(\", \")#Save the result of join to return later\n\t\tarray[array.count-1]=array.last[4..-1]# Attempt to return the starting elemnt to its default state\n\t\tresult#Kinda feel like there is an easier and cleaner way\n\tend\nend",
"def separate_comma(num)\n num = num.to_s\n index = num.length - 1\n if index < 3\n return num\n end\n\n index = index - 3\n\n while index > -1\n num.insert(index.next, \",\")\n index = index - 3\n end\n num\nend",
"def formatAnswersToSimple( answerArr )\n answerArr.join(\"~\")\n end",
"def separate_comma(integer)\n\tinteger = integer.to_s\n\ti = -4\n\tif integer.length <= 3\n\t\tp integer\n\telse\n\t\twhile i.abs <= integer.length\n\t\t\tinteger.insert(i,\",\")\n\t\t\ti -= 4\n\t\tend\n\tend\n\tp integer\nend",
"def parse_line( line )\n\tline.chomp!\n\tvalues = []\n\t#BEGIN_STUDENT\n\twords = line.split(',')\n words.each do |word|\n\t\tvalues += [word]\n end\n\treturn values\n\t#END_STUDENT\nend",
"def separate_comma(num) #takes an integer and converts it to a string with commas in appropriate places\n\tnumber_as_string = num.to_s #converts num to a string\n\tif number_as_string.length < 4 #checks if number isn't long enough to need a comma\n\t\tnumber_as_string #return the number as a string\n\telsif number_as_string.length < 7 #checks if number is bigger than 999, but less than 999,999\n\t\tnumber_as_string.insert -4, ',' #inserts a comma at the 4th from last place in string\n\telse\n\t\tnumber_with_1comma = number_as_string.insert -4, ',' #inserts a comma at the 4th from last place in string and saves that in a variable\n\t\tnumber_with_1comma.insert -8, ',' #inserts second comma in 8th from last place\n\tend\nend",
"def separate_comma (num)\n rev_num = num.to_s.reverse\n count = rev_num.length/3.1\n for i in 1..count\n num = rev_num.insert(4*i-1, \",\").reverse\n end\n num\nend",
"def separate_comma(input)\n number= input.to_s\n if number.length>9\n number.insert(-3,',')\n number.insert(-6,',')\n number.insert(-9,',') \n elsif number.length>6\n \tnumber.insert(-3,',')\n number.insert(-6,',')\n elsif number.length>3\n \tnumber.insert(-3,',')\n else\n \treturn number\nend\nend",
"def get_recipe_ingredients\n puts \"\\nWhat ingredients are in your recipe? Please enter ingredients separated by commas with no ands.\\n \".colorize(:green).bold\n user_ingredients = gets.strip\n if valid_user_input?(user_ingredients)\n user_ingredients.split(/\\s*\\,\\s*/)\n else\n puts \"\\nInvalid ingredients!\\n \".colorize(:red).bold\n get_recipe_ingredients\n end\n end",
"def oxford_comma(array)\n case array.size\n when 0\n \"\"\n when 1\n array.first\n when 2\n array.join(' and ')\n else\n [array[0..-2].join(', '), array.last].join(', and ')\n end\nend",
"def oxford_comma(array)\n if array.length == 1\n array.join # if one element return just this element\n elsif array.length == 2\n var = array[0..array.length-2].join(\", \") # all items except the last element will commas seperated\n var += \" and #{array[-1]}\" #last element will always be seperated by \", and \"\n else\n var = array[0..array.length-2].join(\", \") # all items except the last element will commas seperated\n var += \", and #{array[-1]}\" #last element will always be seperated by \", and \"\n end\nend",
"def separate_comma(int)\n\n result = []\n\n int.to_s.split(\"\").reverse.each_slice(3) do |slice|\n slice << \",\"\n result << slice\n end\n\n p result.flatten.join.chop.reverse\n\nend",
"def separate_comma(pos_integer)\n\t#final solution via Stack Overflow\n\tpos_integer.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(\",\").reverse\n\t\n\n\t# my original solution, didn't quite add commas correctly and couldn't figure out how to join it back together\n\t# list = new_array.reverse.each_slice(3) { |a| p \"#{a.join},\" }\n\n\nend",
"def separate_comma(num)\n\tif num < 1000\n\t\tp num.to_s\n\telse\n\tnew_num = []\n num = num.to_s.reverse\n num = num.chars.to_a\n until num.empty?\n new_num << num.shift(3) \n new_num.push(',')\n end\n new_num.pop\n p new_num.join.reverse\n \n end\nend",
"def separate_comma(integer)\n\tarr_int = integer.to_s.split(\"\").reverse.each_slice(3).to_a\n\tcommas = [\",\"] * integer.to_s.length\n\tanswer = arr_int.zip(commas).flatten.reverse.join\n\tif answer.start_with?(\",\")\n\t\tanswer[0] = \"\"\n\t\treturn answer\n\telse answer\n\tend\nend",
"def answer_texts\n self.answers.map { |a| a.choice }\n end",
"def answer_texts\n self.answers.map { |a| a.choice }\n end",
"def separate_comma(num)\n num_as_array = num.to_s.split(\"\").reverse\n curr_index = 0\n until (curr_index + 3) >= (num_as_array.length)\n curr_index += 3\n num_as_array[curr_index] = \",\" + num_as_array[curr_index]\n end\n num_as_array.join(\"\").reverse\nend",
"def question_to_csv(array)\n #mete las preguntas y respuestas a el array\n @model.ask_csv(array[0],array[1])\n end",
"def fields(input_fields)\n output = input_fields.gsub(/[\\s,]/ , \" \")\n output_array = output.split\n return output_array\nend"
] |
[
"0.680871",
"0.68013906",
"0.6725226",
"0.66144794",
"0.6599786",
"0.6464852",
"0.6413902",
"0.6099468",
"0.59617704",
"0.5886474",
"0.58621216",
"0.58137965",
"0.57926846",
"0.57704324",
"0.5759983",
"0.573695",
"0.5736252",
"0.5711745",
"0.57016957",
"0.5692117",
"0.5681086",
"0.5652553",
"0.5636154",
"0.5617797",
"0.56161",
"0.56038874",
"0.5592379",
"0.5590821",
"0.5587315",
"0.5573362",
"0.55700284",
"0.5555785",
"0.55517745",
"0.5550941",
"0.55482805",
"0.5543979",
"0.5543979",
"0.5532812",
"0.55231017",
"0.5519393",
"0.5511808",
"0.55117095",
"0.5510294",
"0.54775393",
"0.54701424",
"0.5468132",
"0.54675925",
"0.5464801",
"0.5449076",
"0.5447558",
"0.54454994",
"0.54454994",
"0.54425186",
"0.543921",
"0.5435461",
"0.5431444",
"0.5418849",
"0.5418793",
"0.5417586",
"0.54132575",
"0.540883",
"0.54068667",
"0.54056257",
"0.5397002",
"0.5395958",
"0.5385009",
"0.53768384",
"0.5376463",
"0.53749603",
"0.53704375",
"0.53637797",
"0.53627783",
"0.5360661",
"0.5355933",
"0.5349083",
"0.5347593",
"0.53470135",
"0.53457755",
"0.53396505",
"0.5339014",
"0.53363687",
"0.53363067",
"0.5333063",
"0.53295577",
"0.53279954",
"0.53235453",
"0.5320215",
"0.5319323",
"0.53186345",
"0.5317296",
"0.53172183",
"0.5315198",
"0.5314178",
"0.5313335",
"0.5303656",
"0.52973336",
"0.52973336",
"0.5291688",
"0.52885056",
"0.52790695"
] |
0.62643254
|
7
|
Getter for the +synonym_dictionaries+ class variable
|
def synonym_dictionaries
@@synonym_dictionaries
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def synonym_dict\n return @@synonym_dict if @@synonym_dict\n @@synonym_dict = {}\n config[\"synonyms\"].each do |syn_set|\n syn_set.each {|syn| @@synonym_dict[syn] ||= Set.new; @@synonym_dict[syn].merge syn_set }\n end\n @@synonym_dict\n end",
"def synonyms\n @synonyms ||= self.class.synonyms\n @synonyms\n end",
"def synonyms; end",
"def get_synonym(property, key)\n return unless property[:synonyms] && property[:synonyms].include?(key)\n property[:synonyms][key]\n end",
"def _autonyms\n @autonyms\n end",
"def synonyms #:nodoc:\n select_all(\"SELECT synonym_name, table_owner, table_name, db_link FROM all_synonyms where owner = SYS_CONTEXT('userenv', 'session_user')\").collect do |row|\n OracleEnhanced::SynonymDefinition.new(oracle_downcase(row[\"synonym_name\"]),\n oracle_downcase(row[\"table_owner\"]), oracle_downcase(row[\"table_name\"]), oracle_downcase(row[\"db_link\"]))\n end\n end",
"def synonyms\n @synonyms ||= {\n /^awesome$/i => %w[great excellent cool awesome splendid],\n /^okay$/i => %w[okay great alright],\n /^hello$/i => %w[hello hi greetings],\n /^yes$/i => %w[yes affirmative definitely correct certainly],\n /^no$/i => %w[no negative incorrect false],\n /^update$/i => %w[update change modify revise alter edit adjust],\n /^updated$/i => %w[updated changed modified revised altered edited adjusted],\n /^add$/i => %w[add create],\n /^added$/i => %w[added created],\n /^what|how$/i => %w[how what]\n }\n end",
"def get_synonym_set(engine_name, id)\n get(\"engines/#{engine_name}/synonyms/#{id}\")\n end",
"def dictionary\n @dictionary\n end",
"def synonyms(opts = {})\n self.meanings.uniq.collect { |ref| ref.tags }.flatten.uniq\n end",
"def get_term_from_synonym\n sql = <<-SQL\n select term.*\n from term\n join ontology on ontology.ontology_id = term.ontology_id\n join term_synonym on term.term_pk = term_synonym.term_pk\n where term_synonym.synonym_value = ?\n order by ontology.fully_loaded desc, ontology.load_date asc\n SQL\n \n term_set = OLS_DB[ sql, @name ].all()\n \n raise OntologyTermNotFoundError, \"Unable to find the term '#{@name}' in the OLS database.\" \\\n if term_set.size == 0\n \n subject = term_set.first\n @name = subject[:identifier]\n @content = subject[:term_name]\n @term_pk = subject[:term_pk]\n @ontology_id = subject[:ontology_id]\n end",
"def dictionary()\n return @data[:words]\n end",
"def nouns\n\t\treturn synsets_dataset.nouns\n\tend",
"def name\n \tself.marker_synonyms.collect{|ms| ms.name}.join(',')\n end",
"def lookup_silo_name\n return \"#{self.name.gsub('::', '__')}_dict\"\n end",
"def dictionary\n @dictionary ||= Dictionary.new(@word)\n end",
"def symbolize_keys; end",
"def dictionary_exists? dictionary\r\n synonym_dictionaries.key?(dictionary.capitalize)\r\n end",
"def universal_dictionary\n @universal_dictionary\n end",
"def noun_phrases\n _noun_phrases\n end",
"def noun_phrases\n _noun_phrases\n end",
"def synonym(existing_word, *synonyms)\n existing_word = existing_word.to_s\n raise \"'#{existing_word}' is not in the vocabulary\" if type(existing_word).nil?\n reduced_form = reduce(existing_word)\n [synonyms].flatten.each do |syn|\n syn = syn.to_s\n existing_definition = @type_map[syn]\n if existing_definition.nil?\n @type_map[syn] = reduced_form\n elsif existing_definition != reduced_form\n raise \"'#{syn}' is already defined and is incompatible as a synonym of #{existing_word}\"\n end\n end\n end",
"def getVarMap\n\t\t@var_map\n\tend",
"def wordnet_lookup_syns(lemma, pos)\n # Convert back to wordnet format\n lemma = lemma.tr(' ', '_')\n if (wordnet_lemma = WordNet::Lemma.find(lemma, pos))\n # Fetch all synonyms (combining all senses of the word)\n wordnet_lemma.synsets.flat_map(&:words).map do |w|\n # Clean up the output\n # - Adjectives can have an adjective marker at their end which needs be\n # stripped. Eg. beautiful(ip), beautiful(p), beautiful(a)\n # - Replace underscores with spaces\n w.gsub(/\\([a-z]*\\)$/, '').tr('_', ' ')\n end\n else\n []\n end\n end",
"def []( word, *args )\n\t\tif word.is_a?( Integer )\n\t\t\t# :TODO: Assumes Synset IDs are all >= 100_000_000\n\t\t\tif word.to_s.length > 8\n\t\t\t\treturn WordNet::Synset[ word ]\n\t\t\telse\n\t\t\t\treturn WordNet::Word[ word ]\n\t\t\tend\n\t\telse\n\t\t\treturn self.lookup_synsets( word, 1, *args ).first\n\t\tend\n\tend",
"def set_syndic\n @syndic = Syndic.find(params[:id])\n end",
"def hash\n self.class.hash ^ @ns.hash\n end",
"def symbolize_keys!; self end",
"def lesson_word_synonym_params\n params.require(:lesson_word_synonym).permit(:lesson_word_id, :synonym_id)\n end",
"def get_word\n dictionary.get_word\n end",
"def dictionary_set\n @@dictionary_set ||= Set.new.tap do |set|\n DICTIONARY_BREAK_ENGINES.each do |break_engine|\n set.merge(break_engine.word_set)\n end\n end\n end",
"def get_definitions\n Dictionary.find_by_word(word_id)\n end",
"def get_term_details\n # This query ensures we look at the most recent fully loaded ontologies\n sql = <<-SQL\n select term.*\n from term\n join ontology on ontology.ontology_id = term.ontology_id\n where term.identifier = ?\n order by ontology.fully_loaded desc, ontology.load_date asc\n SQL\n \n term_set = OLS_DB[ sql, @name ].all()\n \n if term_set.size == 0\n get_term_from_synonym\n else\n subject = term_set.first\n @content = subject[:term_name]\n @term_pk = subject[:term_pk]\n @ontology_id = subject[:ontology_id]\n end\n end",
"def set_lesson_word_synonym\n begin\n @course = Course.find(params[:course_id])\n @lesson = Lesson.find(params[:lesson_id])\n @lesson_word_synonym = LessonWordSynonym.find_by!(synonym_id: params[:synonym_id], lesson_word_id: params[:lesson_word_id])\n end\n end",
"def get_country_synonym(affi_string)\n cleared_affi_string = country_exclude(affi_string)\n $country_synonyms.keys.each do |ctry_key|\n if cleared_affi_string.include?(ctry_key.to_s)\n return ctry_key.to_s\n end\n end\n return nil\nend",
"def find_synonyms(synonyms)\n return self.find_helper(@start_node, synonyms)\n end",
"def symbolize\n Hash.new\n end",
"def dictionary\n @dictionary ||= ngrams.first.probabilities \n end",
"def instance_variable_names; end",
"def dictionary\n @dictionary ||= Set.new(File.read('../dictionary.txt').downcase.split(\"\\n\"))\n end",
"def describe_synonym(schema_name, synonym_name) #:nodoc:\n raise NoMethodError, \"Not implemented for this raw driver\"\n end",
"def variable_objects()\n @var_set.values\n end",
"def dictionary\n return {} if self.collection_yaml.nil?\n return self[:dictionary] unless self[:dictionary].nil?\n \n document_words = self.treat_collection.documents.map { |doc| doc.words }\n \n self[:dictionary] = Hash.new\n document_words.each do |word_list|\n word_list.each do |word|\n dictionary[word.to_s.downcase] = word.tf_idf\n end\n end\n self.save!\n \n self[:dictionary]\n end",
"def words_with_unapproved_synonyms\n return Keyword.joins(:synonyms).where(\"synonyms.approved\" => false).all\n end",
"def getSAttr()\n return @obj_secondattr\n end",
"def class_variable_get(sym) end",
"def attr_values\n values = self.instance_variables.collect do |key|\n [key, self.instance_variable_get(key)]\n end\n return Hash[values]\n end",
"def to_savon\n hash = Hash.new()\n type_mappings.keys.each do |ivar_name|\n value = map_to_savon(ivar_name, instance_variable_get(\"@#{ivar_name}\"))\n hash[ivar_name.to_sym] = value unless value.nil?\n end\n hash\n end",
"def show\n @meanings = Meaning.where(word_id: @word.id)\n @synonymous = Synonymou.all\n end",
"def get_class_variable_pins(namespace); end",
"def instance_variables() end",
"def symbolized_instance_variables\n instance_variables.map { |ivar| ivar.to_sym }\n end",
"def symbolize_keys!\n self.class.symbolize_keys(self)\n end",
"def semantic_search_keys \n semantic_search_map.keys\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def sa\n return self[:sa]\n end",
"def semantic_search_map \n # Hash[] conveniently takes an array of k-v pairs. \n return Hash[\n search_field_definitions.collect do |field, defn|\n [ defn[:semantic].to_s, field ] if defn && defn[:semantic]\n end.compact \n ]\n end",
"def gyms\n self.memberships.map {|membership| membership.gym}\n end",
"def associated_object_keys\n self[:keys]\n end",
"def get_synonym_for(word, country = nil, age_from = nil, age_to = nil,\n gender = nil, education = nil)\n keyword = Keyword.find_by_name(word)\n\n if keyword.blank?\n Keyword.add_keyword_to_database(word)\n return nil\n end\n\n if self.project.present?\n prefered_synonym = PreferedSynonym\n .where(keyword_id: keyword.id, project_id: self.project.id).first\n return prefered_synonym.synonym if prefered_synonym.present?\n\n country = self.project.country unless country.present?\n age_from = self.project.minAge unless age_from.present?\n age_to = self.project.maxAge unless age_to.present?\n gender = self.project.gender unless gender.present?\n education = self.project.education_level unless education.present?\n end\n\n synonym_list, votes_count =\n keyword.retrieve_synonyms(country, age_from, age_to, gender, education)\n synonym_list.first\n end",
"def class_variables() end",
"def attribute_for sym\n @@array = attributes\n val = @@const_map[sym]\n val if attributes.include? val\n end",
"def vars\n @vars ||= soln.keys\n @vars\n end",
"def attribute_keys_to_copy_to_neo4j\n self.class.instance_variable_get :@attribute_keys_to_copy_to_neo4j\n end",
"def variables\n return @variables unless @variables.nil?\n vars = []\n dict = @instance.getDictionary\n dict.getVariables.each do |var|\n vars << {\n :name => var.getName,\n :qual => var.getQualification.toString.downcase.to_sym,\n :type => var.getType.toString.downcase.to_sym,\n :formula => var.getFormula.getValue,\n :variable => var,\n }\n end\n @variables = vars\n end",
"def mappings\n @mappings ||= []\n end",
"def dict?\n @last_word_pronunciation.first.dict?\n end",
"def property_for(term)\n if mapping.key?(term) && metadata.respond_to?(mapping[term])\n mapping[term]\n elsif metadata.respond_to?(term)\n term\n end\n end",
"def molecule_synonym_params\n params.require(:molecule_synonym).permit(:molecule_id, :synonym)\n end",
"def gyms\n self.memberships.map do |membership_instance|\n membership_instance.gym \n end\n end",
"def []( sym )\n @hash_references[sym]\n end",
"def accessors\n @tracked_attrs.keys ||= []\n end",
"def class_variables; end",
"def word_values\n return @words.values\n end",
"def s1\n return self[:s1]\n end",
"def s1\n return self[:s1]\n end",
"def s1\n return self[:s1]\n end",
"def s1\n return self[:s1]\n end",
"def s1\n return self[:s1]\n end",
"def s1\n return self[:s1]\n end"
] |
[
"0.72524345",
"0.7052447",
"0.6648062",
"0.6587201",
"0.6079081",
"0.6041376",
"0.60287887",
"0.58597106",
"0.57994384",
"0.56783175",
"0.5657994",
"0.5577216",
"0.5484738",
"0.5428246",
"0.54171556",
"0.5338815",
"0.5298998",
"0.5243255",
"0.52053016",
"0.5148142",
"0.5148142",
"0.51190585",
"0.50861466",
"0.5072289",
"0.5051201",
"0.5040339",
"0.503663",
"0.50323945",
"0.5020368",
"0.500602",
"0.49915516",
"0.49873272",
"0.49701104",
"0.494843",
"0.49477726",
"0.49454075",
"0.49222383",
"0.4916586",
"0.4915584",
"0.49070218",
"0.48836458",
"0.4875485",
"0.48637047",
"0.4835781",
"0.48281938",
"0.48244378",
"0.48174304",
"0.48150304",
"0.4806828",
"0.4805133",
"0.48047122",
"0.48034355",
"0.48032355",
"0.4796254",
"0.47901037",
"0.47901037",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47900224",
"0.47896677",
"0.4789579",
"0.4787919",
"0.4783348",
"0.47831115",
"0.47793275",
"0.47753564",
"0.47741157",
"0.4767105",
"0.47606856",
"0.47539598",
"0.47539315",
"0.47482914",
"0.47345594",
"0.47253278",
"0.47247753",
"0.47219464",
"0.47076824",
"0.47073972",
"0.47073972",
"0.47073972",
"0.47073972",
"0.47073972",
"0.47073972"
] |
0.8335839
|
0
|
Checks if the given +dictionary+ symbol is a key in the +synonym_dictionaries+ class variable
|
def dictionary_exists? dictionary
synonym_dictionaries.key?(dictionary.capitalize)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_for_dictionary(dictionary)\n right = dictionary.word_present?(@word)\n return true if right\n false\n end",
"def checking_dictionary_for_word_match\n valid_word?(@prefix)\n end",
"def is_word?(word)\n Constants::DICTIONARY.key?(word.downcase)\n end",
"def tag_in_dictionary?\n !@definition.nil?\n end",
"def dictionary_words? set\n (set & DICTIONARY) == set\n end",
"def has_symbol?(sym)\n\t\t\t@parameters.key?(sym) or @species.key?(sym)\n\t\tend",
"def dictionary_exist?(dic_name)\n\t\t@db::Dictionary.where(:title => dic_name).present?\n\tend",
"def spelled_correctly?(word)\n if @word_list.is_a? Hash\n @word_list.keys.include?(word)\n else\n @word_list.include?(word)\n end\n end",
"def has_key?(symbol)\n immediate_has_key?(symbol) or @parent && @parent.has_key?(symbol)\n end",
"def verified_namespace?(hash, expected_name)\n hash.respond_to?(:has_key?) && hash.has_key?(expected_name.to_s)\n end",
"def exists(word)\n Rails.logger.debug { \"DictionaryGateway#exists(#{word})\" }\n exists = true\n begin\n RestClient::Request.execute(\n method: :get,\n url: \"https://od-api.oxforddictionaries.com/api/v2/entries/en-us/#{word}\",\n timeout: TIMEOUT_SECONDS,\n headers: { 'app_id' => ENV['DICTIONARY_API_APP_ID'],\n 'app_key' => ENV['DICTIONARY_API_APP_KEY'] }\n )\n\n rescue RestClient::Forbidden\n Rails.logger.debug do\n '403 Forbidden from Oxford API ' \\\n \"BOGGLE_APP_ID=#{ENV['DICTIONARY_API_APP_ID']};\" \\\n \"BOGGLE_APP_KEY=#{ENV['DICTIONARY_API_APP_KEY']}\"\n end\n raise\n rescue RestClient::NotFound\n # ignore and leave exists false\n exists = false\n end\n\n exists\n end",
"def is_word?(string, dictionary = Dictionary.new)\n dictionary.include?(string)\nend",
"def mapping_name_is_valid?(mapping_name)\n mapping_name.class == Symbol\n end",
"def is_valid_word?(word)\n DICTIONARY.include?(word)\n end",
"def synonym_dictionaries\r\n @@synonym_dictionaries\r\n end",
"def my_include?(dict, query)\n dict.each do |valid_word|\n if valid_word == query\n return true\n end\n end\n return false\nend",
"def dict?\n @last_word_pronunciation.first.dict?\n end",
"def contains(identifier)\n\t\treturn @symbols.has_key?(identifier)\n\tend",
"def word_exists?(word)\n @wordlist.key?(word)\n end",
"def get_synonym(property, key)\n return unless property[:synonyms] && property[:synonyms].include?(key)\n property[:synonyms][key]\n end",
"def is_word?(fragment)\n dictionary.include?(fragment)\n end",
"def has_key?(key)\n @map.has_key?(key.to_sym)\n end",
"def has_key?(key)\n @h.has_key?(key.to_sym)\n end",
"def key?(key)\n @aliases.key? key\n end",
"def check\n @dictionaries.each do |dictionary|\n @right = check_for_dictionary(dictionary)\n return true if @right\n end\n false\n end",
"def include?(word)\n @table.keys.include?(word)\n end",
"def check_if_present(word)\n chars = word.downcase.split('')\n match = false\n char_count = 0\n crawl = root\n\n chars.each do |a_char|\n char_count += 1\n child = crawl.children\n if child.keys.include?(a_char)\n crawl = child[a_char]\n if crawl.is_end && (char_count == chars.length)\n match=true\n end\n else\n break;\n end\n end\n match # returns if the word is in dictionary or not.\n end",
"def key?(name)\n ::Kernel.raise TypeError, \"name #{name} must convert to_sym\" unless name and name.respond_to?(:to_sym)\n @locals.has_key?(name.to_sym)\n end",
"def test\n dict_list = make_list\n #make sure they're the same length\n if @word1.length != @word2.length\n puts \"Error: Words of different lengths\"\n false\n #make sure it is in the dictionary file\n elsif (!dict_list.include?(@word1)||!dict_list.include?(@word2))\n puts \"Error: Word does not exist\"\n false\n else\n true\n end\n end",
"def key?(key)\n lookup_map.key?(key.to_sym)\n end",
"def has_entry?( dictionary_name, key_name )\n\n KeyError.not_new( dictionary_name, self )\n KeyError.not_new( key_name, self )\n\n return false unless self.has_key?( dictionary_name )\n return self[ dictionary_name ].has_key?( key_name )\n\n end",
"def has_key?(key)\n #if the key is an alias, lookup the real key\n key = aliasing_hash_aliases[key] if aliasing_hash_aliases.include?(key)\n \n super\n end",
"def known_symbol?(s)\n @@known_symbols_by_glass[glass] && @@known_symbols_by_glass[glass].member?(s)\n end",
"def class_variable_defined?(sym) end",
"def has_attributes?(dictname)\n self.attribute_dictionary(dictname) != nil || self.definition.attribute_dictionary(dictname) != nil\nend",
"def valid?(key)\n MENUS.keys.map(&:to_sym).include?(key.to_sym)\n end",
"def include?( word )\n @entries.each do |keyWord, value|\n if word == keyWord # does word match keyword, return true as the hash is stored for word\n return true\n end\n end\n return false # word not found as keyword in entries, not included\n end",
"def has?(key)\n @definitions.has_key?(key)\n end",
"def checking_dictionary_for_word_match\n @prefix = @str[@i_last_real_word...@i]\n \n if valid_word?(@prefix)\n if @skip_counter > 0\n @skip_counter -= 1\n else\n @words[i] = @prefix\n @i_last_real_word = @i\n end\n end\n end",
"def check_dictionary(dict)\n dictionary_redux = []\n for word in dict\n result = check_word(word)\n if result\n dictionary_redux << word\n end\n end\n new_dict = add_reversals(dictionary_redux)\n return new_dict\n end",
"def has_key?(key)\n key.kind_of?(Symbol) ? self.has_key?(key.to_s) : super(key)\n end",
"def dictionary\n words_hash= {:hello => \"hi\", :to => \"2\", :two => \"2\", :too => \"2\", :for => \"4\", :For => 4, :four => \"4\", :be => \"b\", :you => \"u\", :at => \"@\", :and => \"&\"}\n #if words_hash.has_key?(word_sym_key)\n # return words_hash[word_sym_key]\n # end\nend",
"def is_existential_type\n @phrases.size == 1 and\n @phrases[0].is_a?(NounPhrase) and\n !@phrases[0].literal\n end",
"def symbolized?\n all? do |key,value|\n next false unless key == (key.to_sym rescue nil)\n next value.respond_to?(:symbolized?) ? value.symbolized? : true\n end\n end",
"def isnoun(arr)\n bool = false\n arr.each do |noun|\n @synsets.each do |key, values|\n bool = values.include?(noun)\n if bool == true\n break\n end\n end\n if bool == false\n break\n end\n end\n bool\n end",
"def synonym_dict\n return @@synonym_dict if @@synonym_dict\n @@synonym_dict = {}\n config[\"synonyms\"].each do |syn_set|\n syn_set.each {|syn| @@synonym_dict[syn] ||= Set.new; @@synonym_dict[syn].merge syn_set }\n end\n @@synonym_dict\n end",
"def is?(term, type_sym)\n return term[:type] == type_sym\n end",
"def has_key?(key); end",
"def has_key?(key); end",
"def has_key?(p0) end",
"def valid_symbol?(symbol)\n return false if [].include?(symbol)\n true\n end",
"def alias? key\n target = @validators[String(key).to_sym]\n target.is_a?(::Symbol) ? target : nil\n end",
"def has_key?(key_or_instance)\n proxy_across_keytypes(:has_key?, key_or_instance)\n end",
"def dictionary(word)\n dictionary = [\"apple\", \"pie\", \"a\",\n \"hello\", \"world\", \"he\"]\n\n dictionary.include?(word)\nend",
"def dictionary_exists?\n unless File.exist?(\"dictionary.txt\")\n scrub_dictionary(@@raw_dictionary)\n create_dictionary_file(scrub_dictionary(@@raw_dictionary))\n end\n\n end",
"def is_noun(token)\n _is_in(token, @noun_tags)\n end",
"def synonym(existing_word, *synonyms)\n existing_word = existing_word.to_s\n raise \"'#{existing_word}' is not in the vocabulary\" if type(existing_word).nil?\n reduced_form = reduce(existing_word)\n [synonyms].flatten.each do |syn|\n syn = syn.to_s\n existing_definition = @type_map[syn]\n if existing_definition.nil?\n @type_map[syn] = reduced_form\n elsif existing_definition != reduced_form\n raise \"'#{syn}' is already defined and is incompatible as a synonym of #{existing_word}\"\n end\n end\n end",
"def is_prefix?(word)\n Constants::PREFIXES.key?(word.downcase)\n end",
"def has_key? key; key? key; end",
"def api_valid_word?(variable)\n url = \"https://wagon-dictionary.herokuapp.com/#{variable}\"\n wagon_dictionary_serialized = open(url).read\n dictionary = JSON.parse(wagon_dictionary_serialized)\n\n valid_attempt = dictionary['found']\n return valid_attempt\nend",
"def key?(key)\n public_method_defined?(key.to_sym)\n end",
"def instance_attribute_defined?(key)\n case key\n when Symbol\n return instance_variable_defined?(\"@#{key}\")\n when String\n return instance_variable_defined?(\"@#{key}\")\n end\n end",
"def unqualify?(key)\n key[0, 1] == \":\"\n end",
"def respond_to?( sym )\n has_key?( sym ) || super\n end",
"def is_in_english_dict?(input)\n dictionary = CSV.read(\"assets/dictionary-english.csv\")\n valid_word = dictionary.include?(input.downcase) ? true : false\n return valid_word\nend",
"def is_codeword_solved?\n\t\t!@codeword_hash.include?(\"_\") ? true : false\n end",
"def word_matches_context? word, namespace, scope, pin\n return false unless word == pin.name\n return true if pin.kind == Pin::NAMESPACE and pin.path == namespace and scope == :class\n return true if pin.kind == Pin::METHOD and pin.namespace == namespace and pin.scope == scope\n # @todo Handle instance variables, class variables, etc. in various ways\n pin.namespace == namespace and pin.scope == scope\n end",
"def includes? hash\n hash.each_pair do |key, value|\n return false unless send(\"#{key}\") == value\n end\n true\n end",
"def has_key?(key)\n any? {|mod| mod.name == key}\n end",
"def hash_and_matches_redundant_keys?(key, value)\n value.is_a?(Hash) && REDUNDANT_KEYS.any? { |sym| sym == key }\n end",
"def aliased?\n key != name\n end",
"def has_attributes?(dictname)\n self.attribute_dictionary(dictname) != nil\nend",
"def is_in_english_dict?(input)\n input.downcase! \n\n dictionary = CSV.read(\"assets/dictionary-english.csv\")\n dictionary = dictionary.flatten\n\n dictionary.include?(input) ? true : false\nend",
"def has_key?(key)\n @configuration.has_key?(key.to_sym)\n end",
"def submit_word(word)\n letters_present_for(word) && @dictionary.include?(word)\n end",
"def has_singleton?(key)\n return false unless @extensions\n @extensions.key?(key) || @extensions.key?(key.downcase)\n end",
"def has_singleton?(key)\n return false unless @extensions\n @extensions.key?(key) || @extensions.key?(key.downcase)\n end",
"def is_pronoun(token)\n _is_in(token, @pronoun_tags)\n end",
"def hash_correct?(hash)\n hash.keys.all? { |key| ALLOWED_KEYS.include?(key) }\n end",
"def has_key?( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && contains_key( key )\n end",
"def check_name(hash, name_to_check)\n hash.each_key do |name|\n if name == name_to_check\n true\n else\n false\n end\n end\nend",
"def key?(name)\n raw.key?(name.to_s)\n end",
"def identifier_valid?(key)\n key = key.to_s\n ForbiddenChars.each_char do |char|\n return false if key.include?(char)\n end\n end",
"def isNT?(s)\n @ntIndex.has_key?(s)\n end",
"def uncountable?(word)\n Noun[word].uncountable?\n end",
"def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end",
"def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end",
"def has_key?(name)\n hashed.has_key? name\n end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def dict_symbol(plurality)\n # do not allow plurality of :none for a word that has plurality\n # this is a redundant error check and should not happen\n plurality = [:singular, :plural].sample if @can_be_plural && plurality == :none\n\n if plurality == :common || (@can_be_plural && [:singular, :plural].include?(plurality))\n # word can be plural or is from the common set\n \"#{@base_symbol.to_s}_#{plurality.to_s}\".to_sym\n else\n # word type is not relevent to plurality\n @base_symbol\n end\n end",
"def item_included?(str, hash)\n hash.each do |key, value|\n return true if key == str\n end\n false\nend",
"def has_key?(key)\n @hash.has_key?(key)\n end",
"def has_key?(attr_name)\n keys.include?(attr_name.to_s)\n end",
"def has_key(hash, key)\n\thash.has_key? key\nend",
"def lookup_dictionary(abbrev)\n results = []\n dictionary.each do |key, values|\n next if values.nil?\n matched_keys = values.keys.select { |k| k.to_s.casecmp(abbrev) == 0 }\n # => ['tbd', 'rhel'] ...\n matched_keys.each do |k|\n results << [k, values[k]]\n end\n end\n results.empty? ? false : results\n end"
] |
[
"0.6732161",
"0.6651128",
"0.62585914",
"0.619724",
"0.61556536",
"0.6082066",
"0.5996537",
"0.5889723",
"0.5883029",
"0.5878499",
"0.5804458",
"0.5798499",
"0.5776489",
"0.5756547",
"0.5722699",
"0.57173216",
"0.56295604",
"0.5624733",
"0.55810237",
"0.55740976",
"0.5567953",
"0.5551805",
"0.55381024",
"0.5534263",
"0.5522138",
"0.5522117",
"0.551334",
"0.549393",
"0.5493287",
"0.5485423",
"0.54193115",
"0.54149693",
"0.5391319",
"0.5378467",
"0.5372981",
"0.53374493",
"0.5334071",
"0.53215265",
"0.53213274",
"0.5307868",
"0.53068995",
"0.5300882",
"0.5290009",
"0.5281305",
"0.5276008",
"0.52515084",
"0.5250242",
"0.5248151",
"0.5248151",
"0.5219329",
"0.5214844",
"0.52102786",
"0.52091706",
"0.52062804",
"0.51812845",
"0.51779205",
"0.51620215",
"0.51506233",
"0.514845",
"0.5145044",
"0.5137244",
"0.5125755",
"0.5125297",
"0.5123582",
"0.5110618",
"0.51099944",
"0.51090735",
"0.5098247",
"0.5093271",
"0.50927395",
"0.5085682",
"0.50821507",
"0.50805265",
"0.5080396",
"0.50680363",
"0.5064282",
"0.5064282",
"0.50638723",
"0.506012",
"0.5053483",
"0.5050262",
"0.5042983",
"0.50359005",
"0.503204",
"0.5031812",
"0.50315064",
"0.50315064",
"0.5025837",
"0.5018135",
"0.5018135",
"0.5018135",
"0.5018135",
"0.5018135",
"0.5018135",
"0.50075734",
"0.49895218",
"0.49803776",
"0.49748972",
"0.49735332",
"0.49664485"
] |
0.7829819
|
0
|
Output the config settings
|
def output_config
puts 'Using config file: ' + $CONFIG_FILE
@conf.each { |key, value| puts key + " = " + value }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_config\n self.config_to_hash.each { |k, v| puts \"#{k}: #{v}\" }\n end",
"def display_config\n # Format types and the additional options that apply to each type\n format_opts = {\n \"block\" => [\n \"entry-break\",\n \"element-break\",\n \"exit-break\",\n \"subindent\",\n \"normalize\",\n \"wrap-length\"\n ],\n \"inline\" => [ ],\n \"verbatim\" => [ ]\n }\n @elt_opts.keys.sort.each do |elt_name|\n puts elt_name\n opts = @elt_opts[elt_name]\n format = opts[\"format\"]\n # Write out format type, then options that apply to the format type\n puts \" format = #{format}\"\n format_opts[format].each do |opt_name|\n puts \" #{opt_name} = #{opts[opt_name]}\"\n end\n puts\n end\n end",
"def config\n \n # TODO: Re-enable:\n # # Display the value for a specific machine.\n # $ rudy -e prod -r db config param-name\n \n if @@config.nil? || @@config.empty?\n return if @@global.quiet\n raise Rudy::NoConfig\n end\n\n outform = @@global.format == :json ? :to_json : :to_yaml\n \n types = @option.marshal_dump.keys & @@config.keys # Intersections only\n types = @@config.keys if @option.all\n types = [:machines] if types.empty?\n \n if @option.project\n rf = File.join(RUDY_HOME, 'Rudyfile')\n raise \"Cannot find: #{rf}\" unless File.exists?(rf)\n li File.read(rf)\n \n elsif @option.script\n conf = fetch_script_config\n li conf.to_hash.send(outform) if conf\n \n else\n #li \"# ACCOUNTS: [not displayed]\" if types.delete(:accounts)\n types.each do |conftype|\n li \"# #{conftype.to_s.upcase}\"\n next unless @@config[conftype] # Nothing to output\n if conftype == :accounts\n skey = @@config[conftype][:aws][:secretkey]\n @@config[conftype][:aws][:secretkey] = hide_secret_key(skey)\n end\n \n li @@config[conftype].to_hash.send(outform)\n end\n end\n \n end",
"def output\n puts \"Config files exist for the following sites:\"\n @local[CONFIG_DIR].contents.each do |file|\n puts \"\\t\"+file.name.split('.')[0..-3].to_s+\"\\t\"+file.last_modified.to_s\n end\n\n # And output our help file, too!\n RDoc::usage('synopsis')\n end",
"def config\r\n\t\t\t\"<p>No additional configuration is available</p>\"\r\n\t\tend",
"def list_settings\n configure do |settings|\n settings.reject { |_, setting| setting.internal? }.each do |name, setting|\n @env.ui.info \"#{name}\\t#{setting.description}\", bold: true\n @env.ui.info indent(setting.help, 2) unless setting.help.nil?\n value_info = \"Current value: #{setting.value}\"\n value_info += ' (default)' unless setting.set?\n @env.ui.info indent(value_info, 2)\n @env.ui.info ''\n end\n end\n end",
"def to_config\n require_relative '../../puppet/util/docs'\n # Scrub any funky indentation; comment out description.\n str = Puppet::Util::Docs.scrub(@desc).gsub(/^/, \"# \") + \"\\n\"\n\n # Add in a statement about the default.\n str << \"# The default value is '#{default(true)}'.\\n\" if default(true)\n\n # If the value has not been overridden, then print it out commented\n # and unconverted, so it's clear that that's the default and how it\n # works.\n value = @settings.value(self.name)\n\n if value != @default\n line = \"#{@name} = #{value}\"\n else\n line = \"# #{@name} = #{@default}\"\n end\n\n str << (line + \"\\n\")\n\n # Indent\n str.gsub(/^/, \" \")\n end",
"def output\n @tool.config_file :local_dir, \"#{@service_name}.conf\" do |configfile|\n configfile << @tool.git_header('palletjack2unbound')\n @service_config['service.unbound.server'].each do |config|\n config.each do |key, value|\n configfile << \"#{key}: #{value}\\n\"\n end\n end\n end\n end",
"def do_print_configuration\n frame('Configuration') do\n fade_code = CLI::UI::Color.new(90, '').code\n puts stylize(\"{{?}} #{fade_code}Values starting with {{*}} #{fade_code}were lazy loaded.#{CLI::UI::Color::RESET.code}\")\n print \"\\n\"\n\n configuration.instance_variables.each do |attribute|\n value = configuration.instance_variable_get(attribute)\n\n name = attribute.to_s.sub(/^@/, '')\n\n if value.respond_to? :call\n if @arguments.resolve_callable_attributes?\n value = begin\n configuration.send(name)\n rescue => e\n \"UNABLE TO LOAD: #{e.message}\"\n end\n end\n\n was_callable = true\n else\n was_callable = false\n end\n\n suffix = was_callable ? '{{*}}' : ' '\n\n puts stylize(\"{{yellow:#{name}}}\")\n puts stylize(\"\\t #{suffix} {{blue:#{value.inspect}}}\")\n print \"\\n\"\n end\n end\n end",
"def output_config\n puts <<-END\ngraph_category App\ngraph_title SOLR query times\ngraph_vlabel count\nqtime.label qtime\nEND\n exit 0\nend",
"def inspect\n @config.inspect\n end",
"def config_text\n owner.options\n end",
"def settings_as_formatted_text\n log_without_formatting { info ::SexySettings::Base.instance.as_formatted_text }\n end",
"def output\n @tool.config_file :conf_dir, \"#{@zone}.conf\" do |stubfile|\n stubfile << @tool.git_header('palletjack2unbound')\n stubfile << \"\nstub-zone:\n name: #{@zone}\\n\"\n\n @stub_addrs.each do |addr|\n stubfile << \" stub-addr: #{addr}\\n\"\n end\n\n if @transparent\n stubfile << \"\\nserver:\\n local-zone: \\\"#{@zone}\\\" transparent\\n\"\n end\n end\n end",
"def config\n $stdout.puts \"The current configuration of the pow server is:\\n\\n\"\n result = %x{curl localhost/config.json --silent --header host:pow}\n json = JSON.parse(result)\n json.each_pair {|k,v| $stdout.puts \" #{k}: #{v}\"}\n $stdout.puts \"\\n\"\n end",
"def config_file_contents\n output = []\n output << HEADING\n output << 'linters:' if linters_with_lints.any?\n linters_with_lints.each do |linter, files|\n output << generate_config_for_linter(linter, files)\n end\n output.join(\"\\n\\n\")\n end",
"def dump\n return unless @config_file\n File.open(@config_file,'w') do |fl|\n @todo_container.each do |category,todo_array|\n fl << \"* #{category}\\n\"\n todo_array.each do |todo_item|\n fl << \"#{priority_star(todo_item.priority)} #{todo_item.flag ? 'TODO' : 'DONE'} #{todo_item.text}\\n\"\n end\n end\n end\n end",
"def dump_settings\n File.open(SETTINGS_FILE, 'w') do |out|\n YAML.dump( { :targets => @targets, :src => @src }, out)\n end\n end",
"def dump(io)\n @config.keys.select {|s| String === s}.sort.each do |k|\n v = @config[k]\n case v\n when Array\n io.puts \"#{k}=#{v.join ' '}\"\n else\n io.puts \"#{k}=#{v}\"\n end\n end\n end",
"def config\n # unless ENV.key?('TAXI_ENV')\n # raise StandardError, 'Tried to print environment without $TAXI_ENV set. ' \\\n # 'Abort printing production credentials.'\n # end\n\n Config.instance.print\n end",
"def output_format\n settings[:output_format]\n end",
"def log_configuration_information\n Mako.logger.info \"Configuration File: #{Mako.config.config_file}\"\n Mako.logger.info \"Theme: #{Mako.config.theme}\"\n Mako.logger.info \"Destination: #{Mako.config.destination}\"\n end",
"def print_configuration\n puts \"--------------------------------------\"\n puts \" Server configuration \"\n puts \"--------------------------------------\"\n pp @config\n\n puts \"--------------------------------------\"\n puts \" Registered Instance Types \"\n puts \"--------------------------------------\"\n pp @instance_types \n end",
"def config\n overview[\"config\"]\n end",
"def print_defaults\n puts \"default_settings:\\n\"\n config_keys = @@default_settings.keys.map{|k|k.to_s}\n config_keys.sort.each do |key|\n puts \" #{key} => #{@@default_settings[key.to_sym]} (#{@@default_settings_source[key.to_sym] || 'code'})\\n\"\n end\n end",
"def config_body_for(config)\n res = <<-EOH.gsub(/^ +/, '')\n # This file is managed by Chef.\n # Any changes to it will be overwritten.\n EOH\n res << Hash[config.sort].map { |k, v| config_for(k, v) }.compact\n .join(\"\\n\")\n end",
"def show\r\n puts @configuration_file.file_content\r\n end",
"def to_s\n @config.to_s\n end",
"def write_config\n info(\"writing config.yml\")\n AIPP.config.write! config_file\n end",
"def configuration_summary\n keys = config_source.keys.sort\n max_length = 0\n keys.each { |key| max_length = [ max_length, key.length ].max }\n str = \"%\" + (max_length + 2).to_s + \"s: %s\\n\"\n out = \"\"\n\n keys.each do |key|\n out += str % [ key, config_source[key] ]\n end\n\n out\n end",
"def show\n puts \"------------------- settings -------------------\"\n puts \"Application: #{application}\"\n puts \"Branch: #{branch}\"\n puts \"Stage: #{stage}\"\n puts \"Deployer: #{deployer}\"\n puts \"Local User: #{get_local_user}\"\n puts \"URL: #{webhook_url}\"\n puts \"------------------------------------------------\"\n end",
"def configurations; end",
"def output\n App.settings.log_output\n end",
"def output\n @options[:output]\n end",
"def config_showAndsave\n\t SD::CI.show\n\t if (SD::CI.output)\n\t fname = SD::CI.output('junk.ini')\n\t SD::CI.save(fname)\n\t end \t \n\tend",
"def to_config\n \" PROCESSOR #{@name} #{self.class.name.to_s.class_name_to_filename} #{@item_name} #{@value_type}\\n\"\n end",
"def config\n\n end",
"def output\n config_dir :conf_dir\n config_dir :local_dir\n\n @stub_zones.each {|stub_zone| stub_zone.output }\n @unbound_config.output\n end",
"def config_template\n config = Mihari.config.values.keys.map do |key|\n [key.to_s, nil]\n end.to_h\n\n YAML.dump(config)\n end",
"def output_path\n settings[:output]\n end",
"def ostream\n @settings[:ostream]\n end",
"def conf\n LOG_STAT()\n id = id_gen()\n LOG_CALL(id, true, __method__)\n defer { LOG_CALL(id, false, 'conf') }\n return CONF.privatise.out\n end",
"def write\n return if @options == @original_options\n f = IO.popen('php', 'r+')\n f.write \"<?php var_export(json_decode('#{options_php_json}', true));\\n\"\n f.close_write\n data = f.read\n f.close\n File.open(@file, 'w') { |of| of.write \"<?php\\n$CONFIG = #{data};\\n\" }\n Chef::Log.info('OwnCloud config writen')\n rescue StandardError => e\n raise \"Error writing ownCloud configuration: #{e.message}\"\n end",
"def dump_config\n send_command \"--dump-config\"\n end",
"def sub_config\n puts config_script\n shell(config_script, source_dir(true))\n end",
"def config\n @options[:config]\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def to_rb\n configuration.map { |k,v| \"#{k}(#{v.inspect})\" }.join(\"\\n\")\n end",
"def conf_info(config)\n bc = config.bgColor\n tc = config.textColor\n txt = config.name\n if config.active?\n txt += _INTL(' [ACTIVE]\\n')\n else\n txt += '\\n'\n end\n txt += _INTL('\\tBackground color {1}, {2}, {3}\\n',bc.red,bc.green,bc.blue)\n txt += _INTL('\\tText color {1}, {2}, {3}\\n',tc.red,tc.green,tc.blue)\n txt += _INTL('\\tFont name {1}\\n',config.fontName)\n txt += _INTL('\\tPrompt \\'{1}\\'',config.prompt)\n return txt\n end",
"def flush\n File.open(config_file, 'w') do |f|\n f.puts JSON.pretty_generate(@conf)\n end\n end",
"def flush\n File.open(config_file, 'w') do |f|\n f.puts JSON.pretty_generate(@conf)\n end\n end",
"def config_inspect(config, all = false)\n h = config.to_h\n h = h.except(*NO_INSPECT) unless all\n hashify(h).pretty_inspect.gsub(/:([^=\\n]+)(=>)/, '\\1 \\2 ')\n end",
"def config\n puts <<-END\ngraph_title puppet clients usage\ngraph_vlabel clients\nknown_clients.label Known Clients\navg_compile.label Average configuration compile\nlast5m_count.label Clients in the last 5 minutes\nlast24h_unique_count.label unique clients in the last 24 hours\ngraph_category puppet\nEND\n exit 0\nend",
"def write_config\n File.open(CONFIG_OUT, 'w') do |f|\n f.write(ssh_config + \"\\n\")\n end\nend",
"def list\n run do\n print_config_table(columns: %i[key value], skip_blanks: true)\n end\n end",
"def yaml\n @config.to_yaml\n end",
"def show\n table = Text::Table.new(horizontal_padding: 4)\n table.head = [{ value: 'Configuration', colspan: 2, align: :center }]\n table.rows << :separator\n table.rows << ['Formatters', @formatters]\n table.rows << ['Output File', @output_file]\n\n @file_sets.each do |label, file_set|\n table.rows << :separator\n table.rows << ['Label', label]\n table.rows << ['Style', '']\n file_set[:style].each do |k, v|\n table.rows << ['', \"#{k}: #{v}\"]\n end\n\n table.rows << ['File List', '']\n file_set[:file_list].each { |file| table.rows << ['', file] }\n end\n\n puts table\n end",
"def write\n require 'yaml'\n open config_file_name, 'w' do |io|\n io.write to_yaml\n end\n end",
"def configure(conf)\n super\n \n ## Check if \"output_format\" has a valid value\n unless @output_format.to_s == \"structured\" ||\n @output_format.to_s == \"flat\" ||\n @output_format.to_s == \"statsd\"\n \n raise ConfigError, \"output_format value '#{@output_format}' is not valid. Must be : structured, flat or statsd\"\n end\n end",
"def config\n<<-EOL\nManage the environment's config. Can use this to download the environment's config to jack/cfg folder or upload and apply config in jack/cfg folder to the environment.\n\nExample:\n\n$ jack config get hi-web-stag-1\n\nFor more info:\n\n$ jack help config\n\n$ jack config help upload\n\n$ jack config help download\nEOL\n end",
"def write_configure(config = nil)\n config ||= $configure\n File.open($configure_file, \"w\"){|f| YAML.dump(config, f)}\nend",
"def print\n GoHiring::Config[\"messages\"][\"hello\"] % settings\n end",
"def write_config\n # Allow disabling the local settings.\n return unless new_resource.local_settings_path\n file new_resource.local_settings_path do\n content new_resource.local_settings_content\n mode '640'\n owner new_resource.parent.owner\n group new_resource.parent.group\n end\n end",
"def execute(output: $stdout)\n options.each do |key, val|\n if val == key.to_s\n output.puts RubyEdit.config.send(key)\n else\n RubyEdit.config.send(\"#{key}=\", val)\n output.puts \"#{key.to_s.titleize} changed to #{val}\"\n end\n end\n end",
"def get_config\n\t\tend",
"def options\n config.options\n end",
"def to_config\n \" PROCESSOR #{@name} #{self.class.name.to_s.class_name_to_filename} #{@item_names.join(' ')}\\n\"\n end",
"def configure_output\n RSpec.configuration.output_stream = $stdout\n @formatter = RSpec.configuration.add_formatter(Inspec::Formatters::Base)\n RSpec.configuration.add_formatter(Inspec::Formatters::ShowProgress, $stderr) if @conf[:show_progress]\n set_optional_formatters\n RSpec.configuration.color = @conf[\"color\"]\n end",
"def settings\n # TODO\n {}\n end",
"def config\n @config\n end",
"def config\n @config ||= { :force => false, :quiet => false }\n end",
"def config\n info['Config']\n end",
"def to_s!\n elems = @schema.keys.map do |k|\n v = self[k]\n vstr = Configuration.config?(v) ? v.to_s! : v.inspect\n \"#{k}=#{vstr}\"\n end\n \"<Google::Gax::Configuration: #{elems.join ' '}>\"\n end",
"def config\n @config\n end",
"def config\n @config\n end",
"def config\n @config\n end",
"def configure(conf)\n super\n\n ## Check if \"output_format\" has a valid value\n unless @output_format.to_s == \"structured\" ||\n @output_format.to_s == \"flat\" ||\n @output_format.to_s == \"statsd\"\n\n raise ConfigError, \"output_format value '#{@output_format}' is not valid. Must be : structured, flat or statsd\"\n end\n end",
"def write_config\n File.open(@config_file, \"w\"){|f| YAML.dump(config, f)}\n end",
"def config=(value); end",
"def config(**args)\n # # keep a running record of checks reported, indexed by family\n # with each family keeping an array of checks\n @current_check_family ||= \"general\"\n @progress ||= {\n @current_check_family => []\n }\n \n # it's possible to suppress all output\n # This can be changed by calling config again\n @output_to = if args.has_key?(:output_to)\n args[:output_to].include?('none') ? [] : args[:output_to]\n \n else\n ['console']\n end\n end",
"def config_for(key, value)\n \"#{key}=#{value && value}\\n\"\n end",
"def talia_config\n puts \"Talia configuration\"\n puts \"\"\n puts \"TALIA_ROOT: #{TALIA_ROOT}\"\n puts \"Environment: #{TaliaCore::CONFIG['environment']}\"\n puts \"Standalone DB: #{TaliaCore::CONFIG['standalone_db']}\"\n puts \"Data Directory: #{TaliaCore::CONFIG['data_directory_location']}\"\n puts \"Local Domain: #{N::LOCAL}\"\n end",
"def config=(config); end"
] |
[
"0.7614439",
"0.74402165",
"0.696857",
"0.69136924",
"0.6891031",
"0.6890713",
"0.6855754",
"0.6665212",
"0.66063887",
"0.65654945",
"0.6543973",
"0.6507965",
"0.6497492",
"0.6485931",
"0.647976",
"0.6419686",
"0.6391958",
"0.63871443",
"0.63694614",
"0.6325521",
"0.6306755",
"0.62539136",
"0.6253862",
"0.6252667",
"0.62187773",
"0.61995584",
"0.61740196",
"0.6164377",
"0.6162989",
"0.6151145",
"0.61445045",
"0.6134944",
"0.61332846",
"0.6121414",
"0.61193365",
"0.6118288",
"0.6118162",
"0.60910517",
"0.608409",
"0.60793006",
"0.6075474",
"0.60717374",
"0.6062395",
"0.6039446",
"0.60367465",
"0.60243326",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.6020881",
"0.60012454",
"0.5974826",
"0.59617525",
"0.59617525",
"0.595402",
"0.59537",
"0.5943615",
"0.59291947",
"0.59280735",
"0.591828",
"0.59180623",
"0.5910598",
"0.5905415",
"0.590504",
"0.5904005",
"0.5901864",
"0.58948946",
"0.5885472",
"0.5884717",
"0.5872955",
"0.5872776",
"0.5861716",
"0.5859011",
"0.5857891",
"0.58535165",
"0.58497",
"0.58458",
"0.58458",
"0.58458",
"0.58196557",
"0.58146805",
"0.5814664",
"0.5814158",
"0.5803509",
"0.5802191",
"0.57958865"
] |
0.8242229
|
0
|
Check if the pwd is zup enabled
|
def zup_dir_enabled?
if File.exist?('.zup/enabled')
return true
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def enable_zup_dir\n unless zup_dir_enabled?\n puts ' * Adding current directory'\n # Create .zup directory\n FileUtils.mkdir('.zup') unless File.directory?('.zup')\n # Create file to enable zup\n File.open(\".zup/enabled\", 'w') { |f| f.close }\n else\n puts ' * Directory already initialised'\n return false\n end\n end",
"def zypper?\n File.executable? '/usr/bin/zypper'\n end",
"def disable_zup_dir\n if zup_dir_enabled?\n puts ' * Uninitialising current directory'\n # TODO: Fix uninitialising a directory\n # Removing .zup directory breaks syncing if it's ever re-initialised\n #FileUtils.rm_rf(\".zup\") if File.directory?('.zup')\n FileUtils.rm('.zup/enabled')\n exit 0\n else\n puts ' * Directory not initialised'\n return false\n exit 0\n end\n end",
"def client_is_zypp?\n File.stat(\"/usr/bin/zypper\").executable?\nend",
"def want_up?\n @raw && !pid && @raw[3] == 'u'\n end",
"def is_stub?\n htpasswd.blank?\n end",
"def password?\n FileTest.exist? Puppet[:capass]\n end",
"def admin_mode?\n (`reg query HKU\\\\S-1-5-19 2>&1` =~ /ERROR/).nil?\n end",
"def need_backup_setup?\n backup_sources.active.empty?\n end",
"def tmux_available?\n system \"which tmux >/dev/null 2>&1\"\nend",
"def kacl_cli_installed?\n `which kacl-cli`.strip.empty? == false\n end",
"def check_zone_is_installed()\n if options['host-os-name'].to_s.match(/SunOS/)\n if options['host-os-release'].split(/\\./)[0].to_i > 10\n exists = true\n else\n exists = false\n end\n else\n exists = false\n end\n return exists\nend",
"def for_backups?\n hostname.start_with?('backup') || in_remote_datacenter?\n end",
"def sync_zup_dir\n if zup_dir_enabled?\n local_dir = File.basename(Dir.pwd) \n\n # Output the full unison command if debugging enabled\n puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir) if $ZUP_DEBUG\n\n # Run unison\n system($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir)\n else\n puts \" * Current directory not initialised (Run 'zup init' to add it)\"\n exit 0\n end\n end",
"def zfs_exist?(name)\n cmd = Mixlib::ShellOut.new('zfs', 'get', 'mountpoint', name)\n cmd.environment['PATH'] = \"/usr/sbin:#{ENV['PATH']}\" if platform_family?('solaris2')\n cmd.run_command\n cmd.exitstatus == 0\nend",
"def pmux_mode?\n return false unless uplinks\n return false if uplinks.empty?\n return false if vlt_mode?\n return false unless switch.provider.blade_ioa_switch?\n\n true\n end",
"def up?\n instance.up?('eth1')\n end",
"def valid_environment?\n env['USER'] == config.user && env['HOME'] == config.home_path\n end",
"def is_root?\n cmd_exec('/usr/bin/id -ru').eql? '0'\n end",
"def check_in_tmux\n !ENV['TMUX'].nil?\n end",
"def systemctl?\n systemctl.present?\n end",
"def systemctl?\n systemctl.present?\n end",
"def dot_installed?\n assert_usr_bin_env_exists\n system \"#{USR_BIN_ENV} which dot > /dev/null\"\n end",
"def zip_switches\n if(@fu_conf[:zip_password] && !@fu_conf[:zip_password].blank?)\n password_option = \"-P #{@fu_conf[:zip_password]}\"\n else\n password_option = ''\n end\n \n \"-j #{password_option}\"\n end",
"def enabled?\n return false unless Licensed::Shell.tool_available?(\"pnpm\")\n File.exist?(File.join(config.pwd, \"pnpm-lock.yaml\"))\n end",
"def grsec_installed?\n cmd_exec('test -c /dev/grsec && echo true').to_s.strip.include? 'true'\n rescue\n raise 'Could not determine grsecurity status'\n end",
"def enabled?\n exists? && cmd(\"link show up\", sudo: false).include?(name)\n end",
"def generated_by_zephir?\n !!name.match(/.\\.zep\\.(?:c|h|php)$/)\n end",
"def dropbox_running?\n `pgrep Dropbox` && $?.exitstatus.zero?\n end",
"def installed?\n !IO.popen(\"which #{self}\"){|i| i.read}.empty?\n end",
"def up?\n check = Net::Ping::WMI.new(@ip) if OS.windows?\n check = Net::Ping::TCP.new(@ip) if OS.linux? || OS.mac?\n check.ping?\n end",
"def ubuntu?\n @flavor =~ /ubuntu/\n end",
"def non_script_option?\n version || help || remote\n end",
"def run_as_sudo?\n if ENV['USER']=='root' and (su=ENV['SUDO_USER'])\n su\n else\n false\n end\n end",
"def git_installed?\n\t`git config > /dev/null 2>&1`\n end",
"def git_installed?\n\t`git config > /dev/null 2>&1`\n end",
"def two_factor_backup_codes_generated?\n otp_backup_codes.present?\n end",
"def two_factor_backup_codes_generated?\n otp_backup_codes.present?\n end",
"def two_factor_backup_codes_generated?\n otp_backup_codes.present?\n end",
"def two_factor_backup_codes_generated?\n otp_backup_codes.present?\n end",
"def is_admin?\n cmd_exec('groups | grep -wq admin && echo true').eql? 'true'\n end",
"def is_ubuntu?\n return !!@name.match(/^ubuntu-.*$/)\n end",
"def is_debian?\n return !!@name.match(/^debian-.*$/)\n end",
"def downlevel?\n @downlevel ||= request.user_agent.downcase.include? 'berry'\n end",
"def installed?(utility)\n return false if execute_as_root(\"which #{utility}\").nil?\n true\n end",
"def should_run_ssh_wizard?\n not File.exists? ssh_priv_key_file_path\n end",
"def ping?\n false unless connected?\n false|stat('/')\n rescue ZK::Exceptions::KeeperException\n false\n end",
"def calabash?\n ENV['CALABASH'] == nil ? false : true\n end",
"def running?\n # Permissions are handled by the script, use: :sudo => false\n run_script! :status, :sudo => false\n true\n\n rescue CmdError => e\n return false if e.exit_code == Daemon::STATUS_DOWN_CODE\n raise e\n end",
"def booted?\n IO.popen([\"systemctl\", \"is-system-running\"], &:read).chomp != \"offline\"\n end",
"def git_installed?\n\tbegin\n\t `git config > /dev/null 2>&1`\n\trescue\n\t false\n\tend\n end",
"def show_command?\n ENV['DEBUG'] || ENV['SHOW_COMMAND']\n end",
"def running_as_superuser?\n\tKitchenplan::Log.debug \"#{self.class} : Running as superuser? UID = #{Process.uid} == 0?\"\n\tProcess.uid == 0\n end",
"def upcase?\r\n\t\treturn !press?(:SHIFT) if GetCapState.call(VALUES[:CAPS]) == 1\r\n\t\treturn true if press?(:SHIFT)\r\n\t\treturn false\r\n\tend",
"def password_authentication?\n # if the vm has a linux configuration then interrogate that, otherwise return true\n if !vm.os_profile.linux_configuration.nil?\n !vm.os_profile.linux_configuration.disable_password_authentication\n else\n true\n end\n end",
"def exec_exixts?(name)\n `which #{name}`.start_with?('/')\n end",
"def pour_bottle?\n quiet_system(\"/usr/libexec/java_home --version 1.8 --failfast\")\n end",
"def zypper_version\n cmd = [self.class.command(:zypper),\"--version\"]\n execute(cmd, { :failonfail => false, :combine => true})\n end",
"def has_flag(u, f)\n ret = false\n @opers.each do |oper|\n if oper.can_access(u)\n puts(\"flags: #{oper.flags}\") if $config.options['debug']\n ret = oper.flags.include?(f) || oper.flags.include?('*')\n end\n end\n\n if !ret && $config.options['levels'] && (u.isoper || u.isadmin)\n puts(\"lflags: #{$config.levels[u.olevel]}\")\n ret = $config.levels[u.olevel].include?(f)\n end\n \n return ret\n end",
"def is_running\n !`/etc/init.d/minecraft status`.include?('not')\nend",
"def exist?\n up?\n end",
"def exist?\n up?\n end",
"def down?\n !(up?)\n end",
"def down?\n !(up?)\n end",
"def need_auth?\n @options[:username] || ENV['MEMCACHE_USERNAME']\n end",
"def up?\n up.up?\n rescue\n false\n end",
"def is_superuser?\n superuser? && supermode?\n end",
"def systemd?\n false\n end",
"def zlib?\n cc.defines.include? 'LIBSSH2_HAVE_ZLIB'\n end",
"def in_git?\n Kernel.system('git rev-parse --show-prefix 2>/dev/null')\n end",
"def password_signup?\n if password_digest\n return false\n else\n bool1=(@non_signup_provider_bool == true)\n bool2=(@signup_provider_bool == true)\n bool1||bool2\n end\n end",
"def backup_exist?\n abs_path = File.join(__dir__, @cfg[:backup])\n if File.directory?(abs_path) && Dir.entries(abs_path).size > 200\n true\n end\n false\n end",
"def shell?\n false\n end",
"def active_homedir_exists?( username )\n\t\t\thomedir = HOMEDIR_BASE + username\n\t\t\treturn homedir.directory?\n\t\tend",
"def command?(name)\n !which(name).nil?\n end",
"def is_zz?\n zz[:app_config] != nil\n end",
"def gzip_cmd\n if !`which /bin/gzip`.empty?\n \"/bin/gzip\"\n elsif !`which gzip`.empty?\n \"gzip\"\n end\nend",
"def timezone debug = false\n command = '666,!FzP' + ( Time.now.gmt_offset/60/60 ).to_s\n data = self.raw command, true, debug\n return data == \"666,OK\\r\\n\"\n end",
"def backup_minister_installed?\n software_installed?(APP_NAME)\n end",
"def installed?(cmd)\n !Garcon::FileHelper.which(cmd).nil?\n end",
"def up?(host)\n check = Net::Ping::External.new(host)\n check.ping?\nend",
"def command?(name)\n !which(name).nil?\n end",
"def can_make_leaderbit_active?\n system_admin?\n end",
"def zone_exists?(zone_name)\n output = Mixlib::ShellOut.new(\"zoneadm -z #{zone_name} list -p\").run_command\n if output.stdout.split(':')[1].eql? zone_name\n true\n else\n false\n end\n end",
"def is_test_mode?\n ENV['TEST_MODE'] === 'TRUE'\nend",
"def aptitude?\n File.executable? '/usr/bin/apt-get'\n end",
"def allow_auth_failures?\n return true if node.key?('virtualization') && node['virtualization']['system'] == 'vbox'\n return true if ::File.exist?('/.dockerenv')\n return true if ENV['CI']\n false\n end",
"def running?\n ck_valid\n kvm = File.basename(SysConf.value_for :kvm_bin)\n cmdline =~ /#{kvm}/\n end",
"def correct_runas_user?\n splunk = shell_out(\"ps -ef|grep splunk|grep -v grep|awk '{print$1}'|uniq\")\n splunk_runas_user == splunk.stdout\nend",
"def check_for_local_password\n if ChefUtils.windows?\n powershell_code = <<-CHECKFORPASSWORD\n Try {\n $localpass = Get-ItemPropertyValue -Path \"HKLM:\\\\Software\\Progress\\Authenticator\" -Name \"PfxPass\" -ErrorAction Stop\n return $localpass\n }\n Catch {\n return $false\n }\n CHECKFORPASSWORD\n powershell_exec!(powershell_code).result\n elsif ChefUtils.macos?\n nil\n end\n end",
"def command?(name)\n !which(name).nil?\nend",
"def p2sh?\n false\n end",
"def up?\n direction == UP\n end",
"def launchctl?\n launchctl.present?\n end",
"def launchctl?\n launchctl.present?\n end",
"def gui?\n !ENV.fetch('GUI', '').empty?\nend",
"def vip_installed?\n ssh.directory_exists?(vip_path)\n end",
"def remote_exists?\n system \"which cmus-remote &> /dev/null\"\nend",
"def root?\n Process.uid.zero?\n end",
"def root?\n Process.uid.zero?\n end"
] |
[
"0.69885933",
"0.68684465",
"0.6520007",
"0.6285853",
"0.60789806",
"0.599638",
"0.5930512",
"0.5908339",
"0.5835427",
"0.58321446",
"0.58160293",
"0.58053213",
"0.5750155",
"0.5736638",
"0.57259625",
"0.5686872",
"0.565659",
"0.565015",
"0.5611827",
"0.5549427",
"0.552972",
"0.552972",
"0.5509809",
"0.55045724",
"0.54184246",
"0.541022",
"0.5357958",
"0.53503746",
"0.5348803",
"0.53469074",
"0.5345225",
"0.53447217",
"0.53436226",
"0.5339277",
"0.5332766",
"0.5332766",
"0.53269696",
"0.53269696",
"0.53269696",
"0.5324252",
"0.532116",
"0.5319847",
"0.5314083",
"0.5306801",
"0.5301714",
"0.529473",
"0.5290066",
"0.5285021",
"0.52737325",
"0.52697307",
"0.5267842",
"0.52670044",
"0.5263926",
"0.5246268",
"0.52382153",
"0.5235383",
"0.5232673",
"0.5231094",
"0.52309275",
"0.5225429",
"0.5224578",
"0.5224578",
"0.52219635",
"0.52219635",
"0.52181023",
"0.5209665",
"0.52032053",
"0.5202832",
"0.5195491",
"0.5188612",
"0.5180523",
"0.51781505",
"0.51773113",
"0.5162082",
"0.51553214",
"0.5153941",
"0.5153775",
"0.5150582",
"0.51483506",
"0.514519",
"0.51449144",
"0.5136727",
"0.5135195",
"0.51317835",
"0.5130032",
"0.5129801",
"0.51202613",
"0.51104784",
"0.5109058",
"0.50990236",
"0.50970906",
"0.50918967",
"0.5089623",
"0.50894034",
"0.50894034",
"0.5088717",
"0.50873065",
"0.50869817",
"0.50844055",
"0.50844055"
] |
0.76437134
|
0
|
Enable the pwd so it can sync with the remote host
|
def enable_zup_dir
unless zup_dir_enabled?
puts ' * Adding current directory'
# Create .zup directory
FileUtils.mkdir('.zup') unless File.directory?('.zup')
# Create file to enable zup
File.open(".zup/enabled", 'w') { |f| f.close }
else
puts ' * Directory already initialised'
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def setpwent\n ::Etc.setpwent\n end",
"def pwd; end",
"def pwd()\n instructions = 'pwd'\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n @results[:pwd] = r.chomp\n end",
"def pwd\n @local\n end",
"def cmd_pwd(param)\n send_unauthorised and return unless logged_in?\n send_response \"257 \\\"#{@name_prefix}\\\" is the current directory\"\n end",
"def command_pwd\n # Respond with absolute path for this client\n puts \"Sending #{@directory.path}\"\n @client.puts @directory.path\n end",
"def rsync_password_file\n \"--password-file='#{@password_file.path}'\" if @password_file\n end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def pwd\n cmd_exec(\"pwd\")\n end",
"def master_password=(master_pwd)\n @master_password = master_pwd\n @private_key = OpenSSL::PKey::RSA.new(File.read(\"#@config_dir/#{PRIVATE_KEY}\"), master_pwd)\n @public_key = OpenSSL::PKey::RSA.new(File.read(\"#@config_dir/#{PUBLIC_KEY}\"))\n @unlocked = true\n end",
"def passwd\r\n @password = \"12345\"\r\n end",
"def passwd=(p0) end",
"def passwd=(p0) end",
"def sshpassword\nsshhost = ''\nsshuser = ''\n\n Net::SSH.start(sshhost, sshuser) do |ssh|\n ssh.open_channel do |channel|\n channel.on_request \"exit-status\" do |channel, data|\n $exit_status = data.read_long\n end\n channel.request_pty do |channel, success|\n channel.exec(\"smbldap-passwd #{@authex.username}\") # sshuser should be root\n if success\n channel.on_data do |channel, data|\n channel.send_data(\"#{@newpasswd}\\n\")\n sleep 0.1\n end\n else\n puts \"Password change FAILED!!\"\n end\n end\n channel.wait\n puts \"Password change SUCCESS!!\" if $exit_status == 0\n end\n end\n\nend",
"def master_password(ignore_this)\n @db.passphrase = prompt(\"Enter new master password\", :echo => '*', :validate => true, :width => 45) \n hsay \"New master password set.\", :information\n end",
"def sync_cmd\n \"rsync --delete -avzhe '#{@ssh_path} -p #{@port}' #{cygdrive_path @log_dir} #{user_at_host}:#{@remote_log_parent_dir}\"\n end",
"def cmd_pwd(*args)\n\t\tprint_line(client.fs.dir.getwd)\n\tend",
"def mirror_locally=(value)\n cobbler('repo', 'edit', '--name=' + @resource[:name], '--mirror-locally=' + value.to_s)\n @property_hash[:mirror_locally]=(value.to_s)\n cobbler('reposync')\n end",
"def sync_zup_dir\n if zup_dir_enabled?\n local_dir = File.basename(Dir.pwd) \n\n # Output the full unison command if debugging enabled\n puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir) if $ZUP_DEBUG\n\n # Run unison\n system($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir)\n else\n puts \" * Current directory not initialised (Run 'zup init' to add it)\"\n exit 0\n end\n end",
"def rsync_command\n if @config[:rsync][:direction] == 'up'\n from = absolute_path(@config[:local_path])\n to = @config.ssh_user_and_host + ':' + @config[:remote_path]\n else\n from = @config.ssh_user_and_host + ':' + @config[:remote_path]\n to = absolute_path(@config[:local_path])\n end\n \"rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'\"\n end",
"def root_dir\n 'gen_passwd'\n end",
"def chmod_remote!(username, pass)\n com = \"chmod 644 #{CONFIG[:server_path] + @filename}\"\n ssh_command(com, username, pass)\n\tend",
"def smb_shell\n if @hashpass\n system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} --pw-nt-hash #{@pass}\")\n else\n system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} #{@pass}\")\n end\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def change_mongo_password_for!( instance )\n process_data =\n systemu \\\n command( instance ),\n :cwd => ansible_deploy_dir\n \n Ansible::Process.for_systemu *process_data\n end",
"def remote_set_immutable(host, files)\n remote_ssh_cmd(host, \"sudo chattr +i #{files.join(\" \")}\")\nend",
"def command_for_rsync\n args = []\n args << \"-l #{@options[:user]}\" if @options[:user]\n args << \"-p #{@options[:port]}\" if @options[:port]\n if @options[:keys]\n @options[:keys].each { |key| args << \"-i #{key}\" }\n end\n \"ssh #{args.join(' ')}\"\n end",
"def sync\n rm_berks_cookbooks\n target_dir = \"/home/#{USER}/provisioning\"\n rsync_current_dir target_dir: target_dir\n ssh_exe \"sudo chown #{USER}:#{USER} -R #{target_dir}\"\n end",
"def before_sync(chdir: true, &block)\n @before_sync_hook = Hook.new(block, chdir)\n end",
"def pwd\r\n # auao\r\n 5 + 5\r\n end",
"def pwd\r\n # auao\r\n 5 + 5\r\n end",
"def userpwd=(value)\n Curl.set_option(:userpwd, value_for(value, :string), handle)\n end",
"def passwd(*) end",
"def passwd(*) end",
"def enable_privileged(password)\n @transport.cmd('String' => 'enable', 'Match' => /.+assword.+/)\n @transport.cmd(password)\n end",
"def debian_password\n nil\n end",
"def sync_code_dir\n fs_commands = { 'commit': '{\"commit-all\": true}', 'force-sync': \"\" }\n fs_commands.each do |fs_cmd, data|\n curl = %W[\n curl\n -X POST\n --cert $(puppet config print hostcert)\n --key $(puppet config print hostprivkey)\n --cacert $(puppet config print localcacert)\n -H \"Content-type: application/json\"\n https://#{master}:8140/file-sync/v1/#{fs_cmd}\n -d '#{data}'\n ].join(\" \")\n\n on(master, curl)\n end\n end",
"def set_perms_on_remote(host, path, mode, owner=nil, group=nil)\n if (owner.nil?)\n owner = on(host, puppet('config', 'print', 'user')).stdout.rstrip\n end\n\n if (group.nil?)\n group = on(host, puppet('config', 'print', 'group')).stdout.rstrip\n end\n\n on(host, \"chmod -R #{mode} #{path}\")\n on(host, \"chown -R #{owner}:#{group} #{path}\")\nend",
"def pwd\r\n ndev.rpc.command(\"show cli directory\").text.strip\r\n end",
"def rsync_port\n \"-e 'ssh -p #{port}'\"\n end",
"def set_perms_on_remote(host, path, mode, opts = {})\n opts[:owner] ||= on(host, puppet('config print user')).stdout.rstrip\n opts[:group] ||= on(host, puppet('config print group')).stdout.rstrip\n\n on(host, \"chmod -R #{mode} #{path}\")\n on(host, \"chown -R #{opts[:owner]}:#{opts[:group]} #{path}\")\n end",
"def insync?(*)\n provider.priv_password_in_sync?\n end",
"def command=(cmd)\n set(\"drmaa_remote_command\", cmd) \n end",
"def backuppassword\n @shadow_location = \"#{@home}/etc/#{domain}\"\n @shadow = \"#{@shadow_location}/shadow\"\n @backup_account = `grep -w ^#{@email_account_without_domain} #{@shadow} > #{@shadow_location}/#{@email_account_without_domain}.mailtool`\n end",
"def ssh_login\n deploy_test_on_hosts_as self.host_admin, self.hosts, \"/home/#{self.host_admin}\\n\", \"should be able to connect via ssh\" do\n 'pwd'\n end\n end",
"def enter_password_shared\n end",
"def password=(new_password); end",
"def setup_proc\n comp = self\n raise ArgumentError.new( \"File #{comp.local} is not exist!\" ) if !File.exists? comp.local\n\n set_check( ->(host) do \n if !test(\" [ -f #{comp.remote} ] \" )\n next false\n end\n\n local_checksum = `md5sum #{comp.local}`\n remote_checksum = capture( :md5sum, comp.remote )\n local_checksum.strip.split(\" \")[0] == remote_checksum.strip.split(\" \")[0]\n end )\n\n set_up( Proc.new{ |host|\n upload! comp.local, \"tmp\"\n if comp.permission\n execute( :chmod, comp.permission, \"tmp\" )\n end\n if test( \" [ -w '#{File.dirname comp.remote}' ] \" )\n execute( :mv, \"tmp\", comp.remote ) \n else\n prepare_sudo_password( host ) do\n as :root do\n execute( :mv, \"tmp\", comp.remote ) \n end\n end\n end\n if comp.owner\n prepare_sudo_password( host ) do\n as :root do\n execute( :chmod, comp.permission, comp.remote )\n end\n end\n end\n })\n\n set_down( Proc.new{ |host|\n if test( \" [ -w '#{File.dirname comp.remote}' ] \" )\n execute( :rm, comp.remote ) \n else\n prepare_sudo_password( host ) do \n as :root do\n execute( :rm, comp.remote ) \n end\n end\n end\n } )\n end",
"def insync?(*)\n provider.auth_password_in_sync?\n end",
"def rsync_from(source, target, dest, port = 22, extra_flags = [])\n rsync = find_program_on_path('rsync')\n flags = \"-rHlv -O --no-perms --no-owner --no-group\"\n unless extra_flags.empty?\n flags << \" \" << extra_flags.join(\" \")\n end\n ex(\"#{rsync} -e '#{ssh_command(port)}' #{flags} #{target}:#{source} #{dest}\")\n end",
"def sync_dir(dir=Dir.getwd)\n @r.cmd \"setwd('#{dir}')\"\n end",
"def surun(command)\n password = fetch(:root_password, Capistrano::CLI.password_prompt(\"root password: \"))\n run(\"su - -c '#{command}'\") do |channel, stream, output|\n channel.send_data(\"#{password}n\") if output\n end\nend",
"def sync\n # preparation\n check_remote_path_valid\n check_git_repo\n reset_remote_repo\n\n diff_text = local_diff\n apply_diff_to_remote diff_text\n\n # output = @ssh.exec! 'hostname'\n # puts output\n end",
"def enable_ownership\n run_baby_run 'diskutil', ['enableOwnership', self.dev_node], :sudo => true\n end",
"def backup_od\n begin\n \tputs \"Be sure to note this for later use.\\nPlease type a password for the OD backup:\"\n \t system \"stty -echo\"\n \t @pass = $stdin.gets.chomp\n \t system \"stty echo\"\n \trescue NoMethodError, Interrupt\n \t system \"stty echo\"\n end\n mkpassdb = \"/usr/sbin/mkpassdb\"\n tmpfile = \"/tmp/sacommands\"\n commands=[\"dirserv:backupArchiveParams:archivePassword = #{@pass}\", \"dirserv:backupArchiveParams:archivePath = #{@dest}/odbackup-#{@date}\", \"dirserv:command = backupArchive\"]\n sacommands = File.open(\"#{tmpfile}\", \"w\") do |f|\n f.puts commands.each {|command| command}\n end\n system \"/usr/sbin/serveradmin command < #{tmpfile}\"\n system \"#{mkpassdb} -backupdb #{@dest}/mkpassdb-#{@date}\"\n FileUtils.rm(tmpfile)\nend",
"def get_password host,username\n print \"Password for \"+username+\"@\"+host+\": \"\n system \"stty -echo\"\n pw = gets.delete(\"\\n\")\n system \"stty echo\"\n puts\n pw\n end",
"def master_password=(master_password)\n @master_password = master_password\n @private_key = OpenSSL::PKey::RSA.new(File.read(\"#@config_dir/#{PRIVATE_KEY}\"), master_password)\n @public_key = OpenSSL::PKey::RSA.new(File.read(\"#@config_dir/#{PUBLIC_KEY}\"))\n @unlocked = true\n end",
"def pass(passwd)\n send_msg(\"PASS #{passwd}\")\n end",
"def enable_root(host)\n host['ssh'] = {:password => host['instance'].id}\n @logger.notify(\"netscaler: nsroot password is #{host['instance'].id}\")\n #if host['user'] != 'root'\n # host.exec(Command.new(\"modify sys db systemauth.disablerootlogin value false\"), :acceptable_exit_codes => [0,1])\n # for tries in 1..10\n # begin\n # #This command is problematic as the netscaler is not always done loading\n # if host.exec(Command.new(\"modify sys global-settings gui-setup disabled\"), :acceptable_exit_codes => [0,1]).exit_code == 0 and host.exec(Command.new(\"save sys config\"), :acceptable_exit_codes => [0,1]).exit_code == 0\n # backoff_sleep(tries)\n # break\n # elsif tries == 10\n # raise \"Instance was unable to be configured\"\n # end\n # rescue Beaker::Host::CommandFailure => e\n # @logger.debug(\"Instance not yet configured (#{e})\")\n # end\n # backoff_sleep(tries)\n # end\n # host['user'] = 'root'\n # host.close\n # sha256 = Digest::SHA256.new\n # password = sha256.hexdigest((1..50).map{(rand(86)+40).chr}.join.gsub(/\\\\/,'\\&\\&'))\n # host['ssh'] = {:password => password}\n # host.exec(Command.new(\"echo -e '#{password}\\\\n#{password}' | tmsh modify auth password admin\"))\n # @logger.notify(\"netscaler: Configured admin password to be #{password}\")\n # host.close\n #end\n end",
"def save_settings_NoPwd(file_path)\n \tbegin\n \t\ttryAgain = true\n \t\tNet::SCP.download!(@host, @sshusers, \"/tmp/enb_lterf.conf\", file_path, :ssh => { :paranoid => false })\n \t\treturn true\n \trescue Errno::ECONNRESET\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::ECONNRESET\"\n \t\tretry\n \tend\n \trescue Errno::ECONNREFUSED\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::ECONNREFUSED\"\n \t\tretry\n \tend\n \trescue Errno::EHOSTUNREACH\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::EHOSTUNREACH\"\n \t\tretry\n \tend\n \trescue => e\n \terror(\"Exception in scp command: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\")\n \tend\n end",
"def remote_sync_if_necessary(options={})\n false\n end",
"def change_temp_password\n\tend",
"def enable_root(host)\n if host['user'] != 'root'\n copy_ssh_to_root(host, @options)\n enable_root_login(host, @options)\n host['user'] = 'root'\n host.close\n end\n end",
"def reset_password\n set :password, Proc.new {\n Capistrano::CLI.password_prompt(\"Password (for user: #{user}): \")\n } \n end",
"def sync (vm_config)\n vm_config.synced_folder @host_path, guest_path\n end",
"def password=(pass)\n @good_password = false if system(\"look \\\"#{pass.downcase}\\\" > /dev/null 2>&1\")\n super Encrypt::Password.createHash pass\n end",
"def set_passphrase\n @pass = get_passphrase()\n end",
"def set_password; nil; end",
"def remote_sync_ftp\n @attributes[:remote_sync_ftp]\n end",
"def setup_credentials\n\n cmd = @config[:path] + @command_line_tool + \" \" + @@login_command\n\n Open3.popen3( cmd ) { |input, output, error|\n input.puts @config[:url]\n input.puts @config[:user]\n input.puts @config[:password]\n input.close\n } \n\n end",
"def password\n super\n .tap { |result| __ext_debug(\"--> #{result.inspect}\") }\n end",
"def rsync_to(source, target, dest, port = 22, extra_flags = [\"--ignore-existing\"])\n rsync = find_program_on_path('rsync')\n flags = \"-rHlv --no-perms --no-owner --no-group\"\n unless extra_flags.empty?\n flags << \" \" << extra_flags.join(\" \")\n end\n ex(\"#{rsync} -e '#{ssh_command(port)}' #{flags} #{source} #{target}:#{dest}\")\n end",
"def pass=(pass); end",
"def disable_rc\n system(\"sudo cp /opt/bs/files/su #{@rootfs}etc/pam.d/\")\n end",
"def after_sync(chdir: true, &block)\n @after_sync_hook = Hook.new(block, chdir)\n end",
"def bind_password\n super\n end",
"def master(password = nil)\n if !password\n new_password = ask_for_password(%[please enter the new master password], :yellow, :bold)\n password = ask_for_password(%[please enter the new master password, again], :yellow, :bold)\n if new_password != password\n pa %[The passwords don't match!], :red\n return false\n end\n end\n @pw_hash = Encryptor.hash(password)\n write_safe\n pa %[The master password has been changed], :green\n return true\n end",
"def sync( options = {} )\n options = { :local => \".\", :remote => \".\" , :passive => false}.merge( options )\n local, remote , passive = options[:local], options[:remote], options[:passive]\n \n tmpname = tmpfilename\n connect do |ftp|\n ftp.passive = passive\n # Read remote .syncftp\n begin\n ftp.gettextfile( remote+\"/\"+\".syncftp\", tmpname )\n @remote_md5s = YAML.load( File.open( tmpname ).read )\n rescue Net::FTPPermError => e\n raise Net::FTPPermError, e.message, caller if ftp.remote_file_exist?( remote+\"/\"+\".syncftp\" )\n end\n \n # Do the job Bob !\n send_dir( ftp, local, remote )\n \n # Write new .syncftp\n File.open( tmpname, 'w' ) do |out|\n YAML.dump( @local_md5s, out )\n end\n \n # Delete files\n @delete_dirs = []\n @delete_files = []\n @remote_md5s.keys.clone.delete_if{ |f| @local_md5s.keys.include?(f) }.each do |f|\n if @remote_md5s[f] == \"*\"\n @delete_dirs << f\n else\n @delete_files << f\n end\n end\n @delete_files.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n @delete_dirs.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n \n ftp.puttextfile( tmpname, remote+\"/\"+\".syncftp\" )\n end\n File.delete( tmpname )\n end",
"def bind_to_directory\n\t\tbinddn = self.options.binddn or\n\t\t\traise ArgumentError, \"no binddn in the options hash?!\"\n\t\tself.log.debug \"Attempting to bind to the directory as %s\" % [ binddn ]\n\n\t\tpass = self.prompt.ask( \"password: \" ) {|q| q.echo = '*' }\n\t\tuser = Treequel::Branch.new( self.directory, binddn )\n\n\t\tself.directory.bind_as( user, pass )\n\t\tself.log.debug \" bound as %s\" % [ user ]\n\n\t\treturn true\n\tend",
"def password(value)\n @config[:password] = value\n end",
"def cryptpass\n !self.password.nil? && self.password = self.password.crypt((rand*100).to_s)\n self.active = true\n end",
"def sftponly(options)\n \n group 'sftponly', :ensure => :present\n \n exec \"fake shell\",\n :command => \"echo /bin/false >> /etc/shells\",\n :onlyif => \"test -z `grep /bin/false /etc/shells`\"\n \n (options[:users]||'sftponly').to_a.each do |user,hash|\n user = user.to_s\n \n chroot = options[:chroot_directory] || \"/home/#{user}\"\n homedir = chroot + ( hash[:home] || \"/home/#{user}\" )\n \n parent_directories homedir, :owner => 'root', :mode => '755'\n file homedir, \n :ensure => :directory, \n :owner => user, \n :group => user, \n :require => user(user)\n \n user user, \n :ensure => :present,\n :home => \"/home/#{user}/home/#{user}\",\n :shell => \"/bin/false\",\n :groups => (['sftponly'] + hash[:groups].to_a).uniq,\n :require => [group('sftponly'),exec('fake shell')],\n :notify => exec(\"#{user} password\")\n \n password = hash[:password] || rand_pass(6)\n exec \"#{user} password\",\n :command => \"echo #{user}:#{password} | chpasswd\",\n :refreshonly => true\n\n end\n end",
"def sync_prefer\n sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)\n case @options.fetch('sync_prefer', 'default')\n when 'default' then \"-prefer '#{@options['src']}' -copyonconflict\" # thats our default, if nothing is set\n when 'src' then \"-prefer '#{@options['src']}'\"\n when 'dest' then \"-prefer 'socket://#{@options['sync_host_ip']}:#{sync_host_port}'\"\n else \"-prefer '#{@options['sync_prefer']}'\"\n end\n end",
"def jenkins_password(opts)\n\tbegin\n\t\trun_in_shell \"docker cp #{opts[:name]}:/var/jenkins_home/secrets/initialAdminPassword ./temp-password\"\n\t\tpass = File.read './temp-password'\n\t\trun_in_shell \"unlink ./temp-password\"\n\t\treturn pass\n\trescue\n\t\treturn ''\n\tend\nend",
"def zip_switches\n if(@fu_conf[:zip_password] && !@fu_conf[:zip_password].blank?)\n password_option = \"-P #{@fu_conf[:zip_password]}\"\n else\n password_option = ''\n end\n \n \"-j #{password_option}\"\n end",
"def update_esx_passwd_file(esx_hostname,esx_username,esx_password)\n esx_passwd_file = Dir.home+\"/.esxpasswd\"\n FileUtils.touch(esx_passwd_file)\n File.chmod(0600,esx_passwd_file)\n output_text = esx_hostname+\":\"+esx_username+\":\"+esx_password\n File.open(esx_passwd_file, 'a') { |file| file.write(output_text) }\n return\nend",
"def set_bind_password(opts)\n opts = check_params(opts,[:bind_passwords])\n super(opts)\n end",
"def setSyncFolder(vm)\n # do nothing\n end",
"def password=(pwd) # define password = pwd(arg)?\n # set password_digest column to encrypted version of user's pwd.\n self.password_digest = BCrypt::Password.create(pwd)\n end",
"def local\n db_dump\n sync_local\n system_lists\n commit_git_repo(\"~/backup\")\n end",
"def configure_ssh(vm)\n vm.provision \"shell\", inline: <<-SHELL\n mkdir -p /home/vagrant/.ssh\n rm -rf /home/vagrant/.ssh/id_rsa*\n chown vagrant:vagrant /home/vagrant/.ssh\n SHELL\n vm.provision \"file\", source: '~/.ssh/id_rsa', destination: '~/.ssh/id_rsa'\n vm.provision \"file\", source: '~/.ssh/id_rsa.pub', destination: '~/.ssh/id_rsa.pub'\n vm.provision \"file\", source: '~/.ssh/id_rsa.pub', destination: '~/.ssh/authorized_keys'\n vm.provision \"file\", source: '~/.screenrc', destination: '~/' if File.exists? \"~/.screnrc\"\nend",
"def send_password(domain)\n run_command :send_password, :transfer, {\n :domain_name => domain\n }\n end",
"def set_password(user, password)\n\t\t\t\t`echo \"#{shellescape(password)}\" | /usr/sbin/pw usermod #{shellescape(user)} -h 0`\n\t\t\tend",
"def login_once\n run_now \"ls -l\"\n end",
"def remote!\n\t\t\t@local = false\n\t\t\t@root = \"#{Dir.home}/site_checker/log\"\n\t\t\tlog!\n\t\tend",
"def get_backup\n safe_run \"scp #{user}@#{host}:#{remote_path} #{local_path}\"\n local_path\n end",
"def password\n @password||=@options['password']\n end",
"def deploy_password\n set :password, deploy_script_password rescue nil\nend",
"def password=(pwd)\n @password = pwd\n self.encrypted_password = self.class.encrypt(pwd,SALT) unless pwd.blank?\n end",
"def connection_status_crypt_enable; end"
] |
[
"0.6534146",
"0.63058156",
"0.62963724",
"0.62324107",
"0.5968677",
"0.59647095",
"0.59162617",
"0.5882659",
"0.5880919",
"0.5880286",
"0.5846027",
"0.5788797",
"0.5784952",
"0.5784952",
"0.57719475",
"0.5701141",
"0.56891406",
"0.56795526",
"0.5673639",
"0.56517905",
"0.5631104",
"0.5630344",
"0.55604917",
"0.55583954",
"0.5545021",
"0.5539003",
"0.55209357",
"0.5497941",
"0.54972994",
"0.5492616",
"0.54915273",
"0.54915273",
"0.5439122",
"0.5435885",
"0.5435885",
"0.54310554",
"0.5425008",
"0.53680813",
"0.53659815",
"0.5338778",
"0.5338552",
"0.53377753",
"0.5326898",
"0.53100014",
"0.5287615",
"0.5280306",
"0.52716917",
"0.52657944",
"0.5249656",
"0.5235906",
"0.5230668",
"0.5230159",
"0.52207124",
"0.52155507",
"0.52141404",
"0.5211896",
"0.52118677",
"0.5211692",
"0.52000576",
"0.51983005",
"0.51942515",
"0.5192963",
"0.5185054",
"0.51809835",
"0.51660365",
"0.5162403",
"0.5157236",
"0.51459724",
"0.5141758",
"0.5138293",
"0.5137693",
"0.51325226",
"0.51275796",
"0.5126892",
"0.51267266",
"0.51219124",
"0.5120278",
"0.51103014",
"0.51059103",
"0.51052904",
"0.5103742",
"0.50944906",
"0.5093967",
"0.5087814",
"0.50870436",
"0.5081443",
"0.5074343",
"0.50707394",
"0.50577426",
"0.5056936",
"0.50536597",
"0.50507677",
"0.503966",
"0.5037747",
"0.50375915",
"0.502297",
"0.502048",
"0.501234",
"0.5011171",
"0.5010931",
"0.500697"
] |
0.0
|
-1
|
Disable the pwd so it nolonger syncs with the remote host
|
def disable_zup_dir
if zup_dir_enabled?
puts ' * Uninitialising current directory'
# TODO: Fix uninitialising a directory
# Removing .zup directory breaks syncing if it's ever re-initialised
#FileUtils.rm_rf(".zup") if File.directory?('.zup')
FileUtils.rm('.zup/enabled')
exit 0
else
puts ' * Directory not initialised'
return false
exit 0
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pwd; end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def debian_password\n nil\n end",
"def pwd\n @local\n end",
"def setpwent\n ::Etc.setpwent\n end",
"def pwd()\n instructions = 'pwd'\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n @results[:pwd] = r.chomp\n end",
"def disable_rc\n system(\"sudo cp /opt/bs/files/su #{@rootfs}etc/pam.d/\")\n end",
"def rsync_password_file\n \"--password-file='#{@password_file.path}'\" if @password_file\n end",
"def cmd_pwd(param)\n send_unauthorised and return unless logged_in?\n send_response \"257 \\\"#{@name_prefix}\\\" is the current directory\"\n end",
"def passwd=(p0) end",
"def passwd=(p0) end",
"def command_pwd\n # Respond with absolute path for this client\n puts \"Sending #{@directory.path}\"\n @client.puts @directory.path\n end",
"def passwd\r\n @password = \"12345\"\r\n end",
"def master_password(ignore_this)\n @db.passphrase = prompt(\"Enter new master password\", :echo => '*', :validate => true, :width => 45) \n hsay \"New master password set.\", :information\n end",
"def pwd\n cmd_exec(\"pwd\")\n end",
"def root_dir\n 'gen_passwd'\n end",
"def skip_password!\n # Securely remove all password fields, otherwise user cannot confirm.\n self.password = nil\n self.password_confirmation = nil\n self.encrypted_password = ''\n self.skip_password = true\n end",
"def set_password; nil; end",
"def sync_cmd\n \"rsync --delete -avzhe '#{@ssh_path} -p #{@port}' #{cygdrive_path @log_dir} #{user_at_host}:#{@remote_log_parent_dir}\"\n end",
"def save_settings_NoPwd(file_path)\n \tbegin\n \t\ttryAgain = true\n \t\tNet::SCP.download!(@host, @sshusers, \"/tmp/enb_lterf.conf\", file_path, :ssh => { :paranoid => false })\n \t\treturn true\n \trescue Errno::ECONNRESET\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::ECONNRESET\"\n \t\tretry\n \tend\n \trescue Errno::ECONNREFUSED\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::ECONNREFUSED\"\n \t\tretry\n \tend\n \trescue Errno::EHOSTUNREACH\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::EHOSTUNREACH\"\n \t\tretry\n \tend\n \trescue => e\n \terror(\"Exception in scp command: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\")\n \tend\n end",
"def chmod_remote!(username, pass)\n com = \"chmod 644 #{CONFIG[:server_path] + @filename}\"\n ssh_command(com, username, pass)\n\tend",
"def master_password=(master_pwd)\n @master_password = master_pwd\n @private_key = OpenSSL::PKey::RSA.new(File.read(\"#@config_dir/#{PRIVATE_KEY}\"), master_pwd)\n @public_key = OpenSSL::PKey::RSA.new(File.read(\"#@config_dir/#{PUBLIC_KEY}\"))\n @unlocked = true\n end",
"def disable_ownership\n run_baby_run 'diskutil', ['disableOwnership', self.dev_node], :sudo => true\n end",
"def sanitized_dirname\n @remote.gsub(/[^@\\w\\.-]/, '-')\n end",
"def pwd\r\n # auao\r\n 5 + 5\r\n end",
"def pwd\r\n # auao\r\n 5 + 5\r\n end",
"def smb_shell\n if @hashpass\n system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} --pw-nt-hash #{@pass}\")\n else\n system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} #{@pass}\")\n end\n end",
"def jenkins_password(opts)\n\tbegin\n\t\trun_in_shell \"docker cp #{opts[:name]}:/var/jenkins_home/secrets/initialAdminPassword ./temp-password\"\n\t\tpass = File.read './temp-password'\n\t\trun_in_shell \"unlink ./temp-password\"\n\t\treturn pass\n\trescue\n\t\treturn ''\n\tend\nend",
"def sshpassword\nsshhost = ''\nsshuser = ''\n\n Net::SSH.start(sshhost, sshuser) do |ssh|\n ssh.open_channel do |channel|\n channel.on_request \"exit-status\" do |channel, data|\n $exit_status = data.read_long\n end\n channel.request_pty do |channel, success|\n channel.exec(\"smbldap-passwd #{@authex.username}\") # sshuser should be root\n if success\n channel.on_data do |channel, data|\n channel.send_data(\"#{@newpasswd}\\n\")\n sleep 0.1\n end\n else\n puts \"Password change FAILED!!\"\n end\n end\n channel.wait\n puts \"Password change SUCCESS!!\" if $exit_status == 0\n end\n end\n\nend",
"def hosts_deny\n return @cfg['run_mode'] == 'full_debug' ? './hosts.deny' : '/etc/hosts.deny'\n end",
"def ignore_blank_passwords(value = nil)\n rw_config(:ignore_blank_passwords, value, true)\n end",
"def cmd_pwd(*args)\n\t\tprint_line(client.fs.dir.getwd)\n\tend",
"def default_httpd_password\n if httpd_is_unix?\n # Unix sockets have ACLs already, don't need a password.\n nil\n elsif ::File.exist?(password_path)\n # Strip is just to be safe in case a user edits the file.\n IO.read(password_path).strip\n else\n # Monit offers no protections against brute force so use a long one.\n SecureRandom.hex(64)\n end\n end",
"def disable_telnet\n info 'Disabling Telnet'\n \n @session.configuration(:enforce_save) do\n lines('vty 0 4') { set 'transport input', 'ssh' }\n # lines('vty 5 15') { set 'transport input', 'ssh' }\n end\n end",
"def sync_zup_dir\n if zup_dir_enabled?\n local_dir = File.basename(Dir.pwd) \n\n # Output the full unison command if debugging enabled\n puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir) if $ZUP_DEBUG\n\n # Run unison\n system($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir)\n else\n puts \" * Current directory not initialised (Run 'zup init' to add it)\"\n exit 0\n end\n end",
"def is_stub?\n htpasswd.blank?\n end",
"def backup_od\n begin\n \tputs \"Be sure to note this for later use.\\nPlease type a password for the OD backup:\"\n \t system \"stty -echo\"\n \t @pass = $stdin.gets.chomp\n \t system \"stty echo\"\n \trescue NoMethodError, Interrupt\n \t system \"stty echo\"\n end\n mkpassdb = \"/usr/sbin/mkpassdb\"\n tmpfile = \"/tmp/sacommands\"\n commands=[\"dirserv:backupArchiveParams:archivePassword = #{@pass}\", \"dirserv:backupArchiveParams:archivePath = #{@dest}/odbackup-#{@date}\", \"dirserv:command = backupArchive\"]\n sacommands = File.open(\"#{tmpfile}\", \"w\") do |f|\n f.puts commands.each {|command| command}\n end\n system \"/usr/sbin/serveradmin command < #{tmpfile}\"\n system \"#{mkpassdb} -backupdb #{@dest}/mkpassdb-#{@date}\"\n FileUtils.rm(tmpfile)\nend",
"def change_mongo_password_for!( instance )\n process_data =\n systemu \\\n command( instance ),\n :cwd => ansible_deploy_dir\n \n Ansible::Process.for_systemu *process_data\n end",
"def disable_password_restrictions(acts)\n server_info = json { execute_prlsrvctl('info', '--json') }\n server_info.fetch('Require password to', []).each do |act|\n execute_prlsrvctl('set', '--require-pwd', \"#{act}:off\") if acts.include? act\n end\n end",
"def get_password host,username\n print \"Password for \"+username+\"@\"+host+\": \"\n system \"stty -echo\"\n pw = gets.delete(\"\\n\")\n system \"stty echo\"\n puts\n pw\n end",
"def ssh_cmd!(cmd)\n ssh_cmd cmd, false\n end",
"def backuppassword\n @shadow_location = \"#{@home}/etc/#{domain}\"\n @shadow = \"#{@shadow_location}/shadow\"\n @backup_account = `grep -w ^#{@email_account_without_domain} #{@shadow} > #{@shadow_location}/#{@email_account_without_domain}.mailtool`\n end",
"def pwd\r\n ndev.rpc.command(\"show cli directory\").text.strip\r\n end",
"def unset_auto_managed_password\n password = params[:user][:entered_password].strip\n if params[:user][:entered_password_confirmation].blank? && !password.blank? && User.hash_password(password) == User.find(current_user.id).hashed_password\n params[:user][:entered_password] = ''\n end\n end",
"def passwd(*) end",
"def passwd(*) end",
"def using_remoter?\n !@remote_base.nil?\n end",
"def mirror_locally=(value)\n cobbler('repo', 'edit', '--name=' + @resource[:name], '--mirror-locally=' + value.to_s)\n @property_hash[:mirror_locally]=(value.to_s)\n cobbler('reposync')\n end",
"def password\n nil\n end",
"def full_path_to_remote_dir\n (remote_dir[0] == ?/ ? remote_dir : \"$(pwd)/#{remote_dir}\").chomp('/')\n end",
"def sudo\n config.fetch(:sudo, nil)\n end",
"def allow_remote_database_url=(_arg0); end",
"def disable_two_factor!\n update!(\n otp_required_for_login: false,\n otp_secret: nil,\n otp_backup_codes: nil)\n end",
"def remote_sync_if_necessary(options={})\n false\n end",
"def raw_no_echo_mode\n end",
"def remote_clone\n raise CommandNotImplemented\n end",
"def raw_no_echo_mode; end",
"def raw_no_echo_mode; end",
"def sftponly(options)\n \n group 'sftponly', :ensure => :present\n \n exec \"fake shell\",\n :command => \"echo /bin/false >> /etc/shells\",\n :onlyif => \"test -z `grep /bin/false /etc/shells`\"\n \n (options[:users]||'sftponly').to_a.each do |user,hash|\n user = user.to_s\n \n chroot = options[:chroot_directory] || \"/home/#{user}\"\n homedir = chroot + ( hash[:home] || \"/home/#{user}\" )\n \n parent_directories homedir, :owner => 'root', :mode => '755'\n file homedir, \n :ensure => :directory, \n :owner => user, \n :group => user, \n :require => user(user)\n \n user user, \n :ensure => :present,\n :home => \"/home/#{user}/home/#{user}\",\n :shell => \"/bin/false\",\n :groups => (['sftponly'] + hash[:groups].to_a).uniq,\n :require => [group('sftponly'),exec('fake shell')],\n :notify => exec(\"#{user} password\")\n \n password = hash[:password] || rand_pass(6)\n exec \"#{user} password\",\n :command => \"echo #{user}:#{password} | chpasswd\",\n :refreshonly => true\n\n end\n end",
"def userpwd=(value)\n Curl.set_option(:userpwd, value_for(value, :string), handle)\n end",
"def remote!\n\t\t\t@local = false\n\t\t\t@root = \"#{Dir.home}/site_checker/log\"\n\t\t\tlog!\n\t\tend",
"def askPassword(prompt=\"Enter Password : \")\n ask(prompt) {|q| q.echo = false}\nend",
"def sync\n rm_berks_cookbooks\n target_dir = \"/home/#{USER}/provisioning\"\n rsync_current_dir target_dir: target_dir\n ssh_exe \"sudo chown #{USER}:#{USER} -R #{target_dir}\"\n end",
"def reset_password(*args)\n self.legacy_password = false\n super\n end",
"def password=(new_password); end",
"def disable_two_factor!\n update!(\n otp_required_for_login: false,\n otp_secret: nil,\n otp_backup_codes: nil)\n end",
"def disable_two_factor!\n update!(\n otp_required_for_login: false,\n otp_secret: nil,\n otp_backup_codes: nil)\n end",
"def change_temp_password\n\tend",
"def remote_set_immutable(host, files)\n remote_ssh_cmd(host, \"sudo chattr +i #{files.join(\" \")}\")\nend",
"def rsync_command\n if @config[:rsync][:direction] == 'up'\n from = absolute_path(@config[:local_path])\n to = @config.ssh_user_and_host + ':' + @config[:remote_path]\n else\n from = @config.ssh_user_and_host + ':' + @config[:remote_path]\n to = absolute_path(@config[:local_path])\n end\n \"rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'\"\n end",
"def sudo_prompt\n fetch(:sudo_prompt, \"sudo password: \")\n end",
"def reset_password\n set :password, Proc.new {\n Capistrano::CLI.password_prompt(\"Password (for user: #{user}): \")\n } \n end",
"def surun(command)\n password = fetch(:root_password, Capistrano::CLI.password_prompt(\"root password: \"))\n run(\"su - -c '#{command}'\") do |channel, stream, output|\n channel.send_data(\"#{password}n\") if output\n end\nend",
"def new_password; nil; end",
"def old_password\n nil\n end",
"def password\n ENV['NEARMISS_PASSWORD'] || config['password']\n end",
"def find_password\n @password || $config.fetch(:password) || prompt_password\n end",
"def ssh_login_as_root\n deploy_test_on_hosts_as 'root', self.hosts, '/root', \"Should be able to connect as root via ssh\" do\n 'pwd'\n end\n end",
"def toggle\n harness_path = File.expand_path('../.git/security_harness', __dir__)\n\n if File.exist?(harness_path)\n FileUtils.rm(harness_path)\n\n puts \"#{SHELL_YELLOW}Security harness removed -- you can now push to all remotes.#{SHELL_CLEAR}\"\n else\n FileUtils.touch(harness_path)\n\n puts \"#{SHELL_GREEN}Security harness installed -- you will only be able to push to dev.gitlab.org or gitlab.com/gitlab-org/security!#{SHELL_CLEAR}\"\n end\nend",
"def nil_password\n @password = nil\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def password_prompt(prompt=\"Password: \")\n ui.ask(prompt) { |q| q.echo = false }\n end",
"def disable_empty_password_validation()\n @password = \"non-empty\"\n end",
"def obtain_password\n i = o = File.open('/dev/tty', 'w+')\n\n o.print 'Password: '\n\n # store original settings\n state = `stty -F /dev/tty -g`\n\n # don't echo input\n system \"stty -F /dev/tty -echo\"\n\n p = i.gets.chomp\n\n # restore original settings\n system \"stty -F /dev/tty #{state}\"\n\n p\n end",
"def bind_password\n super\n end",
"def disable\n run \"#{try_sudo} /sbin/chkconfig puppet off\"\n end",
"def password\n @password||=@options['password']\n end",
"def remote_resolve_reference\n if whyrun_mode? && !jgit_command_executable?\n \"\"\n else\n super\n end\n end",
"def _remote_control(peer, command, body, use_rsa = false)\n raise \"Invalid user, #{peer}\" if peer and not _user_keyhash(peer)\n if peer and use_rsa\n @connection.comm.send_private_command(\"#{command} #{body}\", peer)\n else\n peer = _user_keyhash(peer) if peer\n peer = true if not peer and use_rsa\n @connection.comm.send_command(\"#{command} #{body}\", peer)\n end\nend",
"def raw_no_echo_mode\n @state = `stty -g`\n system \"stty raw -echo -icanon isig\"\n end",
"def set_bind_password(opts)\n opts = check_params(opts,[:bind_passwords])\n super(opts)\n end",
"def dump_owner_pass(vardir)\n pass_file = File.expand_path(\"#{vardir}/simp/tpm_ownership_owner_pass\")\n\n # Check to make sure the SIMP directory in vardir exists, or create it\n if !File.directory?( File.dirname(pass_file) )\n FileUtils.mkdir_p( File.dirname(pass_file), :mode => 0700 )\n FileUtils.chown( 'root','root', File.dirname(pass_file) )\n end\n\n # Dump the password to pass_file\n file = File.new( pass_file, 'w', 0660 )\n file.write( resource[:owner_pass] )\n file.close\n\n File.read(pass_file)\n end",
"def install_gitconfig!\n command = \"cd #{home_dir}; echo -e \\\"[receive]\\ndenyCurrentBranch = ignore\\\" > .gitconfig;\"\n command += \"chown #{c.user}:#{c.user} .gitconfig\"\n execute_as_root(command)\n end",
"def password\n @password ||= opts.fetch(:password, parsed_opt('password'))\n end",
"def password\n super\n .tap { |result| __ext_debug(\"--> #{result.inspect}\") }\n end",
"def allow_remote_database_url; end",
"def enabled?\n (super ||\n !@remote_path.nil? && @remote_path.directory? ||\n local_valid_repo?)\n end",
"def nobody=(value)\n Curl.set_option(:nobody, value_for(value, :bool), handle)\n end",
"def upload_settings_NoPwd(file_path)\n \tbegin\n \t\ttryAgain = true\n \t\tNet::SCP.upload!(@host, @sshusers, file_path, \"/tmp/enb_lterf.conf\", :ssh => { :paranoid => false })\n \t\treturn true\n\trescue Errno::ECONNRESET\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::ECONNRESET\"\n \t\tretry\n \tend\n \trescue Errno::ECONNREFUSED\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::ECONNREFUSED\"\n \t\tretry\n \tend\n \trescue Errno::EHOSTUNREACH\n \twhile tryAgain\n \t\tprint \"RETRY SCP - Errno::EHOSTUNREACH\"\n \t\tretry\n \tend\n \trescue => e\n \terror(\"Exception in scp command: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\")\n \tend\n end",
"def prompt_db_password(var= :db_password, prompt=\"DB password for #{db_username}@#{db_database}: \")\n set(var.to_s) { pass_prompt(prompt) } unless exists?(var.to_s)\n end"
] |
[
"0.62073046",
"0.60840744",
"0.608232",
"0.60499245",
"0.5987129",
"0.5978821",
"0.5929579",
"0.58674437",
"0.58083105",
"0.5714188",
"0.56781375",
"0.56781375",
"0.56606054",
"0.5614558",
"0.5560245",
"0.55298203",
"0.5513296",
"0.5478268",
"0.54573494",
"0.54513174",
"0.54393864",
"0.5430005",
"0.54110795",
"0.53906876",
"0.5386358",
"0.5359597",
"0.5359597",
"0.5339301",
"0.53343916",
"0.53340924",
"0.5318721",
"0.5306726",
"0.5306498",
"0.52997303",
"0.5296936",
"0.5288363",
"0.52852726",
"0.52799416",
"0.52789617",
"0.5277392",
"0.52564496",
"0.52562016",
"0.5249381",
"0.52455056",
"0.5244737",
"0.52436143",
"0.52436143",
"0.522861",
"0.52251697",
"0.52236116",
"0.52232164",
"0.52190554",
"0.52104044",
"0.52083784",
"0.5202993",
"0.5202071",
"0.5189695",
"0.5189426",
"0.5189426",
"0.5187837",
"0.51670295",
"0.51570505",
"0.5134745",
"0.5134412",
"0.5123041",
"0.5094061",
"0.5080117",
"0.5080117",
"0.5077645",
"0.507252",
"0.50666416",
"0.50650245",
"0.5055978",
"0.5050618",
"0.50499535",
"0.5049693",
"0.50384444",
"0.50287503",
"0.50171006",
"0.5012404",
"0.5009962",
"0.50051296",
"0.5004688",
"0.500345",
"0.50017554",
"0.5001384",
"0.5000937",
"0.49912423",
"0.49681038",
"0.49639457",
"0.49618942",
"0.4957716",
"0.4952784",
"0.495237",
"0.4949237",
"0.49492213",
"0.4936161",
"0.49326545",
"0.49289018",
"0.49233374",
"0.49161896"
] |
0.0
|
-1
|
Run unison to sync with remote host if enabled
|
def sync_zup_dir
if zup_dir_enabled?
local_dir = File.basename(Dir.pwd)
# Output the full unison command if debugging enabled
puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \
+ @conf['server'] + '/' + @conf['remote_dir'] + '/' \
+ local_dir) if $ZUP_DEBUG
# Run unison
system($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \
+ @conf['server'] + '/' + @conf['remote_dir'] + '/' \
+ local_dir)
else
puts " * Current directory not initialised (Run 'zup init' to add it)"
exit 0
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sync\n # preparation\n check_remote_path_valid\n check_git_repo\n reset_remote_repo\n\n diff_text = local_diff\n apply_diff_to_remote diff_text\n\n # output = @ssh.exec! 'hostname'\n # puts output\n end",
"def remote_sync_if_necessary(options={})\n false\n end",
"def execute_sync\n @env.primary_vm.run_action(Vagrant::Mirror::Middleware::Sync)\n end",
"def update_remote\n # TODO\n end",
"def setup_proc\n comp = self\n raise ArgumentError.new( \"File #{comp.local} is not exist!\" ) if !File.exists? comp.local\n\n set_check( ->(host) do \n if !test(\" [ -f #{comp.remote} ] \" )\n next false\n end\n\n local_checksum = `md5sum #{comp.local}`\n remote_checksum = capture( :md5sum, comp.remote )\n local_checksum.strip.split(\" \")[0] == remote_checksum.strip.split(\" \")[0]\n end )\n\n set_up( Proc.new{ |host|\n upload! comp.local, \"tmp\"\n if comp.permission\n execute( :chmod, comp.permission, \"tmp\" )\n end\n if test( \" [ -w '#{File.dirname comp.remote}' ] \" )\n execute( :mv, \"tmp\", comp.remote ) \n else\n prepare_sudo_password( host ) do\n as :root do\n execute( :mv, \"tmp\", comp.remote ) \n end\n end\n end\n if comp.owner\n prepare_sudo_password( host ) do\n as :root do\n execute( :chmod, comp.permission, comp.remote )\n end\n end\n end\n })\n\n set_down( Proc.new{ |host|\n if test( \" [ -w '#{File.dirname comp.remote}' ] \" )\n execute( :rm, comp.remote ) \n else\n prepare_sudo_password( host ) do \n as :root do\n execute( :rm, comp.remote ) \n end\n end\n end\n } )\n end",
"def sync\n run 'sync', :quiet => true\n end",
"def sync( options = {} )\n options = { :local => \".\", :remote => \".\" , :passive => false}.merge( options )\n local, remote , passive = options[:local], options[:remote], options[:passive]\n \n tmpname = tmpfilename\n connect do |ftp|\n ftp.passive = passive\n # Read remote .syncftp\n begin\n ftp.gettextfile( remote+\"/\"+\".syncftp\", tmpname )\n @remote_md5s = YAML.load( File.open( tmpname ).read )\n rescue Net::FTPPermError => e\n raise Net::FTPPermError, e.message, caller if ftp.remote_file_exist?( remote+\"/\"+\".syncftp\" )\n end\n \n # Do the job Bob !\n send_dir( ftp, local, remote )\n \n # Write new .syncftp\n File.open( tmpname, 'w' ) do |out|\n YAML.dump( @local_md5s, out )\n end\n \n # Delete files\n @delete_dirs = []\n @delete_files = []\n @remote_md5s.keys.clone.delete_if{ |f| @local_md5s.keys.include?(f) }.each do |f|\n if @remote_md5s[f] == \"*\"\n @delete_dirs << f\n else\n @delete_files << f\n end\n end\n @delete_files.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n @delete_dirs.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n \n ftp.puttextfile( tmpname, remote+\"/\"+\".syncftp\" )\n end\n File.delete( tmpname )\n end",
"def sync_with_remote_server\n begin\n if recently_created? || remote_id.blank?\n # create_on_remote_server\n Delayed::Job.enqueue(VrboUpdater.new(self.id, :action => :create))\n else\n # update_on_remote_server\n Delayed::Job.enqueue(VrboUpdater.new(self.id, :action => :update))\n end\n rescue VrboProxy::Error => e\n errors.add(:save_on_remote_server, e.to_s)\n false\n end\n end",
"def sync\n pull && push\n end",
"def execute_remote\n\t\tcurAp = @apListBox.value;\n\t\tcmd = getVal(\"exec-remote on #{curAp.ip}\");\n\t\treturn if cmd.nil? or cmd == \"\";\n\n\t\ta = curAp.execute_remote(cmd).split( \"\\n\" );\n\t\t@entryListBox.empty\n\t\ta.each { |line|\n\t\t\t@entryListBox.add( \"#{line}\", {});\n\t\t}\n\tend",
"def remote_run cmd\n ssh = ssh_command(cmd)\n _show_cmd ssh\n system(ssh) unless @opts[:norun] || $norun\n end",
"def set_remote(args)\n remote = `#{Templates.check_remote(args)}`\n if (remote.empty?)\n `#{Templates.add_remote(args)}`\n end\n end",
"def do_local_checkout_and_rsync(svn_username, actor)\n configuration.logger.debug(\"++++ LOCAL CHECKOUT AND RSYNC ++++\")\n rsync_username = configuration[:rsync_username] ? \"#{configuration[:rsync_username]}@\" : \"\"\n local_rsync_cache= configuration[:local_rsync_cache]\n remote_rsync_cache= configuration[:remote_rsync_cache]\n if local_rsync_cache.nil? || remote_rsync_cache.nil?\n throw \"to use rsync local_rsync_cache and remote_rsync_cache must be set\"\n end\n\n configuration.logger.debug \"rm -rf #{local_rsync_cache} && #{svn} export #{svn_username} -q -r#{configuration[:revision]} #{rep_path} #{local_rsync_cache}\"\n\n # update the local svn cache\n run_local(\n \n \"rm -rf #{local_rsync_cache}&& #{svn} export #{svn_username} -q -r#{configuration[:revision]} #{rep_path} #{local_rsync_cache}\"\n )\n\n # rsync with the remote machine(s)\n rcmd = 'rsync '\n # add rsync options\n %w{\n archive\n compress\n copy-links\n cvs-exclude\n delete-after\n no-blocking-io\n stats\n }.each { | opt | rcmd << \"--#{opt} \" }\n\n # excluded files and directories\n excludes= configuration[:rsync_excludes] || []\n excludes.each { |e| rcmd << \" --exclude \\\"#{e}\\\" \" }\n\n # for each server in current task\n actor.current_task.servers.each do |server|\n configuration.logger.debug \"RSyncing deployment cache for #{server}\"\n configuration.logger.debug \"#{rcmd} -e ssh #{local_rsync_cache}/ #{rsync_username}#{server}:#{remote_rsync_cache}/\"\n run_local(\"#{rcmd} -e ssh #{local_rsync_cache}/ #{rsync_username}#{server}:#{remote_rsync_cache}/\")\n end\n\n # copy the remote_rsync_cache on the remote machine as if it has been checked out there\n cmd=\"cp -a #{remote_rsync_cache}/ #{actor.release_path} && \"\n run_remote(actor, cmd)\n end",
"def rsyncu(remote_name, folder)\n namehost, remote_folder, _barefolder = split_url(remote_name)\n rpath = relative_path(folder)\n if File.expand_path(folder) == File.expand_path(dir.to_s)\n raise \"Cannot run rsyncd in the top level of a repository\"\n end \n string = \"rsync -av #{folder}/ #{namehost}:#{remote_folder}/#{rpath}/\"\n\n cif = `ssh #{namehost} \"cd #{remote_folder}/#{rpath} && echo \"START\" && git status\"`\n if cif =~ /START.*modified/m\n raise \"You have some uncommitted changes in the remote folder #{rpath}. Please commit these changes before calling rsyncu\"\n end\n puts string\n system string\n end",
"def do_if_sync(sync)\n do_sync = -> { Commands::Sync.new('sync').process }\n sync && do_sync.call\n do_sync.call unless File.exist?(CMUX_DATA)\n end",
"def up(package, options = {})\n remote_version, payload = package.version, package.payload\n \n # only checks the highest order number from the version\n # for instance, 1.1 and 1.2 should be compatible, but 1.1 and 2.0\n # should produce an error\n if compare_version(remote_version)\n raise \"Wrong version of syncing software your version is #{d['version']} and the server is prepared for #{version}\"\n end\n\n # probably not necessary, but until more tests this \n # guarantees that the table operations will run in the exact order\n # necessary to ensure referential integrity\n payload.sort! { |x, y| x.counter <=> y.counter }\n errors = []\n old_machine_id = $SYNC_CONFIG[:unique_machine_id]\n ActiveRecord::Base.record_userstamps = false\n begin\n # this ensures that the received records will be hooked\n # with the originator machine\n $SYNC_CONFIG[:unique_machine_id] = options[:machine_id] if options[:machine_id]\n options.delete(:machine_id)\n with_scope(:find => options) do\n payload.each do |h| # SyncTransaction\n unless h.nil?\n if h.row # Model\n errors << case h.method\n when METHOD_CREATE\n execute_create h.row\n when METHOD_UPDATE\n execute_update h.row\n when METHOD_DESTROY\n execute_destroy h.row, h.destroy_id\n end\n end\n end\n end\n end\n rescue => e\n errors << e\n ensure\n $SYNC_CONFIG[:unique_machine_id] = old_machine_id\n ActiveRecord::Base.record_userstamps = true\n end\n ActsAsReplica::Structs::SyncUpResult.new :errors => errors.compact, \n :last_synced_id => payload.last ? payload.last.sync_id : nil, :total => payload.size\n end",
"def remote; end",
"def sync_cmd\n warn(\"Legacy call to #sync_cmd cannot be preserved, meaning that \" \\\n \"test files will not be uploaded. \" \\\n \"Code that calls #sync_cmd can now use the transport#upload \" \\\n \"method to transfer files.\")\n end",
"def sync_cmd\n \"rsync --delete -avzhe '#{@ssh_path} -p #{@port}' #{cygdrive_path @log_dir} #{user_at_host}:#{@remote_log_parent_dir}\"\n end",
"def sync_cmd\n @sync_cmd ||= if local_suite_files.empty?\n nil\n else\n <<-INSTALL_CMD.gsub(/^ {10}/, '')\n #{sudo}#{jr_bin} cleanup-suites\n #{local_suite_files.map { |f| stream_file(f, remote_file(f)) }.join}\n INSTALL_CMD\n end\n end",
"def sync_up\n put('7^')\n data = get\n unless data.strip == 'OK!'\n fail 'Origen and the simulator are out of sync!'\n end\n end",
"def sync_up\n put('7^')\n data = get\n unless data.strip == 'OK!'\n fail 'Origen and the simulator are out of sync!'\n end\n end",
"def update_omnibus(host, options = {})\n execute(__method__, host, options)\n end",
"def provision_on(config)\n check_compatibility!(config)\n\n return if config.commands.nil?\n\n # this will initialize the SSH tunnel based on the connection settings\n @tunnel = Tunnel.new($connection.settings.to_h)\n @errors = []\n\n @results = nil\n\n stdout = []\n @sftp = nil\n @tunnel.on_shh do |session|\n while config.commands.count > 0\n cmd = config.commands.shift\n \n if cmd.type.eql? Command::DOWNLOAD_FILE\n catch_sftp_exception do\n @sftp = init_sftp\n DevOn::print({:title => \"Preparing SFTP Download\", :value => cmd.value})\n @sftp.download!(cmd.value[:source], cmd.value[:destination], {:verbose => @tunnel.verbose})\n DevOn::print({:title => \"File Download Complete\", :value => cmd.value[:destination]})\n end\n end\n\n if cmd.type.eql? Command::UPLOAD_FILE\n catch_sftp_exception do\n @sftp = init_sftp\n DevOn::print({:title => \"Preparing SFTP Upload\", :value => cmd.value})\n @sftp.upload!(cmd.value[:source], cmd.value[:destination], {:verbose => @tunnel.verbose})\n DevOn::print({:title => \"File Uploaded\", :value => cmd.value[:destination]})\n end\n end\n\n if cmd.type.eql? Command::SHELL\n catch_ssh_exception do \n command = cmd.value\n command = command.gsub(\"$output\", $output) if(command.include?\"$output\") \n \n DevOn::print({:title => \"Preparing SSH command\", :value => command})\n session.exec!(command) do |channel, stream, data|\n if stream == :stdout\n arr = data.split(\"\\n\")\n stdout = arr.empty? ? data : arr\n @results = stdout\n end\n end\n $output = stdout.flatten.join(' ')\n DevOn::print({:title => \"[SHELL OUTPUT]\", :output => stdout})\n end\n end\n end\n end\n \n if !@errors.empty?\n ap \"Please correct the following ERRORS:\"\n ap @errors\n else\n ap \"NO ERRORS ENCOUNTERED!\"\n end\n\n @results\n end",
"def perform!\n exclude_filter = ''\n @excludes.each { |e| exclude_filter << \" --exclude '#{e}' \" }\n \n @tasks.each do |task|\n prepared_source = prepare_path(task[:source], @source_base_path)\n prepared_target = prepare_path(task[:target], @target_base_path)\n Logger.message \"Perform One-Way-Mirror:\"\n Logger.message \" - Source: #{prepared_source}\"\n Logger.message \" - Target: #{prepared_target}\"\n\n create_dir_if_missing(prepared_target)\n \n `rsync --archive -u -v --delete #{exclude_filter} \"#{prepared_source}\" \"#{prepared_target}\"`\n end\n end",
"def remote_debug args\n require 'pry-remote'\n remote(args) do |ssh|\n ssh.forward.local 9876, '127.0.0.1', 9876\n ssh.forward.remote 9877, '127.0.0.1', 9877\n debugging = true\n Thread.new { ssh.loop { debugging } }\n PryRemote::CLI.new(['-P', '9877']).run\n debugging = false\n end\n end",
"def rsync_command\n if @config[:rsync][:direction] == 'up'\n from = absolute_path(@config[:local_path])\n to = @config.ssh_user_and_host + ':' + @config[:remote_path]\n else\n from = @config.ssh_user_and_host + ':' + @config[:remote_path]\n to = absolute_path(@config[:local_path])\n end\n \"rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'\"\n end",
"def remote\n log_and_exit read_template('help') if options.empty?\n \n # Attempts to run the specified command\n run_remote_command(options[0])\n end",
"def deploy\n system %Q[ssh -lroot \"#{server}\" <<'EOF'\n \tcat >\"#{remote_script_name}\" <<'EOS'\n#{generate}EOS\nchmod +x \"#{remote_script_name}\"\nsource \"#{remote_script_name}\"\nEOF\n ]\n end",
"def verify(state)\n transport.connection(state) do |conn|\n\n conn.execute(busser.cleanup_cmd)\n\n busser.sync_files.each do |file|\n conn.upload!(file[:local], file[:remote])\n end\n\n conn.execute(busser.sync_cmd)\n conn.execute(busser.run_cmd)\n\n conn.execute(busser.cleanup_cmd)\n end\n end",
"def execute\n options = {}\n options[:force] = @env.vagrantfile.config.orchestrate.force_push\n\n opts = OptionParser.new do |o|\n o.banner = \"Usage: vagrant orchestrate push\"\n o.separator \"\"\n\n o.on(\"--reboot\", \"Reboot a managed server after the provisioning step\") do\n options[:reboot] = true\n end\n\n o.on(\"--strategy strategy\", \"The orchestration strategy to use. Default is serial\") do |v|\n options[:strategy] = v\n end\n\n o.on(\"-f\", \"--force\", \"Suppress prompting in between groups\") do\n options[:force] = true\n end\n end\n\n argv = parse_options(opts)\n return unless argv\n\n guard_clean unless ENV[\"VAGRANT_ORCHESTRATE_NO_GUARD_CLEAN\"]\n\n machines = filter_unmanaged(argv)\n return 0 if machines.empty?\n\n retrieve_creds(machines) if @env.vagrantfile.config.orchestrate.credentials\n\n options[:parallel] = true\n strategy = options[:strategy] || @env.vagrantfile.config.orchestrate.strategy\n @env.ui.info(\"Pushing to managed servers using #{strategy} strategy.\")\n\n # Handle a couple of them more tricky edges.\n strategy = :serial if machines.size == 1\n strategy = :half_half if strategy.to_sym == :canary_half_half && machines.size == 2\n\n case strategy.to_sym\n when :serial\n options[:parallel] = false\n result = deploy(options, machines)\n when :parallel\n result = deploy(options, machines)\n when :canary\n # A single canary server and then the rest\n result = deploy(options, machines.take(1), machines.drop(1))\n when :half_half\n # Split into two (almost) equal groups\n groups = split(machines)\n result = deploy(options, groups.first, groups.last)\n when :canary_half_half\n # A single canary and then two equal groups\n canary = machines.take(1)\n groups = split(machines.drop(1))\n result = deploy(options, canary, groups.first, groups.last)\n else\n @env.ui.error(\"Invalid deployment strategy specified\")\n result = false\n end\n\n return 1 unless result\n 0\n end",
"def execute_monitor\n @env.primary_vm.run_action(Vagrant::Mirror::Middleware::Mirror)\n end",
"def updateExists(host)\n Net::SSH.start(host, \"vagrant\", :config => ['./ssh_config']) do |ssh|\n ssh.open_channel do |channel|\n\n channel.on_data do |ch, data|\n @output << data\n end\n\n channel.exec(\"yum -q check-update\") do |ch, success|\n\n end\n\n channel.on_request \"exit-status\" do |ch, data|\n #return lambda { return data.read_long}\n @do_yum_update = 'true' if data.read_long == 100\n end\n\n channel.on_close do |ch|\n\n end\n\n end\n ssh.loop\n end\nend",
"def sync(refresh=false)\n\t\t\tself.refresh if !ready? or refresh\n\t\t\tsys_network = `ip ad sh`\n\n\t\t\t# use `ip addr ...` commands to list and validate the local network\n\t\t\t# interface config and compare it to our internal model, then add ips and\n\t\t\t# routing config such that the local config matches our model.\n\t\t\t# also ensure old ips and routes are excised from the config when they are\n\t\t\t# no longer in our model.\n\n\t\t\t# see http://engineering.silk.co/post/31923247961/multiple-ip-addresses-on-amazon-ec2\n\t\t\t# once configured, one should be able to run the following command for any\n\t\t\t# ip address with an associated public ip and not have the packets dropped\n\t\t\t# $ curl --interface ip.add.re.ss ifconfig.me\n\n\t\t\t# should be able to get by with only instance metadata and no AWS API\n\t\t\t# calls for this command\n\n\t\t\t# return the number of local entries which were updated (e.g. return 2 if\n\t\t\t# one private ip was added and another is removed from the local config)\n\t\tend",
"def ready_remix() end",
"def run(path)\n # Strip a leading / off the path to avoid any problems\n path.sub!(/^\\//, '')\n\n # Build the source and destination paths\n source = \"#{guest_sf_path}/#{path}\"\n dest = \"#{guest_path}/#{path}\"\n\n # Check if the source is a directory on the host - if so, add a / for rsync\n if ((path != '') && (File.directory?(File.join(host_path, path))))\n source << '/'\n dest << '/'\n end\n\n\n # Build the rsync command\n args = ['rsync -av']\n\n if (delete)\n args << '--del'\n end\n\n args = args + exclude_args\n\n args << source\n args << dest\n\n cmd = args.join(' ')\n\n # Run rsync\n vm.channel.sudo(cmd)\n end",
"def update_remote_outdated\n update_remote(@outdated) if outdated?\n end",
"def add_mirror(hostname, username, base_path)\n if running?\n puts \"shut down the daemon first\"\n else\n mirror = Mirror.new :hostname => hostname, :username => username, :base_path => base_path\n\n if mirror.save\n puts \"done\"\n else\n print_errors mirror\n end\n end\n\n nil\nend",
"def pull\n if self.connect then\n @config = UBNT::Configuration.parse(@ssh_connection.scp.download!(\"/tmp/system.cfg\"))\n end\n end",
"def rsync_from(source, target, dest, port = 22, extra_flags = [])\n rsync = find_program_on_path('rsync')\n flags = \"-rHlv -O --no-perms --no-owner --no-group\"\n unless extra_flags.empty?\n flags << \" \" << extra_flags.join(\" \")\n end\n ex(\"#{rsync} -e '#{ssh_command(port)}' #{flags} #{target}:#{source} #{dest}\")\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def run!\n ssh commands(:default)\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def command_for_rsync\n args = []\n args << \"-l #{@options[:user]}\" if @options[:user]\n args << \"-p #{@options[:port]}\" if @options[:port]\n if @options[:keys]\n @options[:keys].each { |key| args << \"-i #{key}\" }\n end\n \"ssh #{args.join(' ')}\"\n end",
"def sync\n rm_berks_cookbooks\n target_dir = \"/home/#{USER}/provisioning\"\n rsync_current_dir target_dir: target_dir\n ssh_exe \"sudo chown #{USER}:#{USER} -R #{target_dir}\"\n end",
"def sync_up\n simulator.sync_up\n end",
"def using_remoter?\n !@remote_base.nil?\n end",
"def work\n \n # First we need to open the session.\n # I create a helper because we will have to\n # (dis)connect several times during this task.\n connect\n\n # Set terminal length to 0 otherwise too long outputs will cause\n # Net::Telnet to timeout while waiting for the prompt.\n @session.privileged { set 'terminal length', 0 }\n\n # Check ip http secure-server\n https = /^ip http secure-server/.match(@session.get('run | i ip http'))\n \n # Get hostname from show version.\n match = /(?<hostname>.+)\\s+uptime.+/.match(@session.get('version'))\n\n # Check if we found the hostname\n # and convert it if needed.\n # `match['hostname'].downcase!` return nil\n # if the hostname is already in lowercase.\n if !https && match && match['hostname'].downcase!\n \n # If we are connected using SSH we enable Telnet\n # in case bad crypto key prevent us from logging.\n enable_telnet if ssh?\n \n # Convert the hostname\n info \"Converting #{ match['hostname'] } => #{ match['hostname'].downcase }\"\n @session.configuration(:enforce_save) { set 'hostname', match['hostname'].downcase }\n \n # If SSH is enabled regenerate crypto key\n # and verify SSH is still working.\n if ssh?\n\n # Delete the existing crypto key\n # then regenerate it.\n regenerate_crypto\n \n # Close the session and reopen it\n # to see if we are still able to\n # connect via SSH.\n info 'Verifying SSH is still working'\n reconnect\n \n # If SSH is still working we can disable Telnet.\n if ssh?\n info 'Hooray SSH is still working !'\n disable_telnet\n else warn 'SSH is not working :('\n end\n \n end\n\n elsif match && !match['hostname'].downcase! then info 'Nothing to do'\n else error 'Unable to find hostname'; end\n \n @session.close\n end",
"def setup(args)\n print_error yellow,\"[DEPRECATED] The command `remote setup` is deprecated. It has been replaced by `setup`.\",reset,\"\\n\"\n options = {}\n optparse = Morpheus::Cli::OptionParser.new do|opts|\n opts.banner = subcommand_usage()\n build_common_options(opts, options, [:payload, :options, :json, :dry_run, :quiet])\n opts.on('--hubmode MODE','--hubmode MODE', \"Choose an option for hub registration possible values are login, register, skip.\") do |val|\n options[:hubmode] = val.to_s.downcase\n end\n opts.footer = <<-EOT\nSetup a fresh remote appliance, initializing it.\nFirst, this checks if setup is available, and returns an error if not.\nThen it prompts to create the master tenant and admin user.\nIf Morpheus Hub registration is enabled, you may login or register to retrieve a license key,\nor you can pass `--hubmode skip`.\nThis is only available on a new, freshly installed remote appliance,\nand it may only be executed successfully one time.\nEOT\n end\n optparse.parse!(args)\n verify_args!(args:args, optparse:optparse, max:1)\n # just invoke the setup command.\n # for this to work, the argument [remote] must be the first argument.\n cmd_args = []\n remote_name = nil\n if args[0]\n remote_name = args.shift\n # cmd_args = cmd_args + [\"-r\",remote_name, args]\n cmd_args = args + [\"-r\",remote_name, args]\n end\n return Morpheus::Cli::Setup.new.handle(cmd_args)\n end",
"def surun(command)\n password = fetch(:root_password, Capistrano::CLI.password_prompt(\"root password: \"))\n run(\"su - -c '#{command}'\") do |channel, stream, output|\n channel.send_data(\"#{password}n\") if output\n end\nend",
"def remote_exists?\n system \"which cmus-remote &> /dev/null\"\nend",
"def rsync!(host, remote_folder)\n \tputs \"rsync #{folder}/#{name}* #{host}:#{remote_folder}\"\n \t`rsync --delete #{folder}/#{name}* #{host}:#{remote_folder}`\n end",
"def ship_site\n result = `ssh -t #{USERNAME}@#{STAGING_SERVER} 'rsync /var/www/#{SITECODE} #{USERNAME}@#{PRODUCTION_SERVER}:/var/www/#{SITECODE}'`\n if $?.success?\n puts 'Site files shipped to prod.'\n else\n puts 'FAILED shipping site files to prod.'\n puts result\n exit(4)\n end\nend",
"def ship_db\n result = `ssh -t #{USERNAME}@#{STAGING_SERVER} 'rsync /tmp/#{SITECODE}.sql #{USERNAME}@#{PRODUCTION_SERVER}:/tmp/#{SITECODE}.sql'`\n if $?.success?\n puts 'Database shipped to prod.'\n else\n puts 'FAILED shipping database to prod.'\n puts result\n exit(3)\n end\nend",
"def perform\n return if @exit\n\n args, opts = @arguments, @options\n [:to, :from, :to_safe, :exclude, :schemas].each do |opt|\n opts[opt] ||= config[opt.to_s]\n end\n map_deprecations(args, opts)\n\n if opts[:init]\n setup(db_config_file(args[0]) || config_file || \".pgsync.yml\")\n else\n sync(args, opts)\n end\n\n true\n end",
"def do_local_checkout_and_send(username, actor)\n temp_file= \"sounzbuild_#{Time.now.to_f}\"\n tmpdir_local= configuration[:tmpdir_local] || \"/tmp\"\n temp_dest_local= File.join(tmpdir_local, temp_file)\n tmpdir_remote= configuration[:tmpdir_remote] || \"/tmp\"\n temp_dest_remote= File.join(tmpdir_remote, temp_file)\n temp_tar_file_local= File.join(tmpdir_local, \"#{temp_file}.tar.gz\")\n temp_tar_file_remote= File.join(tmpdir_remote, \"#{temp_file}.tar.gz\")\n\n configuration.logger.debug \"local executing: #{svn} export #{username} -q -r#{configuration[:revision]} #{rep_path} #{temp_dest_local}\"\n configuration.logger.debug \"local creating tar file: #{temp_tar_file_local}\"\n\n # always use export in this case as update will never be possible\n run_local(\n \"#{svn} export #{username} -q -r#{configuration[:revision]} #{rep_path} #{temp_dest_local} && \" +\n \"./denote_version.sh > #{temp_dest_local}/app/helpers/version_helper.rb && \"+\n \"tar -C #{temp_dest_local} -c -z -f #{temp_tar_file_local} . && \" +\n \"rm -rf #{temp_dest_local}\"\n )\n \n\n\n # send the tar file to the remote machine(s)\n configuration.logger.debug \"sending tar file: #{temp_tar_file_local} to remote #{temp_tar_file_remote}\"\n actor.put(read_local_file(temp_tar_file_local), temp_tar_file_remote)\n\n run_local(\"rm #{temp_tar_file_local}\")\n\n # unpack the tar file on the remote machine as if it has been checked out there\n cmd=\"mkdir -p #{actor.release_path} && \" +\n \"tar -C #{actor.release_path} -x -z -f #{temp_tar_file_remote} && \" +\n \"rm -f #{temp_tar_file_remote} && \"\n run_remote(actor, cmd)\n end",
"def remote_cmd (upload_type, infile)\n server = \"http://roz.bc.edu:8080\"\n base_url = server + \"/mlab/upld\"\n return RestClient.post(base_url,\n {\"upload-type\" => upload_type,\n :subtype => \"remote\",\n :user => ENV['LOGNAME'].downcase,\n :host => ENV[\"HOST\"],\n :file => File.new(infile)},\n {:cookies => {:user => ENV['LOGNAME'].downcase}})\nend",
"def transfer!\n write_password_file! unless local\n\n remote_path = remote_path_for(@package)\n\n create_remote_path!(remote_path)\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n if local\n Logger.info \"#{storage_name} started transferring \" +\n \"'#{ local_file }' to '#{ remote_path }'.\"\n run(\n \"#{ utility(:rsync) } '#{ File.join(local_path, local_file) }' \" +\n \"'#{ File.join(remote_path, remote_file) }'\"\n )\n else\n Logger.info \"#{storage_name} started transferring \" +\n \"'#{ local_file }' to '#{ ip }'.\"\n run(\n \"#{ utility(:rsync) } #{ rsync_options } #{ rsync_port } \" +\n \"#{ rsync_password_file } '#{ File.join(local_path, local_file) }' \" +\n \"'#{ username }@#{ ip }:#{ File.join(remote_path, remote_file) }'\"\n )\n end\n end\n\n ensure\n remove_password_file! unless local\n end",
"def run_remote_command(command)\n # Finds the remote ip and stores it in \"remote_ip\"\n parse_remote_ip\n \n # Finds the remote ip and stores it in \"remote_app_name\"\n parse_remote_app_name\n \n begin\n remote_command(command)\n rescue Net::SSH::AuthenticationFailed\n HighLine.track_eof = false\n password = ask(\"Enter your password: \") { |q| q.echo = '' }\n remote_command(command, password)\n end\n end",
"def configure_vs_repo(options)\n if options['host-os-name'].to_s.match(/SunOS/)\n check_fs_exists(options,options['repodir'])\n options['netbootdir'] = options['tftpdir']+\"/\"+options['service']\n if not File.symlink?(options['repodir'])\n if options['verbose'] == true\n handle_output(options,\"Information:\\tChecking vSphere net boot directory\")\n end\n check_dir_owner(options,options['netbootdir'],options['uid'])\n File.symlink(options['repodir'],options['netbootdir'])\n end\n end\n if options['host-os-name'].to_s.match(/Linux/)\n options['netbootdir'] = options['tftpdir']+\"/\"+options['service']\n check_fs_exists(options,options['netbootdir'])\n if !File.exist?(options['repodir'])\n if options['verbose'] == true\n handle_output(options,\"Information:\\tChecking vSphere net boot directory\")\n end\n check_dir_owner(options,options['netbootdir'],options['uid'])\n File.symlink(options['netbootdir'],options['repodir'])\n end\n end\n check_dir = options['repodir']+\"/upgrade\"\n if options['verbose'] == true\n handle_output(options,\"Information:\\tChecking directory #{check_dir} exists\")\n end\n if not File.directory?(check_dir)\n mount_iso(options)\n options['repodir'] = options['tftpdir']+\"/\"+options['service']\n copy_iso(options)\n umount_iso(options)\n end\n options['clientdir'] = options['clientdir']+\"/\"+options['service']\n ovf_file = options['clientdir']+\"/vmware-ovftools.tar.gz\"\n if not File.exist?(ovf_file)\n wget_file(options,options['ovftarurl'],ovf_file)\n if options['host-os-uname'].match(/RedHat/) and options['host-os-version'].match(/^7|^6\\.7/)\n message = \"Information:\\tFixing permission on \"+ovf_file\n command = \"chcon -R -t httpd_sys_rw_content_t #{ovf_file}\"\n execute_command(options,message,command)\n end\n end\n return\nend",
"def run_from_command_line\n handle_exceptions do\n remotes.load\n handle_options\n execute_command_from_command_line\n end\n end",
"def sync (vm_config)\n vm_config.synced_folder @host_path, guest_path\n end",
"def fsync() end",
"def fsync() end",
"def fsync() end",
"def toggle_host_status\n if !self.host.listings.empty?\n self.host.update(host: true)\n else\n self.host.update(host: false)\n end\n end",
"def sync\n self.disabled_reason = nil\n if valid?\n execute_sync\n true\n else\n false\n end\n end",
"def execute\n return unless active\n load_host_data\n update_state('HOSTS_LOADED', 1)\n deactivate(@flag)\n end",
"def sync_code_dir\n fs_commands = { 'commit': '{\"commit-all\": true}', 'force-sync': \"\" }\n fs_commands.each do |fs_cmd, data|\n curl = %W[\n curl\n -X POST\n --cert $(puppet config print hostcert)\n --key $(puppet config print hostprivkey)\n --cacert $(puppet config print localcacert)\n -H \"Content-type: application/json\"\n https://#{master}:8140/file-sync/v1/#{fs_cmd}\n -d '#{data}'\n ].join(\" \")\n\n on(master, curl)\n end\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def sync_prefer\n sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)\n case @options.fetch('sync_prefer', 'default')\n when 'default' then \"-prefer '#{@options['src']}' -copyonconflict\" # thats our default, if nothing is set\n when 'src' then \"-prefer '#{@options['src']}'\"\n when 'dest' then \"-prefer 'socket://#{@options['sync_host_ip']}:#{sync_host_port}'\"\n else \"-prefer '#{@options['sync_prefer']}'\"\n end\n end",
"def reshare dir, host\n if File.exist? \"#{dir}/#{host}/.completed\"\n `share -F nfs -o ro=#{host},anon=0 #{dir}/#{host} > /dev/null 2>&1`\n end\nend",
"def shell_provisioners_once(vm, host)\n if host.has_key?('shell_once')\n host['shell_once'].each do |script|\n vm.provision \"shell\", inline: script['cmd']\n end\n end\nend",
"def update_software(ssh_session,hostname,username,password,local_version,depot_version,filename,mode,doaction,depot_url,reboot)\n update_available = compare_versions(local_version,depot_version,mode)\n if update_available == \"y\" and mode != \"check\"\n if filename.match(/[A-z]/)\n patch_file = File.basename(filename)\n depot_dir = \"/scratch/downloads\"\n depot_file = depot_dir+\"/\"+patch_file\n (ssh_session,output) = ssh_session_exec(ssh_session,\"mkdir #{depot_dir}\")\n puts \"Copying local file \"+filename+\" to \"+hostname+\":\"+depot_file\n Net::SCP.upload!(hostname, username, filename, depot_file, :ssh => { :password => password })\n else\n depot_file = depot_url\n end\n if doaction != \"y\"\n while doaction !~ /y|n/\n print \"Install update [y,n]: \"\n doaction = gets.chomp\n end\n end\n if doaction == \"y\"\n puts \"Installing \"+depot_version+\" from \"+depot_file\n (ssh_session,output) = ssh_session_exec(ssh_session,\"esxcli software vib update -d=#{depot_file}\")\n else\n puts \"Performing Dry Run - No updates will be installed\"\n (ssh_session,output) = ssh_session_exec(ssh_session,\"esxcli software vib update -d=#{depot_file} --dry-run\")\n end\n puts output\n if output.match(/Reboot Required: true/) and reboot == \"y\"\n puts \"Rebooting\"\n (ssh_session,output) = ssh_session_exec(ssh_session,\"reboot\")\n end\n end\n return ssh_session\nend",
"def rsync( srcs, target, opts )\n @commands << rsync_args( host, srcs, target, opts )\n ( rand(2) == 1 ) ? [ [ 'something', 'somefile' ] ] : []\n end",
"def setup_remote(args)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n formatter = Printer.new(@config).build_formatter\n formatter.print_header\n\n # Get $HOME/.watsonrc to check for remotes\n _home_conf = Watson::Config.home_conf\n\n print BOLD + \"Existing Remotes:\\n\" + RESET\n\n # Check the config for any remote entries (GitHub or Bitbucket) and print\n # We *should* always have a repo + API together, but API should be enough\n if _home_conf.github_api.empty? && @config.bitbucket_api.empty? && @config.asana_api.empty?\n formatter.print_status \"!\", YELLOW\n print BOLD + \"No remotes currently exist\\n\\n\" + RESET\n end\n\n unless _home_conf.github_api.empty?\n print BOLD + \"- GitHub APIs -\\n\" + RESET\n _home_conf.github_api.each_with_index do |_api, _i|\n print BOLD + \"#{_i+1}. #{_api[0]}\" + RESET + \" : #{_api[1]}\\n\"\n end\n print \"\\n\\n\"\n end\n\n unless @config.github_repo.empty?\n print BOLD + \"GitHub Repo : \" + RESET + \"#{ @config.github_repo }\\n\\n\"\n end\n\n\n if !@config.bitbucket_api.empty?\n print BOLD + \"Bitbucket User : \" + RESET + \"#{ @config.bitbucket_api }\\n\" + RESET\n print BOLD + \"Bitbucket Repo : \" + RESET + \"#{ @config.bitbucket_repo }\\n\\n\" + RESET\n end\n\n if !@config.gitlab_api.empty?\n print BOLD + \"GitLab User : \" + RESET + \"#{ @config.gitlab_api }\\n\" + RESET\n print BOLD + \"GitLab Repo : \" + RESET + \"#{ @config.gitlab_repo }\\n\\n\" + RESET\n end\n\n if !@config.asana_api.empty?\n print BOLD + \"Asana API Key : \" + RESET + \"#{ @config.asana_api }\\n\" + RESET\n print BOLD + \"Asana Workspace : \" + RESET + \"#{ @config.asana_workspace }\\n\" + RESET\n print BOLD + \"Asana Project : \" + RESET + \"#{ @config.asana_project }\\n\\n\" + RESET\n end\n\n # If github or bitbucket passed, setup\n # If just -r (0 args) do nothing and only have above printed\n # If more than 1 arg is passed, unrecognized, warn user\n if args.length == 1\n case args[0].downcase\n when \"github\"\n debug_print \"GitHub setup called from CL\\n\"\n Watson::Remote::GitHub.setup(@config)\n\n when \"bitbucket\"\n debug_print \"Bitbucket setup called from CL\\n\"\n Watson::Remote::Bitbucket.setup(@config)\n\n when \"gitlab\"\n debug_print \"GitLab setup called from CL\\n\"\n Watson::Remote::GitLab.setup(@config)\n\n when \"asana\"\n debug_print \"Asana setup called from CL\\n\"\n Watson::Remote::Asana.setup(@config)\n\n end\n elsif args.length > 1\n formatter.print_status \"x\", RED\n puts <<-SUMMERY.gsub(/^ {,8}/, '')\n #{BOLD}Incorrect arguments passed#{RESET}\n Please specify either Github or Bitbucket to setup remote\n Or pass without argument to see current remotes\n See help (-h/--help) for more details\n SUMMERY\n\n return false\n end\n end",
"def rsync_to(source, target, dest, port = 22, extra_flags = [\"--ignore-existing\"])\n rsync = find_program_on_path('rsync')\n flags = \"-rHlv --no-perms --no-owner --no-group\"\n unless extra_flags.empty?\n flags << \" \" << extra_flags.join(\" \")\n end\n ex(\"#{rsync} -e '#{ssh_command(port)}' #{flags} #{source} #{target}:#{dest}\")\n end",
"def local_remote_control(body)\n peer = _pop_token(body)\n command = _pop_token(body)\n _remote_control(peer, command, body)\nend",
"def update\n unless ENV.has_key? 'MWV_NO_UPDATE' or File.exist?($VP + 'no-update')\n system('git fetch origin') if Time.now - File.mtime($VP + '.git/FETCH_HEAD') > 604800 rescue nil\n end\nend",
"def execute_remote_command(server, cmd)\n ssh(server, cmd).status == 0\n end",
"def upload\n if !@local_target.nil? && !@remote_target.nil?\n if @verbose\n system \"#{ @dbu } upload #{ @local_target } #{ @remote_target }\"\n else\n exec = `#{ @dbu } upload #{ @local_target } #{ @remote_target }`\n end\n else\n error_msg = 'Local and remote targets cannot be nil'\n @logger.error(error_msg) if @logger\n fail StandardError, error_msg\n end\n end",
"def pull; end",
"def sync\n local_directories.each do |local_directory|\n if settings[:dry_run]\n log.info(sync_command(local_directory))\n else\n IO.popen(sync_command(local_directory)).each { |line| handle_output(line) }\n end\n end\n end",
"def set_upstream(clone_path, upstream_url)\n remotes = `cd #{clone_path} && git remote -v`\n unless remotes.include?('upstream')\n puts `cd #{clone_path} && git remote add upstream #{upstream_url}`\n end\nend",
"def update!(**args)\n @auth_mechanism_for_remote_requests = args[:auth_mechanism_for_remote_requests] if args.key?(:auth_mechanism_for_remote_requests)\n end",
"def install_component\n if (backend != :stdlib && command?('rsync')) || backend == :rsync\n FileUtils.mkdir_p destination_path\n cmd = [command?('rsync'), '-rtc', '--del', '--links', \"#{source_path}/\", destination_path]\n logger.debug { \"Running command: #{cmd.join ' '}\" }\n system(*cmd)\n else\n FileUtils.remove_entry_secure destination_path if Dir.exist? destination_path\n FileUtils.mkdir_p destination_path\n FileUtils.cp_r \"#{source_path}/.\", destination_path, preserve: true\n end\n end",
"def update(options = {})\n if connected?\n push_settings\n import_torrents_from_daemon_and_update_existing\n \n unless options[:skip_sources]\n Source.enabled.each do |source|\n source.fetch_new_torrents\n end\n end\n\n push_new_torrents_to_daemon\n cleanup_completed_torrents\n end\n end",
"def ssh!(hostspec, script)\n CommandRunner.instance.ssh! hostspec, script\n end",
"def remote?\n true\n end",
"def remote?\n false\n end",
"def remotes_action(command, id, host, action, remote_dir, std_in=nil)\n super(command,id,host,ACTION[action],remote_dir,std_in)\n end",
"def fsync\n end",
"def fsync\n end",
"def run_syncdb\n manage_py_execute('syncdb', '--noinput') if new_resource.syncdb\n end",
"def exec(argv, options = {}, &block)\n sshcmd = %W( ssh #{@remote} -tS #{controlsocket} )\n\n sshcmd += %W( cd #{options[:chdir]} && ) if options.has_key?(:chdir)\n\n @local.exec(sshcmd + argv, &block)\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def action_sync\n assert_target_directory_valid!\n if ::File.exist?(::File.join(@new_resource.destination, 'CVS'))\n Chef::Log.debug \"#{@new_resource} update\"\n converge_by(\"sync #{@new_resource.destination} from #{@new_resource.repository}\") do\n run_command(run_options(:command => sync_command))\n Chef::Log.info \"#{@new_resource} updated\"\n end\n else\n action_checkout\n end\n end",
"def toggle\n harness_path = File.expand_path('../.git/security_harness', __dir__)\n\n if File.exist?(harness_path)\n FileUtils.rm(harness_path)\n\n puts \"#{SHELL_YELLOW}Security harness removed -- you can now push to all remotes.#{SHELL_CLEAR}\"\n else\n FileUtils.touch(harness_path)\n\n puts \"#{SHELL_GREEN}Security harness installed -- you will only be able to push to dev.gitlab.org or gitlab.com/gitlab-org/security!#{SHELL_CLEAR}\"\n end\nend"
] |
[
"0.6375961",
"0.6325847",
"0.62261987",
"0.5861778",
"0.56953704",
"0.5694294",
"0.5652193",
"0.56343615",
"0.5618496",
"0.5607516",
"0.55646706",
"0.552747",
"0.5507347",
"0.54969",
"0.5482247",
"0.54487777",
"0.5443176",
"0.54225856",
"0.54140884",
"0.53845",
"0.53729093",
"0.53729093",
"0.53712636",
"0.53618425",
"0.5351773",
"0.5344128",
"0.5338917",
"0.5312427",
"0.52938545",
"0.5288177",
"0.52818024",
"0.52595395",
"0.5256461",
"0.5242959",
"0.5239117",
"0.5230238",
"0.5225561",
"0.5219093",
"0.5217575",
"0.5190744",
"0.5185228",
"0.51753265",
"0.5171216",
"0.51668185",
"0.5163121",
"0.5151777",
"0.51453185",
"0.5115275",
"0.51054484",
"0.5102059",
"0.50963074",
"0.5092632",
"0.5086273",
"0.50840354",
"0.5069291",
"0.5067151",
"0.5064621",
"0.50602823",
"0.50575554",
"0.5055441",
"0.505408",
"0.5053915",
"0.5053636",
"0.5053399",
"0.5053399",
"0.50531065",
"0.5043363",
"0.50392187",
"0.503809",
"0.5031636",
"0.5022402",
"0.50186974",
"0.5017726",
"0.50117373",
"0.5006695",
"0.50045156",
"0.50009835",
"0.49995726",
"0.49955937",
"0.49942803",
"0.49819368",
"0.49770284",
"0.4974432",
"0.49702242",
"0.49665028",
"0.49652264",
"0.49634367",
"0.49624366",
"0.4955035",
"0.49497068",
"0.49480918",
"0.4940124",
"0.4940124",
"0.49381027",
"0.49379432",
"0.49335182",
"0.49335182",
"0.49335182",
"0.4932658",
"0.493034"
] |
0.66907656
|
0
|
such actions should be moved to separate service
|
def remove_customers
@import.customers.destroy_all
@import.update(state: :created, started_at: nil, completed_at: nil, invalid_customers: 0)
redirect_to root_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def service; end",
"def actions; end",
"def services\n\n end",
"def run_actions; end",
"def service_request(service); end",
"def services\n end",
"def action_hook; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def service; raise NotImplementedError; end",
"def lookup_action; end",
"def process_action(...)\n send_action(...)\n end",
"def add_actions; end",
"def invoke\n begin \n # RequestStore.available_services[@amfbody.service_class_name] ||=\n @service = @amfbody.service_class_name.constantize.new #handle on service\n rescue Exception => e\n puts e.message\n puts e.backtrace\n raise RUBYAMFException.new(RUBYAMFException.UNDEFINED_OBJECT_REFERENCE_ERROR, \"There was an error loading the service class #{@amfbody.service_class_name}\")\n end\n \n #call one or the other method depending in the ruby version we are using\n if RUBY_VERSION > RUBY_19\n caller = \"to_sym\"\n else\n caller = \"to_s\"\n end \n\n if @service.private_methods.include?(@amfbody.service_method_name.send(caller))\n raise RUBYAMFException.new(RUBYAMFException.METHOD_ACCESS_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.service_class_file_path}} is declared as private, it must be defined as public to access it.\")\n elsif !@service.public_methods.include?(@amfbody.service_method_name.send(caller))\n raise RUBYAMFException.new(RUBYAMFException.METHOD_UNDEFINED_METHOD_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.service_class_file_path}} is not declared.\")\n end\n \n #clone the request and response and alter it for the target controller/method\n req = RequestStore.rails_request.clone\n res = RequestStore.rails_response.clone\n \n #change the request controller/action targets and tell the service to process. THIS IS THE VOODOO. SWEET!\n controller = @amfbody.service_class_name.gsub(\"Controller\",\"\").underscore\n action = @amfbody.service_method_name\n req.parameters['controller'] = req.request_parameters['controller'] = req.path_parameters['controller'] = controller\n req.parameters['action'] = req.request_parameters['action'] = req.path_parameters['action'] = action\n req.env['PATH_INFO'] = req.env['REQUEST_PATH'] = req.env['REQUEST_URI'] = \"#{controller}/#{action}\"\n req.env['HTTP_ACCEPT'] = 'application/x-amf,' + req.env['HTTP_ACCEPT'].to_s\n \n #set conditional helper\n @service.is_amf = true\n @service.is_rubyamf = true\n \n #process the request\n rubyamf_params = @service.rubyamf_params = {}\n if @amfbody.value && !@amfbody.value.empty?\n @amfbody.value.each_with_index do |item,i|\n rubyamf_params[i] = item\n end\n end\n \n # put them by default into the parameter hash if they opt for it\n rubyamf_params.each{|k,v| req.parameters[k] = v} if ParameterMappings.always_add_to_params \n \n begin\n #One last update of the parameters hash, this will map custom mappings to the hash, and will override any conflicting from above\n ParameterMappings.update_request_parameters(@amfbody.service_class_name, @amfbody.service_method_name, req.parameters, rubyamf_params, @amfbody.value)\n rescue Exception => e\n raise RUBYAMFException.new(RUBYAMFException.PARAMETER_MAPPING_ERROR, \"There was an error with your parameter mappings: {#{e.message}}\")\n end\n\n #fosrias\n #@service.process(req, res)\n\n # call the controller action differently depending on Rails version\n if Rails::VERSION::MAJOR < 3\n @service.process(req, res)\n else\n @service.request = req\n @service.response = res\n @service.process(action.to_sym)\n end\n #fosrias\n \n #unset conditional helper\n @service.is_amf = false\n @service.is_rubyamf = false\n @service.rubyamf_params = rubyamf_params # add the rubyamf_args into the controller to be accessed\n \n result = RequestStore.render_amf_results\n \n #handle FaultObjects\n if result.class.to_s == 'FaultObject' #catch returned FaultObjects - use this check so we don't have to include the fault object module\n e = RUBYAMFException.new(result['code'], result['message'])\n e.payload = result['payload']\n raise e\n end\n \n #amf3\n @amfbody.results = result\n if @amfbody.special_handling == 'RemotingMessage'\n @wrapper = generate_acknowledge_object(@amfbody.get_meta('messageId'), @amfbody.get_meta('clientId'))\n @wrapper[\"body\"] = result\n @amfbody.results = @wrapper\n end\n @amfbody.success! #set the success response uri flag (/onResult)\n end",
"def action args = {}\n\t\tend",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def process_action(method_name, *args); end",
"def perform_action(data); end",
"def services\n\tend",
"def bi_service\n end",
"def across_service_state\n super\n end",
"def before_dispatch(env); end",
"def handler; end",
"def handler; end",
"def response_from_service\n\n end",
"def action_run\n end",
"def perform(request, response); end",
"def action\n end",
"def perform(action)\n case action\n when :index, :new then get action\n when :show, :edit then get action, id: 1\n when :update then put :update, id: 1\n when :create then post :create\n when :destroy then delete :destroy, id: 1\n end\n end",
"def invoke\n\t\tbegin\n\t @service = Object.const_get(@amfbody.service_name).new #handle on service\n\t RequestStore.available_services[@amfbody.service_name] = @service\n\t\trescue LoadError => e\n\t\t\traise RUBYAMFException.new(RUBYAMFException.LOAD_CLASS_FILE, \"The file #{@amfbody.class_file_uri}#{@amfbody.class_file} was not loaded. Check to make sure it exists in: #{RequestStore.service_path}\")\n\t\trescue Exception => e\n\t\t raise RUBYAMFException.new(RUBYAMFException.LOAD_CLASS_FILE, \"There was an error loading file #{@amfbody.class_file_uri}#{@amfbody.class_file}.\")\n\t\tend\n\t\t\n\t\tif @service.private_methods.include?(@amfbody.service_method_name)\n\t\t\traise RUBYAMFException.new(RUBYAMFException.METHOD_ACCESS_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.class_file_uri}#{@amfbody.class_file}} is declared as private, it must be defined as public to access it.\")\n\t\telsif !@service.public_methods.include?(@amfbody.service_method_name)\n\t\t\traise RUBYAMFException.new(RUBYAMFException.METHOD_UNDEFINED_METHOD_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.class_file_uri}#{@amfbody.class_file}} is not declared.\")\n\t\tend\n\t\t\t\t\n\t\t#clone the request and response and alter it for the target controller/method\n\t\treq = RequestStore.rails_request.clone\n\t\tres = RequestStore.rails_response.clone\n\t\t\n\t\t#change the request controller/action targets and tell the service to process. THIS IS THE VOODOO. SWEET!\n\t ct = @amfbody.target_uri.clone.split('Controller')[0].downcase\n\t sm = @amfbody.service_method_name\n\t\treq.parameters['controller'] = ct\n\t\treq.parameters['action'] = sm\n\t\treq.request_parameters['controller'] = ct\n\t\treq.request_parameters['action'] = sm\n\t\treq.request_parameters['amf'] = 'hello world'\n\t\treq.path_parameters['controller'] = ct\n\t\treq.path_parameters['action'] = ct\n\t\treq.env['PATH_INFO'] = \"#{ct}/#{sm}\"\n\t\treq.env['REQUEST_PATH'] = \"#{ct}/#{sm}\"\n\t\treq.env['REQUEST_URI'] = \"#{ct}/#{sm}\"\n\t\treq.env['HTTP_ACCEPT'] = 'application/x-amf,' + req.env['HTTP_ACCEPT'].to_s\n\t\t\n\t\t#set conditional helper\n\t\t@service.is_amf = true\n\t\t@service.is_rubyamf = true\n \n #process the request\n\t\tif @amfbody.value.empty? || @amfbody.value.nil?\n\t\t @service.process(req,res)\n\t\telse\n\t\t @amfbody.value.each_with_index do |item,i|\t\t \n\t\t req.parameters[i] = item\n\t\t if item.class.superclass.to_s == 'ActiveRecord::Base'\n\t\t req.parameters[i] = item.original_vo_from_deserialization.to_hash\n if i < 1 #Only the first parameter will be \n req.parameters.merge!(item.original_vo_from_deserialization.to_hash) #merge in properties into the params hash\n #have to specifically check for id here, as it doesn't show up in any object members.\n if item.original_vo_from_deserialization.id != nil\n #This will override the above params[:id] attempt, because it's the original deserialized values.\n req.parameters[:id] = item.original_vo_from_deserialization.id\n end\n end\n\t req.parameters[item.class.to_s.downcase.to_sym] = item.original_vo_from_deserialization.to_hash\n\t \n\t\t elsif !item._explicitType.nil?\n\t\t t = item._explicitType\n\t\t if t.include?('.')\n\t\t t = t.split('.').last.downcase.to_s\n\t\t end\n \t\t req.parameters[t.to_sym] = item.to_hash\n \t\t if i < 1\n \t\t if item.class.to_s == 'Object' || item.class.to_s == 'OpenStruct'\n \t\t if item.id != nil && item.id.to_s != 'NaN' && item.id != 0\n \t\t req.parameters[:id] = item.id\n \t\t end\n \t\t end\n \t\t req.parameters.merge!(item.to_hash)\n \t\t end\n \t\t \n \t\t elsif item.class.to_s == 'OpenStruct' || item.class.to_s == \"Object\"\n\t\t if i < 1\n \t\t if item.id != nil && item.id.to_s != 'NaN' && item.id != 0\n \t\t req.parameters[:id] = item.id\n \t\t end\n \t\t req.parameters.merge!(item.to_hash)\n \t\t end \t\t \n\t\t end\n end\n\t @service.process(req,res)\n end\n \n #unset conditional helper\n @service.is_amf = false\n\t\t@service.is_rubyamf = false\n \n\t\t#handle FaultObjects\n\t\tif @service.amf_content.class.to_s == 'FaultObject' #catch returned FaultObjects\n raise RUBYAMFException.new(@service.amf_content.code, @service.amf_content.message)\n\t\tend\n\t\t\n\t\t#amf3\n\t\t@amfbody.results = @service.amf_content\n if @amfbody.special_handling == 'RemotingMessage'\n @wrapper = generate_acknowledge_object(@amfbody.get_meta('messageId'), @amfbody.get_meta('clientId'))\n @wrapper.body = @service.amf_content\n @amfbody.results = @wrapper\n\t\tend\n\t @amfbody.success! #set the success response uri flag (/onResult)\n\tend",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def _handle_action_missing(*args); end",
"def process(action, *args); end",
"def action\n end",
"def send_action action_name, service_name\n self.class.actions[action_name][service_name].run(self)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def perform_action(*args)\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def handle_action(username, actiontype)\n \n end",
"def before_dispatch(_env)\n end",
"def mco_action\n raise RuntimeError, \"Not implemented\"\n end",
"def action_locator_args()\n \n end",
"def define_action_hook; end",
"def invoke\n\t\tbegin\n\t\t @service = Object.const_get(@amfbody.service_name).new #handle on service\n\t\t RequestStore.available_services[@amfbody.service_name] = @service\n\t\trescue LoadError => e\n\t\t\traise RUBYAMFException.new(RUBYAMFException.LOAD_CLASS_FILE, \"The file #{@amfbody.class_file_uri}#{@amfbody.class_file} was not loaded. Check to make sure it exists in: #{RequestStore.service_path}\")\n\t\trescue Exception => e\n\t\t raise RUBYAMFException.new(RUBYAMFException.LOAD_CLASS_FILE, \"There was an error loading file #{@amfbody.class_file_uri}#{@amfbody.class_file}. #{e.message}\")\n\t\tend\n \n #authentication, simple\n\t if RequestStore.auth_header != nil\n\t if @service.public_methods.include?('_authenticate')\n\t begin\n \t res = @service.send('_authenticate', *[RequestStore.auth_header.value.userid, RequestStore.auth_header.value.password])\n if res == false #catch false\n \t\t raise RUBYAMFException.new(RUBYAMFException.AUTHENTICATION_ERROR, \"Authentication Failed\");\n elsif res.class.to_s == 'FaultObject' #catch returned FaultObjects\n \t\t raise RUBYAMFException.new(res.code, res.message)\n \t\tend\n \trescue Exception => e #catch raised FaultObjects\n \t if e.message == \"exception class/object expected\"\n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,\"You cannot raise a FaultObject, return it instead.\")\n \t else \n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,e.message)\n \t end\n \tend\n \tend\n\t end\n \n #before_filter\n if @service.public_methods.include?('before_filter')\n\t begin\n\t res = @service.send('before_filter')\n \t if res == false #catch false\n \t raise RUBYAMFException.new(RUBYAMFException.FILTER_CHAIN_HAULTED, \"before_filter haulted by returning false.\")\n \t elsif res.class.to_s == 'FaultObject' #catch returned FaultObjects\n \t raise RUBYAMFException.new(res.code, res.message)\n \t end\n \trescue Exception => e #catch raised FaultObjects\n \t if e.message == \"exception class/object expected\"\n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,\"You cannot raise a FaultObject, return it instead.\")\n \t else \n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,e.message)\n \t end\n \tend\n\t end\n\t \n\t\tif @service.private_methods.include?(@amfbody.service_method_name)\n\t\t\traise RUBYAMFException.new(RUBYAMFException.METHOD_ACCESS_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.class_file_uri}#{@amfbody.class_file}} is declared as private, it must be defined as public to access it.\")\n\t\telsif !@service.public_methods.include?(@amfbody.service_method_name)\n\t\t\traise RUBYAMFException.new(RUBYAMFException.METHOD_UNDEFINED_METHOD_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.class_file_uri}#{@amfbody.class_file}} is not declared.\")\n\t\tend\n\t\t\n\t\tbegin\n\t\t\tif @amfbody.value.empty?\n\t\t\t\t@service_result = @service.send(@amfbody.service_method_name)\n\t\t\telse\n\t\t\t\targs = @amfbody.value\n\t\t\t\t@service_result = @service.send(@amfbody.service_method_name, *args) #* splat the argument values to pass correctly to the service method\n\t\t\tend\n\t\trescue Exception => e #catch any method call errors, transform into RUBYAMFException so that they propogate back to flash correctly\n\t\t\tif e.message == \"exception class/object expected\"\n \t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR,\"You cannot raise a FaultObject, return it instead.\")\n \t else \n\t\t\t raise RUBYAMFException.new(RUBYAMFException.USER_ERROR, e.to_s)\n\t\t\tend\n\t\tend\n\t\t\n\t\t#catch returned custom FaultObjects\n\t\tif @service_result.class.to_s == 'FaultObject'\n\t\t raise RUBYAMFException.new(@service_result.code, @service_result.message)\n\t\tend\n\t\t\t \n\t\t@amfbody.results = @service_result #set the result in this body object\n\t\t\n\t\t#amf3\n if @amfbody.special_handling == 'RemotingMessage'\n @wrapper = generate_acknowledge_object(@amfbody.get_meta('messageId'), @amfbody.get_meta('clientId'))\n @wrapper.body = @service_result\n @amfbody.results = @wrapper\n\t\tend\n\t\t\n\t @amfbody.success! #set the success response uri flag (/onResult)\t\t\n\tend",
"def do_service_action(action)\n validate :service, String\n\n service = request[:service]\n\n begin\n Log.instance.debug(\"Doing #{action} for service #{service}\")\n\n svc = get_puppet(service)\n\n unless action == \"status\"\n svc.send action\n sleep 0.5\n end\n\n reply[\"status\"] = svc.status.to_s\n rescue Exception => e\n reply.fail \"#{e}\"\n end\n end",
"def controller(controller); end",
"def api; end",
"def api; end",
"def perform(request, options); end",
"def operations; end",
"def operations; end",
"def process_action(*_arg0); end",
"def process_action(*_arg0); end",
"def process_action(*_arg0); end",
"def services\n Rails.logger.debug 'Inside service'\n @result_json = {}\n begin\n action = params[:do]\n case action\n when 'login'\n Rails.logger.debug 'Processing login'\n @result_json = login\n when 'register'\n Rails.logger.debug 'Processing registration'\n @result_json = register\n when 'save_linkedin_profile'\n Rails.logger.debug 'Saving Linkedin Profile'\n @result_json = save_linkedin_profile\n when 'get_dim_data'\n dim_type = params[:dim_type]\n Rails.logger.debug \"Getting dimension data - #{dim_type}\"\n @result_json = get_dim_data (dim_type)\n when 'get_filter_data'\n filter_data = params[:filter_data]\n columns = params[:columns]\n Rails.logger.debug \"Getting Filter data - #{filter_data}\"\n @result_json = get_filter_data(filter_data, columns)\n else\n Rails.logger.warn 'Unsupported service call'\n end\n rescue\n Rails.logger.error \"Error in service method #{$!}\"\n ensure\n render json: @result_json\n end\n end",
"def do_action(action, args=[])\n case action\n when 1\n Customer.create_a_customer_account\n output_action_header(\"\\nCustomer Added!\")\n between_views\n when 2\n ActiveCustomer.list\n between_views\n when 3\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Payment.add_payment_to_active_customer\n output_action_header(\"\\nPayment Added!\")\n between_views\n else\n Payment.add_payment_to_active_customer\n output_action_header(\"\\nPayment Added!\")\n between_views\n end\n when 4\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.add_product_to_active_customer\n output_action_header(\"\\nProduct Added!\")\n between_views\n else\n Product.add_product_to_active_customer\n output_action_header(\"\\nProduct Added!\")\n between_views\n end\n when 5\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.add_product_to_active_customer_order\n between_views\n else\n Product.add_product_to_active_customer_order\n between_views\n end\n when 6\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n CompleteOrder.get_active_user_order\n between_views\n else\n CompleteOrder.get_active_user_order\n between_views\n end\n when 7\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.remove_product\n between_views\n else\n Product.remove_product_customer\n between_views\n end\n when 8\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.update_product\n between_views\n else\n Product.update_product_customer\n between_views\n end\n when 9\n Product.stale_products\n between_views\n when 10\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n CustomerRevenue.check_active_customer_rev\n between_views\n else\n CustomerRevenue.check_active_customer_rev\n between_views\n end\n when 11\n Product.product_popularity\n between_views\n when 12\n return :quit\n else\n puts \"I don't understand that command\"\n end\n end",
"def process\n send_request @action\n end",
"def do_service_action(action)\n validate :service, String\n\n service = request[:service]\n\n begin\n Log.instance.debug(\"Doing #{action} for service #{service}\")\n\n svc = get_puppet(service)\n\n unless action == \"status\"\n svc.send action\n sleep 0.5\n end\n\n reply[\"status\"] = svc.status.to_s\n rescue Exception => e\n reply.fail \"#{e}\"\n end\n end",
"def release_actions; end",
"def perform\n \n end",
"def invoke_layered(service_name, method_name, *args)\r\n prepare_request('api', service_name, method_name, *args)\r\n @controller.process(@request, @response)\r\n decode_rpc_response\r\n end",
"def act\n end",
"def method_for_action(action_name); end",
"def actions\n client.actions\n end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def some_business_logic\n # ...\n end",
"def some_business_logic\n # ...\n end",
"def some_business_logic\n # ...\n end",
"def advice\n end",
"def manage\n\n end",
"def copy_actions\r\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 manager\n end"
] |
[
"0.6524496",
"0.65075666",
"0.6451984",
"0.6355279",
"0.62618285",
"0.6258286",
"0.6111734",
"0.6029704",
"0.6029704",
"0.6029704",
"0.6029704",
"0.6029704",
"0.6003889",
"0.5981323",
"0.59458226",
"0.58895713",
"0.5888683",
"0.5872916",
"0.58451754",
"0.58451754",
"0.58451754",
"0.5817953",
"0.5810924",
"0.5803642",
"0.5802402",
"0.57869494",
"0.5785669",
"0.5740821",
"0.5740821",
"0.5739045",
"0.57283396",
"0.5723744",
"0.5722778",
"0.5714006",
"0.56875986",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5644638",
"0.5641242",
"0.5640388",
"0.56098723",
"0.5606469",
"0.5599765",
"0.55994564",
"0.55994564",
"0.5593018",
"0.5591654",
"0.5591654",
"0.5591654",
"0.5577871",
"0.55669856",
"0.5563861",
"0.55566436",
"0.5551441",
"0.5522046",
"0.5506792",
"0.55056",
"0.54889",
"0.54889",
"0.54729676",
"0.5465914",
"0.5465914",
"0.54606396",
"0.54606396",
"0.54606396",
"0.5445415",
"0.5441636",
"0.5435576",
"0.5428971",
"0.5411307",
"0.5378536",
"0.5369284",
"0.53662145",
"0.53643215",
"0.53505117",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53304684",
"0.53218347",
"0.53218347",
"0.53218347",
"0.53168523",
"0.5311707",
"0.5302963",
"0.5292797",
"0.52890027"
] |
0.0
|
-1
|
GET /roles GET /roles.xml
|
def index
@roles = Role.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @roles }
format.json { render :json => @roles.to_json(:only => [:id, :code, :name, :definition]) }
format.js { render (:update){ |page| page[dom_id_nested(:index)].replace :file => "admin/roles/index" } }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @roles = @client.roles\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def index\n @roles = Role.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def index\n @all_roles = Role.all\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def index\n\t\tindex_\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @roles }\n\t\tend\n\tend",
"def show\n @user = User.find(params[:id])\n @roles = @user.roles\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def index\n @roles = Role.all\n \n respond_to do |format|\n format.html { render :layout => 'application' } # use client application's layout\n format.xml { render :xml => @roles }\n end\n end",
"def roles\n self.dig_for_array(\"roles\")\n end",
"def list\n # We don't use pagination here since we want to display the roles in a\n # nice tree. Additionally, there won't be more than ~100 roles in a\n # normal scenario anyway - far less!\n @roles = Role.find(:all)\n end",
"def get_roles_list()\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n\n resource_path = 'identity/v2/manage/role'\n get_request(resource_path, query_parameters, nil)\n end",
"def index\n @roles = Role.all(:order=>'name')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def roles\n response[\"roles\"]\n end",
"def show\n @role = @client.roles.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def show\n @roles_user = RolesUser.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @roles_user }\n end\n end",
"def list\n\n @roles = Role.find(:all, :order => 'name')\n\n end",
"def show\n if can?(:read, User)\n @user = User.find(params[:id])\n @roles = \"\"\n\n @user.roles.each do |role|\n if @roles == \"\"\n @roles += role.name\n else\n @roles += \", \" + role.name\n end\n end\n end\n\n respond_to do |format|\n format.json { render :json => @user }\n format.xml { render :xml => @user }\n format.html \n end\n\n rescue ActiveRecord::RecordNotFound\n respond_to_not_found(:json, :xml, :html)\n end",
"def index\n @roles = System::Role.all\n end",
"def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end",
"def get_external_roles\n get(\"#{url_base}/external_role_map/all?#{dc}\")[\"data\"]\n end",
"def index\n @screen = session.active_screen\n @roles = Role.find(:all).sort_by{|r| r.name }\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def list_roles(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListRoles'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend",
"def index\n @roles = Role.paginate :page => params[:page],\n :per_page => 15,\n :order => sort_order('name')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def roles!(access = {})\n json = Api::Request.new do |request|\n request[:access] = access\n request[:method] = :GET\n request[:path] = '/mgmt/{{client_id}}/roles'\n end.execute!\n\n json[:roles]\n end",
"def show\n @roles = Role.all\n end",
"def roles\n roles_from_users\n end",
"def roles_path\n @roles_path ||= '/api/v2/roles'\n end",
"def index\n @secondary_title = 'Role Administration'\n @pages, @roles = paginate :roles, :order => 'name ASC',\n :per_page => per_page\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @roles.to_xml }\n end\n end",
"def index\n @roles = Rol.all\n end",
"def index\n authorize Role\n\n respond_to do |format|\n format.json { render json: @roles }\n end\n end",
"def index\n @users = User.all\n @roles = Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end",
"def index\n @users=User.find(:all, :limit => 15)\n @roles=Role.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def edit_role\n @user = User.find(params[:id])\n @roles = Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def show\n @role = Role.find_by_name(params[:name])\n @role_authorities = @role.authorities\n \n respond_to do |format|\n format.html { render :layout => 'application' } # use client application's layout\n format.xml { render :xml => @role }\n end\n end",
"def index\n @roles = Role.all\n end",
"def index\n @roles = Role.all\n end",
"def index\n @roles = Role.all\n end",
"def index\n @roles = Role.all\n end",
"def index\n @roles = Role.all\n end",
"def index\n @roles = Role.all\n end",
"def get_roles(options = {})\n request_params = {\n per_page: options.fetch(:per_page, nil),\n page: options.fetch(:page, nil),\n include_totals: options.fetch(:include_totals, nil),\n name_filter: options.fetch(:name_filter, nil)\n }\n get roles_path, request_params\n end",
"def roles\n client.user_roles(id)\n end",
"def roles\n client.user_roles(id)\n end",
"def index\n @user_roles = UserRole.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @cms_roles = Cms::Role.all\n end",
"def claims\n get_all_roles\n end",
"def claims\n get_all_roles\n end",
"def list_roles(options={})\n request({\n 'Action' => 'ListRoles',\n :parser => Fog::Parsers::AWS::IAM::ListRoles.new\n }.merge!(options))\n end",
"def list\n @roles = Role.all(:include => [:groups, :users])\n end",
"def get_role\n # <?xml version=\"1.0\" encoding=\"utf-8\"?>\n # <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n # <soap:Header>\n # <Header xmlns=\"http://www.twinfield.com/\">\n # <SessionID>string</SessionID>\n # </Header>\n # </soap:Header>\n # <soap:Body>\n # <GetRole xmlns=\"http://www.twinfield.com/\" />\n # </soap:Body>\n # </soap:Envelope>\n raise NotImplementedError\n end",
"def show(id = @id, user = @@default_user)\n @attributes = send_request(\"roles/#{id}\", :get) do |req|\n req.params = {\n auth_token: user.auth_token\n }\n end\n end",
"def index\n @roles = Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles }\n end\n end",
"def index\n client_application_id = current_user.client_application_id.to_s\n @roles = Role.where(client_application_id: client_application_id)\n end",
"def all\n data = []\n conn = @ec2_main.environment.iam_connection\n if conn != nil\n begin\n response = conn.list_roles()\n if response.status == 200\n data = response.body[\"Roles\"]\n end\n rescue\n puts \"ERROR: getting all roles #{$!}\"\n end\n end\n return data\n end",
"def role_data(id)\n @conn.get(\"/api/v1/roles/#{id}\")\n end",
"def GetRole id\n\n APICall(path: \"custom_roles/#{id}.json\")\n\n end",
"def index\n @org_roles = OrgRole.all\n end",
"def startup_roles(id, options={})\n get(\"1/startups/#{id}/roles\", options)\n end",
"def display_all_roles\n # Interface method\n end",
"def index\n @roles = Role.page params[:page]\n end",
"def show\n @role = Role.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def show\n @role_types = RoleTypes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role_types }\n end\n end",
"def show\n @role = Role.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def show\n @role = Role.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def show\n @role = Role.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def index\n authorize Role\n @roles = Role.all\n end",
"def index\n @movie_roles = @movie.roles\n end",
"def index\n @users_roles = UsersRole.all\n end",
"def index\n @users = User.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @user_roles }\n end\n end",
"def roles\n @resource_roles\n end",
"def list(options = {})\n @raw = send_get_request(@conn_no_err, ['/v1/acl/roles'], options)\n raise Diplomat::AclNotFound if @raw.status == 403\n\n parse_body\n end",
"def get_roles_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.get_roles ...'\n end\n # resource path\n local_var_path = '/api/3/roles'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ResourcesRole')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#get_roles\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def roles\n @roles = Role.order(\"name\")\n\t@rights = Right.order(\"name\").map {|r| [r.name, r.id] }\n end",
"def display_roles\n \n @active_roles = Role.find_all_active\n \n render(:layout => false)\n \n end",
"def index\n\t\t#@data = {name: '角色', path: '/managers/roles'}\n\t\t@roles = Role.page(params[:page]).per(params[:rows])\n\t\trespond_with({rows: @roles, total: @roles.total_count}) \n\tend",
"def show\n\t\tshow_\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @role }\n\t\tend\n\tend",
"def show\n @userrole = Userrole.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @userrole }\n end\n end",
"def test_role_features\n\n # get members of role with guid 4\n get '/role/3/members'\n assert (last_response.status == 200), \"Get all members of role id 3: response is not 200\"\n\n # get available role attributes\n get '/role/attributes'\n assert (last_response.body.size > 50), \"Get available role attributes: response to small for valid data\"\n\n # get all roles\n get '/role'\n assert (last_response.body.size > 50), \"Get all roles: response to small for valid data\"\n\n # get role with guid \"3\"\n get '/role/3'\n assert (last_response.body.size > 50), \"Get role with id 3: response to small for valid data\"\n end",
"def index\n @roles = policy_scope(Role).page(pagination[:page]).per(pagination[:per])\n end",
"def saml_roles\r\n SAMLRolesController.instance\r\n end",
"def roles(options = {})\n headers = extract_headers!(options)\n json = client.list(\"/v1/auth/approle/role\", options, headers)\n return Secret.decode(json).data[:keys] || []\n rescue HTTPError => e\n return [] if e.code == 404\n raise\n end",
"def index\n role = Role.find_by_name(params[:role])\n @users = role.users unless role.blank?\n #@users = User.paginate(:all, :joins => 'roles', :conditions => :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end",
"def roles\n @users = User.order(\"user_name\").all\n end",
"def resources\n Typus::Configuration.roles[self.roles].compact\n end",
"def index\n role = Role.find_by_name('Admin')\n @users = role.users\n end",
"def index\n @sys_roles = SysRole.all\n end",
"def rbac_role_resource\n url_for(:roles_role, credentials, id) \n end",
"def index\n\t\tparamsr\n\t\tglobal\n\t\t# render json: @roles, each_serializer: RoleSerializer, root: false\n\tend",
"def index\n @entity_roles = EntityRole.all\n end",
"def show\n @role_user = RoleUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @role_user }\n end\n end",
"def roles\r\n @roles ||= user_roles.map(&:name)\r\n end",
"def index\n @iams = $iam.groups.map{ |x| Iam.new(name: x.name) } \n @users = $iam.users\n @roles = $iam.client.list_roles \n end",
"def getRole\n @users = User.where(\"role = ?\", params[:role]).NameOrder\n render json: @users\n end",
"def index\n @role_types = RoleType.sort(:name).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @role_types }\n end\n end",
"def index\n @roles = Role.order(\"name\").all\n @user_list = User.order(\"email\").all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles }\n end\n end",
"def index\n @roles = record.roles.includes(:resource)\n render jsonapi: @roles, include: %i[users groups resource]\n end",
"def index\n role = Role.find_by_name('SuperAdmin')\n @users = role.users\n end",
"def index\n @roles = Role.page params[:page]\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles}\n end\n end",
"def roles\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Role)\n end",
"def get(\n id,\n deadline: nil\n )\n req = V1::RoleGetRequest.new()\n if not @parent.snapshot_time.nil?\n req.meta = V1::GetRequestMetadata.new()\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.id = (id)\n tries = 0\n plumbing_response = nil\n loop do\n begin\n plumbing_response = @stub.get(req, metadata: @parent.get_metadata(\"Roles.Get\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n break\n end\n\n resp = RoleGetResponse.new()\n resp.meta = Plumbing::convert_get_response_metadata_to_porcelain(plumbing_response.meta)\n resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)\n resp.role = Plumbing::convert_role_to_porcelain(plumbing_response.role)\n resp\n end",
"def show\n @roles_and_permission = @roles.roles_and_permission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roles_and_permission }\n end\n end",
"def get_roles(opts = {})\n data, _status_code, _headers = get_roles_with_http_info(opts)\n data\n end"
] |
[
"0.765395",
"0.73884916",
"0.73800194",
"0.73537827",
"0.7349313",
"0.7307362",
"0.71644545",
"0.71563125",
"0.7147755",
"0.709412",
"0.70782536",
"0.7047145",
"0.7045595",
"0.6965548",
"0.6892383",
"0.68836725",
"0.6883257",
"0.6859065",
"0.68405116",
"0.68359077",
"0.68330276",
"0.68261373",
"0.6810299",
"0.68010193",
"0.6783472",
"0.6777457",
"0.67557055",
"0.67225343",
"0.67192024",
"0.6713856",
"0.66523296",
"0.6640048",
"0.66387564",
"0.66387564",
"0.66387564",
"0.66387564",
"0.66387564",
"0.66387564",
"0.6631107",
"0.66076666",
"0.66076666",
"0.6581918",
"0.6556709",
"0.6542727",
"0.6542727",
"0.6529685",
"0.6526511",
"0.6526275",
"0.6509071",
"0.65049577",
"0.6487177",
"0.64823437",
"0.64710593",
"0.64534074",
"0.64290386",
"0.6425261",
"0.64139485",
"0.64092004",
"0.64035666",
"0.6401231",
"0.63962996",
"0.63962996",
"0.6393942",
"0.639216",
"0.6386055",
"0.638484",
"0.6384712",
"0.6366157",
"0.6354139",
"0.6347762",
"0.63271433",
"0.6325532",
"0.6322528",
"0.63221",
"0.6308379",
"0.63029706",
"0.63005227",
"0.6293358",
"0.6285042",
"0.6275739",
"0.62710243",
"0.6265008",
"0.6264352",
"0.6245558",
"0.6235767",
"0.62178314",
"0.6208824",
"0.61800957",
"0.6163139",
"0.6152549",
"0.6131696",
"0.6116323",
"0.6112999",
"0.60995936",
"0.60956764",
"0.60934997",
"0.60926324",
"0.60893714",
"0.6084393",
"0.6078874"
] |
0.61369747
|
90
|
GET /roles/new GET /roles/new.xml
|
def new
@role = Role.new(:category => 0)
@possible_permissions = Permission.by_category(@role.category)
respond_to do |format|
format.xml { render :xml => @role }
format.js #new.js.rjs
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @user = User.new\n @roles = Role.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n\t\t@role = Role.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @role }\n\t\tend\n\tend",
"def new\n @role_user = RolesUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_user }\n end\n end",
"def new\n submenu_item 'role-new'\n @role = Role.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @user_role = UserRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_role }\n end\n end",
"def new\n @role_types = RoleTypes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_types }\n end\n end",
"def new\n @userrole = Userrole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @userrole }\n end\n end",
"def new\n\t\t@roles_new = Role.all\n\t\tif can?(:update, Role)\n\t\t\t@roles_new = Role.all\n\t\tend\n\n @user = User.new if can?(:create, User)\n respond_to do |format|\n format.json { render :json => @user } \n format.xml { render :xml => @user }\n format.html\n end\n end",
"def new\n @role_type = RoleType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_type }\n end\n end",
"def new\n @role_user = RoleUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_user }\n end\n end",
"def new\n \n @roles_and_permission = @roles.roles_and_permission.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @roles_and_permission }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end",
"def new\n @page_role = PageRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_role }\n end\n end",
"def new\n @screen = session.active_screen\n @role = Role.new\n @all_users = User.find_active_users\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end",
"def new\n @operations_role = OperationsRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operations_role }\n end\n end",
"def new\n @primary_role = PrimaryRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @primary_role }\n end\n end",
"def new\n @protocol_role = ProtocolRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @protocol_role }\n end\n end",
"def new\n @role = Role.new\n respond_with(@role)\n end",
"def new\n @provider_role = ProviderRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider_role }\n end\n end",
"def new\n @host = Host.new\n @roles = Role.find(:all, :order => 'role')\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def new\n @user_space_role = UserSpaceRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_space_role }\n end\n end",
"def new\n @partyrole = Partyrole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partyrole }\n end\n end",
"def create\n chef_server_rest.post(\"roles\", self)\n self\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to(@role, :notice => 'Role was successfully created.') }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @user_role = UserRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create\n @role = Role.new(params[:role])\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(@role) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n \n respond_to do |format|\n if @role.save\n format.html { redirect_to(@role, :notice => 'Role was successfully created.') }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to role_url(@role.code) }\n format.xml { head :created, :location => role_url(@role.code) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors.to_xml }\n end\n end\n end",
"def new\n @company = Company.find(params[:company_id])\n @role = Role.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end",
"def new\r\n permissions\r\n @role = Role.new\r\n \r\n #render layout: \"users\"\r\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @client.roles << @role\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to client_role_url(@client, @role) }\n format.xml { render :xml => @role, :status => :created, :location => [@client, @role] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(role_path(@role.slug)) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @role_user = RoleUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role_user }\n end\n end",
"def create\n @role = Role.new(role_params)\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(role_path(@role.slug)) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @roles = Role.paginate :page => params[:page],\n :per_page => 15,\n :order => sort_order('name')\n @role= Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to(roles_url, :notice => 'New User role successfully added.') }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @app_role = AppRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @app_role }\n end\n end",
"def new\n \t @employee = User.new\n @roles = Role.all\n puts \"ROLES ARE GOING NOW\"\n end",
"def create\n if !grant_access(\"edit_roles\", current_user)\n head(403)\n end\n @role = Role.new(role_params)\n @role.user_id = current_user.id\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_role\n new_role = create_role(params[:role][:name])\n\n return redirect_to admin_roles_path, flash: { alert: I18n.t(\"administrator.roles.invalid_create\") } if new_role.nil?\n\n redirect_to admin_roles_path(selected_role: new_role.id)\n end",
"def new\n @role = Role.new\n end",
"def new\n @role = Role.new\n end",
"def new\n @project_role = ProjectRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_role }\n end\n end",
"def new\n #@user = User.new\n @user.active = true\n @user.role_ids = [1]\n @user.groupings << current_user.root_grouping\n #@assigned_roles = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n @tipo_controles = TipoControle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_controles }\n end\n end",
"def new\n @rol = Rol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rol }\n end\n end",
"def new\n @rol = Rol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rol }\n end\n end",
"def new\n logger.debug(\"Role new\")\n @role=Role.new\n setup_role\n if params[:from] == 'organisation'\n @organisation = Organisation.find(params[:id])\n @from='organisation'\n else\n @person = Person.find(params[:id])\n @from='person'\n end\n # explicitly set role_type_id to nil\n # so that the first role type in the\n # list is not displayed in role type\n # drop-down\n @role.role_type_id = nil\n\t\n\tset_default_status(@role)\n \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 new\n @lab_permissions_role = LabPermissionsRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab_permissions_role }\n end\n end",
"def new\n @people = Person.all\n @role = get_role\n respond_with @event, @role\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 new\n @title = \"New User\"\n\n @user = User.new\n @user.user_roles.build\n respond_to do |format|\n format.html #new.html.erb\n format.js\n format.json { render json: @user }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_role }\n end\n end",
"def create\n @role_types = RoleTypes.new(params[:role_types])\n\n respond_to do |format|\n if @role_types.save\n flash[:notice] = 'RoleTypes was successfully created.'\n format.html { redirect_to(@role_types) }\n format.xml { render :xml => @role_types, :status => :created, :location => @role_types }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role_types.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n if @role.save\n redirect_to admin_roles_url\n else\n render :action => \"new\"\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to admin_roles_path, notice: 'Role was successfully created.' }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role_type = RoleType.new(params[:role_type])\n\n respond_to do |format|\n if @role_type.save\n format.html { redirect_to(role_types_path, :notice => 'Role was successfully created.') }\n format.xml { render :xml => role_types_path, :status => :created, :location => @role_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @role_map = RoleMap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role_map }\n end\n end",
"def create\n @user_role = UserRole.new(params[:user_role])\n\n respond_to do |format|\n if @user_role.save\n flash[:notice] = 'UserRole was successfully created.'\n format.html { redirect_to(@user_role) }\n format.xml { render :xml => @user_role, :status => :created, :location => @user_role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @usr = Usr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usr }\n end\n end",
"def index\n @roles = Role.all\n @nrole = Role.new\n end",
"def new\n @robots=\"noindex,nofollow\"\n authorize! :create, Roxiware::Person\n @person = Roxiware::Person.new({:show_in_directory=>true,\n :first_name=>\"First\",\n :middle_name=>\"\",\n :last_name=>\"Last\",\n :role=>\"Role\",\n :email=>\"email@email.com\",\n :bio=>\"Bio\"}, :as=>@role)\n respond_to do |format|\n format.html { render :partial =>\"roxiware/people/editform\" }\n format.json { render :json => @person.ajax_attrs(@role) }\n end\n end",
"def newAdmin\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def create\n @provider_role = ProviderRole.new(params[:provider_role])\n\n respond_to do |format|\n if @provider_role.save\n flash[:notice] = 'ProviderRole was successfully created.'\n format.html { redirect_to(@provider_role) }\n format.xml { render :xml => @provider_role, :status => :created, :location => @provider_role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @role_permision = RolePermision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role_permision }\n end\n end",
"def new\n @admin = Admin.new\n build_permissions\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @menutree = Menutree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menutree }\n end\n end",
"def new\n @user = User.new\n get_list\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @user }\n end\n end",
"def new\n @company = Company.find( params[:company_id])\n @user = @company.users.build\n @roles = ROLE\n end",
"def new\n @group = @authorized_group\n @user = User.new\n @role_mapping = RoleMapping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n @user = User.new\n @role = params[:role]\n end",
"def new\n @nivel = Nivel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nivel }\n end\n end",
"def new\n @administration = Administration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administration }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def create\n @userrole = Userrole.new(params[:userrole])\n\n respond_to do |format|\n if @userrole.save\n flash[:notice] = 'Userrole was successfully created.'\n format.html { redirect_to(@userrole) }\n format.xml { render :xml => @userrole, :status => :created, :location => @userrole }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @userrole.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @role = System::Role.new\n end",
"def create\n @role = Role.new(params[:role])\n \n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @usuario = Usuario.new\n #Creamos al Rol asociado al Usuario...\n @rols_disp = Rol.find(:all, :order => 'id ASC') #Los roles disponibles...\n @rols_selec = [] #Los roles seleccionados...\n\n #@qbe_key = Rol.new()\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end",
"def create\n ActiveRecord::Base.transaction do\n @role, hash = fill_role(params[:role])\n\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(@role) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def create\n error = ''\n \n if params[:roles]\n params[:roles].each do |role|\n @role = Role.new(role) unless role[:title].blank?\n error << model_errors(@role) unless @role.save\n end\n else\n @role = Role.new(params[:roles])\n error << model_errors(@role) unless @role.save\n end\n \n respond_to do |format|\n format.html do\n if error.blank?\n flash[:notice] = \"#{params[:roles].nil? ? 'Role has' : 'Roles have'} been created.\"\n redirect_back_or_default roles_path\n else\n flash[:error] = 'Oops, something went wrong.'\n @role.nil? ? render(:action => 'edit') : redirect_back_or_default(roles_path)\n end\n end\n \n format.js do\n if error.blank?\n flash.now[:notice] = \"#{params[:roles].nil? ? 'Role has' : 'Roles have'} been created.\"\n get_models\n render :action => 'index', :layout => false\n else\n flash.now[:error] = 'Oops, something went wrong.'\n render :action => 'edit', :layout => false\n end\n end\n end\n end",
"def new\n return false unless authorize(permissions = [\"administer_catalog\"])\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end",
"def new\n @namespace = Namespace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @namespace }\n end\n end",
"def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to edit_role_path(@role), :notice => t('hurricane.notice.create_record_success', :type => t_type) }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n if request.get?\n @role = Role.new\n else\n @role = Role.new(params[:role])\n\n # assign parent role\n if not params[:role][:parent].to_s.empty?\n @role.parent = Role.find(params[:role][:parent].to_i)\n end\n\n if @role.save\n # set the roles's static permissions to the static permission from the parameters \n params[:role][:static_permissions] = [] if params[:role][:static_permissions].nil?\n @role.static_permissions = params[:role][:static_permissions].collect { |i| StaticPermission.find(i) }\n\n # the above should be successful if we reach here; otherwise we \n # have an exception and reach the rescue block below\n flash[:success] = 'Role has been created successfully.'\n redirect_to :action => 'show', :id => @role.id\n else\n render :action => 'create'\n end\n end\n \n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'You sent an invalid request.'\n redirect_to :action => 'list'\n end",
"def new\n @account = current_user.accounts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end"
] |
[
"0.7652707",
"0.7652707",
"0.7652707",
"0.7652707",
"0.7645628",
"0.75188315",
"0.74036145",
"0.7401122",
"0.7392047",
"0.7352519",
"0.7314729",
"0.7287063",
"0.72534263",
"0.71865225",
"0.7153129",
"0.7117309",
"0.710744",
"0.710744",
"0.710744",
"0.7058945",
"0.70502895",
"0.70379496",
"0.7036819",
"0.70246357",
"0.69350946",
"0.69214493",
"0.69055647",
"0.6872763",
"0.68658864",
"0.67408055",
"0.67302567",
"0.6714836",
"0.6711994",
"0.6708037",
"0.66925335",
"0.66745573",
"0.6613269",
"0.6608281",
"0.65560865",
"0.6544948",
"0.6527908",
"0.65252554",
"0.6515049",
"0.64958173",
"0.6492636",
"0.64909416",
"0.6472766",
"0.6461405",
"0.6461405",
"0.64055675",
"0.64015853",
"0.63974637",
"0.6390323",
"0.6390323",
"0.6378438",
"0.6360901",
"0.6356208",
"0.634343",
"0.63403666",
"0.6330213",
"0.6303632",
"0.62840146",
"0.6276284",
"0.6273929",
"0.62660736",
"0.6253934",
"0.6240169",
"0.62284976",
"0.6225314",
"0.6214033",
"0.6209953",
"0.6189373",
"0.61757505",
"0.61713785",
"0.6165251",
"0.616197",
"0.61592907",
"0.61465174",
"0.6140327",
"0.6140282",
"0.61159647",
"0.6114706",
"0.61078334",
"0.61078334",
"0.61078334",
"0.61013156",
"0.60997313",
"0.6091747",
"0.60914385",
"0.60884166",
"0.60859865",
"0.6082196",
"0.606743",
"0.6066084",
"0.6064006",
"0.60525525",
"0.60525525",
"0.60525525",
"0.6052251",
"0.6051119"
] |
0.6599124
|
38
|
POST /roles POST /roles.xml
|
def create
@role = Role.new(params[:role])
respond_to do |format|
if @role.save
flash[:notice] = 'Role was successfully created.'
format.xml { render :xml => @role, :status => :created, :location => @role }
format.js #create.js.rjs
else
@possible_permissions = Permission.by_category(@role.category)
format.xml { render :xml => @role.errors, :status => :unprocessable_entity }
format.js #create.js.rjs
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n chef_server_rest.post(\"roles\", self)\n self\n end",
"def post_role(role)\n role = {\n \"id\"=>nil,\n \"name\"=>nil, \n \"description\"=>\"\", \n \"sessionTimeout\"=>\"60\",\n \"roles\"=>[],\n \"privileges\"=>[]\n }.merge(role);\n post(\"#{url_base}/roles\", {\"data\"=>role})[\"data\"]\n end",
"def CreateRole params = {}\n \n APICall(path: 'custom_roles.json',method: 'POST',payload: params.to_json)\n \n end",
"def add_role( xml, person, role )\n\n if user_role_exists?(xml, role)\n puts \"Would not add role to \" + person[:netids][0] + ' (' + person[:uin] + '), role already exists ' + role.to_s\n\n else\n puts \"Adding role, \" + role.to_s + \" to \" + person[:netids][0] + ' (' + person[:uin] + ')'\n role_node = xml.create_element( 'user_role' )\n\n role_node.add_child( xml.create_element 'status', 'ACTIVE' )\n role_node.add_child( xml.create_element 'scope', role[:scope] )\n role_node.add_child( xml.create_element 'role_type', role[:id] )\n\n if role[:parameters]\n\n parameters = xml.create_element( 'parameters')\n\n role[:parameters].each do |type,value|\n \n parameter = xml.create_element( 'parameter')\n \n parameter.add_child( xml.create_element 'type', type ) \n parameter.add_child( xml.create_element 'value', value ) \n\n parameters.add_child( parameter )\n \n end\n\n role_node.add_child( parameters )\n end\n\n user_roles = xml.xpath( '/user/user_roles' ).first.add_child( role_node )\n\n \n \n end\nend",
"def save\n begin\n chef_server_rest.put(\"roles/#{@name}\", self)\n rescue Net::HTTPClientException => e\n raise e unless e.response.code == \"404\"\n\n chef_server_rest.post(\"roles\", self)\n end\n self\n end",
"def save_roles user\n user.add_role(params[:role_name])\n end",
"def create\n @roles = Role.paginate :page => params[:page],\n :per_page => 15,\n :order => sort_order('name')\n @role= Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to(roles_url, :notice => 'New User role successfully added.') }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @client.roles << @role\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to client_role_url(@client, @role) }\n format.xml { render :xml => @role, :status => :created, :location => [@client, @role] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def createSeriesAcl(roles)\n header = Nokogiri::XML('<?xml version = \"1.0\" encoding = \"UTF-8\" standalone =\"yes\"?>')\n builder = Nokogiri::XML::Builder.with(header) do |xml|\n xml.acl('xmlns' => 'http://org.opencastproject.security') {\n roles.each do |role|\n xml.ace {\n xml.action { xml.text(role[:permission]) }\n xml.allow { xml.text('true') }\n xml.role { xml.text(role[:user]) }\n }\n end\n }\n end\n\n return builder.to_xml\nend",
"def create\n if !grant_access(\"edit_roles\", current_user)\n head(403)\n end\n @role = Role.new(role_params)\n @role.user_id = current_user.id\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n abilities = []\n client_application = current_user.client_application_id.to_s\n @abilities = Role.get_method_names.sort\n @role = Role.new(role_params)\n params[:role][:role_abilities].each do |ability|\n abilities << ability.to_sym\n end\n @role.role_abilities = [{\"action\"=> abilities, \"subject\"=>[:api]}]\n @role.client_application_id = client_application\n respond_to do |format|\n if @role.save\n format.html { redirect_to roles_path, notice: 'Role was successfully created.' }\n format.json { render :index, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if roles = params[:user][:roles]\n roles.map { |r| r.downcase }.each do |role|\n unless role.empty?\n @user.roles << Role.new(type: role)\n\n if role == \"admin\"\n respond_to do |format|\n if @user.save\n format.html { redirect_to (flash[:redirect] || :attendees), notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end\n\n if role == \"staff\"\n redirect_to get_staff_list_path\n end\n\n end\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n \n respond_to do |format|\n if @role.save\n format.html { redirect_to(@role, :notice => 'Role was successfully created.') }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_roles(roles_model)\n if roles_model.blank?\n raise LoginRadius::Error.new, getValidationMessage('roles_model')\n end\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n\n resource_path = 'identity/v2/manage/role'\n post_request(resource_path, query_parameters, roles_model)\n end",
"def create\n @user = User.new(params[:user])\n @roles = [Role.find_by_name(params[:user]['role'])]\n @user.person.attributes = (params[:person])\n @user.roles = @roles\n respond_to do |format|\n if @user.save\n flash[:notice] = 'User was successfully created.'\n format.html { redirect_to admin_users_url }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to(@role, :notice => 'Role was successfully created.') }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_roles\n Role.create_roles(self)\n end",
"def create\n @role_types = RoleTypes.new(params[:role_types])\n\n respond_to do |format|\n if @role_types.save\n flash[:notice] = 'RoleTypes was successfully created.'\n format.html { redirect_to(@role_types) }\n format.xml { render :xml => @role_types, :status => :created, :location => @role_types }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role_types.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @roles = @client.roles\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def create\n @role = Role.new(params[:role])\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(@role) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params) \n @role.permissions = []\n @role.set_permissions(params[:permissions]) if params[:permissions]\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roles_privilege = RolesPrivilege.new(roles_privilege_params)\n\n respond_to do |format|\n if @roles_privilege.save\n format.html { redirect_to @roles_privilege, notice: 'Roles privilege was successfully created.' }\n format.json { render :show, status: :created, location: @roles_privilege }\n else\n format.html { render :new }\n format.json { render json: @roles_privilege.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify_roles(email, role)\n\t\tresponse = @client.execute(api_method: @service.acl.insert,\n\t\t\t\t\t parameters: {'calendarId' => ENV['NSCS_Calendar_ID']}, body: JSON.dump({role: role, scope: {type: \"user\", \"value\": email}}))\n\tend",
"def create\n @user_role = UserRole.new(params[:user_role])\n\n respond_to do |format|\n if @user_role.save\n flash[:notice] = 'UserRole was successfully created.'\n format.html { redirect_to(@user_role) }\n format.xml { render :xml => @user_role, :status => :created, :location => @user_role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to role_url(@role.code) }\n format.xml { head :created, :location => role_url(@role.code) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors.to_xml }\n end\n end\n end",
"def create(attrs, user = @@default_user)\n @attributes = send_request(\n \"organizations/#{attrs[:organization_id] || attrs['organization_id']}/roles\", :post\n ) do |req|\n req.body = {\n auth_token: user.auth_token\n }.merge(attrs.except(:organization_id, 'organization_id'))\n end\n end",
"def create\n @role = Role.new(role_params)\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(role_path(@role.slug)) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n @role.save\n respond_with(@role)\n end",
"def create\n @users_role = UsersRole.new(users_role_params)\n\n respond_to do |format|\n if @users_role.save\n format.html { redirect_to @users_role, notice: 'Users role was successfully created.' }\n format.json { render :show, status: :created, location: @users_role }\n else\n format.html { render :new }\n format.json { render json: @users_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @userrole = Userrole.new(params[:userrole])\n\n respond_to do |format|\n if @userrole.save\n flash[:notice] = 'Userrole was successfully created.'\n format.html { redirect_to(@userrole) }\n format.xml { render :xml => @userrole, :status => :created, :location => @userrole }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @userrole.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new role_params\n authorize @role\n flash.now[:notice] = 'Role was successfully created.' if @role.save\n respond_with @role\n end",
"def create\n @role = Role.new(params[:role])\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(role_path(@role.slug)) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @screen = session.active_screen\n @form_content_reuse = params[:form_content_reuse]\n\n user_ids = params[:role][:user_ids]\n params[:role].delete(:user_ids) unless params[:role][:user_ids].nil?\n @role = Role.new(params[:role]) \n\n if @role.save\n @role.users = User.find(user_ids) unless user_ids.nil?\n @role.users.each{|u| u.update_attributes( :updated_at => Time.now ) }\n end\n \n respond_to do |format|\n format.html # create.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def create\n\n @roles_and_permission = @roles.roles_and_permission.new(params[:roles_and_permission])\n \n respond_to do |format|\n if @roles_and_permission.save\n format.html { redirect_to [@roles, @roles_and_permission ], notice: 'Roles and permission was successfully created.' }\n format.json { render json: @roles_and_permission, status: :created, location: @roles_and_permission }\n else\n format.html { render action: \"new\" }\n format.json { render json: @roles_and_permission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def updateSeriesAcl(xml, roles)\n\n doc = Nokogiri::XML(xml)\n newNodeSet = Nokogiri::XML::NodeSet.new(doc)\n\n roles.each do |role|\n newNode = nokogiri_node_creator(doc, \"ace\", \"\")\n newNode << nokogiri_node_creator(doc, \"action\", role[:permission])\n newNode << nokogiri_node_creator(doc, \"allow\", 'true')\n newNode << nokogiri_node_creator(doc, \"role\", role[:user])\n\n # Avoid adding duplicate nodes\n nodeAlreadyExists = false\n doc.xpath(\"//x:ace\", \"x\" => \"http://org.opencastproject.security\").each do |oldNode|\n if sameNodes?(oldNode, newNode)\n nodeAlreadyExists = true\n break\n end\n end\n\n if (!nodeAlreadyExists)\n newNodeSet << newNode\n end\n end\n\n doc.root << newNodeSet\n\n return doc.to_xml\nend",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to admin_roles_path, notice: 'Role was successfully created.' }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_role(role_name, params = {})\n change_role_access(role_name, user_emails_to_ids(params), :post)\n end",
"def role_params\n params.require(:role).permit(:name, :permission_ids => [])\n end",
"def create\n @employees_role = EmployeesRole.create(employees_role_params)\n redirect_to employees_roles_path\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if role.save\n current_user.add_role :admin, role\n format.html { redirect_to admin_role_path(role), notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: role }\n else\n format.html { render :new }\n format.json { render json: role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def grant_role\n @user = User.find_by_email(params[:email])\n @user.roles.append(Role.find_by_name(params[:role]))\n @user.save\n redirect_to action: :user_list\n end",
"def create\n @role = Role.new role_params\n flash[:notice] = 'Role was successfully created.' if @role.save\n respond_with @role\n end",
"def edit_role\n @user = User.find(params[:id])\n @roles = Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def roles!(access = {})\n json = Api::Request.new do |request|\n request[:access] = access\n request[:method] = :GET\n request[:path] = '/mgmt/{{client_id}}/roles'\n end.execute!\n\n json[:roles]\n end",
"def create\n @role = System::Role.new(system_role_params)\n respond_to do |format|\n if @role.save\n format.html { redirect_to system_roles_url, notice: '添加角色成功.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(role_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ActiveRecord::Base.transaction do\n @role, hash = fill_role(params[:role])\n\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully created.'\n format.html { redirect_to(@role) }\n format.xml { render :xml => @role, :status => :created, :location => @role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def index\n\t\tindex_\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @roles }\n\t\tend\n\tend",
"def create\n @role_type = RoleType.new(params[:role_type])\n\n respond_to do |format|\n if @role_type.save\n format.html { redirect_to(role_types_path, :notice => 'Role was successfully created.') }\n format.xml { render :xml => role_types_path, :status => :created, :location => @role_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @role_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role = @company.roles.new(safe_params)\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to [@company, @role], notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @role }\n else\n format.html { render :new }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @role = Role.new(role_params)\r\n @role.save\r\n end",
"def test_system_role_protection\n [:guest_role, :user_role, :admin_role].each do |name|\n post :destroy, :id => roles(name).id\n assert_redirected_to :action => 'list'\n assert_match /Cannot destroy the system role/, flash[:message]\n end\n end",
"def create\n @role = get_role\n flash[:notice] = t('create.success', :scope => get_i18n_scope) if @role.save and not request.xhr?\n respond_with @event, @role, :location => {:action => 'index'}\n end",
"def new\n \n @roles_and_permission = @roles.roles_and_permission.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @roles_and_permission }\n end\n end",
"def index\n authorize Role\n\n respond_to do |format|\n format.json { render json: @roles }\n end\n end",
"def create\n @manage_admin = Manage::Admin.new(manage_admin_params)\n @admin_roles= @manage_admin.roles\n respond_to do |format|\n if @manage_admin.save\n\n # 保存角色信息\n roles_id=params[:roles]\n @manage_admin.roles_in_id=roles_id\n\n format.html { redirect_to @manage_admin, notice: \"成功创建管理员#{@manage_admin.nickname}.\" }\n\n format.json { render :show, status: :created, location: @manage_admin }\n else\n format.html { render :new }\n format.json { render json: @manage_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # rails 3 bug\n params[:user][:roles].reject!(&:blank?)\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: I18n.t(:new_user_notify, name: @user.name, role: @user.role_str ) }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entity_role = EntityRole.new(entity_role_params)\n\n respond_to do |format|\n if @entity_role.save\n format.html { redirect_to @entity_role, notice: 'Entity role was successfully created.' }\n format.json { render :show, status: :created, location: @entity_role }\n else\n format.html { render :new }\n format.json { render json: @entity_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def role_params\n params.require(:role).permit(:name, :active_status, :comment, :user_id, :del_status, :permissions => [])\n end",
"def create_roles\n ['admin', 'lector', 'jefe_calidad', 'jefe_bodega', 'op_bodega'].each do |role_name|\n Role.create!(name: role_name)\n end\nend",
"def create\n @security_agent_role = SecurityAgentRole.new(security_agent_role_params)\n\n respond_to do |format|\n if @security_agent_role.save\n format.html { redirect_to @security_agent_role, notice: 'Security agent role was successfully created.' }\n format.json { render :show, status: :created, location: @security_agent_role }\n else\n format.html { render :new }\n format.json { render json: @security_agent_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_params\n params.require(:user).permit(:email, :roles => [])\n end",
"def create\n respond_to do |format|\n if @role.save\n format.html { redirect_to user_roles_path(@user), notice: I18n.t('controller.create_success_notice', model: '角色') }\n format.json { render action: 'show', status: :created, location: @role }\n else\n format.html { render action: 'new' }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sys_role = SysRole.new(sys_role_params)\n\n respond_to do |format|\n if @sys_role.save\n format.html { redirect_to @sys_role, notice: 'Sys role was successfully created.' }\n format.json { render :show, status: :created, location: @sys_role }\n else\n format.html { render :new }\n format.json { render json: @sys_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @role = Role.new(params[:role])\n\n if @role.save\n redirect_to admin_roles_url\n else\n render :action => \"new\"\n end\n end",
"def create\n @role = Role.new(params[:role])\n \n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def roles_path\n @roles_path ||= '/api/v2/roles'\n end",
"def createAcl(roles)\n header = Nokogiri::XML('<?xml version = \"1.0\" encoding = \"UTF-8\" standalone =\"yes\"?>')\n builder = Nokogiri::XML::Builder.with(header) do |xml|\n xml.Policy('PolicyId' => 'mediapackage-1',\n 'RuleCombiningAlgId' => 'urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides',\n 'Version' => '2.0',\n 'xmlns' => 'urn:oasis:names:tc:xacml:2.0:policy:schema:os') {\n roles.each do |role|\n xml.Rule('RuleId' => \"#{role[:user]}_#{role[:permission]}_Permit\", 'Effect' => 'Permit') {\n xml.Target {\n xml.Actions {\n xml.Action {\n xml.ActionMatch('MatchId' => 'urn:oasis:names:tc:xacml:1.0:function:string-equal') {\n xml.AttributeValue('DataType' => 'http://www.w3.org/2001/XMLSchema#string') { xml.text(role[:permission]) }\n xml.ActionAttributeDesignator('AttributeId' => 'urn:oasis:names:tc:xacml:1.0:action:action-id',\n 'DataType' => 'http://www.w3.org/2001/XMLSchema#string')\n }\n }\n }\n }\n xml.Condition{\n xml.Apply('FunctionId' => 'urn:oasis:names:tc:xacml:1.0:function:string-is-in') {\n xml.AttributeValue('DataType' => 'http://www.w3.org/2001/XMLSchema#string') { xml.text(role[:user]) }\n xml.SubjectAttributeDesignator('AttributeId' => 'urn:oasis:names:tc:xacml:2.0:subject:role',\n 'DataType' => 'http://www.w3.org/2001/XMLSchema#string')\n }\n }\n }\n end\n }\n end\n\n return builder.to_xml\nend",
"def create\n submenu_item 'role_new'\n load_permissions\n ids=params[:permissions].select{|k,v| v=='1'}.map { |k,v| k.to_i } unless params[:permissions].nil?\n if ids.length > 0\n permissions=Permission.find(:all, :conditions => [\"id in (#{ids.join(',')})\"])\n params[:role][:permissions] = permissions\n @role = Role.new(params[:role])\n if @role.save\n flash[:notice] = \"创建角色成功\"\n redirect_to :action => 'index'\n else\n flash[:error] = \"创建角色失败\"\n render :action => 'new'\n end\n else\n flash[:error] = \"角色名或权限不能为空\"\n redirect_to :action => 'new'\n end\n\n end",
"def new\n @user = User.new\n @roles = Role.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def create_employee_role(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/roles'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end",
"def create\n @role = Role.new(params[:role])\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to edit_role_path(@role), :notice => t('hurricane.notice.create_record_success', :type => t_type) }\n format.json { render json: @role, status: :created, location: @role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_set_role\n\n admin_session = cathy_admin_session\n \n pcb_input_gate = Role.find_by_name('PCB Input Gate')\n tracker_admin = Role.find_by_name('Admin')\n \n post(:set_role, { :id => pcb_input_gate.id }, admin_session)\n session_user = User.find(session[:user_id])\n assert_equal(pcb_input_gate.name, session_user.active_role.name)\n assert_redirected_to(:controller => 'tracker')\n\n post(:set_role, { :id => tracker_admin.id }, admin_session)\n session_user.reload\n assert_equal(tracker_admin.name, session_user.active_role.name)\n assert_redirected_to(:controller => 'tracker')\n\n end",
"def create\n @user_role = UserRole.new(params[:user_role])\n\n respond_to do |format|\n if @user_role.save\n flash[:notice] = 'UserRole was successfully created.'\n format.html { redirect_to([:admin, @user_role]) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @org_role = OrgRole.new(org_role_params)\n\n respond_to do |format|\n if @org_role.save\n format.html { redirect_to @org_role, notice: 'Org role was successfully created.' }\n format.json { render :show, status: :created, location: @org_role }\n else\n format.html { render :new }\n format.json { render json: @org_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @all_roles = Role.all\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def index\n @roles = Role.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def create\n \n if request.get?\n @role = Role.new\n else\n @role = Role.new(params[:role])\n\n # assign parent role\n if not params[:role][:parent].to_s.empty?\n @role.parent = Role.find(params[:role][:parent].to_i)\n end\n\n if @role.save\n # set the roles's static permissions to the static permission from the parameters \n params[:role][:static_permissions] = [] if params[:role][:static_permissions].nil?\n @role.static_permissions = params[:role][:static_permissions].collect { |i| StaticPermission.find(i) }\n\n # the above should be successful if we reach here; otherwise we \n # have an exception and reach the rescue block below\n flash[:success] = 'Role has been created successfully.'\n redirect_to :action => 'show', :id => @role.id\n else\n render :action => 'create'\n end\n end\n \n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'You sent an invalid request.'\n redirect_to :action => 'list'\n end",
"def create\n return unless check_permission\n\n @role = Role.new(role_params)\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n else\n @users = User.all\n format.html { render :new }\n end\n end\n end",
"def accept_role role\n self.roles.push role\n end",
"def roles\n self.dig_for_array(\"roles\")\n end",
"def UpdateRole params = {}\n \n APICall(path: 'custom_roles.json',method: 'PUT',payload: params.to_json)\n \n end",
"def create\n @user = User.new(params[:user])\n\n # initialize users with a list and a normal userrole.\n @user.lists.build\n @user.lists.each do |list|\n list[:user_id] = \"some fake data here\"\n end\n normal_userrole = Userrole.where(:name => \"Normal\").first\n @user.userroles << normal_userrole\n respond_to do |format|\n if @user.save\n sign_in @user\n format.html { redirect_to(@user, :notice => 'Welcome to Animurecs!') }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n @title = \"Sign up\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def role_params\n {}\n end",
"def create\n @cms_role = Cms::Role.new(cms_role_params)\n\n respond_to do |format|\n if @cms_role.save\n format.html { redirect_to @cms_role, notice: 'Role was successfully created.' }\n format.json { render :show, status: :created, location: @cms_role }\n else\n format.html { render :new }\n format.json { render json: @cms_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_role = RoleUser.new(params[:role_user])\n\n respond_to do |format|\n if @admin_role.save\n format.html { redirect_to @role_users_path, notice: 'Role was successfully created.' }\n format.json { render json: @admin_role, status: :created, location: @admin_role }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @role_user = RolesUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_user }\n end\n end",
"def edit_roles\n if (@user = find_user(params[:id]))\n begin\n User.transaction(@user) do\n \n roles = params[:user][:roles].collect { |role_id| Role.find(role_id) }\n # add any new roles & remove any missing roles\n roles.each { |role| @user.roles << role if !@user.roles.include?(role) }\n @user.roles.each { |role| @user.roles.delete(role) if !roles.include?(role) }\n\n @user.save\n flash[:notice] = \"Roles updated for user '#{@user.login}'.\"\n end\n rescue\n flash[:warning] = 'Roles could not be edited at this time. Please retry.'\n ensure\n redirect_to :back\n end\n else\n redirect_back_or_default :action => 'list'\n end\n end",
"def create_role(name, perms=nil)\n perms ||= []\n role = {\n :name => name,\n :permissions => perms,\n }\n post(\"/roles\", role)\n end",
"def render_create_success\n render json: @resource, include: [:roles], show_roles: true\n end",
"def create\n\n @user = User.new(params[:user])\n tutorRole = Role.find_by_name('tutor')\n @user.roles = [ tutorRole ]\n @user.save\n success = @user.save && @user.errors.empty?\n errors = @user.errors\n if(success) \n @tutor = Tutor.new()\n @tutor.user_id = @user.id\n success = @tutor.save && @tutor.errors.empty? \n errors = @tutor.errors\n if(! success)\n @user.delete\n end\n end\n\n @user.roles << Role[:tutor]\n \n respond_to do |format|\n if success\n flash[:notice] = 'Tutor was successfully created.'\n format.html { redirect_to(@tutor) }\n format.xml { render :xml => @tutor, :status => :created, :location => @tutor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @role = Role.create(params[:role])\n\n if @role.errors.empty?\n flash['notice'] = \"Role #{@role.display_name} added\"\n redirect_to :action => 'list'\n else\n flash['notice'] = @role.errors.full_messages.pop\n redirect_to :action => 'add'\n end\n \n end",
"def create\n @roles = Role.all\n random_password = Randomstring.generate(20)\n p = user_params\n p[:password] = random_password\n p[:password_confirmation] = random_password\n @user = User.new(p)\n\n respond_to do |format|\n if @user.save\n # Deliver the signup email\n ApplicationMailer.send_signup_email(@user, random_password).deliver_now\n format.html { redirect_to @user, notice: 'Benutzer wurde angelegt.' }\n format.json { render :show, status: :created, location: @user }\n\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_roles(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListRoles'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend",
"def create\n @operations_role = OperationsRole.new(params[:operations_role])\n\n respond_to do |format|\n if @operations_role.save\n flash[:notice] = 'OperationsRole was successfully created.'\n format.html { redirect_to(@operations_role) }\n format.xml { render :xml => @operations_role, :status => :created, :location => @operations_role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @operations_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user_space_role = UserSpaceRole.new(params[:user_space_role])\n\n respond_to do |format|\n if @user_space_role.save\n flash[:notice] = 'UserSpaceRole was successfully created.'\n format.html { redirect_to(@user_space_role) }\n format.xml { render :xml => @user_space_role, :status => :created, :location => @user_space_role }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_space_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user_to_role = UserToRole.new(user_to_role_params)\n\n respond_to do |format|\n if @user_to_role.save\n format.html { redirect_to @user_to_role, notice: 'User to role was successfully created.' }\n format.json { render :show, status: :created, location: @user_to_role }\n else\n format.html { render :new }\n format.json { render json: @user_to_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def role_params\n params.require(:role).permit(:name, :content, :is_admin, :role_status)\n end"
] |
[
"0.6648283",
"0.66474384",
"0.6290778",
"0.61988467",
"0.6091542",
"0.6087422",
"0.60257316",
"0.60000217",
"0.58930975",
"0.5870327",
"0.5833719",
"0.58180964",
"0.5807781",
"0.58023876",
"0.58021086",
"0.5789968",
"0.5771046",
"0.5755769",
"0.57313377",
"0.57262254",
"0.5723669",
"0.5696692",
"0.5679222",
"0.5666051",
"0.56506187",
"0.56483215",
"0.56456786",
"0.5640843",
"0.56331235",
"0.5623888",
"0.5621427",
"0.56134975",
"0.55804306",
"0.5574655",
"0.55711776",
"0.5567643",
"0.55615705",
"0.55526096",
"0.5533646",
"0.55292183",
"0.5528973",
"0.5515419",
"0.5514466",
"0.55140406",
"0.54963815",
"0.5491109",
"0.5491109",
"0.5491109",
"0.5488309",
"0.5483421",
"0.547914",
"0.54519236",
"0.544907",
"0.54386514",
"0.54192036",
"0.54168475",
"0.5415137",
"0.54126424",
"0.5405967",
"0.5405426",
"0.54041433",
"0.5391894",
"0.53896695",
"0.5388238",
"0.53870106",
"0.53858894",
"0.53844213",
"0.53751695",
"0.53640056",
"0.53622484",
"0.536108",
"0.5358755",
"0.5356667",
"0.5346124",
"0.5344325",
"0.5336424",
"0.5334276",
"0.5329914",
"0.5329336",
"0.5326325",
"0.5324747",
"0.5322629",
"0.53199387",
"0.5318922",
"0.5313288",
"0.52999014",
"0.52948993",
"0.52884823",
"0.528631",
"0.528366",
"0.5274399",
"0.5274128",
"0.5273459",
"0.5258265",
"0.5256834",
"0.5254504",
"0.52541894",
"0.5249973",
"0.5248189",
"0.5241752",
"0.5235859"
] |
0.0
|
-1
|
PUT /roles/1 PUT /roles/1.xml
|
def update
respond_to do |format|
if @role.update_attributes(params[:role])
flash[:notice] = 'Role was successfully updated.'
format.html { redirect_to(@role) }
format.xml { head :ok }
format.js
else
@possible_permissions = Permission.by_category(@role.category)
format.html { render :action => "edit" }
format.xml { render :xml => @role.errors, :status => :unprocessable_entity }
format.js
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @role = Role.find_by_name(params[:name])\n \n respond_to do |format|\n @role.authorities = Authority.find_by_name(params[:authority_names])\n format.html { redirect_to(my_gem_role_path(@role.name),\n :notice => 'Role was successfully updated.') }\n format.xml { head :ok }\n end\n end",
"def update\n @role = @client.roles.find(params[:id])\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to client_role_url(@client, @role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_role\n @user = User.find(params[:id])\n @roles = Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def update\n @role = Role.find(params[:id])\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to(@role, :notice => 'Role was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @role = Role.find(params[:id])\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to(@role, :notice => 'Role was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @role.attributes = params[:role]\n respond_to do |format|\n if @role.save\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to role_url(@role.code) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors.to_xml }\n end\n end\n end",
"def edit_role(id, *roles)\n request(:put, \"/users/#{id}.json\", default_params(:role_ids => roles))\n end",
"def save\n begin\n chef_server_rest.put(\"roles/#{@name}\", self)\n rescue Net::HTTPClientException => e\n raise e unless e.response.code == \"404\"\n\n chef_server_rest.post(\"roles\", self)\n end\n self\n end",
"def UpdateRole params = {}\n \n APICall(path: 'custom_roles.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @role = Role.find(params[:id])\n @role.update_attributes(params[:role])\n respond_with(@role)\n end",
"def update\n respond_to do |format|\n if @role.update_attributes(params[:role])\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to(role_path(@role.slug)) }\n format.xml { head :ok }\n else\n format.html { render \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if !grant_access(\"alter_roles\", current_user)\n head(403)\n end\n @role.user_id = current_user.id\n @role.start_point = false if !params[:role][:start_point]\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_roles\n if (@user = find_user(params[:id]))\n begin\n User.transaction(@user) do\n \n roles = params[:user][:roles].collect { |role_id| Role.find(role_id) }\n # add any new roles & remove any missing roles\n roles.each { |role| @user.roles << role if !@user.roles.include?(role) }\n @user.roles.each { |role| @user.roles.delete(role) if !roles.include?(role) }\n\n @user.save\n flash[:notice] = \"Roles updated for user '#{@user.login}'.\"\n end\n rescue\n flash[:warning] = 'Roles could not be edited at this time. Please retry.'\n ensure\n redirect_to :back\n end\n else\n redirect_back_or_default :action => 'list'\n end\n end",
"def update\n @role = Role.find(params[:id])\n \n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_role = UserRole.find(params[:id])\n\n respond_to do |format|\n if @user_role.update_attributes(params[:user_role])\n flash[:notice] = 'UserRole was successfully updated.'\n format.html { redirect_to(@user_role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(value, options = {})\n id = value[:ID] || value['ID']\n raise Diplomat::IdParameterRequired if id.nil?\n\n role_name = value[:Name] || value['Name']\n raise Diplomat::NameParameterRequired if role_name.nil?\n\n custom_params = use_cas(@options)\n @raw = send_put_request(@conn, [\"/v1/acl/role/#{id}\"], options, value, custom_params)\n if @raw.status == 200\n parse_body\n elsif @raw.status == 400\n raise Diplomat::RoleMalformed, @raw.body\n else\n raise Diplomat::UnknownStatus, \"status #{@raw.status}: #{@raw.body}\"\n end\n end",
"def update\n @role_types = RoleTypes.find(params[:id])\n\n respond_to do |format|\n if @role_types.update_attributes(params[:role_types])\n flash[:notice] = 'RoleTypes was successfully updated.'\n format.html { redirect_to(@role_types) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role_types.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @role = Role.find(params[:id])\n \n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role.update_attributes(role_params)\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to(role_path(@role.slug)) }\n format.xml { head :ok }\n else\n format.html { render \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @userrole = Userrole.find(params[:id])\n\n respond_to do |format|\n if @userrole.update_attributes(params[:userrole])\n flash[:notice] = 'Userrole was successfully updated.'\n format.html { redirect_to(@userrole) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @userrole.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n ActiveRecord::Base.transaction do\n @role, hash = fill_role(Role.find(params[:id]), params[:role])\n\n respond_to do |format|\n if @role.update_attributes(hash) && @role.save\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to(@role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update(role, id = @id, user = @@default_user)\n @attributes = send_request(\"roles/#{id}\", :put) do |req|\n req.body = {\n role: role,\n auth_token: user.auth_token\n }\n end\n end",
"def update\r\n @role = Role.find(params[:id])\r\n \r\n if @role.update_attributes(params[:role])\r\n msg= \"Role updated successfully!\"\r\n else\r\n msg= \"Role update failed!\"\r\n end\r\n redirect_to roles_path, :flash => { :notice => msg }\r\n end",
"def update\n @role_user = RolesUser.find(params[:id])\n @role_user.role_id = $new_role_id\n respond_to do |format|\n if @role_user.update_attributes(params[:role_user])\n flash[:notice] = 'CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@role_user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role_user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @role_type = RoleType.find(params[:id])\n\n respond_to do |format|\n if @role_type.update_attributes(params[:role_type])\n format.html { redirect_to(role_types_path, :notice => 'Role was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to admin_roles_path, notice: 'Role was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_role\n @user = User.find( params[:id] )\n @user.update_attributes(params[:user])\n redirect_to users_path\n end",
"def update_role(id, name)\n current_path = \"/api/v1/roles/#{id}/update\"\n payload = { 'new_name' => name }.to_json\n @conn.put(current_path, payload)\n end",
"def update\n @user.roles=params[\"user\"][\"roles\"]\n respond_to do |format|\n if @user.update(event_params)\n format.html { redirect_to users_path, notice: 'User roles change successfully' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n flash.now[:notice] = 'Role was successfully updated.' if @role.update role_params\n respond_with @role\n end",
"def update\n @user = User.find(params[:id])\n params[:user][:roles].reject!(&:blank?)\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, 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 params[:user][:role_ids] ||= []\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n \n \n format.html { redirect_to(users_url, :notice => 'User was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def change_role(role)\n role_list.each do |old_role|\n remove_role old_role\n end\n puts role\n add_role role\n puts roles\n end",
"def updateSeriesAcl(xml, roles)\n\n doc = Nokogiri::XML(xml)\n newNodeSet = Nokogiri::XML::NodeSet.new(doc)\n\n roles.each do |role|\n newNode = nokogiri_node_creator(doc, \"ace\", \"\")\n newNode << nokogiri_node_creator(doc, \"action\", role[:permission])\n newNode << nokogiri_node_creator(doc, \"allow\", 'true')\n newNode << nokogiri_node_creator(doc, \"role\", role[:user])\n\n # Avoid adding duplicate nodes\n nodeAlreadyExists = false\n doc.xpath(\"//x:ace\", \"x\" => \"http://org.opencastproject.security\").each do |oldNode|\n if sameNodes?(oldNode, newNode)\n nodeAlreadyExists = true\n break\n end\n end\n\n if (!nodeAlreadyExists)\n newNodeSet << newNode\n end\n end\n\n doc.root << newNodeSet\n\n return doc.to_xml\nend",
"def update\n @user_space_role = UserSpaceRole.find(params[:id])\n\n respond_to do |format|\n if @user_space_role.update_attributes(params[:user_space_role])\n flash[:notice] = 'UserSpaceRole was successfully updated.'\n format.html { redirect_to(@user_space_role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_space_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role.update(system_role_params)\n format.html { redirect_to system_roles_url, notice: '更新角色成功.' }\n format.json { render :index, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @operations_role = OperationsRole.find(params[:id])\n\n respond_to do |format|\n if @operations_role.update_attributes(params[:operations_role])\n flash[:notice] = 'OperationsRole was successfully updated.'\n format.html { redirect_to(@operations_role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @operations_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n flash[:notice] = 'Role was successfully updated.' if @role.update_attributes role_params\n respond_with @role\n end",
"def update\n respond_to do |format|\n if role.update(role_params) && update_users_roles\n format.html { redirect_to admin_role_path(role), notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: role }\n else\n format.html { render :edit }\n format.json { render json: role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_role\n\t\t@role = Role.find(params[:id])\n\n\t \trespond_to do |format|\n\t\t if @role.update_attributes(role_update_params)\n\t\t format.html { redirect_to(@role, :notice => 'Entry was successfully updated.') }\n\t\t format.json { respond_with_bip(@role) }\n\t\t else\n\t\t format.html { render :action => \"edit\" }\n\t\t format.json { respond_with_bip(@role) }\n\t\t end\n\n \t end\n\tend",
"def update\n @role = Role.find(params[:id])\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to edit_role_path(@role), :notice => t('hurricane.notice.update_record_success', :type => t_type)}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #params[:user][:role_ids] ||= []\n @user = User.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.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n resource.update_attributes params[params_key], as: current_role\n respond_with resource\n end",
"def update\n @role = Role.find(params[:id])\n \n @perms = params[:permissions[\"permissions\"]]\n if @perms != nil\n @permissions = @perms[\"permissions\"]\n end\n #logger.debug \"PERMISSIONS: #{@permissions.inspect}\"\n if @permissions == nil\n @role.read = 0\n @role.write = 0\n @role.execute = 0\n end\n if @permissions != nil\n if @permissions.include?(\"read\")\n @role.read = 1\n else\n @role.read = 0\n end\n if @permissions.include?(\"write\")\n @role.write = 1\n else\n @role.write = 0\n end\n if @permissions.include?(\"execute\")\n @role.execute = 1\n else\n @role.execute = 0\n end\n end\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to @role, notice: t(:role_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @role = Role.find(params[:role][:id])\n\n if @role.update_attributes(params[:role])\n flash['notice'] = 'Role was successfully updated.'\n redirect_to :action => 'edit', \n :id => params[:role][:id]\n else\n flash['notice'] = 'Role not updated'\n redirect_to :action => 'edit', \n :id => params[:role][:id]\n end\n \n\n end",
"def update\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: t('success_update') }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_role = Role.find(params[:id])\n\n respond_to do |format|\n if @admin_role.update_attributes(params[:admin_role])\n format.html { redirect_to @admin_role, notice: 'Role was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sys_role.update(sys_role_params)\n format.html { redirect_to @sys_role, notice: 'Sys role was successfully updated.' }\n format.json { render :show, status: :ok, location: @sys_role }\n else\n format.html { render :edit }\n format.json { render json: @sys_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:user_id])\n @role = Role.find(params[:id])\n unless @user.has_role?(@role.name)\n @user.roles << @role\n end\n redirect_to :action => 'index'\n end",
"def update\n \n if request.get?\n @role = Role.find(params[:id].to_i)\n else\n @role = Role.find(params[:id].to_i)\n\n # set parent role\n if not params[:role][:parent].to_s.empty?\n @role.parent = Role.find(params[:role][:parent])\n else\n @role.parent = nil\n end\n\n # get an array of static permissions and set the permission associations\n params[:role][:static_permissions] = [] if params[:role][:static_permissions].nil?\n permissions = params[:role][:static_permissions].collect { |i| StaticPermission.find(i) }\n @role.static_permissions = permissions\n\n if @role.update_attributes(params[:role])\n flash[:success] = 'Role has been updated successfully.'\n redirect_to :action => 'show', :id => @role\n else\n render :action => 'update'\n end\n end\n \n rescue RecursionInTree\n @role.errors.add :parent, \"must not be a descendant of itself\"\n render :action => 'update'\n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'You sent an invalid request.'\n redirect_to :action => 'list'\n end",
"def update\n authorize! :assign_roles, @user if params[:user][:assign_roles]\n if @user.update_attributes(params[:user])\n redirect_to @user, notice: 'User was successfully updated.'\n else\n render \"edit\"\n end\n end",
"def edit\n @user = User.find(params[:id])\n if can?(:update, @user)\n @roles = \"\"\n\n @user.roles.each do |role|\n if @roles == \"\"\n @roles += role.name\n else\n @roles += \", \" + role.name\n end\n end\n else\n @user = nil\n end\n\n respond_to do |format|\n format.json { render :json => @user } \n format.xml { render :xml => @user }\n format.html\n end\n\n rescue ActiveRecord::RecordNotFound\n respond_to_not_found(:json, :xml, :html)\n end",
"def update\n @role = Role.find(params[:id])\n\n if @role.update_attributes(params[:role])\n redirect_to admin_roles_url\n else\n render :action => \"edit\"\n end\n end",
"def modify_roles(email, role)\n\t\tresponse = @client.execute(api_method: @service.acl.insert,\n\t\t\t\t\t parameters: {'calendarId' => ENV['NSCS_Calendar_ID']}, body: JSON.dump({role: role, scope: {type: \"user\", \"value\": email}}))\n\tend",
"def update\n @team_roleset = TeamRoleset.find(params[:id])\n\n respond_to do |format|\n if @team_roleset.update_attributes(params[:team_roleset])\n format.html { redirect_to(@team_roleset, :notice => 'TeamRoleset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team_roleset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n abilities = []\n params[:role][:role_abilities].each do |ability|\n abilities << ability.to_sym\n end\n @role.role_abilities = [{\"action\"=> abilities, \"subject\"=>[:api]}]\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to roles_path, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:user_id])\n @roles = Role.all\n \n if current_user.is_admin?\n @user.roles.clear\n @roles.each do |role|\n if (params[:role][:role][role.rolename][:hasrole].to_s == 1.to_s)\n @user.roles << role\n end\n end\n else\n @roles.each do |role|\n if !role.admin_only\n if @user.has_role?(role.rolename)\n @user.roles.destroy(role)\n end\n if (params[:role][:role][role.rolename][:hasrole].to_s == 1.to_s)\n @user.roles << role\n end\n end\n end\n end\n \n flash[:notice] = I18n.t(\"user.success.roles_updated\")\n reload_page\n \n end",
"def update\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize(current_user)\n role = params[:user][:role_ids]\n roleModel =Role.find( role)\n if @user.setRole roleModel.name\n @user.save\n redirect_to users_path, :notice => \"Rolle geändert\"\n else\n redirect_to users_path, :notice => \"Rolle nicht geändert\"\n end\n end",
"def update\n roles = params[:user].delete(:roles)\n if roles.present?\n roles.map! { |r| r.downcase }\n ['admin', 'staff'].each do |type|\n role = @user.roles.find_by(type: Role.types[type])\n if role && !roles.include?(type)\n role.destroy\n elsif !role && roles.include?(type)\n @user.roles << Role.new(type: type)\n end\n end\n end\n\n respond_to do |format|\n if @user.update(user_params)\n format.html do\n if request.referer == settings_url\n redirect_to :settings, notice: 'Saved.'\n else\n redirect_to :attendees, notice: 'User was successfully updated.'\n end\n end\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { redirect_to :back, alert: @user.errors.full_messages.first }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_roles(roles)\n self.roles |= roles\n self.save!\n end",
"def update\n @screen = session.active_screen\n @form_content_reuse = params[:form_content_reuse]\n \n @role = Role.find(params[:id]) \n @role.user_ids.each{|u_id| User.find(u_id).update_attributes( :updated_at => Time.now ) }\n @role.users.clear\n @role.users = User.find(params[:role][:user_ids]) unless params[:role][:user_ids].nil?\n @role.user_ids.each{|u_id| User.find(u_id).update_attributes( :updated_at => Time.now ) }\n \n @role.update_attributes(params[:role])\n\n respond_to do |format|\n format.html # create.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def update\n @user = User.find_by(email: params[:user][:email])\n @user.roles = params[:user][:roles]\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to root_path, notice: 'User was successfully updated.' }\n # format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @role.permissions = []\n @role.set_permissions(params[:permissions]) if params[:permissions]\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_role = UserRole.find(params[:id])\n\n respond_to do |format|\n if @user_role.update_attributes(params[:user_role])\n flash[:notice] = 'UserRole was successfully updated.'\n format.html { redirect_to([:admin, @user_role]) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @roles = Role.all\n\n role = user_params[:role_id] ? user_params[:role_id] : @user.role_id\n if user_params[:password].empty?\n new_params = { :role_id => role,\n :first_name => user_params[:first_name],\n :last_name => user_params[:last_name],\n :email => user_params[:email],\n :telephone => user_params[:telephone] }\n else\n new_params = { :role_id => role,\n :first_name => user_params[:first_name],\n :last_name => user_params[:last_name],\n :email => user_params[:email],\n :telephone => user_params[:telephone],\n :password => user_params[:password],\n :password_confirmation => user_params[:password_confirmation] }\n end\n p = new_params\n respond_to do |format|\n if @user.update(p)\n format.html { redirect_to @user, notice: 'Benutzerdaten wurden aktualisiert.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @primary_role = PrimaryRole.find(params[:id])\n\n respond_to do |format|\n if @primary_role.update_attributes(params[:primary_role])\n format.html { redirect_to(@primary_role, :notice => 'Primary role was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @primary_role.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find(params[:company_id])\n @role = Role.find(params[:id])\n \n respond_to do |format|\n if @role.update_attributes(params[:role])\n format.html { redirect_to company_role_path(@company, @role), notice: 'El rol fue editado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@role = Role.find(params[:id])\n\t\t@role.update_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @role.update_attributes(params[:role])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated,:typeobj =>t(:ctrl_role),:ident=>@role.title)\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated,:typeobj =>t(:ctrl_role),:ident=>@role.title, :error => @role.errors.full_messages)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def set_role\r\n @role = Role.find(params[:id])\r\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def edit_users\n @user = User.find(params[:id])\n @role = @user.roles.first.name\n end",
"def update\n @account = Account.find(params[:id])\n params[:account].delete(:role)\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to(@account, :notice => 'Account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @users_role.update(users_role_params)\n format.html { redirect_to @users_role, notice: 'Users role was successfully updated.' }\n format.json { render :show, status: :ok, location: @users_role }\n else\n format.html { render :edit }\n format.json { render json: @users_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @org_role.update(org_role_params)\n format.html { redirect_to @org_role, notice: 'Org role was successfully updated.' }\n format.json { render :show, status: :ok, location: @org_role }\n else\n format.html { render :edit }\n format.json { render json: @org_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n chef_server_rest.post(\"roles\", self)\n self\n end",
"def update\n @roles_and_permission = @roles.roles_and_permission.find(params[:id])\n\n respond_to do |format|\n if @roles_and_permission.update_attributes(params[:roles_and_permission])\n format.html { redirect_to [@roles,@roles_and_permission], notice: 'Roles and permission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @roles_and_permission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_role\n @user = User.find(params[:id])\n\n # Limit access to authorized users\n authorize! :manage, @user\n\n @user.admin = params[:admin_role]\n respond_to do |format|\n if @user.save\n format.json { head :no_content }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit \n @role = Role.find(params[:id])\n @users = User.all\n end",
"def update\n params[:user][:role_ids] ||= []\n @user = User.find(params[:id])\n # @user.roles = Role.find(params[:role_ids]) if params[:role_ids]\n @session_user = session[:user]\n if @session_user.is_super_admin\n @roles = Role.find(:all)\n else\n @roles = Role.find(:all, :conditions => [\"id <> 1\"])\n end\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'User was successfully updated.'\n if permitted_to? :index, User.new\n format.html { redirect_to(@user) }\n else\n format.html { redirect_to(:root) }\n end\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n load_permissions\n ids = params[:permissions].select {|k, v| v == \"1\"}.map {|k,v| k.to_i }\n if ids.length > 0\n permissions = Permission.find(:all, :conditions => [\"id in (#{ids.join(',')})\"])\n @role = Role.find(params[:id])\n params[:role][:permissions] = permissions\n if @role.update_attributes(params[:role])\n flash[:notice] = \"修改角色成功\"\n redirect_to :action => 'index'\n else\n flash[:error] = '修改角色失败'\n redirect_to :action => 'edit', :id => @role.id\n end\n else\n flash[:error] = \"角色名或权限不能为空\"\n redirect_to :action => 'edit', :id => @role.id\n end\n end",
"def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def update_role(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'UpdateRole'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :new_assume_role_policy_document\n\t\t\targs[:query]['NewAssumeRolePolicyDocument'] = optional[:new_assume_role_policy_document]\n\t\tend\n\t\tif optional.key? :role_name\n\t\t\targs[:query]['RoleName'] = optional[:role_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def update\n respond_to do |format|\n if @role.update(safe_params)\n format.html { redirect_to [@company, @role], notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n return unless check_permission\n\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n else\n @users = User.all\n format.html { render :edit }\n end\n end\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end",
"def set_role\n @role = Role.find(params[:id])\n end"
] |
[
"0.6927021",
"0.68739194",
"0.68296283",
"0.6658158",
"0.6658158",
"0.6657796",
"0.6646289",
"0.6639587",
"0.6611606",
"0.65743977",
"0.6448827",
"0.64373785",
"0.6342125",
"0.6340391",
"0.6330269",
"0.6327314",
"0.63118714",
"0.6311083",
"0.6308927",
"0.62863934",
"0.62792355",
"0.6253083",
"0.6231562",
"0.62238526",
"0.6222459",
"0.61948884",
"0.61946195",
"0.6193193",
"0.618933",
"0.61734617",
"0.6139228",
"0.61328423",
"0.6130515",
"0.6117781",
"0.61137664",
"0.6111794",
"0.61104596",
"0.61085314",
"0.6100039",
"0.6098891",
"0.6087179",
"0.60785615",
"0.60590374",
"0.6044768",
"0.6031145",
"0.6031145",
"0.6030508",
"0.6029637",
"0.6025245",
"0.60170084",
"0.5993554",
"0.5989362",
"0.59737283",
"0.59700555",
"0.5965846",
"0.59649366",
"0.5964839",
"0.5954361",
"0.5946351",
"0.59409034",
"0.5934583",
"0.59335595",
"0.5914688",
"0.59091985",
"0.59037256",
"0.5888875",
"0.58856475",
"0.58809805",
"0.58733577",
"0.5863215",
"0.585834",
"0.58582956",
"0.5837255",
"0.5830477",
"0.5830477",
"0.5830477",
"0.5830477",
"0.5830477",
"0.5830477",
"0.5830477",
"0.5830477",
"0.5816723",
"0.58154064",
"0.58143425",
"0.5813598",
"0.58071834",
"0.580703",
"0.5803185",
"0.5793296",
"0.578988",
"0.57852405",
"0.5777931",
"0.5777557",
"0.576702",
"0.5758461",
"0.57467574",
"0.57467574",
"0.57467574",
"0.57467574",
"0.57467574",
"0.57467574"
] |
0.0
|
-1
|
DELETE /roles/1 DELETE /roles/1.xml
|
def destroy
respond_to do |format|
if @role.destroy
format.html { redirect_to(@role) }
format.js { render (:update) {|page| page[dom_id_nested(:item, @role)].remove() } }
else
flash[:notice] = 'Role was not deleted.'
format.html { redirect_to roles_path }
format.js { render (:update) { |page| page.alert("Cannot delete role #{@role.name}") }}
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n chef_server_rest.delete(\"roles/#{@name}\")\n end",
"def destroy\n @role = @client.roles.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n flash[:notice] = 'Role was successfully removed.' \n format.html { redirect_to(client_roles_url(@client)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @userrole = Userrole.find(params[:id])\n @userrole.destroy\n\n respond_to do |format|\n format.html { redirect_to(userroles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find params[:user_id]\n @role = Role.find params[:id]\n\n @user.roles.delete @role\n flash[:notice] = 'Assigment was successfully destroyed.'\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_role = UserRole.find(params[:id])\n @user_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n ActiveRecord::Base.transaction do\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_url) }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n @role_user = RolesUser.find(params[:id])\n @role_user.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role = Role.find_by_id(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_url, :notice => \"User role removed.\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_space_role = UserSpaceRole.find(params[:id])\n @user_space_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_space_roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @role = Role.find(params[:id])\n if @user.has_role?(@role.name)\n @user.roles.delete(@role)\n end\n respond_to do |format|\n format.html {redirect_to :action => 'index' }\n format.xml { head :ok }\n end\n \n end",
"def destroy\n @role_type = RoleType.find(params[:id])\n @role_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to(blog_roles_url(@blog)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @primary_role = PrimaryRole.find(params[:id])\n @primary_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(primary_roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n flash[:notice] = 'Role was successfully destroyed.'\n format.html { redirect_to roles_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @operations_role = OperationsRole.find(params[:id])\n @operations_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(operations_roles_url) }\n format.xml { head :ok }\n end\n end",
"def test_set3_04c_delete_principal()\n user = \"test_user\"\n @test_acl.create_principal(user)\n id = @test_acl.create_ace(user, \"allow\", \"SELECT\", \"test\", \"/db/temporary/testsource\")\n \n @test_acl.delete_principal(user)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end",
"def delete_role_and_associated_nodes\n search_glob = \"#{self.role_name}*\"\n skip_list = Array(self.node_name)\n\n puts \"deleting role with name = '#{search_glob}'\"\n ::Chef::Search::Query\n .new\n .search('role', \"name:#{search_glob}\")\n .first\n .reject { |role| skip_list.include?(role.name)}\n .each { |role| puts role.as_json; role.destroy }\n puts \"deleted role with name = '#{search_glob}'\"\n\n puts \"deleting node with role = '#{search_glob}'\"\n ::Chef::Search::Query\n .new\n .search('node', \"role:#{search_glob}\")\n .first\n .reject { |node| skip_list.any? { |item| node.run_list.include?(item) } }\n .each { |node| puts node['hostname']; node.destroy }\n puts \"deleted node with role = '#{search_glob}'\"\n end",
"def delete(id = @id, user = @@default_user)\n @attributes = send_request(\"roles/#{id}\", :delete) do |req|\n req.body = {\n auth_token: user.auth_token\n }\n end\n end",
"def destroy\n @roles_and_permission = @roles.roles_and_permission.find(params[:id])\n @roles_and_permission.destroy\n\n respond_to do |format|\n format.html { redirect_to roles_and_permissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role_user = RoleUser.find(params[:id])\n @role_user.destroy\n\n respond_to do |format|\n format.html { redirect_to(role_users_url) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\"}'}\n end\n end",
"def destroy\n @rolid = params[:id]\n Role.destroy(@rolid)\n end",
"def destroy\n if !grant_access(\"alter_roles\", current_user)\n head(403)\n end\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def DeleteRole id\n \n APICall(path: \"custom_roles/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to roles_url , :notice => t('hurricane.notice.delete_record_success', :type => t_type)}\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to system_roles_url, notice: '删除角色成功.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role_types = RoleTypes.find(params[:id])\n @role_types.destroy\n\n respond_to do |format|\n format.html { redirect_to(role_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_role = UserRole.find(params[:id])\n @user_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_user_roles_url) }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rol.destroy\n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_role = Role.find(params[:id])\n @admin_role.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @core_user_role.destroy\n respond_to do |format|\n format.html { redirect_to core_user_roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n\n redirect_to roles_path\n end",
"def destroy\n @tree_node_ac_rights = TreeNodeAcRight.find(params[:id])\n @tree_node_ac_rights.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_tree_node_tree_node_permissions_path }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.transaction do\n @user.user_roles.destroy_all\n @user.update_attribute(:admin, false)\n end\n respond_to do |format|\n format.html { redirect_to admin_roles_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_with @role, location: roles_path\n end",
"def destroy\n @role.destroy\n respond_with @role, location: roles_path\n end",
"def destroy \r\n @role = Role.find(params[:id])\r\n if @role.destroy\r\n msg= \"Role deleted successfully!\"\r\n else\r\n msg= \"Role delete failed!\"\r\n end\r\n redirect_to roles_path, :flash => { :notice => msg }\r\n end",
"def destroy\n @page_role = PageRole.find(params[:id])\n @page_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_roles_url) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\"}'}\n end\n end",
"def purge_roles \n xml=self.roleMetadata.ng_xml\n nodes = xml.search('/roleMetadata/role')\n nodes.each do |node|\n node.remove\n end\n end",
"def destroy\n role.destroy\n respond_to do |format|\n format.html { redirect_to admin_roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n \n @users = User.find_by_role_id(@role.id)\n respond_to do |format|\n if @users == nil\n @role.destroy\n format.html { redirect_to roles_url, :notice => t(:role_deleted) }\n format.json { head :no_content }\n else\n format.html { redirect_to roles_url, :alert => t(:role_inuse) }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @provider_role = ProviderRole.find(params[:id])\n @provider_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(provider_roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @protocol_role = ProtocolRole.find(params[:id])\n @protocol_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(protocol_roles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n return unless check_permission\n\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n end\n end",
"def delete(role:, type:)\n\t\t\t\t\tconnection.post(build_path('removeRoles'), nil, roleNames: [role].flatten.join(','),\n\t\t\t\t\t\ttype: type).code == '200'\n\t\t\t\tend",
"def destroy\n @partyrole = Partyrole.find(params[:id])\n @partyrole.destroy\n\n respond_to do |format|\n format.html { redirect_to(partyroles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @partyrole = Partyrole.find(params[:id])\n @partyrole.destroy\n\n respond_to do |format|\n format.html { redirect_to(partyroles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to company_roles_url(@company), notice: 'Role was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to management_roles_url, notice: 'Perfil was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sys_role.destroy\n respond_to do |format|\n format.html { redirect_to sys_roles_url, notice: 'Sys role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_controles = TipoControle.find(params[:id])\n @tipo_controles.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_controles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @roles_privilege.destroy\n respond_to do |format|\n format.html { redirect_to roles_privileges_url, notice: 'Roles privilege was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @users_role.destroy\n respond_to do |format|\n format.html { redirect_to users_roles_url, notice: 'Users role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n respond_with(@role)\n end",
"def destroy\n @user_has_role_for_node.destroy\n respond_to do |format|\n format.html { redirect_to user_has_role_for_nodes_url, notice: 'User has role for node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_role\n\t\t@role = Role.find(params[:id])\n\n\t\tif @role.destroy\n\t\t\tredirect_to \"/details\"\n\t\telse\n\t\t\treder :action => \"delete_role\"\n\t\tend\n\tend",
"def destroy\n\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n \n \n @rpm = Rpm.find(params[:id])\n @rpm.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n\n respond_to do |format|\n format.html { redirect_to rpms_url }\n format.json { head :ok }\n end\n end",
"def delete\n @role = Role.find(params[:id].to_i)\n \n if request.get?\n # render only\n else\n if not params[:yes].nil?\n @role.destroy\n flash[:success] = 'The role has been deleted successfully.'\n redirect_to :action => 'list'\n else\n flash[:success] = 'The role has not been deleted.'\n redirect_to :action => 'show', :id => params[:id]\n end\n end\n\n rescue CantDeleteWithChildren\n flash[:error] = \"You have to delete or move the role's children before attempting to delete the role itself.\"\n redirect_to :action => 'show', :id => params[:id]\n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'This role could not be found.'\n redirect_to :action => 'list'\n end",
"def destroy\n @role.destroy\n\n flash[:notice] = \"Role successfully destroyed.\"\n\n redirect_to roles_path\n end",
"def delete\n @role = Role.find(params[:id])\n \n if request.get?\n # render only\n else\n if not params[:yes].nil?\n @role.destroy\n flash[:success] = 'The role has been deleted successfully.'\n redirect_to roles_path\n else\n flash[:success] = 'The role has not been deleted.'\n redirect_to role_path(Role.find(params[:id]))\n end\n end\n\n rescue CantDeleteWithChildren\n flash[:error] = \"You have to delete or move the role's children before attempting to delete the role itself.\"\n redirect_to role_path(Role.find(params[:id]))\n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'This role could not be found.'\n redirect_to roles_path\n end",
"def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n super\n # if resource.destroy\n # @rolesuser = @Rolesuser.find_all_by_user_id(resource.id)\n # @rolesuser.each do |rolesuser|\n # rolesuser.destroy\n # end\n # end\n end",
"def destroy\n @app_role = AppRole.find(params[:id])\n @app_role.destroy\n\n respond_to do |format|\n format.html { redirect_to app_roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ministerial_role.destroy\n respond_to do |format|\n format.html { redirect_to ministerial_roles_url }\n format.json { head :no_content }\n end\n end",
"def test_set3_04b_delete_group()\n group = \"test_group\"\n user = \"test_user\"\n \n @test_acl.create_principal(user)\n @test_acl.create_group(group, [\"ALL\"], [user])\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n #puts query\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(1, hits)\n \n @test_acl.delete_principal(group)\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @cms_role.destroy\n respond_to do |format|\n format.html { redirect_to cms_roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n \n @status_del_tramite_de_beca = StatusDelTramiteDeBeca.find(params[:id])\n @status_del_tramite_de_beca.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n\n\n\n respond_to do |format|\n format.html { redirect_to status_del_tramite_de_becas_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @company = Company.find(params[:company_id])\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to company_roles_path(@company) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:company_id])\n @role = Role.find(params[:role_id])\n @access_right = @role.access_rights.find(params[:id])\n @access_right.destroy\n redirect_to company_role_path(@company, @role)\n end",
"def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @role_auth_ref.destroy\n respond_to do |format|\n format.html { redirect_to role_auth_refs_url, notice: 'Role auth ref was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lab_permissions_role = LabPermissionsRole.find(params[:id])\n @lab_permissions_role.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_permissions_roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lab_role = LabRole.find(params[:id])\n @lab_role.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @role.destroy\r\n respond_to do |format|\r\n format.html { redirect_to \"index\", notice: 'Role was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @master_role.destroy\n respond_to do |format|\n format.html { redirect_to master_roles_url }\n format.json { head :no_content }\n end\n end",
"def revoke(*roles)\n delete(roles)\n reload\n end",
"def delete_role(name)\n client.delete(\"/v1/auth/approle/role/#{encode_path(name)}\")\n return true\n end",
"def destroy\n @payrole = Payrole.find_by_id(params[:id])\n @payrole.destroy\n\n respond_to do |format|\n format.html { redirect_to user_shift_path(@user, @shift) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n @status_del_admitido = StatusDelAdmitido.find(params[:id])\n @status_del_admitido.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n \n \n\n respond_to do |format|\n format.html { redirect_to status_del_admitidos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n @subsede = Subsede.find(params[:id])\n @subsede.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n\n \n \n\n respond_to do |format|\n format.html { redirect_to subsedes_url }\n format.json { head :ok }\n end\n end",
"def delete\n\n @cook = User.find(params[:id])\n @cook.remove_role :waiter\n \n @cookaccounts = AdminCookAccount.where(id_cook: @cook.id)\n @cookaccounts.delete_all\n\n redirect_to admin_cooks_url\n\n end",
"def delete\n @role = get_role\n respond_with @event, @role\n end",
"def destroy\n @role_privilege.destroy\n respond_to do |format|\n format.html { redirect_to role_privileges_url, notice: 'Veza je usšešno obrisana.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n @status_ref_pago_insc = StatusRefPagoInsc.find(params[:id])\n @status_ref_pago_insc.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n\n \n \n\n respond_to do |format|\n format.html { redirect_to status_ref_pago_inscs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_role_ref.destroy\n respond_to do |format|\n format.html { redirect_to admin_role_refs_url, notice: 'Admin role ref was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @org_role.destroy\n respond_to do |format|\n format.html { redirect_to org_roles_url, notice: 'Org role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n\n @correo = Correo.find(params[:id])\n @correo.destroy\n\nelse\n @correo = Correo.find(params[:id])\n flash[:error] ='No tienes permiso para realizar esta accion'\n redirect_to \"/correos/#{@correo.id}/edit/\"\n return\nend\n\n\n\n respond_to do |format|\n format.html { redirect_to \"/correos\", notice: 'correo was successfully deleted.' }\n format.json { head :ok }\n end\n end",
"def destroy\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n \n \n\n @status_de_la_inscripcion = StatusDeLaInscripcion.find(params[:id])\n @status_de_la_inscripcion.destroy\n\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n \n\n respond_to do |format|\n format.html { redirect_to status_de_la_inscripcions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @security_agent_role.destroy\n respond_to do |format|\n format.html { redirect_to security_agent_roles_url, notice: 'Security agent role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.73153687",
"0.71410984",
"0.70588833",
"0.70588833",
"0.70306534",
"0.69952327",
"0.69625664",
"0.69525975",
"0.6904067",
"0.68919075",
"0.6886388",
"0.6883458",
"0.67904866",
"0.67854214",
"0.6705457",
"0.66825765",
"0.6665933",
"0.66417426",
"0.6618673",
"0.6600824",
"0.65488183",
"0.6531047",
"0.6527349",
"0.6522249",
"0.65108186",
"0.64873374",
"0.6481721",
"0.6476749",
"0.6472135",
"0.646395",
"0.64514273",
"0.64509636",
"0.6441441",
"0.6429008",
"0.64262855",
"0.63977647",
"0.63735926",
"0.6373354",
"0.63665205",
"0.63665205",
"0.63603884",
"0.6360244",
"0.63596565",
"0.6340353",
"0.6305264",
"0.62977934",
"0.6283222",
"0.6260457",
"0.6240237",
"0.6232424",
"0.6232424",
"0.62282896",
"0.62256986",
"0.6223741",
"0.62191695",
"0.62184066",
"0.6213822",
"0.6210485",
"0.62045234",
"0.61883485",
"0.61883485",
"0.61883485",
"0.61883485",
"0.61883485",
"0.61883485",
"0.61839956",
"0.6173202",
"0.61728203",
"0.6169083",
"0.6151024",
"0.6150098",
"0.6149442",
"0.61489314",
"0.61375004",
"0.6122175",
"0.6121609",
"0.61209047",
"0.611207",
"0.61080736",
"0.61050135",
"0.61028963",
"0.6098135",
"0.6096562",
"0.6088316",
"0.6085321",
"0.60843533",
"0.608352",
"0.6081007",
"0.6080458",
"0.6073316",
"0.6068359",
"0.6055044",
"0.6051433",
"0.6051119",
"0.60440624",
"0.60382134",
"0.6037591",
"0.6034636",
"0.6032121",
"0.6021452",
"0.6020947"
] |
0.0
|
-1
|
before every action check if any user is logged in
|
def require_login
if session[:user_id].blank?
redirect_to root_url, notice: "Login is required to perform this action!"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end",
"def ensure_logged_in\n login! if @user.nil?\n end",
"def logged_in\n\t \t!current_user.nil?\n\t end",
"def logged_in\n logged_in_user != nil\n end",
"def logged_in_user\n unless logged_in?\n puts \"not logged in\"\n end\n end",
"def enforce_logged_in\n bounce unless current_user\n end",
"def before_request\n self.login if require_login? && !@authenticating\n end",
"def check_if_logged_in\n # if the current request is coming from a user who is not logged in\n # redirect them to the login page\n # any controller actions that should only be available to\n # logged in users will need to run this method before performing\n unless @current_user.present?\n flash[:error] = 'You must be logged in to perform that action'\n redirect_to login_path\n end # unless\n end",
"def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\t end\n end",
"def my_login_required\n login_required unless User.count==0\n end",
"def already_logged_in\n\t\t\t#current user is not nil\n\t\t\tif !current_user.nil?\n\t\t\t\tredirect_to root_url\n\t\t\tend\n\t\tend",
"def check_login\n unless logged_in?\n access_denied\n end\n end",
"def require_user\n #if not logged in \n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n \n \n end",
"def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end",
"def check_user_before_action\n @blog = Blog.find(params[:id])\n if (current_user != @blog.user) and (@blog.global == false)\n redirect_to({ action: \"index\" }, notice: \"You don't have sufficient permissions\")\n\n end\n end",
"def logged_in\r\n end",
"def logged_in\n current_user != nil\n end",
"def login_required\n not_authorized unless current_user\n end",
"def logged_in_user\n unless current_user \n redirect_to root_path\n end\n end",
"def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\tend\n end",
"def require_login\n end",
"def load_user_if_logged_in\n if user?\n @user = current_user\n else\n @user = nil\n end\n return true\nend",
"def before_filter\n if current_user\n true\n end\n end",
"def check_is_login_required\n authorized_denied unless logged_in?\n end",
"def logged_in_any\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def check_user\n if user_signed_in?\n else\n redirect_to root_path, :alert => \"Unauthorised Access\"\n end\n \n end",
"def check_user\n if user_signed_in?\n else\n redirect_to root_path, :alert => \"Unauthorised Access\"\n end\n \n end",
"def check_authenticated\n @logged_in = session[:logged_in]\n end",
"def login_check\n if session[:user_id].present?\n unless (controller_name == \"user\") and [\"first_login_change_password\",\"login\",\"logout\",\"forgot_password\"].include? action_name\n user = User.active.find(session[:user_id])\n \n \n end\n end\n end",
"def authenticate!\n\t #when we solve the require relative problem write the line: unless session[:user_id] && User.where(id: session[:user_id])\n\n\t\tif session[:user_id] && User.where(id: session[:user_id]).exists? #if the user id saved in session does not belong to any user, also direct to general homepage\n\t\t\ttrue\n\t\telse\n\t\t\tsession[:original_request] = request.path_info\n\t\t\tfalse\n\t\tend\nend",
"def check_login\n head :forbidden unless self.current_user\n end",
"def is_logged_in\n\t\tif self.controller_name == \"music_rating_services\" || self.controller_name == \"registrations\" || self.controller_name == \"sessions\"\n\t\t\treturn\n\t\telsif current_user == nil\n\t\t\tflash[:notice] = \"You must be logged in to access this feature.\"\n\t\t\tredirect_to root_path\n\t\telse\n\t\t\treturn\n\t\tend\n\tend",
"def check_login\n if (current_user.blank? or current_user.username.blank?) and !session[:user_id].blank? \n logger.error(\"logout occurred\")\n session[:user_id] = nil\n elsif session[:user_id].blank? and !current_user_model.blank? and !current_user.blank? \n session[:user_id] = current_user_model.id\n session[:user_id] = '1' if session[:user_id].blank?\n logger.error(\"login occurred\")\n log_request('login')\n end\n end",
"def check_if_logged_in\n redirect_to(new_user_path) if @current_user.nil?\n end",
"def check_if_logged_in\n redirect_to(new_user_path) if @current_user.nil?\n end",
"def require_logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Veuilliez vous connecter svp.\"\n redirect_to login_path\n end\n end",
"def logged_in_user\n unless logged_in?\n redirect_to root_url\n end\n end",
"def ensure_user_logged_in\n bounce_user unless current_user\n end",
"def needs_login?() false end",
"def check_user\n if (!user_signed_in?)\n redirect_to root_path, notice: 'You must log in to do that'\n end\n # if (!current_user.superadmin_role)\n # redirect_to root_path, notice: 'You do not have permissions to do that'\n # end\n end",
"def logged_in\n !current_user.nil?\n end",
"def logged_in?\n redirect_to(root_path, notice: 'Unauthorized access!') unless current_user\n end",
"def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end",
"def verify_logged_in\n redirect_to root_path unless logged_in?\n end",
"def require_login\n if current_user\n gon.current_user_email = current_user.email\n gon.current_user_created_at = current_user.created_at.to_i\n gon.current_user_username = current_user.username.capitalize\n gon.current_user_id = current_user.id\n gon.current_user_coaching_intensity = current_user.preference.coaching_intensity\n gon.current_user_last_login_at = current_user.last_login_at\n\n else\n store_location\n flash[:notice] = \"You must be logged in to access this page\"\n redirect_to login_url\n end\n end",
"def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end",
"def check_logged_in?\n if !logged_in?\n redirect_to root_path\n end\n end",
"def must_be_logged_in\n unless current_user\n redirect_to new_user_session_path\n end\n end",
"def declared_user\n if logged_in?\n if Protege.find_by(user_id: current_user.id.to_i).nil?\n redirect_to root_path, :alert => \"Access denied.\"\n end\n else\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def declared_user\n if logged_in?\n if Protege.find_by(user_id: current_user.id.to_i).nil? and Trainer.find_by(user_id: current_user.id.to_i).nil?\n redirect_to root_path\n end\n else\n redirect_to root_path\n end\n end",
"def must_be_logged_in\n redirect_to root_path unless logged_in?\n end",
"def check_if_login_required\n false\n end",
"def login_required\n call(Rs(:login)) unless logged_in?\n end",
"def is_logged_in\n #since these are also marked as helper methods, they are availalble in not just all ctronollers (cuz they inherit from appc ontroler) but also avialble to views\n\n (session[:user_id] && session[:user_id].present? ) ? true : false\n end",
"def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end",
"def require_logged_in\n \treturn true if current_user\n\n \treturn redirect_to root_path\n\n end",
"def authentication_required\n if !logged_in?\n redirect_to login_path\n end\n end",
"def logged_in?\n !session[:user_id].nil? #&& User.find(session[:user_id]).owns(@current_site)\n end",
"def require_login \n # puts \"#{@@count}\" \n # @@count+=1; \n if !(session[:user_id])\n # puts \"#{@@count} require_login method of application controller found no user logged in: \", session[:user_id]\n redirect_to '/main'\n # else\n # puts \"#{@@count} using require_login private method: Someone is already logged in: \", session[:user_id]\n # current_user = User.find(session[:user_id])\n #return current_user\n end\n end",
"def check_for_login\n #if not, back home with you!\n redirect_to root_path unless @current_user.present?\n end",
"def login_required\n authenticate_user! \n end",
"def check_login_status\n # If user hasn't logged in\n unless logged_in?\n # Show reminder message\n flash[:info] = \"Log in to continue.\"\n\n # Redirect user to login page\n redirect_to login_url\n end\n end",
"def check_logged_in\n return if current_user.present?\n\n redirect_to new_session_path and return\n end",
"def require_login\n\t\tunless current_user\n\t\t\tredirect_to login_url\n\t\tend\n\tend",
"def authenticated\n\t\tif current_user || current_admin\n\t\t\ttrue\n\t\telse\n\t\t\tflash[:error] = \"You must log in to view that page!\"\n\t\t\tredirect_to root_url\n\t\tend\n\tend",
"def require_logged_in\n access_denied(\"You must be logged in to do that.\") unless logged_in?\n end",
"def login_required\n unless session[:user_id].present?\n redirect_to login_user_index_path\n end\n end",
"def login_required\n logged_in? ? true : access_denied\n end",
"def logged_in?\n end",
"def require_login\n not_authorized(\"Please sign up or log in above to access this resource.\") unless current_user\n end",
"def require_user\n #if not logged in \n if !logged_in?\n flash[:alert] = \"You must be logged in to perform that action\"\n #then redirect them away\n redirect_to login_path\n end\n end",
"def require_login\n if !current_user\n redirect_to \"/\"\n end\n end",
"def logged_in_user\n unless logged_in?\n flash[:warning] = \"Please log in\"\n redirect_to root_url\n end\n end",
"def logged_in?\n unless User.find_by(id:session[:user_id])\n redirect_to login_url, notice:\"Please log in as a user before viewing this page.\"\n end\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in first'\n render 'sessions/new', status: :unauthorized\n true # return true to indicate that this triggered things\n end",
"def require_logged_in\n redirect_to root_path unless logged_in?\n end",
"def logged_in_user\n #this only runs if the user is NOT logged in\n #logged_in method comes from the sessions helper file, and returns a boolean\n unless logged_in?\n #this method comes from the sessions_helper file. it stores where you were trying to go, so that after you log in, it will get you there. reference comments in the helper file.\n store_location\n #adds a flash - it is not flash.now because it is redirected to the login page, so that login page counts as a new request which is what we want.\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def auth\n #redirect to login page unless already logged in\n redirect_to new_user_session_path, alert: \"You must login to access that page\" unless logged_in?\n end",
"def require_login\n redirect_to login_path, notice: 'The requested action requires you to log in' unless session[:user_id]\n end",
"def require_login\n !!current_user || access_denied\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Admin Access Only.\"\n redirect_to login_url\n \n end\n end",
"def require_user\n #If not logged in display message then return to home page\n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n end",
"def require_user\n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n end",
"def logged_in_user\n unless logged_in?\n render json: false, status: :unauthorized\n # store_location\n end\n end",
"def index\n redirect_to(:action => 'login') #unless logged_in? || User.count > 0\n end",
"def check_login\n \t\t\tif self.session == nil\n \t\t\t\t login\n \t\t\tend\n \tend",
"def logged_in?\n if current_user\n true\n else \n false\n end\n end",
"def login_required\n return true unless protect?(action_name)\n\n user = session_user\n return true if user && authorize?(user)\n\n # store current location so that we can\n # come back after the user logged in\n store_location\n\n # call overwriteable reaction to unauthorized access\n access_denied\n false\n end",
"def is_logged_in\n if !logged_in?\n redirect_unauthorized(:back, \"You must be logged in to perform this action.\")\n end\n end",
"def require_login\n unless logged_in?\n redirect_to login_path\n end\n end",
"def require_login\n redirect_to root_path unless session.include?(:user_id)\n end",
"def auth_user\n if !current_user\n redirect_to root_url\n end\n end",
"def auth_user\n if !current_user\n redirect_to root_url\n end\n end",
"def auth_user\n if !current_user\n redirect_to root_url\n end\n end",
"def check_access\n if not user_signed_in?\n redirect_to('/users/sign_in')\n end\n end",
"def login_required\n \t\t redirect_to(root_url, notice: 'You have to be signed in to do that! Top right ~') unless current_user\n \tend",
"def ensure_logged_in\n if (!logged_in?)\n redirect_to login_url\n end\n end",
"def user_logged_in\n if session[:just_logged_in] && !current_user.is_admin \n gon.display_login_popup = true\n \n session[:just_logged_in] = false\n end\n end",
"def require_login\n redirect_to login_path if !user_logged?\n end",
"def login_required\n return true unless session[:user_id].blank?\n return false\n end",
"def check_auth\r\n if current_user == nil || @user.id != current_user.id\r\n redirect_to root_path , alert: \"Can't Access A Game That Does not belong to you.\"\r\n end\r\n end"
] |
[
"0.7626321",
"0.7605218",
"0.75437105",
"0.7500471",
"0.74753255",
"0.74608755",
"0.74588656",
"0.7456016",
"0.74548393",
"0.7450612",
"0.7445222",
"0.74270463",
"0.7415904",
"0.7410896",
"0.73965913",
"0.7396289",
"0.73847884",
"0.7373266",
"0.7352127",
"0.73334265",
"0.73302317",
"0.7327236",
"0.73229593",
"0.7299632",
"0.7272834",
"0.7271764",
"0.7271764",
"0.72688824",
"0.725881",
"0.72484416",
"0.72471726",
"0.7236145",
"0.72266245",
"0.72186923",
"0.72186923",
"0.72030395",
"0.719942",
"0.71901107",
"0.71720785",
"0.7171615",
"0.7166332",
"0.7152205",
"0.71467745",
"0.7141446",
"0.71299404",
"0.7127392",
"0.7117211",
"0.711706",
"0.7112983",
"0.7112728",
"0.7110292",
"0.7107764",
"0.7104839",
"0.7103481",
"0.70987755",
"0.709729",
"0.70964193",
"0.70962155",
"0.70894766",
"0.7086601",
"0.7085003",
"0.70747554",
"0.7072726",
"0.7064421",
"0.7063511",
"0.70630705",
"0.7052965",
"0.7049507",
"0.7046228",
"0.7044035",
"0.70426655",
"0.7038969",
"0.7028868",
"0.7023293",
"0.7021541",
"0.7019026",
"0.70169395",
"0.70130676",
"0.70114994",
"0.70105505",
"0.70064944",
"0.7003452",
"0.70022583",
"0.70003396",
"0.69952065",
"0.69909114",
"0.6986944",
"0.69866824",
"0.698575",
"0.69845384",
"0.69813806",
"0.6980419",
"0.6980419",
"0.6980419",
"0.69781286",
"0.6976865",
"0.69762546",
"0.69753885",
"0.6973278",
"0.6970418",
"0.69646686"
] |
0.0
|
-1
|
before every action identify the user that is logged in
|
def identify_user
@user = User.find_by(id: session[:user_id])
if !@user
redirect_to root_url, notice: "User not identified!"
end
if params[:book_id].blank?
redirect_to root_url, :notice => "It is not a valid action!"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logged_in\r\n end",
"def declared_user\n if logged_in?\n if Protege.find_by(user_id: current_user.id.to_i).nil?\n redirect_to root_path, :alert => \"Access denied.\"\n end\n else\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def logged_in_user\n unless logged_in?\n puts \"not logged in\"\n end\n end",
"def loggedIn\n @user = current_user\nend",
"def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\t end\n end",
"def declared_user\n if logged_in?\n if Protege.find_by(user_id: current_user.id.to_i).nil? and Trainer.find_by(user_id: current_user.id.to_i).nil?\n redirect_to root_path\n end\n else\n redirect_to root_path\n end\n end",
"def identify_the_user\n \t@current_user = User.find_by_id(session[\"user_id\"])\n end",
"def logged_in\n logged_in_user != nil\n end",
"def logged_in\n\t \t!current_user.nil?\n\t end",
"def before_request\n self.login if require_login? && !@authenticating\n end",
"def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\tend\n end",
"def before_filter\n if current_user\n true\n end\n end",
"def logged_in_author\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def splash\n @logged_in_user = User.find_by :id => session[:user_id]\n end",
"def require_login\n if current_user\n gon.current_user_email = current_user.email\n gon.current_user_created_at = current_user.created_at.to_i\n gon.current_user_username = current_user.username.capitalize\n gon.current_user_id = current_user.id\n gon.current_user_coaching_intensity = current_user.preference.coaching_intensity\n gon.current_user_last_login_at = current_user.last_login_at\n\n else\n store_location\n flash[:notice] = \"You must be logged in to access this page\"\n redirect_to login_url\n end\n end",
"def get_user_to_act_on\n @user = session[:user]\n end",
"def get_user_to_act_on\n @user = session[:user]\n end",
"def logged_in_user\n unless current_user \n redirect_to root_path\n end\n end",
"def setup \n @user = current_user\n end",
"def login_check\n if session[:user_id].present?\n unless (controller_name == \"user\") and [\"first_login_change_password\",\"login\",\"logout\",\"forgot_password\"].include? action_name\n user = User.active.find(session[:user_id])\n \n \n end\n end\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 enforce_logged_in\n bounce unless current_user\n end",
"def set_current_user\n if logged_in?\n @current_user = current_user\n end\n end",
"def user_on\n session[:user_id] = '3980284084'\n end",
"def logged_in_user\n #this only runs if the user is NOT logged in\n #logged_in method comes from the sessions helper file, and returns a boolean\n unless logged_in?\n #this method comes from the sessions_helper file. it stores where you were trying to go, so that after you log in, it will get you there. reference comments in the helper file.\n store_location\n #adds a flash - it is not flash.now because it is redirected to the login page, so that login page counts as a new request which is what we want.\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in to vote\"\n redirect_to login_url\n end\n end",
"def author_login\r\n user.login if user\r\n end",
"def logged_in_user\n unless logged_in?\n # store current location to automatically redirect user after login\n store_location\n # show a flash message on the page\n flash[:danger] = \"Per favore effettua il login\"\n # redirect user to login page\n redirect_to login_url\n end\n end",
"def load_user_if_logged_in\n if user?\n @user = current_user\n else\n @user = nil\n end\n return true\nend",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Admin Access Only.\"\n redirect_to login_url\n \n end\n end",
"def logged_in\n current_user != nil\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Primero has Log In\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Per compiere quest'azione è necessario effettuare login\"\n redirect_to login_path\n end\n end",
"def set_logged_in_user\n @logged_in_user = logged_in_user\n end",
"def logged_in_user\n\t\tunless logged_in?\n\t\t\tstore_location\n\t\t\tflash[:danger] = \"E' necessario accedere\"\n\t\t\tredirect_to login_url\n\t\tend\n\tend",
"def require_user\n #if not logged in \n if !logged_in?\n flash[:danger] = \"You must be logged in to perform that action\"\n redirect_to root_path\n end\n \n \n end",
"def logging_in\n \t\t\n \tend",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"You must be logged in to use this feature. Please login or make an account.\"\n redirect_to login_url\n end\n end",
"def log_in\n end",
"def set_current_user\n if logged_in?\n whodat = send(Lockdown::Configuration.who_did_it)\n Thread.current[:who_did_it] = whodat\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Veuillez svp vous connecter\"\n redirect_to connexion_url\n end\n end",
"def signed_in_user_filter\n if signed_in?\n redirect_to root_path, notice: \"Already logged in\"\n end\n end",
"def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end",
"def authorize\n @logged_in_user = User.find(session[:user_id])\n rescue\n reset_session\n @logged_in_user = nil\n if User.find(:all).length > 0\n session[:jumpto] = request.parameters\n redirect_to :controller => 'authentication', :action => :login and return false\n else\n redirect_to :controller => 'authentication', :action => :setup and return false\n end\n end",
"def logging_in\n current_user.absorb_from(guest_user)\n end",
"def logged_in_user\n unless logged_in?\n redirect_to root_url\n end\n end",
"def user_logged_in\n if session[:just_logged_in] && !current_user.is_admin \n gon.display_login_popup = true\n \n session[:just_logged_in] = false\n end\n end",
"def logged_in_user\n unless logged_in? #Unless a user is logged in, run this loop\n store_location\n flash[:danger] = \"Please log in to access this material.\" #Flash warning\n redirect_to login_url #Go to login path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Por favor Inicia Sesion.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Вы не вошли на сайт. Пожалуйста выполните вход.\"\n redirect_to login_url\n end\n end",
"def set_current_user\n current_user\n authorize\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Bitte anmelden.\"\n redirect_to login_url\n end\n end",
"def logging_in\n logger.debug \"ApplicationController:logging_in >>> \"\n current_user.transfer_data(guest_user)\n end",
"def initialize_user\n @current_user = User.find_by_id(session[:user]) unless session[:user].blank?\n puts @current_user\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Duhet te kyceni per ta kryer kete veprim!\"\n redirect_to login_url\n end\n end",
"def current_user # Check the current user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n \tend",
"def setup_current_user\n @current_user = User.find(session[:user_id]) unless session[:user_id].nil?\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in first'\n render 'sessions/new', status: :unauthorized\n true # return true to indicate that this triggered things\n end",
"def set_current_user! #naming convention to have the !\n @current_user = User.find_by(id: session[:user_id])\n end",
"def require_login \n # puts \"#{@@count}\" \n # @@count+=1; \n if !(session[:user_id])\n # puts \"#{@@count} require_login method of application controller found no user logged in: \", session[:user_id]\n redirect_to '/main'\n # else\n # puts \"#{@@count} using require_login private method: Someone is already logged in: \", session[:user_id]\n # current_user = User.find(session[:user_id])\n #return current_user\n end\n end",
"def check_user_before_membership\n if current_user\n ncm_membership = current_user.get_membership(@mother)\n epicenter = Epicenter.find_by_slug(params['epicenter_id'])\n\n if epicenter != @mother and not ncm_membership\n session[:new_ncm_membership] = { \n :epicenter_id => params['epicenter_id'], \n :membership_id => params['membership_id'],\n :t => Time.now\n }\n #\n redirect_to new_epicenter_subscription_path(@mother)\n end\n else\n # it's possible that we can put the logic from \"authenticate\" method below here\n redirect_to epicenters_path\n end\n end",
"def logged_in_user\n\t unless logged_in?\n\t store_location # store where the user was going to go (redirects them to it after they log in)\n\t flash[:danger] = \"Please log in.\"\n\t redirect_to login_url\n\t end\n\t end",
"def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash_please_log_in\n redirect_to login_url\n end\n end",
"def logged_in_any\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n\t \t\tunless logged_in?\n\t \t\t\tstore_location\n\t \t\t\tflash[:danger] = t(:please_login)\n\t \t\t\tredirect_to login_url\n\t \t\tend\n\t \tend",
"def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end",
"def logged_in_user\n if user_signed_in? then\n \n else\n redirect_to root_path\n end \n \n end",
"def check_user_before_action\n @blog = Blog.find(params[:id])\n if (current_user != @blog.user) and (@blog.global == false)\n redirect_to({ action: \"index\" }, notice: \"You don't have sufficient permissions\")\n\n end\n end",
"def logged_in_user\n unless logged_in?\n render json: false, status: :unauthorized\n # store_location\n end\n end",
"def current_user\n if session[:user_id]\n @current_user=session[:user_id]\n end\nend",
"def user_authentication\n end",
"def handle_login(u)\n session[:person] = u.id\n end",
"def logged_in_user\n \n unless logged_in?\n\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def authorise\n unless User.find_by_id(session[:user_id]) || (self.controller_name == 'users' && (self.action_name == 'new' || self.action_name == 'create'))\n session[:original_uri] = request.request_uri\n flash[:notice] = \"Please login!\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in first.\"\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n # store intended location to be used for friendly forwarding after\n # the user properly logs in\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logging_in\n end",
"def require_login\n end",
"def check_authenticated\n @logged_in = session[:logged_in]\n end",
"def logged_in_user\n unless logged_in?\n\t store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def user_authorized\n redirect_to \"/\" unless session[:user_id]\n end",
"def current_user\n User.find_by_id(session[:user_id]) if session[:user_id] \n end",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def find_current_user\n # adding if to prevent rails from checking user when logged out\n if is_logged_in?\n #save to a variable\n @current_user = User.find(session[:user_id]);\n else\n @current_user = nil\n end\n end",
"def logged_in_user\n \t\tunless logged_in?\n \t\t\tflash[:error] = \"You must be logged in\"\n \t\tredirect_to login_path\n \t\tend\n \tend",
"def set_logged_in_user_in_audit_module\r\n\t AuditModule.set_current_user=(current_user)\r\n end",
"def logged_in_user\n\t\tunless logged_in?\n\t\tstore_location\n\t\tflash[ :danger] = \"Please log in\"\n\t\tredirect_to login_url\n\tend\n\tend",
"def logged_in_user\n\tunless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in.\"\n\t redirect_to login_url\n\tend\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = 'Du måste logga in.'\n redirect_to login_url\n end\n end",
"def current_user\n@current_user ||= User.find_by(id: session[:user_id])\nend",
"def authenticate!\n\t #when we solve the require relative problem write the line: unless session[:user_id] && User.where(id: session[:user_id])\n\n\t\tif session[:user_id] && User.where(id: session[:user_id]).exists? #if the user id saved in session does not belong to any user, also direct to general homepage\n\t\t\ttrue\n\t\telse\n\t\t\tsession[:original_request] = request.path_info\n\t\t\tfalse\n\t\tend\nend",
"def authorized_user\n unless logged_in?\n store_location\n redirect_to root_url\n flash[:info] = \"You must be logged in to access.\"\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = t(\"users.edit.danger\")\n redirect_to login_url\n end\n end",
"def show\n redirect_to(default_url) unless logged_in? || User.count > 0\n @user = current_user\n end",
"def authorize\n unless @_user = User.find_by_id(session[:user_id])\n# session[:original_uri] = request.request_uri\n flash[:notice] = \"Please login first\"\n redirect_to :controller => :login, :action => :index\n end\n end"
] |
[
"0.7620227",
"0.7241152",
"0.7203908",
"0.71483696",
"0.71065485",
"0.708104",
"0.7080451",
"0.7047475",
"0.7028963",
"0.70267695",
"0.7021245",
"0.70032275",
"0.6993246",
"0.6969713",
"0.6955776",
"0.69535804",
"0.69535804",
"0.6950243",
"0.6941458",
"0.69268006",
"0.6908687",
"0.69042856",
"0.6895128",
"0.6891156",
"0.6879884",
"0.6879724",
"0.68747467",
"0.68706363",
"0.68654937",
"0.6857657",
"0.68545157",
"0.68498737",
"0.68491703",
"0.68450177",
"0.6835134",
"0.68323237",
"0.6823479",
"0.6819952",
"0.6816581",
"0.68157595",
"0.68106204",
"0.68100494",
"0.6803835",
"0.67970276",
"0.67891663",
"0.67873544",
"0.6786884",
"0.6781873",
"0.6780518",
"0.6780332",
"0.67800415",
"0.6779702",
"0.67768943",
"0.6775824",
"0.67727274",
"0.6771931",
"0.67715394",
"0.6770388",
"0.67680943",
"0.67678404",
"0.67671144",
"0.6764667",
"0.676417",
"0.6764156",
"0.6763717",
"0.6763717",
"0.67627215",
"0.6760449",
"0.67589736",
"0.6757508",
"0.67528063",
"0.6750896",
"0.6749684",
"0.6730489",
"0.6724279",
"0.6719367",
"0.6718696",
"0.6712037",
"0.6705154",
"0.6703883",
"0.6691752",
"0.66889673",
"0.66824704",
"0.66803473",
"0.66794956",
"0.66788113",
"0.6676969",
"0.6674627",
"0.66732574",
"0.66731405",
"0.6672553",
"0.6668473",
"0.6666183",
"0.66618735",
"0.6661803",
"0.66574824",
"0.6651481",
"0.6646248",
"0.6645788",
"0.664574",
"0.6642325"
] |
0.0
|
-1
|
We're only going to bother with the first 5 episodes
|
def sync
feed = RSS::Parser.parse(@external_program.podcast_url, false)
return false if !feed || feed.items.empty?
feed.items.first(5).select { |i| can_import?(i) }.each do |item|
episode = @external_program.external_episodes.build(
:title => item.title,
:summary => item.description,
:air_date => item.pubDate,
:external_id => item.guid.content
)
# Import Audio
enclosure = item.enclosure
audio = Audio::DirectAudio.new(
:external_url => enclosure.url,
:size => enclosure.length,
:description => episode.title,
:byline => @external_program.title,
:position => 0
)
episode.audio << audio
end
@external_program.save!
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name => name).first.episode\n else\n last_season = 1\n last_episode = 1\n end\n\n current_season = Tmdb::Season.detail(id, last_season)\n if !current_season['episodes'].nil?\n episodes = current_season['episodes'][last_episode.to_i, current_season['episodes'].length]\n\n number_of_seasons = show['number_of_seasons']\n ((last_season.to_i + 1)..number_of_seasons.to_i).each do |season_number|\n season = Tmdb::Season.detail(id, season_number)\n new_episodes = season['episodes'][0, season['episodes'].length]\n episodes.concat(new_episodes)\n end\n episodes\n else\n nil\n end\n end",
"def latest_episode(index=0)\n latest_ep = nil\n\n\n# self.live_episodes.each do |ep|\n## puts \"#{__FILE__}:#{__LINE__} #{__method__} #{ep.release_date_unix} - #{ep.name}\"\n# latest_ep = ep if latest_ep == nil\n# latest_ep = ep if latest_ep.release_date_unix.to_i < ep.release_date_unix.to_i\n# end\n self.released_episodes.each_with_index do |ep, idx|\n latest_ep = ep if idx == index\n end\n\n sd = ShowDate.new(latest_ep.release_date_unix.to_i) if latest_ep\n sd = ShowDate.new(Time.new.to_i) unless latest_ep\n\n# puts \"#{__FILE__}:#{__LINE__} #{__method__} SD: #{sd.timestamp} - #{self.name} - #{sd.inspect} - #{sd.month_str}, #{sd.day_of_month} ,#{sd.year}\"\n\n sd\n end",
"def index\n @series = Series.find(params[:series_id].to_i)\n @new_episodes = @series.episodes.where(:seen => false).order(\"season desc, episode desc\")\n @seen_episodes = @series.episodes.where(:seen => true).order(\"season desc, episode desc\")\n end",
"def episode; end",
"def episode; end",
"def episode; end",
"def episode; end",
"def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = true\n \n # for now we are only interested in episodes greater than our first one and \n # inclusive of the whole season\n if season.to_i < season_first.to_i \n missing = false\n end\n \n if $config[\"missing\"][\"start_at_first_found\"]\n if episode_first.to_i > episode.to_i \n missing = false \n end\n end\n \n missing\nend",
"def next_episode\n # Not ep(@current_ep + 1) because episodes are not guaranteed to be in\n # sequence (i.e. we could have episodes 1, 2, 4, 5 etc.)\n idx = @episodes.map(&:number).index(@current_ep)\n if idx + 1 < @episodes.size\n @episodes[idx + 1]\n else\n ep(@current_ep)\n end\n end",
"def pushSeason (index, reviews, grades, validSeasons, episodesPerSeason)\n \tputs \"season \" + validSeasons[index].inner_html\n \tif index != 0 then\n \t\tseason = reviews.link_with(class: \"badge season-\" + validSeasons[index].inner_html).click.search('.grade.letter.tv').reverse\n \telse\n \t\tseason = reviews.search('.grade.letter.tv').reverse\n \tend\n\n \ttopJunk = season[season.size - 1] # grabs top element from array\n\n \twhile season[season.size - 1] == topJunk\n \t\tseason.pop\n \tend\n\n \t#season.pop\n\n \t#season.delete(topJunk)\n\t #season.pop # the latest episode is at the top of every page, remove it from the list\n\n\t # for some reason, every couple of days I will test this program and this section messes me up.\n\t # Some days it needs 3 pops to get the right number of episodes, other days it needs 1 pop.\n\t # There's probably a better way of removing duplicates, but I have yet to implement that. Definitely on the to-do list.\n\n\t #season.pop # maybe implement something where you fetch the top episode's ID and make sure the last one isn't that,\n\t #season.pop # except in the caes of the final season/latest season of the show where it is.\n\t season = season.reverse\n\t puts season.length.to_s + \" episodes\"\n\t episodesPerSeason.push(season.length.to_i)\n\t while season.length > 0 do\n\t \tgrades.push(season.pop.inner_text())\n\t end\n\tend",
"def first_episode_number\n @first_episode_number || 1\n end",
"def load_series! api\n @seasons = 1 # determined later\n @episodes = []\n current_season = 1\n begin\n season_url = url + '/episodes?season=%d' % current_season\n load_season!(api, season_url, current_season)\n current_season+=1\n end until current_season > @seasons\n\n # number all episodes\n num = 1\n @seasons.times do |season|\n sorted_episodes = get_season(season+1).sort_by {|epi| epi.episode}\n sorted_episodes.each do |epi|\n epi.number = num\n num += 1\n #debug '%s S%02dE%02d [%d] -- %s' % [title, epi.season, epi.episode, epi.number, epi.airdate]\n end\n end\n\n # remove pages:\n @episodes.each do |episode|\n episode.page = nil\n end\n\n @series_loaded = true\n end",
"def show\n puts \"++++++++ star#show\"\n @star = Star.find(params[:id])\n @episodes = @star.episodes\n #@episode = Episode.new\n #@podcasts = Podcast.all #we don't need all the podcasts.\n\n star_query = @star.name.strip.gsub(/\\s+/, \"+\")\n\n #this works, but super innefficient. \n def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end\n\n if @star.last_search == nil\n s = @star\n s.last_search = Date.today - 10.days\n puts s.last_search\n s.save\n end\n\n l = @star.last_search < (Date.today - 2.days)\n puts l \n #works\n\n if l == true \n many_episodes = all_eps(star_query, 0)\n many_episodes.select! do |e| \n limit = Date.today - 3.years\n def comparable_date(f)\n sec = (f[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n end\n comparable_date(e) > limit\n end #holy shit this works! Needs cleanup\n\n #save each episode - works\n many_episodes.each do |ep|\n new_ep = Episode.new\n pod_name = ep[\"podcast_title_original\"]\n pod = Podcast.find_or_create_by(name: pod_name)\n new_ep.star_id = @star.id\n new_ep.podcast_id = pod.id\n new_ep.title = ep[\"title_original\"]\n new_ep.description = ep[\"description_original\"]\n new_ep.api_id = ep[\"id\"]\n sec = (ep[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n new_ep.release_date = dform\n new_ep.save\n end\n\n @episodes_arr = many_episodes.sort_by { |e| e[\"pub_date_ms\"]}.reverse\n @star.last_search = Date.today\n @star.save\n else\n puts \"WE DIDN RUN THE SEARCH\"\n end\n @display_episodes = @episodes.where(display: true)\n end",
"def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end",
"def get_all_free_episode_links_for_each_show_on_vland\n \t\tShow.all.each do |show|\n \t\t\tputs \"getting epsides for #{show.url}\"\n \t\t\t# sometimes its nice to take a 2-3 sec nap\n \t\t\tsleep(rand(2..3))\n \t\t\tresp = get_resp(show.url)\n \t\t\t# this is the point where I got tired of heavy lifting\n \t\t\thtml_result = Nokogiri::HTML.parse(resp.body)\n \t\t\thtml_result.css(\".entry-card\").each do |clip|\n \t\t\t\t# skip episdes / clips that are not free to watch, may also one day limit it to just episodes.\n \t\t\t\tnext if clip.css(\".unlockable\").first.to_s.include? \"icon-locked\"\n \t\t\t\t# grabs sub link to epsides or clip\n \t\t\t\tepisode_or_clip_url = clip.css(\".cta\").attr(\"href\").to_s\n \t\t\t\t#getting rid of a \"/\" at the start\n \t\t\t\tepisode_or_clip_url[0] = \"\"\n\n \t\t\t\t# lets create some links pertaining to shows and clips from shows\n \t\t\t\tep = Episode.find_or_initialize_by(url: self.url + episode_or_clip_url)\n \t\t\t\tif ep.new_record?\n \t\t\t\t\tep.show_id=show.id\n \t\t\t\t\t#can do fancy stuff here like grab all show episode / clip fields \n \t\t\t\t\tep.save!\n \t\t\t\tend\n \t\t\tend\n \t\tend\n \tend",
"def last_n_events(n)\n events.where(['date < ?', Date.today]).first(5)\n end",
"def recent_videos\n videos.first(6)\n end",
"def episodes\n Episode.all.select{ |episode| episode.show == self }\n end",
"def reccomend_me\n event_list = score_events.keys\n event_list.first 5\n end",
"def new_episodes( season )\n return @seasons[season][1].flatten\n end",
"def getHalfMinuteArticle(showURL,theYear,defaultDate)\n\tpage = Nokogiri::HTML(open(showURL))\n\tshowTitle = page.css('td#contentTd table td h3 strong.title').text.strip\n\tshowDescription = page.css('td#contentTd p').text.strip\n\tepisodeTable = page.css('td#contentTd table td a.hmenu')\n\tepisodeTitle = []\n\tepisodeURL = []\n\tepisodeDate = []\n\tepisodeMaster = []\n\tepisodeDesc = []\n\t\t\n\tepisodeTable.each do |t|\n\t\tepisodeURL.push('http://www.moneyradio.org/'+t['href'])\n\t\ttitleText = t.text.strip\n\t\t#episodeDate.push(titleText.index(theYear))\t\t\n\t\tif(titleText.index(theYear).nil?)\n\t\t\tepisodeDate.push(Date.strptime(defaultDate, '%m/%d/%Y'))\n\t\t\tepisodeTitle.push(t.text.strip)\n\t\t\t#use this print out to debug\n\t\t\t#puts t.text.strip\n\t\telse\n\t\t\tif titleText.index('1011/2007') # this is special case in 2007\n\t\t\t\tepisodeDate.push(Date.strptime(defaultDate, '%m/%d/%Y'))\n\t\t\t\tepisodeTitle.push(t.text.strip)\t\t\t\t\n\t\t\telse\n\t\t\t\tepisodeDate.push(Date.strptime(titleText[0..(titleText.index(theYear)+theYear.length-1)], '%m/%d/%Y'))\n\t\t\t\tepisodeTitle.push(titleText[(titleText.index(theYear)+theYear.length)..titleText.length].to_s.strip)\n\t\t\tend\n\t\t\t#use this print out to debug\n\t\t\t#puts t.text.strip\n\t\tend\n\tend\n\tf = 0\n\t#episodeURL = episodeURL[0..4]\n\tepisodeURL.each do |c|\n\t\tarticlePage = Nokogiri::HTML(open(c))\n\t\tcontent = articlePage.css('td#contentTd p').text.strip\n\t\t#puts content\n\t\tepisodeDesc.push(content)\n\t\tputs f.to_s\n\t\tputs episodeDate[f]\n\t\tputs episodeTitle[f]\n\t\tsleep(3)\n\t\tf = f+1\n\tend\n\t#puts \"title: \"+episodeTitle.length.to_s + \"content: \"+episodeDesc.length.to_s\n\tk = 0\n\tepisodeURL.each do |j|\n\t\tepisode = EpisodePage.new\n\t\tepisode.name = episodeTitle[k]\n\t\tepisode.date = episodeDate[k]\n\t\t#episode.url = j\n\t\tepisode.desc = episodeDesc[k]\n\t\tk = k + 1\n\t\tepisodeMaster.push(episode)\n\tend\n\treturn episodeMaster\nend",
"def episode_number\n return 0 if link_url == 'https://shows.acast.com/easyeaspanish/episodes/trailer'\n if podcast.code == 'easygreek'\n link_url[%r{/episodes/(\\d+)}, 1]&.to_i\n else\n slug[/^\\d+/]&.to_i\n end\n end",
"def episodes( season )\n return @seasons[season].first.flatten\n end",
"def get_episode_info\n\n\t\tbegin\n\t\t\turl = source_url\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/miss-undercover,5cd28786818965652bf912ab.html\"\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/monitor,5cda852e81896518171f509c.html\"\n\t\t\tdoc \t\t\t= send_request(url)\n\t\t\tdata \t\t\t= doc.css(\"article.broadcast-detail\")\n\t\t\t# header \t\t= doc.css(\"header.broadcast-detail__header\")\n\t\t\t# duration \t\t= header.css(\"div.text-wrapper span.text-row\")[1].text[-7..-2] rescue nil\n\t\t\tchannel \t\t= doc.css(\"span.tv-show-label__channel\").text\n\t\t\tvideo \t\t\t= get_video_url(doc)\n\t\t\tdescription = doc.css(\"section.broadcast-detail__description p\").text.delete(\"\\\"\").delete(\"\\r\").delete(\"\\n\")\n\t\t\tcast \t\t\t= doc.css(\"section.cast dl\")\n\t\t\tcasts \t\t\t= get_cast(cast[0])\n\t\t\tactors \t\t\t= get_cast(cast[1])\n\t\t\tthumb = doc.css('div.editorial-rating')[0].values[0].split(\" \")[1] rescue nil\n\t\t\t# transmitter_valid(channel)\n\t\t\timage = doc.css(\".broadcast-detail__stage img\").first.attributes[\"src\"].value rescue []\n\t self.program.update(genre: casts[\"Genre\"]) if (casts[\"Genre\"].present? && program.genre.nil?)\n\t\t\t\n\t\t\tparam = {is_scraped: true} \n\t\t\tparam.merge!(preview_video_url: video) if video.present?\n\t\t\tself.update(param)\n\n\t self.episode_infos.create(description: description, country: casts[\"Land\"], year: casts[\"Jahr\"],age_rating: casts[\"Altersfreigabe\"], director: casts[\"Regie\"], producer: casts[\"Produzent\"], script: casts[\"Drehbuch\"], camera: casts[\"Kamera\"], music: casts[\"Musik\"], original_title: casts[\"Originaltitel\"], actors: actors ,thumb: thumb, image_urls: image)\n\t get_rating(doc)\n\t rescue StandardError => e\n\t \tRails.logger.info \"================================================\"\n\t \tRails.logger.info \"Having some issues during storing episode info.\"\n\t \tRails.logger.info \"#{e}\"\n\t end\n\tend",
"def recent_videos\n videos = self.videos\n\n return [] unless videos\n videos.first(6)\n end",
"def episode_show_pagination\n\t\tself.class.episode_show_pagination( self, @show )\n\tend",
"def add_episode_to_podcasts\n \tPodcast.all.each do |podcast|\n show_hash = Scraper.scrape_show_page(podcast.show_page_url)\n \t podcast.add_episode_name(show_hash)\n \tend\n end",
"def thetvdb_missing_plex_first_ep(show)\n log_debug\n first_ep = '0;0'\n \n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n if first_ep == '0;0' \n first_ep = \"#{season};#{episode}\"\n end\n end\n end\n \n return first_ep.split(';')\nend",
"def extract_video_page_urls(webpage,options)\r\n puts \"Extracting data from html5 data\"\r\n webpage.css('li.regularitem').each do |post|\r\n link = post.css('h4.itemtitle').css('a').first\r\n description = post.css('div.itemcontent').first.text\r\n download_episode(link.child.text,link['href'],description, options)\r\n end\r\nend",
"def thetvdb_missing_last_process(show)\n log_debug\n \n $thetvdb.show(show)\n\n season_last, episode_last = thetvdb_missing_plex_last_ep(show)\n season_first, episode_first = thetvdb_missing_plex_first_ep(show)\n log_debug(\"#{show} start s#{season_first}e#{episode_first} : last s#{season_last}e#{episode_last}\")\n\n if $thetvdb.episodes.has_key?(show)\n $thetvdb.episodes[show]['episodes'].keys.each do |season|\n next if season == \"0\"\n \n $thetvdb.episodes[show]['episodes'][season].keys.each do |episode|\n first_aired = $thetvdb.episodes[show]['episodes'][season][episode]['first_aired']\n show_index = show_index(season, episode)\n plex_has = thetvdb_missing_plex_found(show,season,episode)\n missing = thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = false if plex_has\n \n if first_aired =~ /\\w/\n date_available = Date.today\n date_aired = Date.parse first_aired\n if ( date_available > (date_aired + 1) ) and missing\n missing_process show, show_index,\"aired: #{first_aired}\"\n end\n end\n end\n end\n end\nend",
"def episode\n\t\tlimit = params[:limit] || Setting['vms-protected-visible-episode-comment-count'].value_typed\n\t\tstart_at_id = params[:start_at_id]\n\n\t\t# ensure no one abuses the system\n\t\tlimit = Setting['vms-protected-visible-episode-comment-count'].value_typed if limit > Setting['vms-protected-visible-episode-comment-count'].value_typed\n\t\t@episode = Episode.find( params[:id], :readonly => true )\n\t\tif !@episode.available? or !@episode.show.available?\n\t\t\tredirect_to home_url and return\n\t\tend\n\t\topts = {:limit => limit, :order => 'id DESC', :readonly => true}\n\t\topts[:conditions] = ['id < ?',start_at_id] unless start_at_id.nil?\n\t\t@comments = @episode.episode_comments.find( :all, opts )\n\t\tuser_ids = @comments.collect{|c| c.user_id }.uniq\n\t\t@users = User.all( :conditions => { :id => user_ids }, :readonly => true )\n\t\trespond_to do |format|\n\t\t\tformat.json do\n\t\t\t\trender( :json => '{ comments: {' + @comments.collect{|x| x.to_json}.join(',') + '}, users: {' + @users.collect{|x| x.to_public_json}.join(',') + '} }' ) and return\n\t\t\tend\n\t\tend\n\tend",
"def fetch_episodes_for_playlist(user)\n all_episodes_array = []\n favorites_on_array = Favorite.where(user_id: user.id, playlist_on_off: \"on\")\n favorites_on_array.each do |favorite_instance|\n all_episodes_array += fetch_episodes_by_id(favorite_instance.show_id)\n end\n add_playlist_to_table(all_episodes_array, user)\nend",
"def episode\n fetch('cowboy_bebop.episode')\n end",
"def init\n update_episodes\n end",
"def index\n if params[:id]\n @pieces = Piece.published.where('id < ?', params[:id]).limit(5)\n else\n @pieces = Piece.published.limit(5)\n end\n end",
"def index\n @episodes = @season.episodes\n end",
"def latest_five\n self.find :all, :limit=>5, :order => \"created_at desc\"\n end",
"def end_of_feed?\n load_result.videos.length < 25\n end",
"def getArticleWithHTML(showURL)\n\tpage = Nokogiri::HTML(open(showURL))\n\tshowTitle = page.css('td#contentTd table td h3 strong.title').text.strip\n\tshowDescription = page.css('td#contentTd p').text.strip\n\tepisodeTable = page.css('td#contentTd table td a.hmenu')\n\tepisodeTitle = []\n\tepisodeURL = []\n\tepisodeDate = []\n\tepisodeMaster = []\n\tepisodeDesc = []\n\t\t\n\tepisodeTable.each do |t|\n\t\tepisodeURL.push('http://www.moneyradio.org/'+t['href'])\n\t\ttitleText = t.text.strip\n\t\tputs titleText\n\tend\n\tf = 0\n\t#episodeURL = episodeURL[0..4]\n\tepisodeURL.each do |c|\n\t\tarticlePage = Nokogiri::HTML(open(c))\n\t\tcontent = articlePage.css('td#contentTd p').text.strip\n\t\tputs content\n\t\tepisodeDesc.push(content)\n\t\t#puts f.to_s\n\t\t#puts episodeTitle[f]\n\t\tsleep(3)\n\t\tf = f+1\n\tend\n\t#puts \"title: \"+episodeTitle.length.to_s + \"content: \"+episodeDesc.length.to_s\n\tk = 0\n\tepisodeURL.each do |j|\n\t\tepisode = EpisodePage.new\n\t\tepisode.name = episodeTitle[k]\n\t\tepisode.date = ''\n\t\t#episode.url = j\n\t\tepisode.desc = episodeDesc[k]\n\t\tk = k + 1\n\t\tepisodeMaster.push(episode)\n\tend\n\treturn episodeMaster\nend",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def get \n log_debug\n $plex.episodes.keys.each do |show|\n thetvdb_missing_last_process(show)\n end\nend",
"def show\n @query = Episode.where(podcast_id: @podcast.id).search(params[:q])\n if params[:q]\n @query.sorts = 'pub_date desc' if @query.sorts.empty?\n @episodes = @query.result.paginate(:page => params[:page], :per_page => 15)\n else\n @episodes = @podcast.episodes.order(pub_date: :desc).paginate(:page => params[:page], :per_page => 15)\n end\n end",
"def size\n @episodes.size\n end",
"def get_upcoming_episodes(seriesid)\n # See if we already have both a name for the series, if there exists a name episodes should be updated\n seriesInformation = SeriesInformation.find_by seriesid: seriesid\n upcomingEpisodes = EpisodeInformation.where(seriesid: seriesid)\n if seriesInformation.nil?\n seriesInformation,upcomingEpisodes = initialize_cache_and_return_data(seriesid)\n end\n # If, for some reason, neither database lookup or cache updating didn't return an array, create one.\n if upcomingEpisodes.nil?\n upcomingEpisodes = Array.new\n end\n upcoming_episodes_for_return = Array.new\n # Go through list of episodes found\n for j in 0..(upcomingEpisodes.length-1)\n # Check if episode is still in the future\n if(upcomingEpisodes[j].firstaired > Date.today.prev_day)\n upcoming_episodes_for_return.push(upcomingEpisodes[j])\n else\n # If not, delete it (should be safe to do here as the data is only removed from database, not from array)\n # NOTE: This is the only place old episodes are pruned out when updates are not occurring. This should probably also be in a cleanup function. \n upcomingEpisodes[j].delete\n end\n end\n return upcoming_episodes_for_return\n end",
"def episode(*args)\n if args.first.is_a? String\n episode_by_title *args\n else\n episode_by_numbers *args\n end\n end",
"def index\n @last_episodes = current_user.last_episodes\n end",
"def only_five(arr)\n index = 0\n new_arr = []\n until index == 5\n new_arr << arr[index]\n index += 1\n end\n new_arr\nend",
"def shows_with_blanks(festival_start)\n @shows_with_blanks = []\n @current_time_check = festival_start\n i = 0\n until i >= @shows_at_venue_per_day.length\n start_of_show = @shows_at_venue_per_day[i].start_date_time\n find_show_start_time(start_of_show)\n @shows_with_blanks << @shows_at_venue_per_day[i]\n @current_time_check = @shows_with_blanks.last.end_date_time\n check_previous_end_time(start_of_show, end_time_of_previous_show)\n i += 1\n end\n return @shows_with_blanks\n end",
"def next5\n x = @exact[0,5]\n x + @list[0,5 - x.size]\n end",
"def ep(ep_num)\n idx = @episodes.map(&:number).index(ep_num.to_i)\n return nil if idx.nil?\n @episodes[idx]\n end",
"def generate_top_tracks(year)\n weeklycharts = lastfm.user.get_weekly_chart_list(\"pulleasy\")\n weeklycharts.each do |weekly_chart|\n charts = []\n if weekly_chart[\"from\"] > year.to_time.to_i && weekly_chart[\"to\"] < year.next_year.to_time.to_i\n charts << weekly_chart\n end\n end\nend",
"def episodes_get\n log_debug\n\n # build syntax if we looking for a specific show\n show_wanted = ''\n \n if self.show\n show_wanted = \"and title = '#{self.show}'\"\n end\n \n sql_shows = \"select id,title,guid from metadata_items where metadata_type=2 and library_section_id in (select id from library_sections where section_type = 2) #{show_wanted} order by title\" \n \n sql_select(sql_shows).each do |row_shows|\n\n sql_seasons = \"select id,\\\"index\\\" from metadata_items where metadata_type=3 and parent_id=#{row_shows[0]} order by \\\"index\\\"\"\n sql_select(sql_seasons).each do |row_seasons|\n show = row_shows[1]\n season = row_seasons[1]\n guid = row_shows[2] \n \n sql_episodes = \"select \\\"index\\\",title, id from metadata_items where metadata_type=4 and parent_id=#{row_seasons[0]} order by \\\"index\\\"\"\n sql_select(sql_episodes).each do |row_episodes|\n episode = row_episodes[0]\n name = row_episodes[1]\n metadata_item_id = row_episodes[2]\n \n #puts \"metadata_item_id : #{metadata_item_id}\"\n episodes_track show, season, episode, name\n found_debug show, season, episode, name \n \n sql_items = \"select id from media_items where metadata_item_id = #{metadata_item_id}\"\n sql_select(sql_items).each do |row_items|\n media_items_id = row_items[0]\n # puts \"media_items_id : #{media_items_id}\"\n \n sql_parts = \"select file from media_parts where media_item_id = #{media_items_id}\"\n sql_select(sql_parts).each do |row_parts|\n file = row_parts[0]\n # puts \"file : #{file}\"\n shows_track show, guid, season, file\n \n end\n \n end\n\n \n end\n end\n end\n\n end",
"def getEpisodeToPlay(client)\n\n\t\tbegin\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='海外ドラマ' and @id='textView']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='見放題で楽しめる厳選良作!海外ドラマ編']\")\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recyclerView' and ./preceding-sibling::*[./*[@text='見放題で楽しめる厳選良作!海外ドラマ編']]]/*/*/*[@id='imageView' and ./parent::*[@id='maskLayout']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@id='searchButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=国内ドラマ一覧\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=すべての作品\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=見放題\", 0, 1)\n\t\t\t\tclient.sleep(3000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*[@id='thumbnail'])\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\tend\n\t\t\tclient.swipe2(\"Down\", 250, 2000)\n\t\t\tclient.sleep(3000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\")\n\t\t\t\tclient.click(\"NATIVE\", \"text=エピソードを選択\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*/*[@id='download_indicator' and ./parent::*[@id='image_container']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(10000)\n\t\t\t\tHistoryPlay.new.playbackCheck(client)\n\t\t\t\tHistoryPlay.new.leavingPlayer(client)\n\t\t\telse\n\t\t\t\tputs \"::MSG:: This contents does not have episode list!!!\"\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Error occurred while episode playing..\" + e.message\n\t\t\t$obj_rtnrs.returnNG\n\t\tend\t\t\n\t\tclient.sleep(2000)\n\tend",
"def find_shows(page)\n # Looks like it is consistent in the classes it uses\n # so grab what we need\n page.search(\".entry-content-live\").map do |elem|\n dateNode = elem.at(\".artist_date\")\n # convert the date so we can see the year\n date = Date.today\n unless dateNode.nil?\n # it is delimited by '|' and the date is on the first index\n date = Date.parse(dateNode.text.strip.split(\"|\")[0])\n # if its parsed to be before today then in actual the following year\n if date < Date.today\n date = date.next_year()\n end\n end\n # openers are delimited by '|'\n supports = []\n supportsNode = elem.at(\".openers\")\n unless supportsNode.nil?\n supports = supportsNode.text.strip.split(\"|\").map do |support|\n support.strip\n end\n end\n # create the show object\n {\n venue: \"Rock & Roll Hotel\",\n date: date,\n headliner: grab_text(elem, \".artist_title a\", \"\"),\n support: supports\n }\n end\n end",
"def index\n @next_sessions = Event.where('events.date >= ?', Date.today)\n .order('date ASC').first&.sessions\n\n @most_recent = Meetup.active.joins(:events).where('events.date < ?', Date.today)\n .order('date DESC').first(3)\n @most_popular = Meetup.active.joins(:events).where('events.date < ?', Date.today)\n .joins(\"LEFT OUTER JOIN sessions AS meetup_sessions ON \" +\n \"meetup_sessions.meetup_id = meetups.id LEFT OUTER JOIN \" +\n \"assistances ON assistances.session_id = meetup_sessions.id\")\n .group(:id)\n .order('COUNT(assistances.id) DESC').first(3)\n end",
"def main\n @trainings = Training.limit(12).order(date: :desc)\n #En el root muestro los 12 últimos entrenamientos, de quien sean\n end",
"def episode_title; end",
"def thetvdb_missing_plex_last_ep(show)\n log_debug\n last_ep = '0;0'\n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n last_ep = \"#{season};#{episode}\"\n end\n end\n \n return last_ep.split(';')\nend",
"def bottom_five(db)\r\n\t\tputs \"\\t -- Worst Five -- \"\r\n\t \tputs \" - - Title - - Rating - - Comments - - \"\r\n\t\tmovie = db.execute(\"SELECT * FROM movies WHERE rating = 1 ORDER BY title ASC LIMIT 5\")\r\n\t\tmovie.each do |mov|\r\n\t\t\tprintf \" * %-13s| %-4s| %-5s\\n\", \"#{mov['title']}\", \"#{mov['rating']}\", \"#{mov['comments']}\"\r\n\t\tend\r\n\t\tputs\"-\"*60\r\n\tend",
"def last_five_builds\n last_builds(5)\n end",
"def index\n @episodes = Episode.all\n @views_chart = get_all_views(@episodes)\n @change_chart = get_all_differences(@episodes)\n end",
"def thetvdb_missing_plex_found(show,season,episode)\n plex_has = false\n \n # remove shows that we have\n if $plex.episodes.has_key? show \n if $plex.episodes[show].has_key?(season.to_i)\n if $plex.episodes[show][season.to_i].has_key?(episode.to_i)\n plex_has = true \n end\n end\n end\n plex_has\nend",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def finished_at\n @episodes.last.first_watched\n end",
"def explore\n @users = User.all\n @TopChart = Song.all\n @TopArtist = User.last(5)\n @topDJ = Broadcaster.find_by_sql(\"select * from broadcasters where is_playing = true order by num_listeners DESC limit 5\")\n end",
"def events_seven_days()\n events = []\n today = Date.today\n for i in 0..6 do\n events += events_by_date(today + i)\n end\n return events\nend",
"def shows_at_venue_per_day(week_day)\n festival_start = find_days_start_time(week_day)\n shows_at_venue = Event.where(\"venue_id\" => @venue.id)\n @shows_at_venue_per_day = []\n shows_at_venue.each do |show|\n if show.weekday == week_day\n @shows_at_venue_per_day << show\n end\n end\n if @shows_at_venue_per_day != []\n @shows_at_venue_per_day.sort_by! { |obj| obj.start_date_time}\n shows_with_blanks(festival_start)\n fill_out_final_blanks(festival_start)\n end\n return @shows_with_blanks\n end",
"def top_five(db)\r\n\t \tputs \"\\t -- Top Five -- \"\r\n\t \tputs \" - - Title - - Rating - - Comments - - \"\r\n\t\tmovie = db.execute(\"SELECT * FROM movies WHERE rating = 10 ORDER BY title ASC LIMIT 5\")\r\n\t\tmovie.each do |mov|\r\n\t\t\tprintf \" * %-13s| %-4s| %-5s\\n\", \"#{mov['title']}\", \"#{mov['rating']}\", \"#{mov['comments']}\"\r\n\t\tend\r\n\t\tputs\"-\"*60\r\n\tend",
"def index\n @episodes = Episode.online.desc_human.recommend_before_today\n\n _project_ids = @episodes.pluck(:project_list).map{|x| x.split(\",\") }\n project_ids = _project_ids.flatten.map(&:to_i)\n\n projects = Project.online.where(id: project_ids).includes(:github_info, :category => :catalog)\n\n # @recommend_gems = projects.gemspec.includes(:github_info, :category => :catalog)\n\n # @recommend_pods = projects.pod.includes(:github_info, :category => :catalog)\n end",
"def fifth\n at(4)\n end",
"def final_ep\n @episodes.last.number\n end",
"def episodes \n object.episodes.collect do |episode|\n { \n :episode_code => episode.episode_code, \n :episode_name => episode.episode_name\n }\n end \n end",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def up_gallery_has_room\n\t\tif page == frames[0]\n\t\t\tnum = image.date_taken.strftime(\"%d\").to_i/7 \n\t\t\t@up_gallery_beg_range = image.date_taken.beginning_of_month+num.weeks \n\t\t\t@up_gallery_end_range = @up_gallery_beg_range+6.days \n\t\tend\n\t\t(date_taken=(up_gallery_beg_range..@up_gallery_end_range)&page=true).count < 5\n\tend",
"def find_and_set_season_episode_fields\n @season_ep_field_pos = nil\n SeasonEp_Regexps.each do |re|\n @filename_fields.each_with_index do |fn_field, idx|\n if fn_field =~ re\n @season_ep_field_pos = idx\n @result[:season] = $1.to_i\n @result[:episode] = $2.to_i\n break\n end\n end\n break unless @season_ep_field_pos.nil?\n end\n @season_ep_field_pos\n end",
"def index\n query = \"https://itunes.apple.com/lookup?id=#{params[:podcast_id]}\"\n feed_url = params[:feedUrl] || itunes_query_results(query)[0]['feedUrl']\n hashed_xml = Crack::XML.parse(open(feed_url).read)['rss']['channel']\n parsed_episodes = parse_episodes(hashed_xml)\n # parsed_episodes = EpisodeLoader.find(feed_url)\n # for DB saving, changing from JSON camelCase to Rails snake_case\n snaked_episodes = parsed_episodes.map(&:to_snake_keys).take(100)\n current_guids = Episode.where(collection_id: params[:podcast_id]).map(&:guid)\n snaked_episodes.each do |episode|\n new_episode(episode) unless current_guids.include?(episode[:guid])\n # new_episode_with_status(episode) unless Episode.find_by_guid(episode[:guid])\n end\n render json: Podcast.find(params[:podcast_id]).episodes\n # render json: parsed_episodes\n end",
"def episode_list(sid)\n xml = get('/feeds/episode_list.php', :query => {:sid => sid})\n xml[\"Show\"]\n end",
"def episode_number\n @ole.EpisodeNumber\n end",
"def run(dont_update_last_run)\n\t\t\tdate = check_date\n\n\t\t\tmyepisodes = MyEpisodes.new(@config[:myepisodes_user], @config[:cookie])\n\t\t\t# Log in using cookie by default\n\t\t\tmyepisodes.load_cookie\n\t\t\tshows = myepisodes.get_shows(date)\n\t\t\t\n\t\t\tif shows.empty?\n\t\t\t\tputs \"Nothing to download\"\n\n\t\t\telse\n\t\t\t\tt = Torrent.new(@config[:grabber])\n\t\t\t\tto_download = fix_names(shows)\n\n\t\t\t\tqueue = Queue.new\n\t\t\t\t\n\t\t\t\t# Adds a link (or empty string to the queue)\n\t\t\t\tlink_t = Thread.new do\n\t\t\t\t\tto_download.each { |show| queue << get_link(t, show) }\n\t\t\t\tend\n\n\t\t\t\t# Downloads the links as they are added\n\t\t\t\tdownload_t = Thread.new do\n\t\t\t\t\tto_download.size.times do\n\t\t\t\t\t\tmagnet = queue.pop\n\t\t\t\t\t\tnext if magnet == \"\" # Doesn't download if no torrents are found\n\t\t\t\t\t\tdownload(magnet)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Downloading the subtitles\n\t\t\t\t# subs_t = @config[:subs] and Thread.new do\n\t\t\t\t# \tto_download.each { |show| @s.get_subs(show) }\n\t\t\t\t# end\n\n\t\t\t\tlink_t.join\n\t\t\t\tdownload_t.join\n\t\t\t\t# subs_t.join\n\n\t\t\t\tputs \"Completed. Exiting...\"\n\t\t\tend\n\n\t\t\t@config[:date] = Date.today unless dont_update_last_run\n\n\t\trescue InvalidLoginError\n\t\t\twarn \"Wrong username/password combination\"\n\t\tend",
"def started_at\n @episodes.first.first_watched\n end",
"def getNextShow()\n #todo: implement priority checking\n #this query only grabs shows that should currently be recording\n #assume shows do not overlap, just the padded times overlap\n shows = Array.new\n now_showing = \"SELECT DATE_FORMAT(start, '#{DATE_TIME_FORMAT_XML}') as start, \n DATE_FORMAT(p.stop, '#{DATE_TIME_FORMAT_XML}') as stop, \n number, filename, p.xmlNode as xmlNode, channelID, priority\n FROM Scheduled s JOIN Channel USING (channelID)\n JOIN Programme p USING(channelID, start)\n WHERE start <= '#{PaddedTime.strstart}'\n AND p.stop > '#{PaddedTime.strstop}'\"\n \n databasequery(\"SELECT * FROM (#{now_showing}) as sub1\n WHERE priority = (SELECT max(priority) FROM (#{now_showing}) as sub2 )\").each_hash { |show_hash| \n shows << Show.new(show_hash['start'], \n show_hash['stop'], \n show_hash['number'], \n show_hash['xmlNode'], \n show_hash['filename'], \n show_hash['channelID'])\n }\n return nil if shows.length == 0\n if shows.length > 1\n #we have adjacent shows, or at least close enough so they overlap when padded\n shows.sort! {|a,b| a.starts_in <=> b.starts_in }\n (1...shows.length).each {|pos|\n shows[pos-1].unpad(shows[pos])\n }\n shows.delete_if { |show| show.notShowing }\n end\n #LOG.debug(\"The next show to record is #{shows[0].filename}\")\n shows[0]\nend",
"def handle_series(episode)\n tvdb_result = series_lookup(episode) if ($opt[\"tvdb\"]) && (! @tvdb_episodes.has_key?(episode.show))\n if tvdb_result == false\n handle_error(\"failed to find tvshow \\'#{episode.show}\\' from tvdb, skipping..\") if $opt[\"debug\"]\n return false\n end\n re_cache = episode.fix_via_tvdb @tvdb_episodes if $opt[\"tvdb\"] and @tvdb_episodes.has_key?(episode.show)\n\n # we do one round of re-caching only if the episode name is not found\n if re_cache\n log(\"re-caching from tvdb\")\n $opt[\"tvdb-refresh\"] = true\n @tvdb_episodes = {}\n tvdb_result = series_lookup(episode) if ($opt[\"tvdb\"]) && (! @tvdb_episodes.has_key?(episode.show))\n if tvdb_result == false\n handle_error(\"failed to find tvshow \\'#{episode.show}\\' from tvdb, skipping..\")\n return false\n end\n episode.fix_via_tvdb @tvdb_episodes if $opt[\"tvdb\"] and @tvdb_episodes.has_key?(episode.show)\n end\n \n # FIXME: temporay way to handle new destination folder\n target_directory_original = @tvdir\n if $show_storage.has_key? episode.show\n @tvdir = $show_storage[episode.show]\n end\n \n season_pre = \"season.\"\n season_pre = $config[\"settings\"][\"season_dir_prepend\"] if $config[\"settings\"].has_key? \"season_dir_prepend\"\n season = \"#{season_pre}#{episode.season}\"\n season = \"specials\" if episode.season == \"0\"\n target = \"#{@tvdir}/#{episode.show_on_fs}/#{season}\" \n target = \"#{@tvdir}\" if $opt[\"dst_no_hierarchy\"]\n\n move_file(episode.original_file,target)\n @tvdir = target_directory_original\nend",
"def episode_title\n fetch('simpsons.episode_titles')\n end",
"def show\n @banner_ad = \"/31902320/Shows_Leaderboard\"\n @banner_id = 'div-gpt-ad-1411894829676-0'\n @dfp_header = \"shows\"\n @active=\"shows\"\n @show_follow_status = ''\n # @f = @show.user_followers.random(5)\n # @followers = (@f.compact!).nil? ? @f : @f.compact!\n\n @followers = @show.user_followers.offset(rand(@show.user_followers.count)).limit(5)\n \n if(@episode.nil?) \n @episode = @show.episodes.first\n end\n\n\n @ga_page_params = \", {'dimension1': '#{@episode.creator.id}', 'dimension2': '#{@episode.id}'}\"\n\n #we want to have different items based on single or episodic info\n @description = @show.single? ? @show.description : @episode.description\n @title = @show.single? ? @show.title : \"#{@show.title} : #{@episode.title}\"\n\n \n\n#meta fun\n\n # @meta_description = @show.single? ? \"#{@show.title} : #{@episode.description}\" : \"#{@show.title} : #{@episode.title} - #{@episode.description}\"\n @meta_description = \"#{@title} - #{@episode.description}\"\n if(!@episode.tag_list.empty?)\n @page_keywords = @episode.tag_list.to_s\n end\n if(!@episode.keyword_list.empty?)\n @page_keywords = @episode.keyword_list.to_s\n end\n # if current user following\n if !current_user.nil? && current_user.following?(@show)\n @show_follow_status = \"You are following\"\n else\n @show_follow_status = \"status\"\n end\n \n @likers = @episode.votes.up.by_type(User).voters.compact\n # @voters = Votes.where(votable: @episode).random(3).map(&:voter)\n end",
"def add_new_episodes( season, *episodes)\n @seasons[season][1].concat(episodes)\n @seasons[season].flatten\n end",
"def games_and_players(num1, num2)\n average = []\n total_viewers_for_streamers = 0\n total_viewers_for_games = 0\n #gets top num games from list\n games = Twitch.games.top(:limit => num1)\n games.each do |x|\n streamers = []\n streamer_display_names = []\n #get the top 5 streamers for each game\n x.streams(:limit => num2).each do |yy|\n streamers << yy.channel.display_name\n streamer_display_names << yy.channel.display_name\n #store display name here, use index later to call these names back\n end\n #output who top 5 are and their viewer count\n puts \"================= GAME - #{x.name} =====================\"\n puts \"#{x.name} has #{x.viewer_count} viewers on #{x.channel_count} channels\"\n puts \"That is an average of \" + (x.viewer_count/x.channel_count).to_s + \" per channel.\"\n puts \"The top 5 streamers of this game are currently: \"\n single_game_total = 0\n streamers.each_with_index do |y,i|\n streams = Twitch.streams.get(y)\n follows_hash = Scraper.new(y)\n percent_watching = (streams.viewer_count.to_f/x.viewer_count.to_f*100).round(2)\n puts \"#{i+1}. #{streamer_display_names[i]} with #{streams.viewer_count} viewers. \".ljust(40) + \"That's #{percent_watching}% of the total viewers of this game watching this channel.\".ljust(72) + \"This channel has #{follows_hash.follower_count} followers\"\n total_viewers_for_streamers += streams.viewer_count\n single_game_total += streams.viewer_count\n end\n total2 = (single_game_total.to_f/x.viewer_count.to_f*100).round(2)\n total_viewers_for_games += x.viewer_count\n puts \"\"\n puts \"\".rjust(45) + \"They account for #{total2}% of the game's total viewer count.\"\n 3.times do puts \"\" end\n end\n avg_percent = (total_viewers_for_streamers.to_f / total_viewers_for_games.to_f*100).round(2)\n puts \"That means for these games the top #{num1} streamers are responsible for\"\n puts \"an averge of #{avg_percent}% of the total viewership of their games.\"\n 3.times do puts \"\" end\nend",
"def fetch_articles(published_before: nil, limit_num: 6)\n if published_before\n articles = Article.includes(:outlet).where(outlet_name: following.pluck(:outlet_name))\n .where('articles.published_at < ?', published_before.to_datetime)\n else\n articles = Article.includes(:outlet).where(outlet_name: following.pluck(:outlet_name))\n end\n articles.limit(limit_num)\n end",
"def sync_numbers(offset: 0)\n episodes = Episode.published.full.ascending\n .where.not(number: nil)\n .where.not(podbean_id: nil)\n .offset(offset)\n\n episodes.find_each.with_index do |episode, index|\n response = Podbean.update_episode(\n episode.podbean_id,\n {episode_number: episode.number}\n )\n puts \"#{index}, #{response[\"error_description\"]}, #{episode.id}\"\n end\n end",
"def skip_week\n for item in action_items\n item.skip! unless item.complete?\n end\n\n end",
"def trip(url, steps=10)\n so_far = [] # (3) \n\n steps.times do \n page = fetch(url)\n book_info = scrape_book_info(page)\n so_far << book_info[:title]\n puts format_output(book_info)\n \n next_book = scrape_affinity_list(page).find do | possible | # (4) \n not so_far.include?(possible[:title])\n end\n\n url = next_book[:url]\n end\nend",
"def index\n q = params[:q]\n @tags = Tag.includes(:episodes).all.sort_by {|t| -t.episodes.count}\n if !(params[:tag_id]).blank?\n @current_tag = Tag.includes(:episodes).find(params[:tag_id])\n @episodes = @current_tag.episodes.order(:release_date).reverse_order.paginate(page: params[:page], per_page: 15)\n elsif q.blank?\n @q = \"\"\n @episodes = Episode.includes(:tags).order(:release_date).reverse_order.paginate(page: params[:page], per_page: 15)\n elsif q.match(/^#[0-9]+/)\n @q = q\n @episode = Episode.includes(:tags).order(:release_date).where(\"MATCH (name) AGAINST ('#{q}' IN NATURAL LANGUAGE MODE)\")[0]\n if @episode.blank?\n render file: \"#{Rails.root}/public/404\", status: :not_found \n else\n redirect_to \"/episodes/#{@episode.id}\"\n end\n else\n @q = q\n if params[:search].blank?\n @episodes = Episode.includes(:tags).where(\"MATCH (episodes.name, episodes.description) AGAINST ('#{q}' IN NATURAL LANGUAGE MODE)\").or(Episode.includes(:tags).where(\"MATCH (tags.name) AGAINST ('#{q}' IN NATURAL LANGUAGE MODE)\").references(:tags)).order(:release_date).reverse_order.paginate(page: params[:page], per_page: 15)\n elsif params[:search] == \"name\"\n @episodes = Episode.includes(:tags).order(:release_date).reverse_order.where(\"MATCH (name) AGAINST ('#{q}' IN NATURAL LANGUAGE MODE)\").paginate(page: params[:page], per_page: 15)\n end\n end\n respond_to do |format|\n format.html {}\n format.json { render json: @episodes}\n end\n end",
"def make_podcasts\n \tpodcast_array = Scraper.scrape_list_page(\"http://www.maximumfun.org/shows/comedy\")\n \tPodcast.create_from_scrape(podcast_array)\n end",
"def show\n @entries = @slideshow.entries.recent.limit(12)\n\n @active_feeds = @slideshow.feeds.order(title: :asc)\n @available_feeds = Feed.where.not(id: @slideshow.feed_ids).order(title: :asc)\n end",
"def get_latest_movies (vcdq_rss_url, movies_collection)\n # @TODO: Error checking.\n feed = Feedzirra::Feed.fetch_raw(vcdq_rss_url)\n feed_parsed = Feedzirra::Feed.parse(feed)\n\n current_date = Time.now\n\n i = 0\n feed_parsed.entries.each do |movie_item|\n movie_title_parts = movie_item.title.split('.')\n\n # puts movie_item\n $logger.debug(\"Processing title: #{movie_item.title}\")\n\n # Parse the title and categories for useful info.\n movie_info = get_movie_info(movie_title_parts, movie_item.categories)\n\n # If we couldn't parse any info, just log this incident and move on\n # @TODO: reformat to throw exception instead\n next if movie_info.nil?\n\n # Create a movie.\n movie_document_id = get_movie_document_id(movie_info[:title], movie_info[:year])\n movie = {\n _id: movie_document_id,\n title: movie_info[:title],\n title_lower: movie_info[:title].downcase,\n year: movie_info[:year],\n created: current_date,\n releases: Array.new\n }\n save_movie(movie, movies_collection)\n\n # Create a release\n release = {\n quality: movie_info[:quality],\n url: movie_item.url,\n date: movie_item.published,\n created: current_date\n }\n save_release(release, movie_document_id, movies_collection)\n\n # $logger.debug(\"Parsed movie info: #{movie_info}\")\n\n i += 1\n end\n\n $logger.debug(\"======== only #{i}/#{feed_parsed.entries.length} were good\")\nend"
] |
[
"0.65678346",
"0.6417063",
"0.6287272",
"0.62093246",
"0.62093246",
"0.62093246",
"0.62093246",
"0.6151687",
"0.6137111",
"0.6129858",
"0.61132944",
"0.6012718",
"0.5989661",
"0.5920803",
"0.59150416",
"0.5903672",
"0.58997595",
"0.58929527",
"0.5868579",
"0.57257944",
"0.5709784",
"0.56882256",
"0.56507635",
"0.56102544",
"0.5579954",
"0.5565914",
"0.55579215",
"0.5550992",
"0.55482453",
"0.55318874",
"0.55239636",
"0.55098116",
"0.5504368",
"0.5485615",
"0.54770625",
"0.54458326",
"0.54299533",
"0.54152507",
"0.5414992",
"0.5411438",
"0.5406795",
"0.5398604",
"0.5398604",
"0.5398604",
"0.5398604",
"0.5398604",
"0.5398604",
"0.5391062",
"0.5363644",
"0.53628206",
"0.5357501",
"0.53402686",
"0.5311005",
"0.5307621",
"0.5306017",
"0.53048736",
"0.5301816",
"0.529893",
"0.52936816",
"0.52879226",
"0.5282636",
"0.5276489",
"0.5275747",
"0.52624553",
"0.5251527",
"0.5245994",
"0.52293706",
"0.52228194",
"0.52216965",
"0.5221425",
"0.5220296",
"0.5213316",
"0.5210321",
"0.52003306",
"0.51994646",
"0.5176331",
"0.51708436",
"0.516944",
"0.5169019",
"0.51622236",
"0.51571566",
"0.514998",
"0.5137716",
"0.5132199",
"0.5131037",
"0.51271385",
"0.5122215",
"0.5116796",
"0.511677",
"0.5114364",
"0.51111764",
"0.51101947",
"0.51083755",
"0.51055205",
"0.50936955",
"0.50849724",
"0.5082572",
"0.50717914",
"0.5068922",
"0.5068674",
"0.5066636"
] |
0.0
|
-1
|
Tacks the registry behind local_tag
|
def full_tag(local_tag, registry)
"#{registry}/#{local_tag}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tag(tag); end",
"def tag(tag); end",
"def our_tags\n tag_map.tap do |t|\n t.each_pair { |k, v| t[k] = tags.fetch(v, nil) }\n end\n end",
"def local_tags\n @local.tags\n end",
"def tags_to_add\n local_tags.reject { |t, v| aws_tags.include?(t) and aws_tags[t] == v }\n end",
"def local_task_tag(name)\n Roby::Models::TaskServiceModel::DRoby.anon_tag_factory(name)\n end",
"def tag(name); end",
"def tag(new_tag); end",
"def register_tags(*additional_tags); end",
"def create_local_tag tag_name\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\nend",
"def consider_tag\n\n tag = attribute(:tag)\n\n return unless tag && tag.strip.size > 0\n\n h.tagname = tag\n h.full_tagname = applied_workitem.tags.join('/')\n\n return if h.trigger\n #\n # do not consider tags when the tree is applied for an\n # on_x trigger\n\n h.full_tagname = (applied_workitem.tags + [ tag ]).join('/')\n\n set_variable(h.tagname, h.fei)\n set_variable('/' + h.full_tagname, h.fei)\n\n applied_workitem.send(:add_tag, h.tagname)\n\n @context.storage.put_msg(\n 'entered_tag',\n 'tag' => h.tagname,\n 'full_tag' => h.full_tagname,\n 'fei' => h.fei,\n 'workitem' => h.applied_workitem)\n end",
"def add(namespace:, name:, tags:)\n @registry[key(namespace, name)] = Set.new(tags)\n end",
"def register_transitive_tags(object); end",
"def with_register name = \"temp\"\n reg = register(name)\n yield reg\n release_register reg\n end",
"def tagged?; end",
"def registry; end",
"def registry; end",
"def register tag, name\n @tags[name] = tag\n end",
"def register tag, name\n @tags[name] = tag\n end",
"def add_for_namespace(namespace:, tags:)\n @registry[namespace] = Set.new(tags)\n end",
"def tags=(_arg0); end",
"def register(hook, obj = T.unsafe(nil), &blk); end",
"def tag; end",
"def tag; end",
"def test_register \n tag = Liquid::Template.tags['t']\n assert_not_nil tag\n assert_equal 'Jekyll::ThumbnailifyTag', tag.to_s\n end",
"def exclude_from_registry; end",
"def _get_tags(tag)\n tags = if tag.attr['tags'] && !tag.attr['tags'].blank?\n Tag.from_list(tag.attr['tags'], false) # false parameter -> not to create missing tags\n elsif tag.locals.page.respond_to?(:requested_tags)\n tag.locals.page.requested_tags\n elsif tag.locals.page\n tag.locals.page.attached_tags.visible\n else\n []\n end\n tag.locals.tags = tags.uniq.compact\n end",
"def registers; end",
"def tag tag = nil\n @tag = tag if tag\n @tag\n end",
"def store\n @by_cache.each{|cache, tags| cache[:tags] = tags }\n end",
"def push_to_global_registry\n async(:async_push_to_global_registry)\n end",
"def push_to_global_registry\n async(:async_push_to_global_registry)\n end",
"def tag_name=(_arg0); end",
"def tags(host)\n tags = [\"cluster\"]\nend",
"def registry\n @registry ||= {}\n end",
"def add_tag(tag)\n\n (h.fields['__tags__'] ||= []) << tag\n end",
"def initialize(registry = T.unsafe(nil)); end",
"def tag(string); end",
"def __linus_tags()\n\t$remotes ||= load_remotes\n\tpattern = Regexp.new '^' + $remotes['linus']['release_tag_pattern'].sub(' ', '$|^') + '$'\n\ttags = get_tags(pattern, $remotes['linus']['release_tag_committer'])\n\ttags = sort_tags(pattern, tags)\n\ttags_order = {}\n\ttags.each_with_index do |tag, i|\n\t\ttags_order[tag] = -i\n\tend\n\ttags_order\nend",
"def register name = \"temp\"\n Registers::Temp.new name, \"r64\"\n end",
"def log_tags=(_arg0); end",
"def log_tags=(_arg0); end",
"def log_tags=(_arg0); end",
"def atomic_replace\n @mutex.synchronize do\n @new_registry = @exported_registry.clone\n\n begin\n yield(@new_registry)\n ensure\n @exported_registry = @new_registry\n end\n end\n\n nil\n end",
"def handle_adding_tag(tag, tags)\n if tags.include?(tag)\n puts \"Warning: duplicate tag #{tag} detected\"\n else\n tags.push(tag)\n end\n return tags\n end",
"def handle_adding_tag(tag, tags)\n if tags.include?(tag)\n puts \"Warning: duplicate tag #{tag} detected\"\n else\n tags.push(tag)\n end\n return tags\n end",
"def register(curr); end",
"def getlocal() end",
"def tagging_raw_handle\n name\n end",
"def tagging_raw_handle\n name\n end",
"def add_tag(tag)\r\n self.tags.new(:name => tag.name)\r\n end",
"def tag!(tag)\n H[tag, attr, convert_children]\n end",
"def do_tag(registry)\n docker_connection = docker_api.connection\n image = Docker::Image.get(\"#{image_name}:#{version}\", {}, docker_connection)\n puts \"Tagging image: #{image_name}\"\n image.tag('repo' => \"#{registry}/#{image_name()}\", 'image' => 'unicorn', 'tag' => version(), force: true)\n end",
"def tag(tags)\n context = Thread.current[:lumberjack_context]\n context&.tag(tags)\n end",
"def add_request_tags(tags=[])\n if tags.any?\n tags.collect! { |tag| Tag.find_by_title(Rack::Utils::unescape(tag)) }\n self.requested_tags = (self.requested_tags + tags.select{|t| !t.nil?}).uniq\n end\n end",
"def tag\n @handler.tag\n end",
"def receive_unkeyed_tag_att\n\n return [] if @node['tags']\n # \"tag:\" encountered, walk away\n\n ret = @message['payload']['ret']\n ret = Array(ret).flatten\n ret = nil unless ret.any? && ret.all? { |e| e.is_a?(String) }\n\n return [] unless ret\n\n (@node['tags'] ||= []).concat(ret)\n\n wrap('point' => 'entered', 'nid' => nid, 'tags' => ret)\n end",
"def tags(name = T.unsafe(nil)); end",
"def tag\n end",
"def tag\n end",
"def first_matching_tag\n r = Registry.get\n return unless r\n\n RegistryEvent.all.find_each do |event|\n data = JSON.parse(event.data)\n _, _, tag_name = r.get_namespace_from_event(data)\n return event.dup if tag_name == @tag\n end\n\n nil\n end",
"def tags() ; info[:tags] ; end",
"def tags() ; info[:tags] ; end",
"def tag(tag_name, &block)\n tag = TagConfig.new(name, reference_dir, tag_name)\n tag.docker_name(docker_name)\n if block_given?\n tag.instance_eval(&block)\n end\n tags[tag_name] = tag\n end",
"def register\n grab_header.invert\n end",
"def tag(tags)\n tags.each do |key, value|\n @tags[key.to_s] = value\n end\n end",
"def push_reg reg\n @fisk.push reg.to_register\n end",
"def encode_by(tag, string)\n Tags[tag][0][1] = string\n end",
"def tag_name; end",
"def tag_name; end",
"def tag_name; end",
"def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend",
"def resolve_tagged(tag)\n resolved = Array.new\n\n @definitions.each_value do |definition|\n if definition.tags and definition.tags.include? tag\n resolved.push definition.resolve\n end\n end\n\n resolved\n end",
"def set_tag_for_search(tag)\n @page.all(input_elements[:entries])\n @page.find(input_elements[:tag_filter_field]).set(tag)\n @page.find(input_elements[:tag_selected]).click\n @used_tag = tag\n end",
"def push_image_to_registries(tag:, override_tag: false)\n digest = nil\n\n DockerRegistry.all.each_with_index do |registry, i|\n primary = i.zero?\n repo = project.docker_repo(registry, build.dockerfile)\n\n if override_tag\n @output.puts(\"### Tagging and pushing Docker image to #{repo}:#{tag}\")\n else\n @output.puts(\"### Pushing Docker image to #{repo} without tag\")\n end\n\n ImageBuilder.send(:local_docker_login) do |login_commands|\n full_tag = \"#{repo}:#{tag}\"\n\n @execution.executor.quiet do\n return nil unless @execution.executor.execute(\n *login_commands,\n @execution.executor.verbose_command(\"docker tag #{build.docker_image.id} #{full_tag.shellescape}\"),\n @execution.executor.verbose_command(\"docker push #{full_tag.shellescape}\")\n )\n end\n\n if primary\n # cache-from also produced digest lines, so we need to be careful\n return nil unless sha = @execution.executor.output.to_s.split(\"\\n\").last[DIGEST_SHA_REGEX, 1]\n digest = \"#{repo}@#{sha}\"\n end\n end\n end\n\n digest\n end",
"def registry_entry( registry, entry_name )\n r = @registry[ registry ]\n r[ entry_name ] if r\n end",
"def registered\n @@registry_lock.synchronize { @@registry.keys }\n end",
"def register_object(local_object, known_siblings = {})\n register_siblings(local_object, local_id => local_object.droby_id)\n register_siblings(local_object, known_siblings)\n end",
"def register(object); end",
"def register_id(object, type, remote_id, local_id)\n @keymap[type.to_s][remote_id] = local_id\n c = object.class\n while !['Object', 'ActiveRecord::Base'].include?(c.name)\n @keymap[c.name][remote_id] = local_id\n c = c.superclass\n end\n end",
"def with_tag_data( newhash={} )\n\t\traise LocalJumpError, \"no block given\" unless block_given?\n\t\t# self.log.debug \"Overriding tag state with: %p\" % [ newhash ]\n\n\t\tbegin\n\t\t\t@tag_data.push( @tag_data.last.merge(newhash) )\n\t\t\tyield( self )\n\t\tensure\n\t\t\t@tag_data.pop\n\t\tend\n\tend",
"def named_tag_scope\r\n NamedTagScopeController.instance\r\n end",
"def replace_using(tag, string)\n Tags[tag][1] = string\n end",
"def resolve\n tags = self.tags\n if tags.empty?\n tag 'latest'\n end\n tags.map do |_, tag|\n variables = self.variables.dup\n variables.merge! tag.variables\n variables.delete_if { |_, t| !t }\n\n resolve_variable_matrix(variables) do |var|\n resolved = TagConfig.new(tag.name, tag.reference_dir, tag.tag_name)\n resolved.volumes.concat(tag.volumes).concat(volumes)\n resolved.docker_name(tag.docker_name)\n resolved.docker_tag_name(tag.docker_tag_name)\n resolved.variables.merge!(var)\n resolved\n end\n end.flatten\n end",
"def auto_create_tag\n\t\n\tget_tags.each do |tag|\n\t\t@items << Nanoc3::Item.new(\n\t\t\"<%= render 'tag', :tag => '#{tag}' %>\",\n\t { :title => \"Category: #{tag}\", :is_hidden => true, :tag => \"#{tag}\"}, # do not include in sitemap.xml\n\t \"/tags/#{tag}/\", # identifier\n\t :binary => false\n\t)\n\n\tend\n\tnil\nend",
"def tag_set(p_tag_sym, p_val) tag.send(\"#{p_tag_sym.to_s}=\", p_val) end",
"def register_for(id); end",
"def use_tag(tag_name)\n raw \"_#{tag_name}\"\n end",
"def registry\n @registry\n end",
"def local(l = nil)\n l = get_local if !l\n label(l)\n end",
"def finish_register\n end",
"def add_tags(tag)\n remove_previous_tags\n if @page.find(input_elements[:tag_input_field]).present?\n @page.find(input_elements[:tag_input_field]).set(tag)\n else\n @page.find(input_elements[:tag_input_field2]).set(tag)\n end\n @page.find(input_elements[:tag_selected]).click\n @used_tag = tag\n end",
"def initialize\n @registry = {}\n end",
"def complete_tags\n\n end",
"def create_standalone_remote_tag tag_name\n in_secondary_repository do\n run 'git checkout -b temp'\n run 'touch a.txt'\n run 'git add -A'\n run 'git commit -m \"temp\"'\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\n run 'git push --tags'\n end\nend",
"def active_tags\n active_tags = [:global]\n active_tags << feature_tag.to_sym if feature_tag\n active_tags + super\n end",
"def build_reverse_tag_lookup_cache\n @tags_for_node_cache = ArrayHash.new\n tags.inject(@tags_for_node_cache) do |hash, (tag, tag_node)|\n hash[tag_node] << tag\n hash\n end\n end",
"def all_tags\n\n all_variables.remap do |(fei, vars), h|\n vars.each { |k, v| (h[k] ||= []) << v if Ruote.is_a_fei?(v) }\n end\n end",
"def add_tag (tag)\n `rs_tag --add \"#{tag}\"`\n end",
"def tags_to_add\n return @tags_to_add\n end"
] |
[
"0.55408585",
"0.55408585",
"0.5540361",
"0.5477359",
"0.54692864",
"0.5456492",
"0.5453355",
"0.54405653",
"0.54222846",
"0.539707",
"0.5288271",
"0.52485037",
"0.52144533",
"0.5187233",
"0.51737446",
"0.5171082",
"0.5171082",
"0.51461905",
"0.51461905",
"0.513562",
"0.5133854",
"0.51252085",
"0.51144063",
"0.51144063",
"0.51061404",
"0.51045674",
"0.5076025",
"0.505854",
"0.5035049",
"0.5031164",
"0.5020773",
"0.5020773",
"0.50199974",
"0.50187105",
"0.5004443",
"0.50006795",
"0.49984506",
"0.4984342",
"0.49823084",
"0.49768966",
"0.49746215",
"0.49746215",
"0.49746215",
"0.49606714",
"0.49426404",
"0.49426404",
"0.49344873",
"0.49257368",
"0.49230883",
"0.49230883",
"0.4908558",
"0.4906406",
"0.49023953",
"0.48886058",
"0.4888222",
"0.4872828",
"0.48669106",
"0.4851081",
"0.48478284",
"0.48478284",
"0.48383555",
"0.48269314",
"0.48269314",
"0.48220485",
"0.4821356",
"0.48169693",
"0.48163232",
"0.4811057",
"0.48036477",
"0.48036477",
"0.48036477",
"0.47964376",
"0.47914955",
"0.478693",
"0.47792092",
"0.47786084",
"0.47774497",
"0.47666708",
"0.47665453",
"0.476596",
"0.4765194",
"0.47608328",
"0.47575906",
"0.4757588",
"0.47553802",
"0.47512534",
"0.47447222",
"0.47428286",
"0.47394305",
"0.47381043",
"0.4735779",
"0.47306752",
"0.47288322",
"0.47286206",
"0.47269037",
"0.4724076",
"0.47089535",
"0.46879983",
"0.46844867",
"0.46789712"
] |
0.70968634
|
0
|
Calculate the SHA256 of the concatenated content of the given list of files after line endings have been stripped
|
def sha256(files)
sha = Digest::SHA2.new
files.each do |f|
next if File.directory?(f)
content = File.binread(f)
# work around possible git checkout issues by removing CR and LF from the file
content.gsub!("\n", "")
content.gsub!("\r", "")
sha << content
end
sha.hexdigest
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def digest_sha2(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA2.hexdigest(File.read(file)) : nil\n }\n end",
"def digest_sha1(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA1.hexdigest(File.read(file)) : nil\n }\n end",
"def sha256\n # get all dependency checksums\n deps = Hash[locked_dependencies.list.map { |k, v| [k, v.profile.sha256] }]\n\n res = OpenSSL::Digest::SHA256.new\n files = source_reader.tests.to_a + source_reader.libraries.to_a +\n source_reader.data_files.to_a +\n [[\"inspec.yml\", source_reader.metadata.content]] +\n [[\"inspec.lock.deps\", YAML.dump(deps)]]\n\n files.sort_by { |a| a[0] }\n .map { |f| res << f[0] << \"\\0\" << f[1] << \"\\0\" }\n\n res.digest.unpack(\"H*\")[0]\n end",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end",
"def integrity(path)\n \"sha256-#{Base64.encode64(Digest::SHA256.digest(File.read(path))).chomp}\"\n end",
"def files_digest(paths)\n digest(paths.map { |path| file_digest(path) })\n end",
"def file_sha256_hash(file_path)\n file = File.read(file_path)\n Digest::SHA256.hexdigest(file) if file\n end",
"def file_checksum(file_path)\n Digest::SHA256.file(file_path).hexdigest\n end",
"def file_sha256\n Digest::SHA256.file(self).hexdigest\n end",
"def digest_md5(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::MD5.hexdigest(File.read(file)) : nil\n }\n end",
"def checksum(file)\n sha = ::Digest::SHA1.new\n File.open(file, 'r') do |fh|\n fh.each_line do |l|\n sha << l\n end\n end\n sha.hexdigest\n end",
"def digest\n OpenSSL::Digest::SHA256.file(path).hexdigest\n end",
"def files_digest(paths)\n self.digest(paths.map { |path| self.file_digest(path) })\n end",
"def findSmallHash(f)\r\n return Digest::SHA1.file(f).hexdigest()\r\nend",
"def findLargeHash(f)\r\n incr_digest = Digest::SHA1.new()\r\n file = File.open(f, \"rb\")\r\n count = 0\r\n file.each_line do |line|\r\n if count == 1\r\n incr_digest << line\r\n end\r\n count = count + 1\r\n if count >= 2\r\n break\r\n end\r\n end\r\n return incr_digest.hexdigest + File.size(f).to_s(16)\r\nend",
"def filehash(filepath)\n sha1 = Digest::SHA1.new\n File.open(filepath) do|file|\n buffer = ''\n # Read the file 512 bytes at a time\n while not file.eof\n file.read(512, buffer)\n sha1.update(buffer)\n end\n end\n return sha1.to_s\n end",
"def compute_checksums data\n\n digest = OpenSSL::Digest::Digest.new('sha256')\n tree_digest = OpenSSL::Digest::Digest.new('sha256')\n tree_parts = []\n\n until data.eof?\n\n chunk = data.read(1024 * 1024) # read 1MB\n tree_parts << tree_digest.update(chunk).digest\n tree_digest.reset\n\n digest.update(chunk)\n\n end\n\n data.rewind\n\n [digest.to_s, compute_tree_hash(tree_parts)]\n\n end",
"def checksums; end",
"def SHA256 arr\n Digest::SHA256.digest(arr.map(&:chr).join).bytes\nend",
"def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end",
"def sha256; end",
"def checksum\n digest = @digest_klass.new\n buf = ''\n\n File.open(@path, \"rb\") do |f|\n while !f.eof\n begin\n f.readpartial(BUFFER_SIZE, buf)\n digest.update(buf)\n rescue EOFError\n # Although we check for EOF earlier, this seems to happen\n # sometimes anyways [GH-2716].\n break\n end\n end\n end\n\n digest.hexdigest\n end",
"def get_hashes(items)\n hashes = []\n items.each do |item|\n hashes.push((Digest::SHA2.new << item).to_s)\n end\n\n return hashes\n end",
"def generate_sha(file)\n\n sha1 = Digest::SHA1.file file\n return sha1\n\nend",
"def manifested_files\n manifest_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 decode_filename(path)\n end\n }\n\n (acc + files).uniq\n end\n end",
"def file_remote_digestsha2(file_name)\n data = read_file(file_name)\n chksum = nil\n if data\n chksum = Digest::SHA256.hexdigest(data)\n end\n return chksum\n end",
"def md5sum_file(file)\n return `md5sum #{file}`\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 digest\n assert_file!\n Digest::SHA256.hexdigest(@name + Digest::SHA256.file(@path).to_s)\n end",
"def hash_file(name, length)\n pieces = String.new\n file = ::File.open(name, 'r')\n pieces << Digest::SHA1.digest(file.read(length)) until file.eof?\n file.close\n pieces\n end",
"def manifested_files\n\n manifest_files.inject([]) do |acc, mf|\n\n files = open(mf) do |io|\n\n io.readlines.map do |line|\n digest, path = line.chomp.split /\\s+/, 2\n path\n end\n\n end\n\n (acc + files).uniq\n end\n\n end",
"def digest_filename(filename)\n digest = Digest::SHA256.digest(filename.to_s)\n Base64.urlsafe_encode64(digest, padding: false)\n end",
"def file_digest(file)\n # Get the actual file by #tempfile if the file is an `ActionDispatch::Http::UploadedFile`.\n Digest::SHA256.file(file.try(:tempfile) || file).hexdigest\n end",
"def hash( *strs )\n return Digest::MD5.hexdigest( strs.join )\n end",
"def merge_data(input_files)\n for filename in input_files\n merge_into_hash(filename)\n end\n sanitize_hash\n end",
"def checksum\n\t\taddends.reduce(:+)\n\tend",
"def digest\n digest = ''\n @entries.each { |entry| digest << entry.digest << ' ' }\n digest\n end",
"def generate_checksum(*strings)\n csum = 0\n strings.each {|s| s.each_byte {|c| csum += c}}\n (csum % 256).chr\n end",
"def fingerprint(filename)\n \"SHA256: \" + X509.fingerprint(\"SHA256\", Path.named_path(filename))\n end",
"def get_committed_files\n # set the current branch name to be the current branch you're on --> need to check that this works as part of push\n curr_branch_name = `git rev-parse --abbrev-ref HEAD`\n\n # raw_sha_list lists all the local, unpushed commit SHAs from your current branch\n raw_sha_list = `git log --graph --pretty=format:'%H' #{curr_branch_name}`\n\n committed_files = []\n # loop through the raw_sha_list and push properly formatted SHAs into the all_shas arr\n raw_sha_list.each_line { |sha|\n # using the .tr method on the sha makes a copy of the sha and replaces instances that matches with the to_str (second arg),\n # unless the range starts with a ^ carrot, in which case, it replaces on matches outside the range\n curr_sha = sha.tr('^A-Za-z0-9', '')\n\n # this `git diff-tree --no-commit-id --name-only -r <SHA>` will list the files of an individual commit when you add the SHA\n # on each iteration, set the changed_files variable to be the list of files from a particular commit, based its SHA\n changed_files = `git diff-tree --no-commit-id --name-only -r #{curr_sha}`\n\n # loop over the changed_files and add in each file that's part of a commit and add into the committed_files arr\n changed_files.each_line { |file|\n # remove any trailing whitespace from the file name and add into our arr\n committed_files << file.rstrip()\n }\n }\n # return the final, no-repeat array of committed files in this push\n return committed_files.uniq\nend",
"def sha256(options = {})\n required_input_files :path\n required_output_values :sha256\n\n path = input_file(:path)\n\n unless File.exist?(path)\n raise \"path '#{path}' does not exist\"\n end\n \n sha256 = FileHash.sha256(path)\n output_value(:sha256, sha256)\n\n return true\n end",
"def generate_hexdigest_indexed_list(size_indexed_list, head_size = nil)\n result = {}\n size_indexed_list.each_pair{|old_key, filename_arr|\n filename_arr.each{|filename|\n if head_size == nil\n $stdout.puts \"SHA512 hash calculation: #{filename}\"\n else\n $stdout.puts \"Header (#{head_size}) SHA512 hash calculation: #{filename}\"\n end\n\n hexdigest = get_file_header_sha512(filename, head_size)\n\n if result.has_key?(hexdigest) == false\n result[hexdigest] = []\n end\n result[hexdigest].push(filename)\n }\n }\n return result\nend",
"def sha256\n @sha256 ||= digest(path, :sha256)\n end",
"def bundle_files(files)\n output = \"\"\n files.select { |f| !f.content.empty? }.each do |file|\n content = file.content\n path = file.path\n output << bundled_file_header(path) \n output << include_imported_files(content, path) if file.type[:ext] == 'css'\n content << javascript_fix if file.type[:ext] == '.js' \n output << content\n output << bundled_file_footer(path)\n end\n output\n end",
"def append_md5(file, digest, hashless: false)\n return file if hashless\n\n [[file.split(ex = File.extname(file)).first, digest].join('-'), ex].join\n end",
"def combined_hash\n hashes = @contracts.map { |c| c.bth }.sort\n concatenated_hash = [payment_base.to_base58].concat(hashes).join\n Tapyrus.sha256(concatenated_hash)\n end",
"def digestFile(filename)\n\tfh = File.open(filename)\n\tarray = String.new\n\tpreparse = true\n\tfh.each_line do |line|\n\t\tif preparse\n\t\t\tif line =~ /\\{/\n\t\t\t\tpreparse = false\n\t\t\t\tarray << line\n\t\t\tend\n\t\telse\n\t\t\t#Sub numberlongs\n\t\t\tif line.include? \"NumberLong\\(\"\n\t\t\t\tline.slice!(/NumberLong\\(/)\n\t\t\t\tline.slice!(/\\)/)\n\t\t\tend\n\n\t\t\t#ObjectId(\"4ef4af0963389003f300c2e7\"),\n\t\t\tif line.include? \"ObjectId\"\n\t\t\t\tline = line.gsub(\"ObjectId\\(\\\"\", \"\\\"ObjectId\\(\")\n\t\t\t\tline = line.gsub(\"\\\"\\)\", \"\\)\\\"\")\n\t\t\tend\n\n\t\t\t#Timestamp(10000, 27),\n\t\t\tif line.include? \": Timestamp\\(\"\n\t\t\t\tline = line.gsub(\"Timestamp\\(\", \"\\\"Timestamp\\(\")\n\t\t\t\tline = line.gsub(\"\\)\", \"\\)\\\"\")\n\t\t\tend\n\t\t\t#ISODate(\"2012-01-26T00:00:00Z\")\n\t\t\tif line.include? \": ISODate\\(\\\"\"\n\t\t\t\tline = line.gsub(\"ISODate\\(\\\"\", \"\\\"ISODate\\(\")\n\t\t\t\tline = line.gsub(\"\\\"\\)\", \"\\)\\\"\")\n\t\t\tend\n #BinData\n if line.include? \": BinData\\(\"\n line = line.gsub(\"BinData\\(\", \"\\\"BinData\\(\")\n line = line.gsub(\"\\\"\\)\", \"\\)\\\"\")\n line = line.gsub(\",\\\"\", \",\")\n end\n if line.include? \"\\\" : \\/\"\n line = line.gsub(\"\\\" : \\/\", \"\\\" : \\\"\\/\")\n line = line.gsub(\"\\/,\", \"\\/\\\",\")\n end\n\t\t\tif line !~ /bye/\n\t\t\t array << line\n\t\t\tend\n\t\tend\n\tend\n\tfh.close\n\tdoc = Yajl::Parser.parse(array)\n\treturn doc\nend",
"def calculate_file_name(file_path,file_name)\n file_sha = Digest::SHA256.file(file_path)\n \"#{file_sha}_#{file_name}\"\n end",
"def combine( path_list )\n path_list\n .collect { |p| File.read( File.join(SRC_DIR, p) ) }\n .join(\"\\n\\n\")\n end",
"def create_chksum_manifest\n chksum_manifest = {}\n files = Dir['*'].select{ |f| File.file? f }\n files.each do |file|\n chksum_manifest[file] = Digest::MD5.file(file).hexdigest\n end\n chksum_manifest\n end",
"def digest\n Digest::MD5.file(file).hexdigest\n end",
"def gen_digest_byte_tests\n FILES.each do |path, hashlen|\n name = File.basename(path).split('.')[0]\n\n f = File.new(\"sha3_digest_#{hashlen}_spec.rb\", 'w')\n f.puts(REQUIRED)\n f.puts(\n SPEC\n .gsub(/HASH_LEN/, hashlen.to_s)\n .gsub(/NAME/, name)\n )\n\n contents = File.read(path).split('Len = ')\n contents.each do |test|\n lines = test.split(\"\\n\")\n next unless !lines.empty? && lines[0] !~ /^#/\n\n length = lines[0].to_i\n next unless (length % 8).zero? && length != 0\n\n msg_raw = lines[1].split(' = ').last\n digest = lines[2].split(' = ').last.downcase\n\n f.puts(\n EXPECT\n .gsub(/HASHLEN/, hashlen.to_s)\n .gsub(/MSG/, msg_raw)\n .gsub(/DIGEST/, digest)\n )\n end\n\n f.puts(ENDING)\n f.close\n end\nend",
"def hash(*tokens)\n result = tokens.flatten.join(joiner)\n cost.times { result = Digest::SHA512.hexdigest(result) }\n result\n end",
"def calculate_checksum(file)\n @lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: \"rb\")) rescue \"\"\n end",
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def validate_file(file_list, timestamp, prev_hash)\n acc_balances = {}\n acc_balances.default = 0\n prepared_hashes = PreHash.new\n file_list.each_with_index do |line, line_no|\n parsed_lines = split_line line, line_no\n check_block_number parsed_lines[0], line_no\n verify_previous_hash prev_hash, parsed_lines[1], line_no\n timestamp = verify_and_return_datetime timestamp, parsed_lines[3], line_no\n verify_transactions parsed_lines[2], line_no, acc_balances\n hash_string = \"#{parsed_lines[0]}|#{parsed_lines[1]}|#{parsed_lines[2]}|#{parsed_lines[3]}\"\n prev_hash = verify_current_hash hash_string, parsed_lines[4], line_no, prepared_hashes\n end\n print_balances acc_balances\n true\nend",
"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 calc_checksum\n @encrypted_name.chars.delete_elem('-').group_eq.transform_values(&:length).sort_by do |_, v|\n -v\n end.group_by(&:second).map do |_, v|\n v.sort\n end.sum.map(&:first).take(5).join\n end",
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def concatinate(f1, f2)\n\t\tDir.foreach(\"#{f1}\") do |x0|\n\t\t\tnext if x0 == '.' or x0 == '..' or x0.start_with?('.')\n\t\t\tDir.foreach(\"#{f2}\") do |x1|\n\t\t\t\tnext if x1 == '.' or x1 == '..' or x1.start_with?('.')\n\t\t\t\t\n\t\t\t\t# concatenate x and y \t\t\n \t\t\t\tsystem(\"cat #{f1}/#{x0} #{f2}/#{x1} > t1/#{x0}#{x1}\")\n\t\t\t\t# compress concatenated files\n \t\t\t\tsystem(\"7za a -t7z t2/#{x0}#{x1}.7z t1/#{x0}#{x1}\")\n \t \t\t#system(\"7za a -t7z -mx9 -mmt2 -ms4g -m0=lzma:d128m:fb256 t2/#{x0}#{x1}.7z t1/#{x0}#{x1}kd\")\n \t \t\t\n \t \tend \n \t end\t\t\n\tend",
"def fedora_shasum\n \"urn:sha1:#{Digest::SHA1.file(file_path)}\"\n end",
"def test_transform(f1,f2,hashpass,salt,iteration,option)\n succes = nil\n begin\n datastring = \"\"\n File.open(f1).each do |line|\n datastring = datastring + line.gsub(\"a\",\"4\")\n end\n\n file2 = File.new(f2,\"w\")\n file2.write(datastring)\n file2.close\n counter = 1\n lines = File.foreach(f2).count\n File.open(f2).each do |line|\n if option == \"-v\"\n fr = counter * (100.0/lines)\n printf(\"\\r%15s: [%-100s]\",\"#{line.chomp}\", \"=\" * (fr))\n end\n if cracked?(hashpass, line.chomp,salt,iteration,option)\n return succes = line\n end\n counter +=1\n end\n puts \"\"\n succes\n\n rescue => err\n puts \"Exception: #{err}\"\n end\nend",
"def file_remote_digestsha1(file_name)\n data = read_file(file_name)\n chksum = nil\n if data\n chksum = Digest::SHA1.hexdigest(data)\n end\n return chksum\n end",
"def generate_hash(*args)\n Digest::SHA3.hexdigest(args.join(''))\n\n end",
"def generate_hash(*args)\n Digest::SHA3.hexdigest(args.join(''))\n end",
"def get_md5sum(file)\n get_sum(file, 'md5')\n end",
"def get_file_hash(fullPath)\n contents = File.read(fullPath)\n fileHash = Digest::MD5.hexdigest(contents)\n return fileHash\nend",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def core_sha1(x, len)\n # append padding\n x[len >> 5] ||= 0\n x[len >> 5] |= 0x80 << (24 - len % 32)\n x[((len + 64 >> 9) << 4) + 15] = len\n\n w = Array.new(80, 0)\n a = 1_732_584_193\n b = -271_733_879\n c = -1_732_584_194\n d = 271_733_878\n e = -1_009_589_776\n\n # for(var i = 0; i < x.length; i += 16)\n i = 0\n while i < x.length\n olda = a\n oldb = b\n oldc = c\n oldd = d\n olde = e\n\n # for(var j = 0; j < 80; j++)\n j = 0\n while j < 80\n if j < 16\n w[j] = x[i + j] || 0\n else\n w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)\n end\n\n t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),\n safe_add(safe_add(e, w[j]), sha1_kt(j)))\n e = d\n d = c\n c = rol(b, 30)\n b = a\n a = t\n j += 1\n end\n\n a = safe_add(a, olda)\n b = safe_add(b, oldb)\n c = safe_add(c, oldc)\n d = safe_add(d, oldd)\n e = safe_add(e, olde)\n i += 16\n end\n [a, b, c, d, e]\n end",
"def digest(data); end",
"def filter_matched_lines(matched_files)\n matched_lines = []\n\n matched_files.each do |file|\n diff = git.diff_for_file(file)\n next if diff.binary?\n\n patch_lines = diff.patch.split(\"\\n\").map(&:strip)\n diff_start_line = [patch_lines.select { |line| line.start_with? \"@@\" }].flatten.compact\n next if diff_start_line.empty?\n\n start_line_number = patch_lines.index(diff_start_line[0]) + 1\n matched_lines += patch_lines[start_line_number, patch_lines.count - 1]\n .map(&:strip)\n .select { |line| line.start_with? \"+\" }\n end\n\n return [matched_lines].flatten.compact\n end",
"def core_sha1(x, len)\n # append padding\n x[len >> 5] ||= 0\n x[len >> 5] |= 0x80 << (24 - len % 32)\n x[((len + 64 >> 9) << 4) + 15] = len\n\n w = Array.new(80, 0)\n a = 1732584193\n b = -271733879\n c = -1732584194\n d = 271733878\n e = -1009589776\n\n #for(var i = 0; i < x.length; i += 16)\n i = 0\n while(i < x.length)\n olda = a\n oldb = b\n oldc = c\n oldd = d\n olde = e\n\n #for(var j = 0; j < 80; j++)\n j = 0\n while(j < 80)\n if(j < 16) \n w[j] = x[i + j] || 0\n else \n w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1)\n end\n\n t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),\n safe_add(safe_add(e, w[j]), sha1_kt(j)))\n e = d\n d = c\n c = rol(b, 30)\n b = a\n a = t\n j += 1\n end\n\n a = safe_add(a, olda)\n b = safe_add(b, oldb)\n c = safe_add(c, oldc)\n d = safe_add(d, oldd)\n e = safe_add(e, olde)\n i += 16\n end\n return [a, b, c, d, e]\n end",
"def checksum(hex)\n sha256(sha256(hex))[0...8]\nend",
"def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend",
"def file_digest_key(stat)\n \"file_digest:#{compressed_path}:#{stat}\"\n end",
"def encrypt(*tokens)\n digest = tokens.flatten.join(join_token)\n stretches.times { digest = Digest::SHA512.hexdigest(digest) }\n digest\n end",
"def get_hash_prefixes(items)\n prefixes = []\n items.each do |item|\n prefixes.push((Digest::SHA2.new << item).to_s[0..7])\n end\n\n return prefixes\n end",
"def pass_two()\n lines = get_cert_lines\n lines.sort!\n lines.each do |line|\n # Split the line using a doulbe quote. This is needed to ensure that file names with spaces work\n items = line.split('\"')\n \n # Get the oid string which is the first item in the array.\n oid_str = items.shift\n oid_str.gsub!(/\\s/, '')\n \n # For each line in the evroot.config there may be multiple certs for a single oid string.\n # This is supported by adding an array in the EVRoots.plist\n index = 0\n cmd_str = @plistbuddy_tool_path + \" -c \" + '\"' + \"add :#{oid_str} array\" + '\"' + \" \" + @evroots_plist_path\n `#{cmd_str}`\n Utilities.bail(\"#{cmd_str} failed\") if $? != 0\n \n # Loop through all of the cert file names in the line. \n items.each do |cert_file|\n # Get the full path to the cert file.\n next if cert_file.empty? || cert_file == \" \"\n cert_file.gsub!(/\\\"/, '')\n cert_to_hash = File.join(CertTools.root_certs_dir, cert_file) \n Utilities.bail(\"#{cert_to_hash} does not exist\") if !FileTest.exists?(cert_to_hash)\n \n # Use the openssl command line tool (yuck!) to get the fingerprint of the certificate\n cmd_str = @open_ssl_tool_path + \" x509 -inform DER -in \" + Utilities.quote_str(cert_to_hash) + \" -fingerprint -noout\"\n finger_print = `#{cmd_str}`\n Utilities.bail(\"#{cmd_str} failed\") if $? != 0\n \n # Post process the data from the openssl tool to get just the hex hash fingerprint.\n finger_print.gsub!(/SHA1 Fingerprint=/, '')\n finger_print.gsub!(/:/,'').chomp!\n puts \"Certificate fingerprint for #{cert_file} SHA1: #{finger_print}\" if @verbose\n \n # Convert the hex hash string to binary data and write that data out to a temp file\n binary_finger_print = Utilities.hex_to_bin(finger_print)\n FileUtils.rm_f \"/tmp/certsha1hashtmp\"\n File.open(\"/tmp/certsha1hashtmp\", \"w\") { |f| f.write binary_finger_print }\n\n # Use the PlistBuddy tool to add the binary data to the EVRoots.plist array for the oid \n cmd_str = @plistbuddy_tool_path + \" -c \" + '\"' + \"add :#{oid_str}:#{index} data\" + '\"' + \" -c \" + '\"' +\n \"import :#{oid_str}:#{index} \" + \"/tmp/certsha1hashtmp\" + '\"' + \" \" + @evroots_plist_path\n `#{cmd_str}`\n Utilities.bail(\"#{cmd_str} failed\") if $? != 0\n\n # Verify the hash value by using the PListbuddy tool to read back in the binary hash data\n cmd_str = @plistbuddy_tool_path + \" -c \" + '\"' + \"print :#{oid_str}:#{index} data\" + '\" ' + @evroots_plist_path\n file_binary_finger_print = `#{cmd_str}`\n Utilities.bail(\"#{cmd_str} failed\") if $? != 0\n file_binary_finger_print.chomp!\n\n # Convert the binary data into hex data to make comparision easier\n hex_finger_print = Utilities.bin_to_hex(binary_finger_print)\n hex_file_finger_print = Utilities.bin_to_hex(file_binary_finger_print)\n \n # Compare the two hex strings to ensure the all is well\n if hex_finger_print != hex_file_finger_print\n puts \"### BUILD FAILED: data verification error\"\n puts \"You likely need to install a newer version of #{@plistbuddy_tool_path} see <rdar://6208924> for details\"\n CertTools.restoreKeychainList\n FileUtils.rm_f @evroots_plist_path\n exit 1\n end \n \n # All is well prepare for the next item to add to the array\n index += 1\n \n end # items.each do |cert_file|\n end # lines.each do |line| \n end",
"def calculate_checksum()\n # Don't calculate, if a checksum was already provided.\n if not self.checksum.nil?\n return\n end\n\n # Create an array of process strings, sort, and md5\n process_strings = []\n self.os_processes.each do |p|\n\n # Begin string with process name.\n process_string = p.name.to_s\n\n # Append sorted files.\n file_strings = []\n p.process_files.each do |f|\n if (f.event == \"Delete\" ||\n f.file_content.nil? ||\n f.file_content.md5 == \"UNKNOWN\" ||\n f.file_content.sha1 == \"UNKNOWN\")\n file_string = f.name.to_s\n else\n file_string = f.file_content.md5.to_s + f.file_content.sha1.to_s\n end\n file_string += f.event.to_s\n file_strings << file_string\n end\n process_string += file_strings.sort.join(\"\")\n\n # Append sorted registries.\n registry_strings = []\n p.process_registries.each do |rk|\n registry_string = rk.name.to_s\n registry_string += rk.event.to_s\n registry_string += rk.value_name.to_s\n # XXX: Does not currently include value name or value type.\n registry_strings << registry_string\n end\n process_string += registry_strings.sort.join(\"\")\n process_strings << process_string\n end\n\n # Calculate the corresponding checksum.\n if process_strings.size == 0\n # If the fingerprint is empty, then generate a random checksum.\n self.checksum = Digest::MD5.hexdigest(rand.to_s)\n else\n self.checksum = Digest::MD5.hexdigest(process_strings.sort.join(\"\"))\n end\n end",
"def file_sha1\n Digest::SHA1.file(self).hexdigest\n end",
"def compute_changed_and_risk_files(params)\n commit_hash, file_arr = commit_info(params)\n changed_file_freq = file_arr.flatten!.each_with_object(Hash.new(0)) {|file, freq_acc| freq_acc[file] += 1}\n changed_g2_files = []\n changed_file_freq.select {|file, freq| changed_g2_files << file if freq > 2}\n risk_files = changed_g2_files.dup\n rf = risk_files.each_with_object({}) do |file, acc|\n author_set = Set.new\n commit_hash.each do |file_arr, author|\n acc[file] = (author_set << author ) if file_arr.include? (file)\n end\n end\n rf.delete_if {|_file, author_arr| author_arr.length < 2}\n {\n \"changed_files\" => changed_g2_files,\n \"risk_files\" => rf\n }\n end",
"def getHash element\n\tfile = File.new(element)\n\thash = Digest::SHA256.file file\n\tfile.close\n\treturn hash.hexdigest \n\tend",
"def hash256(hex)\n binary = [hex].pack(\"H*\")\n hash1 = Digest::SHA256.digest(binary)\n hash2 = Digest::SHA256.digest(hash1)\n return hash2.unpack(\"H*\").join\n end",
"def sum_from_file(filename)\nend",
"def sum_from_file(filename)\nend",
"def checksum(hex)\n sha256(sha256(hex))[0...8]\n end",
"def all_chunk_hashes\n\t\t\n\t\tbegin\n\t\t\t@all_chunk_map = \"\"\n\t\t\t0.upto(num_chunks-1) { |i|\n\t\t\t\t@all_chunk_map += sha1_chunk(i)\n\t\t\t}\n\n\t\tend unless @all_chunk_map\n\t\t@all_chunk_map\n\tend",
"def checksum\n Digest::SHA256.file(sample_dmg).hexdigest\nend",
"def dirHash(directory, regexp)\n directory = Pathname.new(directory)\n contents = \"\"\n Dir.foreach(directory) {\n | entry |\n if entry =~ regexp\n contents += IO::read(directory + entry)\n end\n }\n return Digest::SHA1.hexdigest(contents)\nend",
"def unique_files(list)\n files = []\n list.each do |entry|\n files << entry unless files.any? { |f| File.identical?(f, entry) }\n end\n files\n end",
"def unique_files(list)\n files = []\n list.each do |entry|\n files << entry unless files.any? { |f| File.identical?(f, entry) }\n end\n files\n end",
"def git_add_all_files\n files = `git ls-files`.split(\"\\n\").collect {|f| \"'#{f}'\"}\n index = 0\n while index < files.size\n block_size = 100\n to_process = files[index, block_size]\n index += block_size\n mysystem(\"git add --all --force #{to_process.join(' ')} 2> /dev/null > /dev/null\")\n end\n end",
"def checksum\n render json: content_files_checksums(druid).to_json\n end",
"def script_sha(conn, file_name)\n if (sha = SCRIPT_SHAS.get(file_name))\n return sha\n end\n\n sha = conn.script(:load, script_source(file_name))\n SCRIPT_SHAS.put(file_name, sha)\n sha\n end",
"def difffiles(fileone, filetwo, addresskeys)\n fileoneresult = String.new\n filetworesult = String.new\n arry = Array.new\n addresskeys.each do |key|\n fileoneresult = balongnvtool(fileone, key)\n filetworesult = balongnvtool(filetwo, key)\n unless fileoneresult.eql? filetworesult\n #Determine the name of the feild that has a diff\n arry.push(getdifname(fileoneresult))\n end\n end\n cleanedarry = removebandspecificaddresses(arry)\n puts cleanedarry\n return cleanedarry\n end",
"def evaluate_prefix(file_path)\n lines = File.readlines(file_path)\n lines.map(&:strip!)\n\n results = []\n\n lines.each do |line|\n results << calculate_prefix(line)\n end\n\n results.join(\"\\n\")\nend",
"def merge_files(files)\n files.reduce(nil) do |merged, file|\n puts \"Merging #{file}\" if @verbose\n merge(merged, file)\n end\n end",
"def store_entries(entries)\n path_checksums = {}\n entries.each do |entry|\n path_checksums[entry.path] = entry.sha256 if entry.sha256.present?\n store_entry entry\n end\n store_checksums path_checksums\n end",
"def sha512; 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"
] |
[
"0.66718936",
"0.63775253",
"0.6148582",
"0.5974193",
"0.5872315",
"0.58635956",
"0.5860442",
"0.58485496",
"0.5744255",
"0.5714874",
"0.5702175",
"0.5652525",
"0.56464887",
"0.56072354",
"0.55387217",
"0.55273",
"0.5516689",
"0.5507359",
"0.550718",
"0.55028313",
"0.542722",
"0.5391373",
"0.5383546",
"0.53670037",
"0.53499955",
"0.5343905",
"0.53388995",
"0.53357345",
"0.53290236",
"0.5321161",
"0.53053313",
"0.523557",
"0.5220836",
"0.5218196",
"0.5200152",
"0.51876074",
"0.5142654",
"0.5142057",
"0.51399535",
"0.5115613",
"0.51135427",
"0.50977945",
"0.50919694",
"0.5070654",
"0.50689876",
"0.50534225",
"0.5042742",
"0.5033022",
"0.50312376",
"0.5021896",
"0.50041556",
"0.49981004",
"0.4975429",
"0.49673235",
"0.49616924",
"0.49536628",
"0.49536285",
"0.4952373",
"0.49464983",
"0.49459532",
"0.49439877",
"0.49295545",
"0.49181974",
"0.4915596",
"0.48900443",
"0.4886086",
"0.48686635",
"0.48633397",
"0.48483664",
"0.48204032",
"0.48180434",
"0.48118582",
"0.48027974",
"0.48008695",
"0.4793102",
"0.47846055",
"0.47738832",
"0.476895",
"0.4765788",
"0.47583765",
"0.47575834",
"0.4749249",
"0.47471127",
"0.4746694",
"0.4746694",
"0.47448042",
"0.47421947",
"0.47258416",
"0.472079",
"0.47191468",
"0.47191468",
"0.4715125",
"0.47150084",
"0.47145158",
"0.4713702",
"0.47126284",
"0.47094044",
"0.47039387",
"0.4695067",
"0.4690825"
] |
0.7338418
|
0
|
Returns a string to be used as an image tag
|
def content_version(image_sourcefiles)
"content-#{sha256(image_sourcefiles)}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def as_img_tag()\n \"<img src='#{self.encode}' />\"\n end",
"def image_tag(image)\n raw \"<img src=\\\"/images/\" + image + \"\\\"/>\"\n end",
"def make_img_tag(x)\n\n\"<img src='\" + x +\"'/>\"\n\nend",
"def image_tag(image, opts={})\n if is_uri?(image)\n path = image\n else\n path = url(\"/images/#{image}\")\n end\n return \"<img src=\\\"#{path}\\\"#{parse_options(opts)} />\"\n end",
"def image_markup(image)\n render_to_string(\n file: 'bootsy/images/_image',\n formats: [:html],\n locals: { image: image },\n layout: false\n )\n end",
"def pet_image_tag\n return '' if pet.image_id.to_s.empty?\n\n html.div class: 'pet' do\n h2 'Actual image'\n img src: \"#{UrlAws}#{pet.image_id}\"\n end\n end",
"def image path, attrs = {}\n Tagz.tag :img, { :src => path }.merge(attrs)\n end",
"def image url, alt=url\n \"\"\n end",
"def to_s\n image\n end",
"def sss_image_tag url, options = {}\n options[:url] = url\n url = Builder.new(options).build_url()\n '<img src=\"#{url}\">'\n end",
"def to_erb\n url = @img['src']\n url.sub!(\"/images/\", \"\")\n data_pixel = ''\n\n # resolve special data-pixel-density-2 case\n if @img.to_s.include? 'data-pixel-density-2'\n data_value = @img['data-pixel-density-2']\n data_value.sub!(\"/images/\", \"\")\n data_pixel = \", 'data-pixel-density-2': image_path('#{data_value}')\"\n end\n\n options_str = process_options\n\n if url.include?(\"<%= \") && url.include?(\" %>\")\n url.sub!(\"<%= \", '#{')\n url.sub!(\" %>\", \"}\")\n url_string = \"\\\"#{url.to_s}\\\"\"\n\n \"<%= image_tag(#{url_string}#{options_str}#{data_pixel})%>\"\n else\n \"<%= image_tag('#{url}'#{options_str}#{data_pixel})%>\"\n end\n end",
"def xf_image_tag (src, attrs = {})\n attrs = attrs.symbolize_keys()\n content = \"\"\n caption = attrs.delete(:caption)\n unless caption.nil?\n content += typeWithAttrs(\"caption\", caption, nil, xhtml2prefix)\n end\n width = attrs.delete(:width)\n unless width.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-width\", :value => width}, xhtml2prefix)\n end\n height = attrs.delete(:height)\n unless height.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-height\", :value => height}, xhtml2prefix)\n end\n attrs[:src] = src\n typeWithAttrs(\"object\", content, attrs, xhtml2prefix)\n end",
"def icon\n image_tag( \"tags/#{ @name }.png\" , :height => 8 )\n end",
"def image_tag(source, options = {})\n options.symbolize_keys!\n\n options[:src] = path_to_image(source)\n options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize\n\n if size = options.delete(:size)\n options[:width], options[:height] = size.split(\"x\") if size =~ %r{^\\d+x\\d+$}\n end\n\n if mouseover = options.delete(:mouseover)\n options[:onmouseover] = \"this.src='#{image_path(mouseover)}'\"\n options[:onmouseout] = \"this.src='#{image_path(options[:src])}'\"\n end\n\n tag(\"img\", options)\n end",
"def image_string_creator\r\n n = []\r\n n << \"src:\".ljust(TO_S_SIZE) + self.src.to_s\r\n n << \"file date:\".ljust(TO_S_SIZE) + self.fileCreatedDate.to_s\r\n n << \"file size:\".ljust(TO_S_SIZE) + self.fileSize.to_s\r\n n << \"width:\".ljust(TO_S_SIZE) + self.width.to_s\r\n n << \"height:\".ljust(TO_S_SIZE) + self.height.to_s\r\n n << \"alt:\".ljust(TO_S_SIZE) + self.alt.to_s\r\n return n\r\n end",
"def image_tag( file_or_url, options = {} )\n\n # if the file is from ActiveStorage, convert it, then convert it into a URL\n file_or_url = polymorphic_url( file_or_url ) unless file_or_url.is_a?( String )\n file_or_url = asset_url_for( file_or_url ) unless file_or_url.match?( /^(http(s)?\\:|data\\:|system\\/|\\/)/ )\n\n # set/default some attrs\n options[:src] = file_or_url\n options[:alt] ||= ''\n\n # return the IMG tag\n tag( :img, options )\n\n end",
"def img(image_src, options = {})\n image_src = case image_src.to_s\n when /^\\/images/\n image_src\n when /^images/\n '/' + image_src\n when /^\\//\n image_src\n else\n '/images/' + image_src\n end\n image_src = \"#{get_resource_root(image_src)}#{image_src}?#{configatron.mack.assets.stamp}\"\n non_content_tag(:img, {:src => image_src}.merge(options))\n end",
"def image(image = nil)\n if image\n if image.include?('/')\n # pathological case, a ':' may be present which starts the 'port'\n # part of the image name and not a tag. example: 'host:1337/blah'\n # fortunately, tags are only found in the 'basename' part of image\n # so we can split on '/' and rebuild once the tag has been parsed.\n dirname, _, basename = image.rpartition('/')\n r, t = basename.split(':', 2)\n r = [dirname, r].join('/')\n else\n # normal case, the ':' starts the tag part\n r, t = image.split(':', 2)\n end\n repo r\n tag t if t\n end\n \"#{repo}:#{tag}\"\n end",
"def image_tag src = nil, opts = {}\n src.is_a?(Hash) && (opts = src.dup) && (src = nil)\n opted_src = opts.delete(:src)\n src ||= opted_src || raise('Please provide image URL as first argument or :src option')\n opts[:alt] ||= ::File.basename(src, ::File.extname(src))\n \"<img src=\\\"%s\\\" %s />\\n\" % [\n opted_src ? opted_src : assets_url(src),\n __e__.assets__opts_to_s(opts)\n ]\n end",
"def image(options = {}, html_options = {})\n html_options[:src] = if options.is_a?(String) then options else self.url_for(options) end\n html_options[:alt] ||= File.basename(html_options[:src], '.*').split('.').first.capitalize\n\n if html_options[:size]\n html_options[:width], html_options[:height] = html_options[:size].split(\"x\")\n html_options.delete :size\n end\n\n tag(\"img\", html_options)\n end",
"def make_emoticon image, alt\n '<img src=\"' << escape_html(\"/emoticons/#{image}.png\") << '\" alt=\"' << escape_html(alt) << '\" title=\"' << escape_html(alt) << '\"/>'\n end",
"def ImageTag(smiley, animated = false)\n if animated\n '<img src=\"/public/smileys/animated/'+smiley+'.gif\" title=\"('+smiley+')\" height=\"20px\" width=\"20px\" style=\"display:inline;margin:0;vertical-align:middle\"/>'\n else\n '<img src=\"/public/smileys/general/'+smiley+'.png\" title=\":'+smiley+':\" height=\"20px\" width=\"20px\" style=\"display:inline;margin:0;vertical-align:middle\"/>'\n end\n end",
"def image(name, html_options = {})\n %Q{<img src=\"img/#{name}.png\" alt=\"#{name}\" #{%Q{id=\"#{html_options[:id]}\"} if html_options[:id]} #{%Q{class=\"#{html_options[:class]}\"} if html_options[:class]} #{%Q{style=\"#{html_options[:style]}\"} if html_options[:style]}/>}\n end",
"def ubiquo_image_tag(name, options={})\n options[:src] ||= ubiquo_image_path(name)\n options[:alt] ||= \"Ubiquo image\"\n tag('img', options)\n end",
"def facebook_image_tag(name,options={})\n tag \"img\",:src=>\"http://#{ENV['FACEBOOKER_STATIC_HOST']}#{image_path(name)}\"\n end",
"def image_hwstring(width, height)\n out = ''\n if width\n out += 'width=\"' + width.to_i.to_s + '\" '\n end\n if height\n out += 'height=\"' + height.to_i.to_s + '\" '\n end\n out\n end",
"def image_tag src = nil, opts = {}\n src.is_a?(Hash) && (opts = src.dup) && (src = nil)\n opted_src = opts.delete(:src)\n src ||= opted_src || raise('Please provide image URL as first argument or :src option')\n opts[:alt] ||= ::File.basename(src, ::File.extname(src))\n \"<img src=\\\"%s%s\\\" %s>\\n\" % [\n opted_src ? opted_src : assets_url(src),\n opts.delete(:ext),\n __e__assets__opts_to_s(opts)\n ]\n end",
"def image\n (object.image_url.nil? || object.image_url.empty?) ? h.content_tag(:span,\"\",class: \"glyphicon glyphicon-picture\") : h.image_tag(object.image_url)\n end",
"def image_tag(source, options = {})\n options[:src] = url_for(source)\n tag(\"img\", options)\n end",
"def image(name, options = {})\n path = \"/images/#{name}\"\n path += \".png\" unless path.match(/.[A-za-z]{3,4}$/)\n image_tag(name, {:alt => \"\"}.update(options))\n end",
"def getImg(width=64, height=64)\n if self.image\n self.image+\"?width=#{width}&height=#{height}\"\n else\n \"no_image.png\"\n end\n end",
"def cms_image_tag(img_key, options = {})\n image_tag cms_image_url(img_key), options\n end",
"def og_image(image)\n\t\tbase_image = \"http://i.imgur.com/DfYlA.png\"\n\t\tif image.empty?\n\t\t\tbase_image\n\t\telse\n\t\t\timage\n\t\tend\n\tend",
"def image_tag(src, html_options = {})\n src = \"#{Compass.configuration.images_dir}/#{src}\" unless src =~ /^(https?:|\\/)/\n tag(:img, html_options.merge(:src=>src))\n end",
"def image_element(url, name)\n abs_url = @base_url + url\n size = content_size(abs_url)\n\n ret = \"<image url=#{abs_url.encode(xml: :attr)} name=#{name.encode(xml: :attr)} size=\\\"#{size}\\\">\\n\"\n ret += \"<checksum type=\\\"sha256\\\" disposition=#{(abs_url + '.sha256').encode(xml: :attr)}/>\\n\"\n ret += \"</image>\"\n ret.html_safe\n end",
"def image(arg=nil)\n set_or_return(:image, arg, :kind_of => String)\n end",
"def image(opts)\n \"#{opts[:alt] || opts[:title]}\"\n end",
"def render_image(image)\n id_attr = image.id ? %( id=\"attachment_#{image.id}\") : \"\"\n lines = []\n lines << %(<figure#{id_attr} class=\"image embedded\">)\n lines << %(<div class=\"img\"><img src=\"#{encode(image.url)}\" alt=\"#{encode(image.alt_text)}\"></div>)\n lines << image.figcaption_html if image.figcaption?\n lines << \"</figure>\"\n lines.join\n end",
"def localized_image_tag(source, options = {})\n\n return image_tag(source, options) if default_locale?\n image_tag = get_localized_image_tag( source, options, false )\n if !image_tag.blank?\n return image_tag\n else\n # fallback on text\n if options[:altclass]\n return \"<span class='#{options[:altclass]}'>\" + options[:alt] + \"</span>\"\n else\n return options[:alt]\n end\n end\n end",
"def process_image_tag(tag)\n parts = tag.split('|')\n return if parts.size.zero?\n\n name = parts[0].strip\n\n path = if file = media_file_exist?(name)\n file\n elsif name =~ /^https?:\\/\\/.+(jpg|png|gif|svg|bmp)$/i\n name\n end\n\n if path\n opts = parse_image_tag_options(tag)\n containered = false\n\n classes = [] # applied to whatever the outermost container is\n attrs = [] # applied to the image\n\n align = opts['align']\n if opts['float']\n containered = true\n align ||= 'left'\n if %w{left right}.include?(align)\n classes << \"float-#{align}\"\n end\n elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)\n attrs << %{align=\"#{align}\"}\n elsif align\n if %w{left center right}.include?(align)\n containered = true\n classes << \"align-#{align}\"\n end\n end\n\n if width = opts['width']\n if width =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{width=\"#{width}\"}\n end\n end\n\n if height = opts['height']\n if height =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{height=\"#{height}\"}\n end\n end\n\n if alt = opts['alt']\n attrs << %{alt=\"#{alt}\"}\n end\n\n attr_string = attrs.size > 0 ? attrs.join(' ') + ' ' : ''\n\n if opts['frame'] || containered\n classes << 'frame' if opts['frame']\n %{<span class=\"#{classes.join(' ')}\">} +\n %{<span>} +\n %{<img src=\"#{path}\" #{attr_string}/>} +\n (alt ? %{<span>#{alt}</span>} : '') +\n %{</span>} +\n %{</span>}\n else\n %{<img src=\"#{path}\" #{attr_string}/>}\n end\n end\n end",
"def light_image_tag(source, options = {})\n options.symbolize_keys!\n src = options[:src] = path_to_image(source)\n unless src =~ /^(?:cid|data):/ || src.blank?\n options[:alt] = options.fetch(:alt){ image_alt(src) }\n end\n if size = options.delete(:size)\n options[:width], options[:height] = size.split(\"x\") if size =~ %{^\\d+x\\d+$}\n end\n if mouseover = options.delete(:mouseover)\n options[:onmouseover] = \"this.src='#{path_to_image(mouseover)}'\"\n options[:onmouseout] = \"this.src='#{src}'\"\n end\n\n content_tag(:a, tag(\"img\", options), :href => src, :class => \"image-link\")\n # content_tag :a, :class => \"image-link\" do\n # content_tag :img, options\n # end\n # tag(\"a\", href: src) do\n # tag(\"img\", options)\n # end\n end",
"def photo(image, alt_text = '')\n image_tag('image/todd_ramirez_' + image,\n alt: alt_text,\n title: alt_text)\n end",
"def image(full_path, opts = {})\n image_name = template.add_image(full_path)\n output = '<draw:frame text:anchor-type=\"as-char\" '\n opts[:width] && output << %Q(svg:width=\"#{opts[:width]}cm\" )\n opts[:height] && output << %Q(svg:height=\"#{opts[:height]}cm\")\n output << '>'\n output << %Q(<draw:image xlink:href=\"Pictures/#{image_name}\" )\n output <<\n 'xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>'\n output << '</draw:frame>'\n end",
"def page_asset_image_tag(image_file_name)\n %{<img src=\"#{page_assets_link_base}#{image_file_name}\" />}\n end",
"def image_tag(url, options={})\n options = { :src => image_path(url) }.update(options)\n options[:alt] ||= image_alt(url) unless url.to_s =~ /\\A(?:cid|data):|\\A\\Z/\n tag(:img, options)\n end",
"def image(src, options = {})\n media = extract_media!(options)\n (@images ||= []) << IMAGE.new(src, media, options)\n\n # Do not render anything here!\n return \"\"\n end",
"def image(operations = nil)\n image_tag(url(operations))\n end",
"def og_image_tag(url)\n tag(:meta, :property => 'og:image', :content => url).html_safe if url\n end",
"def goth_image_full_tag(goth)\n\t\timage = image_path \"goths/#{goth.name}.jpg\"\n\t\turl = \"#{root_url.chomp('/')}#{image}\"\n\t\timage_tag url, :alt => goth.name, :title => goth.name\n\tend",
"def convert_img(el, opts)\n alt_text = el.attr['alt'].to_s#.gsub(ESCAPED_CHAR_RE) { $1 ? \"\\\\#{$1}\" : $2 }\n src = el.attr['src'].to_s\n if src.empty?\n \"![#{alt_text}]()\"\n else\n title = parse_title(el.attr['title'])\n link = if src.count(\"()\") > 0\n \"<#{src}>\"\n else\n src\n end\n \"\"\n end\n end",
"def image\n lambda do |text|\n begin \n hash = parse_text(text)\n image = find_image(hash)\n src = get_image_src(hash, image)\n\n unless image.nil?\n engine = gen_haml('image.haml')\n engine.render(nil, {:src => src, :id => hash['id'], :class_name => hash['class'], :alt => hash['alt'], :title => hash['title'], :itemprop => hash['itemprop'], :height => hash['height'], :width => hash['width']})\n end\n rescue NoMethodError => e\n Rails.logger.error \"#{e} could not find image with the params: #{text}\"\n end\n end\n end",
"def alt\n output = self.name\n tags_str = self.photo_tags.collect(&:tag).join(', ')\n output += ' (' + tags_str.strip + ')' if tags_str != ''\n output += tags_str == '' ? self.caption : ': ' + self.caption if self.caption && self.caption != ''\n output += ' - ' + self.location if self.location && self.location != ''\n output\n end",
"def process_image_tag(tag)\n parts = tag.split('|')\n return if parts.size.zero?\n\n name = parts[0].strip\n path = if file = find_file(name)\n ::File.join @wiki.base_path, file.path\n elsif name =~ /^https?:\\/\\/.+(jpg|png|gif|svg|bmp)$/i\n name\n end\n\n if path\n opts = parse_image_tag_options(tag)\n\n containered = false\n\n classes = [] # applied to whatever the outermost container is\n attrs = [] # applied to the image\n\n align = opts['align']\n if opts['float']\n containered = true\n align ||= 'left'\n if %w{left right}.include?(align)\n classes << \"float-#{align}\"\n end\n elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)\n attrs << %{align=\"#{align}\"}\n elsif align\n if %w{left center right}.include?(align)\n containered = true\n classes << \"align-#{align}\"\n end\n end\n\n if width = opts['width']\n if width =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{width=\"#{width}\"}\n end\n end\n\n if height = opts['height']\n if height =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{height=\"#{height}\"}\n end\n end\n\n if alt = opts['alt']\n attrs << %{alt=\"#{alt}\"}\n end\n\n attr_string = attrs.size > 0 ? attrs.join(' ') + ' ' : ''\n\n if opts['frame'] || containered\n classes << 'frame' if opts['frame']\n %{<span class=\"#{classes.join(' ')}\">} +\n %{<span>} +\n %{<img src=\"#{path}\" #{attr_string}/>} +\n (alt ? %{<span>#{alt}</span>} : '') +\n %{</span>} +\n %{</span>}\n else\n %{<img src=\"#{path}\" #{attr_string}/>}\n end\n end\n end",
"def image\n if formatted_image.present?\n formatted_image\n else\n original_image\n end\n end",
"def tag_icon(tag)\n return \"\" if tag.blank?\n icon = <<-HTML\n <i class=\"icon-tag\"></i>\n HTML\n unless tag.icon_url.blank?\n icon = <<-HTML\n <img src=\"#{tag.icon_url}\" width=\"20\" height=\"20\">\n HTML\n end\n icon.html_safe\n end",
"def image(image_name, _opts)\n opts = _opts[:img] || {}\n opts[:alt] ||= _opts[:title]\n\n # TODO: understand === if you want to use case statement\n image_path = if image_name.class == String\n image_name\n elsif image_name.class == Symbol\n \"image_link/#{image_name}.png\"\n elsif image_name == false\n false\n else\n 'image_link/default.png'\n end\n\n image_path ? image_tag(image_path, opts) : raw('')\n end",
"def photo_text_s(image, text, alt_text = t(text))\n image_tag('image/todd_ramirez_' + image,\n alt: alt_text,\n title: alt_text) + tag(:br) +\n content_tag(:itext, t(text)) + tag(:br) + tag(:br) + tag(:br) + tag(:br)\n end",
"def to_html\n \"<img src='#{@url}' height='#{@height}' width='#{width}' />\"\n end",
"def image_url\n if image.present?\n image\n else\n \"http://loremflickr.com/320/240/#{CGI.escape name}\"\n end\n end",
"def course_image_preview(entity)\n return '' if entity.image.blank?\n\n versions = \"#{entity.image.preview_2x.url} 2x\"\n image_tag(entity.image.preview.url, alt: entity.title, srcset: versions)\n end",
"def image_tag_url(image, options={})\n image_tag \"#{root_url}images/#{image.gsub(/^\\//,'')}\", options\n end",
"def decorate_image\n if model.image_processed?\n return h.image_tag model.image_url(:thumb) if model.image?\n else\n return '<em>processing...</em>'\n end\n end",
"def image_tag_for_key(key, url=nil, alt=nil, url_options={}, label=key.humanize, remote=false)\n\n if (label == 'Destroy')\n label = 'Delete';\n end\n\n return nil unless (filename = icon_filename_for_key(key.downcase))\n\n image_options = alt ? { :alt => alt } : { :alt => key.humanize }\n img_tag = image_tag(filename, image_options)\n\n inner = img_tag;\n inner = \"#{img_tag} #{label}\" unless label == nil\n\n if (url)\n if (remote)\n inner = link_to_remote(inner, url, url_options);\n else\n inner = link_to(inner, url, url_options)\n end\n end\n\n return '<span class=\"icon\">' + inner + '</span>';\n end",
"def logo\n image_tag(\"boulder.png\", :width => \"100\", \n :height => \"75\",\n :alt => \"Learning RoR\", \n :class => \"round\")\n end",
"def image(link, title, alt_text)\n if link =~ /^(.+?)\\s*=+(\\d+)(?:px|)$/\n # \n # \n %(<img src=\"#{$1}\" style=\"width: #{$2}\" alt=\"#{alt_text}\">)\n elsif link =~ /^(.+?)\\s*=+(\\d+)(?:px|)x(\\d+)(?:px|)$/\n # \n %(<img src=\"#{$1}\" style=\"width: #{$2}; height: #{$3};\" alt=\"#{alt_text}\">)\n else\n %(<img src=\"#{link}\" title=\"#{title}\" alt=\"#{alt_text}\">)\n end\n end",
"def image_tag(path, params={})\n params.symbolize_keys!\n\n # We'll use these for different purposes below.\n file_name = File.basename( path )\n file_base = File.basename( path, '.*' )\n file_extn = File.extname( path )\n file_path = File.dirname( path )\n\n # Here's we're going to log missing images, i.e., images that\n # were requested for for which no file was found. Note that this\n # won't detect images requested via md ![tag][reference].\n checking_path = File.join(source_dir, path)\n unless File.exist?( checking_path )\n puts_red \"#{file_name} was requested but is not in the source!\"\n end\n\n # Here we're going to automatically substitute a target-specific image\n # if the specified image includes the magic prefix `all-`. We have to\n # make this check prior to the srcset below, so that srcset can check\n # for the existence of the correct, target-specific file we determine\n # here.\n if file_name.start_with?(\"all-\")\n proposed_name = file_name.sub(\"all-\", \"#{target_name}-\")\n checking_path = File.join(source_dir, file_path, proposed_name)\n\n if File.exist?( checking_path )\n file_name = proposed_name\n file_base = File.basename( file_name, '.*' )\n path = file_name\n end\n end\n\n # Here we're going to automatically include an @2x image in <img> tags\n # as a `srcset` attribute if there's not already a `srcset` present.\n if extensions[:Middlemac].options.Retina_Srcset\n\n unless params.key?(:srcset)\n proposed_name = \"#{file_base}@2x#{file_extn}\"\n checking_path = File.join(source_dir, file_path, proposed_name)\n\n if File.exist?( checking_path )\n srcset_img = File.join(file_path, \"#{file_base}@2x#{file_extn} 2x\")\n params[:srcset] = srcset_img\n end\n end\n\n end # if extensions\n\n super(path, params)\n end",
"def img_name\n \"#{@function}_#{@side.to_s[0,1]}\"\n end",
"def ver_foto\n %Q(<img src=\"#{foto}\" alt=\"#{nombre}\" />)\n end",
"def source_type(source)\n return \"<div class='source'><img src='https://www.bungie.net/#{source['icon']}' title='#{source['sourceName']}' class='image'><div class='text'><span class='title'>#{source['sourceName']}</span><span class='desc'>#{source['description']}</span></div></div>\".html_safe\n end",
"def diswimage(image_text)\n image_options = image_text.gsub(/#/, '').gsub(/diswimage:/, '').split(':')\n image_title = image_options[0]\n image_extension = image_options[1]\n option_count = image_options[2]\n image_width = image_options[3]\n return \"!{width: #{image_width}px}http://doitidiot.s3.amazonaws.com/#{image_title}-#{rand(option_count)+1}.#{image_extension}!\"\n end",
"def image(path, options = {})\n o = Hash(options).map { |k, v| \"#{k}='#{v}'\" }.join(' ')\n\n asset_html(path, [IMAGE_CDN.chomp, o].join(' '),\n [IMAGE_LOCAL.chomp, o].join(' '), options)\n end",
"def startIndivThumbnail image\n return \"\n <li class='span3'>\n <div class='thumbnail'>\n <img id='peopleImg' src= #{image} >\n <div class='caption'> \"\n end",
"def semantic_entry_image(e, style, max_width=nil, popup=true, use_alt_img=false)\n c = '<figure vocab = \"http://schema.org/\" typeof=\"ImageObject\"> '.html_safe\n sc = e.raw_title.blank? ? e.image_caption : e.raw_title\n c += \"<meta property='name' content='#{sc}'> \".html_safe\n c += \"<div class='#{style.to_s} image_wrapper'>\".html_safe\n c += image_with_style(e, style, max_width, popup, use_alt_img)\n c += '</div>'.html_safe\n unless e.image_caption.blank? || style == :home\n c += \"<figcaption class='caption'> <div class='caption-inner' property='description'>#{e.image_caption}</div> </figcaption> \".html_safe\n end\n c += '</figure>'.html_safe\n end",
"def icon aFileName, aAlt = nil, aTitle = nil\n aTitle ||= aAlt\n\n %{<img class=\"icon\" src=\"icons/#{aFileName}\" alt=\"#{aAlt}\" title=\"#{aTitle}\" />}\n end",
"def cl_image_tag(source, options = {})\r\n cloudinary_tag source, options do |source, options|\r\n if source\r\n image_tag_without_cloudinary(source, options)\r\n else\r\n tag 'img', options\r\n end\r\n end\r\n\r\n end",
"def image\n 'gh.png'\n end",
"def image()\n @image__\n end",
"def to_html\r\n return '' unless image?\r\n %(<div>\r\n <a href=\"#{@url}\" target=\"_blank\">\r\n <img src=\"#{@image_url}\">\r\n </a>\r\n </div>)\r\n end",
"def image alt_text, href\n \"!\" + link_to(alt_text, href)\n end",
"def image_name\n path = \"sets/#{set}/#{dimension}_#{polarity}_#{verbal}\"\n # Rails.application.assets.find_asset(path).nil? ? 'placeholder' : path\n path\n end",
"def absolute_image_tag(*args)\n raw(image_tag(*args).sub( /src=\"(.*?)\"/, \"src=\\\"#{request.protocol}#{request.host_with_port}\" + '\\1\"'))\n end",
"def image_tag(url, options={})\n options.reverse_merge!(:src => image_path(url))\n tag(:img, options)\n end",
"def image_for(id, size=:source)\n image_tag \"https://spoonacular.com/recipeImages/#{id}-#{IMAGE_SIZES[size]}\"\n end",
"def create_image_object(obj)\n return content_tag(:div, tag(:img, :src => obj.link), :style => \"position:absolute; top: #{obj.y}px; left: #{obj.x}px;\")\n end",
"def icon_tag(image, alt, opts={})\n image+= \".png\" unless image.match(/\\.[a-z]+$/)\n image_tag \"icons/#{image}\", { alt: alt, title: alt, size: \"16x16\" }.merge(opts)\n end",
"def to_s\n @result_html = ''\n @images_urls.each do |url|\n @result_html += \"<img src=\\\"#{url}\\\"/>\"\n end\n @result_html.html_safe\n end",
"def label_for_image_link(_opts)\n return raw('') unless _opts[:label_text]\n text = _opts[:label_text]\n opts = _opts[:label]\n \n content_tag :span, text, opts\n end",
"def course_image_small(entity, add_options = {})\n return '' if entity.image.blank?\n\n alt_text = entity.image_alt_text.to_s\n versions = \"#{entity.image.medium.url} 2x\"\n options = { alt: alt_text, srcset: versions }.merge(add_options)\n image_tag(entity.image.small.url, options)\n end",
"def course_image_medium(entity, add_options = {})\n return '' if entity.image.blank?\n\n alt_text = entity.image_alt_text.to_s\n versions = \"#{entity.image.big.url} 2x\"\n options = { alt: alt_text, srcset: versions }.merge(add_options)\n image_tag(entity.image.medium.url, options)\n end",
"def img_file\n return \"map_\" + symbol.to_s + \"_full\"\n end",
"def image_name(extension = true)\n if @image_name.nil? and self.type == LAYER_NORMAL\n name = \"#{self.uid}.png\"\n else\n name = @image_name\n end\n\n if extension\n name\n else\n name.sub(\".png\", \"\")\n end\n end",
"def image_alt_attribute_name\r\n return \"#{self.name}\"\r\n end",
"def image_alt_attribute_name\r\n return \"#{self.name}\"\r\n end",
"def image_alt_attribute_name\r\n return \"#{self.name}\"\r\n end",
"def format\n \"image/jpeg\"\n end",
"def image_name\n @image_name || image_bundle.image_name\n end",
"def service_image(name, size = 24)\n %Q{/images/service_icons/#{size}/#{name}}\n end",
"def badge_image\n badge_type.image_url + year.to_s + \".png\"\n end",
"def png\n self.to_s\n end",
"def image\n if !self.extend_url.blank?\n self.qrcode\n elsif self.page_content.try(:content) =~ /<img\\s+.*src\\s*=\\s*\"(.*\\.(?:jpg|png|gif))\"/i\n $1\n else\n \"/assets/avatar.jpg\"\n end\n end",
"def image _args\n \"image _args;\" \n end"
] |
[
"0.7878503",
"0.784707",
"0.73892283",
"0.7232643",
"0.70964324",
"0.7091647",
"0.7081505",
"0.69948363",
"0.69067574",
"0.69045",
"0.68845636",
"0.68583536",
"0.6829865",
"0.68250823",
"0.6755572",
"0.6719416",
"0.670958",
"0.6705684",
"0.67030185",
"0.66915226",
"0.66844594",
"0.66841245",
"0.66772217",
"0.6660692",
"0.6620505",
"0.661579",
"0.6612957",
"0.66074365",
"0.6603533",
"0.65960926",
"0.6589456",
"0.65867144",
"0.65853876",
"0.6574435",
"0.65676725",
"0.656313",
"0.6554861",
"0.6554211",
"0.6545747",
"0.64947027",
"0.6487767",
"0.6478166",
"0.6465593",
"0.6453496",
"0.6447942",
"0.64359593",
"0.6399913",
"0.63896817",
"0.63862246",
"0.6385454",
"0.6378384",
"0.63707453",
"0.6343865",
"0.63364244",
"0.63328606",
"0.6327308",
"0.63166636",
"0.63086283",
"0.62959397",
"0.6291753",
"0.6287738",
"0.6279726",
"0.6279346",
"0.6277641",
"0.62761354",
"0.62691903",
"0.6267476",
"0.62602156",
"0.62561107",
"0.6249925",
"0.62345535",
"0.6199237",
"0.61975116",
"0.61931807",
"0.6180239",
"0.61763924",
"0.61741763",
"0.6168385",
"0.6155722",
"0.6150774",
"0.61454666",
"0.6131717",
"0.6106478",
"0.60838044",
"0.6083464",
"0.60744053",
"0.60725933",
"0.6064164",
"0.6062935",
"0.6057557",
"0.60563964",
"0.6052579",
"0.6052579",
"0.6052579",
"0.60490847",
"0.6048799",
"0.604696",
"0.6043662",
"0.60402244",
"0.6039259",
"0.60268843"
] |
0.0
|
-1
|
Download json with a thousand ways of a certain category
|
def get_json_from_openstreetmaps(key,val,constrain_to_usa = true)
timeout = 20000
bounds = "#{CONTINENTAL_US[:s]},#{CONTINENTAL_US[:w]},#{CONTINENTAL_US[:n]},#{CONTINENTAL_US[:e]}"
bounds_string = constrain_to_usa ? "(#{bounds})" : ""
#This string fetches all geometry of a way including center points, but does not restrict how many ways to download
#str = "data=[out:json][timeout:#{timeout}];way[\"#{key}\"=\"#{val}\"](#{bounds_string});foreach((._;>;);out center #{NUMBER_TO_DOWNLOAD};);"
#This string fetches almost all geometry of a way except for center points. Does restrict number to download.
str = "data=[out:json][timeout:#{timeout}][maxsize:1073741824];way[\"#{key}\"=\"#{val}\"]#{bounds_string};out count;out meta geom #{NUMBER_TO_DOWNLOAD};"
print str
base_url = "http://overpass-api.de/api/interpreter?"
url = "#{base_url}#{URI.escape(str)}"
puts url
response = Typhoeus.get(url, {followlocation: true, timeout: timeout})
response.body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch_categories(count = ENV['DEFAULT_CATEGORY_COUNT'].to_i)\n max_category = 18418\n uri = \"http://jservice.io/api/categories?count=#{count}&offset=#{1+rand(max_category/count.to_f)}\"\n request = HTTParty.get(uri)\n data = JSON.parse(request.body)\nend",
"def categories()\n @web.get('http://www.waymarking.com/cat/categorydirectory.aspx') do |page|\n ile = 0\n #puts page.parser.to_html.to_s\n cache = {}\n\n page.parser.css('div#content div.gutter a').each do |cat|\n href = cat.attr('href')\n m = Category::GUID_REGEXP.match href\n key = Waymarking::Utils.parameterize(cat.text)\n unless m.nil? then\n ile +=1\n raise DuplicatedCategory if cache.has_key? key\n\n cache[key] = m[1]\n #puts \"#{ile} #{key} #{cat.text} #{m[1]}\"\n else\n puts href\n end\n\n end\n\n cache2 = {}\n cache.keys.each do |key|\n @web.get(\"http://www.waymarking.com/cat/details.aspx?f=1&guid=#{cache[key]}&exp=True\") do |page2|\n begin\n cat = Waymarking::Category.from_html(page2)\n cache2[key] = cat\n rescue\n puts key\n end\n end\n end\n\n File.open('categories.yml', 'w') do |f|\n f.write YAML::dump(cache2)\n end\n end\n end",
"def downloadable_games\n [].tap do |all_games|\n data.each do |category_name, category|\n games = category.fetch('games').select do |_, game|\n game['downloadable']\n end\n\n category_path = category_path_for(category_name)\n\n games.each do |game_name, hash|\n game_path = category_path.join(Helpers.sanitize_file_name(game_name))\n next if game_path.exist? && !game_path.size.zero?\n\n all_games << {\n name: game_name,\n file_path: game_path,\n page_url: hash['download_url']\n }\n end\n end\n end\n end",
"def gather_uri(key = nil, cat = nil, val = nil)\n uri = \"http://jservice.io/api/\"\n if !key.nil? && !cat.nil?\n category = return_categories(key)\n category = category.select {|c| c[\"title\"] == cat}[0] if category.kind_of? Array\n uri += \"clues?category=#{category['id']}\"\n if !val.nil?\n uri += \"&value=#{val}\"\n end\n else\n uri += \"random?count=1\"\n end\n uri\nend",
"def api_get_json(url, page, o = {})\n u = absolute_url(url)\n\n options = {}.merge(o)\n options[:_page] = page if page.is_a? Integer\n resp = []\n\n time_taken = Benchmark.measure do\n while u\n json = get_json(u, options)\n result = json['result']\n\n resp.concat(result['items']) unless item_endpoint?(page)\n resp = result['primaryTopic'] if item_endpoint?(page)\n\n u = (fetch_all?(page) || fetch_more?(o, resp)) && more?(result)\n options.delete(:_page) if u\n end\n end\n\n Rails.logger.debug(\"Completed remote JSON LDA execution in: #{time_taken}\")\n resp\n end",
"def get_character_movies_from_api(character)\n #make the web request\n page = 1\n # iterate over the character hash to find the collection of `films` for the given\n # `character`\n # collect those film API urls,\n until page == 10\n all_characters = RestClient.get(\"https://swapi.co/api/people/?page=#{page}\")\n character_hash = JSON.parse(all_characters)\n\n character_hash[\"results\"].each do |value|\n if value[\"name\"] == character\n films_hash = value[\"films\"]\n end\n end\n page +=1\n end\n\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def download\n page = params[:page].to_i\n\n a = download_conjugation(page)\n @verbs_conj.each do |verb|\n v = Verb.new(:infinitive => verb[:infinitive], :translation => verb[:translation], :group => verb[:group])\n if v.save\n @tenses.each_with_index do |tense, index|\n @forms.each_with_index do |form, index2|\n if(verb[tense][form].strip != '')\n @form = Form.new(:content => verb[tense][form], :temp => index.to_i, :person => index2.to_i,:verb => v)\n @form.save\n end\n end\n end\n end\n end\n File.open(\"public/temp_#{page}.json\",\"w\") do |f|\n f.write(JSON.pretty_generate(@verbs_conj))\n end\n\n @verbs = Verb.all\n respond_to do |format|\n format.html{ render action: 'index'}\n format.json { head :no_content }\n end\n\n end",
"def jacket_API_data\n if @style == 0 # Athletic\n #########################################\n # API call for Sweatshirts category.\n # Search with 'active' and 'hoodies' queries\n #########################################\n build_partial_url(\"&cat=girls-sweatshirts\", @jacket_size)\n\n @request_url += '&fts=active&fts=hoodies'\n\n sweatshirts_by_query_response = HTTParty.get(@request_url)\n\n sweatshirts_by_query_products = JSON.parse(sweatshirts_by_query_response.body)[\"products\"]\n\n jackets_products = sweatshirts_by_query_products\n\n elsif @style == 1 # Formal\n #########################################\n # API call for Sweaters category.\n # Search with 'cardigan' query\n #########################################\n build_partial_url(\"&cat=girls-sweaters\", @jacket_size)\n\n @request_url += '&fts=cardigan'\n\n sweaters_by_query_response = HTTParty.get(@request_url)\n\n sweaters_by_query_products = JSON.parse(sweaters_by_query_response.body)[\"products\"]\n\n jackets_products = sweaters_by_query_products\n\n elsif @style == 2 # Everyday\n #########################################\n # API call for Sweaters category.\n # Search with no query\n #########################################\n build_partial_url(\"&cat=girls-sweaters\", @jacket_size)\n\n sweaters_response = HTTParty.get(@request_url)\n\n sweaters_products = JSON.parse(sweaters_response.body)[\"products\"]\n\n #########################################\n # API call for Sweatshirts category.\n # Search with no query\n #########################################\n build_partial_url(\"&cat=girls-sweatshirts\", @jacket_size)\n\n sweatshirts_response = HTTParty.get(@request_url)\n\n sweatshirts_products = JSON.parse(sweatshirts_response.body)[\"products\"]\n\n #########################\n # Combine products\n #########################\n # Zip (interweave) products data into one array\n jackets_products = sweatshirts_products.zip(sweaters_products).flatten.compact\n\n elsif @style == 3 # Trendy\n #########################################\n # API call for Sweaters category.\n # Search with 'print' query\n #########################################\n build_partial_url(\"&cat=girls-sweaters\", @jacket_size)\n\n @request_url += '&fts=print'\n\n sweaters_by_query_response = HTTParty.get(@request_url)\n\n sweaters_by_query_products = JSON.parse(sweaters_by_query_response.body)[\"products\"]\n\n jackets_products = sweaters_by_query_products\n\n else\n puts \"ERROR. No style indicated\"\n end\n\n # Return an array of filtered products\n return jackets_products\n end",
"def get_top100_urls(keyword)\n hash = get(keyword)\n struct = JSON.parse(hash.to_json, object_class: OpenStruct)\n\n urls = []\n struct.data.each { |i| urls << i.url }\n urls\n end",
"def by_category_and_difficulty\n questions = Question.q_by_category(params[:category_id], params[:difficulty])\n # byebug\n # some method that returns questions based on params category_Id and difficulty\n render json: questions.to_json(\n :methods => :shuffle\n )\n end",
"def process_json_data jd\n\tjd.each do |gk, hash|\n\t\thash['subproducts'].each do |prod|\n\t\t\tsubroot = get_root prod['machine_name']\n\t\t\tprod['downloads'].each do |dd|\n\t\t\t\troot = subroot.dup\n\t\t\t\t# Fix KindomRush classic being put under Origin because it's included by\n\t\t\t\t# Origin Premium package\n\t\t\t\tif dd['machine_name']\n\t\t\t\t\tnewroot = get_root dd['machine_name']\n\t\t\t\t\troot = newroot.dup if newroot == 'kingdomrush/'\n\t\t\t\tend\n\t\t\t\ttype = dd['platform']\n\t\t\t\tsavepath = File.join(root, type)\n\t\t\t\t$dirs << savepath\n\t\t\t\tdd['download_struct'].each do |ds|\n\t\t\t\t\tsha1 = ds['sha1']\n\t\t\t\t\tmd5 = ds['md5']\n\t\t\t\t\tts = ds['timestamp']\n\t\t\t\t\tif ds['url']\n\t\t\t\t\t\tlink = ds['url']['web']\n\t\t\t\t\t\tbtlink = ds['url']['bittorrent']\n\t\t\t\t\t\tbtlink = nil if btlink and btlink.empty?\n\t\t\t\t\t\tdl = true\n\t\t\t\t\telsif (link = ds['external_link'])\n\t\t\t\t\t\t# TODO only announce once per external link\n\t\t\t\t\t\tSTDERR.puts \"# No automatic downloads for #{savepath} (#{ds['name']}), go to #{link}\"\n\t\t\t\t\t\tdl = false\n\t\t\t\t\tend\n\t\t\t\t\tif dl\n\t\t\t\t\t\tfname = get_filename link\n\t\t\t\t\t\tfkey = fname.intern\n\t\t\t\t\t\t# TODO use sha1\n\t\t\t\t\t\t$files[fkey] << Game.new(fname, md5, savepath, link, btlink, [hash['product']['human_name'], gk])#, ts)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend",
"def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end",
"def fetch_json\n res = open(\"http://www.cleanairmakemore.com/widget_json.cfm\").read\n\n # Documented in views/burn/phx/data.json.\n s = res.index(\"facts\")\n json = res[0, s-4] + \"}\"\n\n # json = File.read(\"views/burn/phx/data.json\")\n json\n end",
"def get_overview_info\n start = Time.now\n\n # open the json file of all cars and models and years\n json = JSON.parse(File.read(@all_cars_file_with_years))\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_to_download = json.values.map{|x| x['models'].values.map{|y| y['years'].length}}.flatten.inject(0, :+)\n total_left_to_download = json.values.map{|x| x['models'].values.map{|y| y['years'].length}}.flatten.inject(0, :+)\n\n # for each car, model, year - get overview\n json.each do |key_car, car|\n car['models'].each do |key_model, model|\n\n model['details'] = Hash.new\n\n model['years'].each do |year|\n model['details'][year] = Hash.new\n\n # request the url\n request = Typhoeus::Request.new(\n @overiew_url.gsub('{car}', car['seo']).gsub('{model}', model['seo']).gsub('{year}', year.to_s),\n :headers=>{\"User-Agent\" => @user_agent},\n followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0\n )\n\n request.on_complete do |response|\n # process the html\n model['details'][year]['overview'] = process_overview_page(response.response_body)\n\n total_left_to_download -= 1\n\n if total_left_to_download % 100 == 0\n puts \"\\n\\n- #{total_left_to_download} overview files left to downloaded (out of #{total_to_download}); time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n end\n hydra.queue(request)\n end\n end\n end\n\n hydra.run\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years_overview, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE OVERVIEWS TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend",
"def fetch_movie_data_and_cache_in_json_files\n query = Imdb::Top250.new\n movies = query.movies.map do |m|\n HTTParty.get(\"http://www.omdbapi.com/?i=tt#{m.id}&plot=short&r=json\")\n end\n movies = fetch_movie_data_from_list\n File.open('db/data/movie_data.json', 'w') { |file| file.write(movies.to_json) }\nend",
"def club_cache(page)\n information = Hash.new\n fields = [:name,:mission,:link,:location,:affiliations,:service]\n\n table_info = page.css('table[class=\"c-table\"]').children\n\n count = 0\n table_info.each do |club|\n inside = 0\n if count > 2\n club_info = fields.each_with_object(nil).to_h\n club.children.each do |value|\n if !value.text.strip.empty?\n if inside == 0\n name = value.css('a').text.strip\n club_info[:name] = name\n link = \"https://activities.osu.edu\" + value.css('a').attribute('href')\n club_info[:link] = link\n elsif inside == 1\n mission = value.text.strip\n club_info[:mission] = mission\n elsif inside == 2\n pre_split = value.text.strip\n post_split = pre_split.split(',')\n location, affiliations, *service = pre_split.split(',')\n club_info[:location] = location\n club_info[:affiliations] = affiliations\n club_info[:service] = service*\", \"\n end\n inside += 1\n end\n information[name] = club_info\n end\n end\n count+=1\n end\n \n #Saves as json \n json_file = File.write 'clubs.txt', information.to_s\nend",
"def index\n \tif params[:category] == \"METRO\"\n \trender :json => Interest.stops.to_json\n elsif params[:category] == \"Photos\"\n render :json => Interest.panoramio\n \telsif params[:category]\n \t\tcategory_id = Category.find_by_name(params[:category]).id\n \t\trender :json => Interest.find_all_by_category_id(category_id).to_json(:methods => :category_name)\n \telse\n \t\trender :json => Interest.all\n \tend\n\n end",
"def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend",
"def cat_count\n total_arr = []\n counter = 0\n #cat_array1 = [\"Characters\", \"Films\", \"Planets\", \"Starships\", \"Species\"]\n\n 5.times do\n #x = cat_array1[0]\n url_array = [\"http://www.swapi.co/api/people\", \"http://www.swapi.co/api/films\",\n \"http://www.swapi.co/api/planets\", \"http://www.swapi.co/api/starships\",\n \"http://www.swapi.co/api/species\"]\n response_string = RestClient.get(url_array[counter])\n response_hash = JSON.parse(response_string)\n total = response_hash[\"count\"]\n total_arr << total\n counter = counter + 1\n end\n total_arr\nend",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def download\n URI.extract(json, ['http', 'https']).each do |url|\n get_asset(url)\n end\n\n json\n end",
"def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end",
"def do_get_cats_data\n message = {country_id: @client.country_code, webapi_key: @client.webapi_key}\n @client.call(:do_get_cats_data, message: message)\n end",
"def get_from_digg\n route = 'http://digg.com/api/news/popular.json'\n raw_response = RestClient.get route\n response = JSON.load raw_response\n response[\"data\"][\"feed\"].map do |story|\n categories = []\n story[\"content\"][\"tags\"].map do |tags|\n categories.push(tags[\"display\"]) # Push the 'tags' for each Digg article to an array.\n end\n category_string = categories.join(\", \") # Make a string for each story's category array for Digg.\n story_hash = {\n title: story[\"content\"][\"title\"],\n score: story[\"digg_score\"],\n category: category_string, # There are multiple categories so you're going to have to use .join to get all the different categories to be part of the array.\n author: story[\"content\"][\"author\"]\n }\n end\nend",
"def get_specification_info\n start = Time.now\n\n # open the json file of all cars and models and years\n # if the specs file exists, use it, else start with the styles\n json = if File.exist?(@all_cars_file_with_years_overview_styles_specs)\n JSON.parse(File.read(@all_cars_file_with_years_overview_styles_specs))\n else\n JSON.parse(File.read(@all_cars_file_with_years_overview_styles))\n end\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_downloaded = 0\n total_to_download = 0\n\n # for each car, model, year - get overview\n json.each do |key_car, car|\n puts \"-----------\"\n puts \"car: #{car['name']}\"\n car['models'].each do |key_model, model|\n puts \"- model: #{model['name']}\"\n model['years'].each do |year|\n year = year.to_s\n\n # only continue if the styles hash exists\n if !model['details'][year]['styles'].nil?\n\n model['details'][year]['styles'].keys.each do |style|\n # if the style data already exists, skip it\n # else get the data\n if model['details'][year]['styles'][style].nil?\n\n request = Typhoeus::Request.new(\n @specs_url.gsub('{slug}', style),\n :headers=>{\"User-Agent\" => @user_agent},\n followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0\n )\n\n total_to_download += 1\n\n request.on_complete do |response|\n # process the html\n model['details'][year]['styles'][style] = process_specification_page(response.response_body)\n\n total_downloaded += 1\n\n if total_downloaded % 50 == 0\n puts \"\\n\\n- #{total_downloaded} specification files downloaded so far (out of #{total_to_download}); time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n\n # since there are lots of files to download\n # let's save to file after every 1000 records are processed\n if total_downloaded % 1000 == 0\n puts \"\\n\\n- saving to file \\n\\n\"\n File.open(@all_cars_file_with_years_overview_styles_specs, 'wb') { |file| file.write(JSON.generate(json)) }\n end\n end\n hydra.queue(request)\n end\n end\n end\n end\n end\n end\n\n hydra.run\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years_overview_styles_specs, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE SPECIFICATIONS TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def load_cookie_categorys\n unless @cookie_categorys\n cookie_category_info = load_json_file(\"data/luxgen/cookie_categorys.data\", \"cid\")\n\n @cookie_categorys = {}\n cookie_category_info.each do |key, value|\n categorys = (@cookie_categorys[key] ||= Set.new)\n\n value['cat'].split(\",\").each do |category|\n categorys.add(category)\n end\n end\n end\n\n @cookie_categorys\nend",
"def get_model_years_slow\n start = Time.now\n\n # open the json file of all cars and models\n json = JSON.parse(File.read(@all_cars_file))\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n # get all of the car ids with model ids\n # model_ids = json.map{|key, value| value['models'].keys}.flatten\n car_model_ids = json.map{|key, value| [key, value['models'].keys]}\n\n if car_model_ids.nil? || car_model_ids.length == 0\n puts \"ERROR - could not find model ids\"\n exit\n end\n\n puts \"- found #{car_model_ids.length} cars with a total of #{car_model_ids.map{|x| x[1]}.flatten.length} models\"\n\n total_left_to_process = car_model_ids.length\n car_model_ids.each_with_index do |car, index|\n puts \"-------------------\"\n puts \"#{index} cars download so far in #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n\n car[1].each do |model_id|\n puts \"- car #{car[0]}, model #{model_id}\"\n # save years\n json[car[0]]['models'][model_id]['years'] = JSON.parse(open(\"#{@model_years_url}#{model_id}\").read)\n end\n end\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def find_categories\n page = agent.get(WEBSITE_URL)\n\n page.search(CATEGORIES_SELECTOR).each do |a|\n category_name = a.text.strip\n path = a.attribute('href').value.strip\n\n next if category_name.blank? || path.blank?\n\n data[category_name] = {\n 'url' => URI.join(WEBSITE_URL, path).to_s\n }\n end\n\n Helpers.wait\n end",
"def country_api\n # endpoint = \"https://corona.lmao.ninja/countries\"\n endpoint = 'https://corona.lmao.ninja/v2/countries'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result =[]\n endpoint_all = \"https://corona.lmao.ninja/all\"\n response1 = HTTParty.get(endpoint_all)\n data1 = JSON.parse response1.body\n res1 = data1\n result<<{\n country: \"world\",\n cases: res1[\"cases\"],\n todayCases: res1[\"todayCases\"],\n deaths: res1[\"deaths\"],\n todayDeaths: res1[\"todayDeaths\"],\n recovered: res1[\"recovered\"],\n active: res1[\"active\"],\n critical: res1[\"critical\"],\n casesPerOneMillion: res1[\"casesPerOneMillion\"],\n deathsPerOneMillion: res1[\"deathsPerOneMillion\"],\n tests: res1[\"tests\"],\n testsPerOneMillion: res1[\"testsPerOneMillion\"],\n affectedCountries: res1[\"affectedCountries\"]\n }\n\n res.each do |country|\n result<<{\n country: country[\"country\"],\n lat: country[\"countryInfo\"][\"lat\"],\n long: country[\"countryInfo\"][\"long\"],\n flag: country[\"countryInfo\"][\"flag\"],\n cases: country[\"cases\"],\n todayCases: country[\"todayCases\"],\n deaths: country[\"deaths\"],\n todayDeaths: country[\"todayDeaths\"],\n recovered: country[\"recovered\"],\n active: country[\"active\"],\n critical: country[\"critical\"],\n casesPerOneMillion: country[\"casesPerOneMillion\"],\n deathsPerOneMillion: country[\"deathsPerOneMillion\"],\n tests: country[\"tests\"],\n testsPerOneMillion: country[\"testsPerOneMillion\"]\n }\n end\n render json: result\n end",
"def bottoms_API_data\n if @style == 0 # Athletic\n \n #########################################\n # API call for Pants category.\n # Search with 'active,' 'training,' \n # 'yoga,' 'athletic' query\n #########################################\n build_partial_url(\"&cat=girls-pants\", @pant_size)\n\n @request_url += '&fts=active&fts=training&fts=yoga&fts=athletic'\n\n pants_by_query_response = HTTParty.get(@request_url)\n\n pants_by_query_products = JSON.parse(pants_by_query_response.body)[\"products\"]\n\n #########################################\n # API call for Shorts category.\n # Search with 'active' and 'run' query\n #########################################\n build_partial_url(\"&cat=girls-shorts\", @pant_size)\n\n @request_url += '&fts=active&fts=run'\n\n shorts_by_query_response = HTTParty.get(@request_url)\n\n shorts_by_query_products = JSON.parse(shorts_by_query_response.body)[\"products\"]\n\n # Merge two products into one array\n bottoms_products = shorts_by_query_products.zip(pants_by_query_products).flatten.compact\n\n elsif @style == 1 # Formal\n # None returned\n\n elsif @style == 2 # Everyday\n \n #########################################\n # API call for Jeans category.\n # Search all. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-jeans\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n jeans_response = HTTParty.get(@request_url)\n\n jeans_products = JSON.parse(jeans_response.body)[\"products\"]\n\n #########################################\n # API call for Pants category.\n # Search all. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-pants\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n pants_response = HTTParty.get(@request_url)\n\n pants_products = JSON.parse(pants_response.body)[\"products\"]\n\n #########################################\n # API call for Shorts category.\n # Search query 'denim'. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-shorts\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n @request_url += '&fts=denim'\n\n shorts_response = HTTParty.get(@request_url)\n\n shorts_products = JSON.parse(shorts_response.body)[\"products\"]\n\n #########################################\n # API call for Skirts category.\n # Search all. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-skirts\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n skirts_response = HTTParty.get(@request_url)\n\n skirts_products = JSON.parse(skirts_response.body)[\"products\"]\n\n # Merge products\n bottoms_products = jeans_products.zip(pants_products).flatten.compact\n bottoms_products = bottoms_products.zip(shorts_products).flatten.compact\n bottoms_products = bottoms_products.zip(skirts_products).flatten.compact\n\n elsif @style == 3 # Trendy\n \n #########################################\n # API call for Jeans category.\n # Search all. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-jeans\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n jeans_response = HTTParty.get(@request_url)\n\n jeans_products = JSON.parse(jeans_response.body)[\"products\"]\n\n ############################################################\n # API call for Pants category.\n # Search by 'ponte' and 'leggings' query. Limit output to 15\n #############################################################\n build_partial_url(\"&cat=girls-pants\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n @request_url += '&fts=ponte&fts=leggings'\n\n pants_response = HTTParty.get(@request_url)\n\n pants_products = JSON.parse(pants_response.body)[\"products\"]\n\n #########################################\n # API call for Shorts category.\n # Search all. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-shorts\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n shorts_response = HTTParty.get(@request_url)\n\n shorts_products = JSON.parse(shorts_response.body)[\"products\"]\n\n #########################################\n # API call for Skirts category.\n # Search all. Limit output to 15\n #########################################\n build_partial_url(\"&cat=girls-skirts\", @pant_size)\n\n @request_url.sub! 'limit=50', 'limit=15'\n\n @request_url += '&fts=tulle&fts=tiered&&fts=tutu'\n\n skirts_response = HTTParty.get(@request_url)\n\n skirts_products = JSON.parse(skirts_response.body)[\"products\"]\n\n # Merge products\n bottoms_products = jeans_products.zip(pants_products).flatten.compact\n bottoms_products = bottoms_products.zip(shorts_products).flatten.compact\n bottoms_products = bottoms_products.zip(skirts_products).flatten.compact\n\n else\n puts \"ERROR. No style indicated\"\n end\n\n return bottoms_products\n end",
"def categories\n parsed_json['data']\n end",
"def fetch_data(connection,path,definition)\n @definition=definition\n @headers = definition.data_headers\n @headers.delete_if {|x| x=='source'}\n @raw_headers=headers # headers are the full set here\n items = []\n page = 1\n while page <= AMEE::Data::Category.get(connection, \"/data#{path}\").pager.last_page do\n category = AMEE::Data::Category.get(connection, \"/data#{path}\", { 'page' => \"#{page}\" })\n category.items.each do |item|\n items << item\n end\n page += 1\n end\n parse_api_rows items\n end",
"def get_styles_info\n start = Time.now\n\n # open the json file of all cars and models and years\n json = JSON.parse(File.read(@all_cars_file_with_years_overview))\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_to_download = json.values.map{|x| x['models'].values.map{|y| y['years'].length}}.flatten.inject(0, :+)\n total_left_to_download = json.values.map{|x| x['models'].values.map{|y| y['years'].length}}.flatten.inject(0, :+)\n\n # for each car, model, year - get overview\n json.each do |key_car, car|\n puts \"-----------\"\n puts \"car: #{car['name']}\"\n car['models'].each do |key_model, model|\n puts \"- model: #{model['name']}\"\n model['years'].each do |year|\n year = year.to_s\n\n # only continue if the specs url exists\n if !model['details'][year]['overview']['specs_url_slug'].nil?\n\n model['details'][year]['styles'] = Hash.new\n\n # call the default style page and get all of the styles\n request = Typhoeus::Request.new(\n @specs_url.gsub('{slug}', model['details'][year]['overview']['specs_url_slug']),\n :headers=>{\"User-Agent\" => @user_agent},\n followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0\n )\n\n request.on_complete do |response|\n # get list of each style\n styles = process_specification_for_styles(response.response_body)\n\n if !styles.nil? && styles.length > 0\n styles.each do |style|\n model['details'][year]['styles'][style] = nil\n\n # if the style is the same as the overview specs url slug\n # then we have already retrieved the page and we can just process it.\n if style == model['details'][year]['overview']['specs_url_slug']\n # process the html\n model['details'][year]['styles'][style] = process_specification_page(response.response_body)\n end\n end\n end\n\n total_left_to_download -= 1\n\n if total_left_to_download % 50 == 0\n puts \"\\n\\n- #{total_left_to_download} style specification files downloaded (out of at #{total_to_download}); time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n\n end\n\n hydra.queue(request)\n end\n end\n end\n end\n\n hydra.run\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years_overview_styles, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE STYLE SPECIFICATIONS TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def extract_observations(url)\n\n JSON.load(open(url))\n\n end",
"def harvest_for_sunetid_with_wos_json(sunetid, path_to_json, batch_size = 20)\n logger.info \"Started Web Of Science harvest for #{sunetid} with wos-json #{path_to_json}\"\n wos_ids = JSON.parse(IO.read(path_to_json))\n harvest_sw_pubs_by_wos_array_and_sunetid sunetid, wos_ids, batch_size\n end",
"def get_digg\n\nresponse = JSON.parse(RestClient.get 'http://digg.com/api/news/popular.json')\n# puts response['data']['feed'][0]['content']['title']\n\nstories = []\n\nresponse['data']['feed'].each do |story|\n\tstory_hash = {}\n\tstory_hash[:title] = story['content']['title']\n\tstory_hash[:category] = story['content']['tags'][0]['display']\n\tcalculate_upvotes(story_hash)\n\tstories.push(story_hash)\n\tend\n\tshow_all_stories(stories)\nend",
"def get_clicks( file , ofile, format )\n File.open( file ) do |f|\n File.open( ofile, 'w' ) do |of|\n while line = f.gets\n #begin\n batch, id, hash, url =* line.split(/\\s+/)\n api_key = \"R_12855747ed682ddadbfdc9425eab0bb8\"\n #access_token = \"ed0f9b209a3cfbdac11e246afb9bb9581591a195\"#{}\"1f7683b87663b59c5417e60ab5a9b7f014bea063\"\n puts \"#{id}, #{hash}, #{url}\"\n api_url = \"curl https://api-ssl.bitly.com/v3/clicks?login=lifidea&apiKey=#{api_key}&shortUrl=#{url}\"\n #api_url = \"curl https://api-ssl.bitly.com/v3/clicks?access_token=#{access_token}&shortUrl=#{url}\"\n puts api_url\n content = `#{api_url}`#Net::HTTP.get(URI.parse(api_url))\n of.puts \"#{hash}\\t#{content.size}\\t#{url}\"\n #Dir.mkdir(format) if !File.exist?(format)\n File.open( \"clicks/#{hash}.#{format}\",'w'){|of2|of2.puts content}\n #rescue Exception => e\n # puts \"Error in [#{line}]\",e\n #end\n sleep(1)\n end\n end\n end\nend",
"def read_json(request_type)\n case request_type\n when :manga\n @json_key = \"unapproved_manga\".freeze\n @url_part = \"manga\".freeze\n else\n @json_key = \"unapproved_anime\".freeze\n @url_part = \"anime\".freeze\n end\n @parsed_json = $id_cache.get()\n @parsed_info = $info_cache.get()\n @ids = @parsed_json[@json_key].map(&:to_s)\n @info = @parsed_info[@json_key]\n @data = {}\n @ids.each do |i|\n @id_url = \"https://myanimelist.net/#{@url_part}/#{i}\".freeze\n @data[i] = if @info.key?(i)\n @info[i]\n else\n { \"name\".freeze => @id_url, \"type\".freeze => \"?\".freeze, \"nsfw\".freeze => false }\n end\n @data[i][\"url\".freeze] = @id_url\n end\n [@ids, @data]\nend",
"def get_data(flag, url)\n\t\t\t\t\t\tdata = \"\"\n\t\t\t\t\t\t\t\tresponse = 0\n\t\t\t\t\t\t\t\t\t\tif flag == false\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresponse = RestClient.get(url)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdata = JSON.load response\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\treturn data\nend",
"def get_model_years_fast\n start = Time.now\n\n # open the json file of all cars and models\n json = JSON.parse(File.read(@all_cars_file))\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n # get all of the car ids with model ids\n # model_ids = json.map{|key, value| value['models'].keys}.flatten\n car_model_ids = json.map{|key, value| [key, value['models'].keys]}\n\n if car_model_ids.nil? || car_model_ids.length == 0\n puts \"ERROR - could not find model ids\"\n exit\n end\n\n puts \"- found #{car_model_ids.length} cars with a total of #{car_model_ids.map{|x| x[1]}.flatten.length} models\"\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_left_to_process = car_model_ids.length\n\n car_model_ids.each_with_index do |car, index|\n puts \"-------------------\"\n puts \"#{index} cars download so far in #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n\n car[1].each do |model_id|\n puts \"- car #{car[0]}, model #{model_id}\"\n request = Typhoeus::Request.new(\"#{@model_years_url}#{model_id}\",\n :headers=>{\"User-Agent\" => @user_agent}, followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0)\n\n request.on_complete do |response|\n # save years\n json[car[0]]['models'][model_id]['years'] = JSON.parse(response.response_body)\n\n # decrease counter of items to process\n total_left_to_process -= 1\n if total_left_to_process == 0\n puts \"TOTAL TIME TO DOWNLOAD = #{((Time.now-start)/60).round(2)} minutes\"\n\n elsif total_left_to_process % 10 == 0\n puts \"\\n\\n- #{total_left_to_process} files remain to download; time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n end\n hydra.queue(request)\n end\n end\n\n hydra.run\n\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend",
"def index\n @q = scope.search(categories_name_eq: params[:category])\n @dishes = @q.result.includes(:categories).order(\"categories.position\")\n\n c = Hash.new {|x,v| x[v] = []}\n @dishes = @dishes.reduce(c) do |h, dishe|\n dishe.categories.each do |c|\n h[c.name] << dishe\n end\n h\n end.reject {|c, d| d.blank? }\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def get_character_movies_from_api(character)\n all_characters = RestClient.get('http://www.swapi.co/api/people/')\n character_hash = JSON.parse(all_characters)\n\n results = []\n still_searching = true\n\n while still_searching\n results << character_hash[\"results\"] # results pushed into results array on every loop iteration\n if character_hash[\"next\"]\n next_page = RestClient.get(character_hash[\"next\"])\n character_hash = JSON.parse(next_page)\n else\n still_searching = false\n end\n end\n\n results = results.flatten\n results = results.select {|chara| chara[\"name\"].downcase == character}\n # results is an array containing a hash\n\n if results.length > 0\n film_hash = results[0][\"films\"].map do |film_url|\n film = RestClient.get(film_url)\n film = JSON.parse(film)\n end\n end\nend",
"def index\n @partial = {\n name: 'categories'\n }\n @partial = partial_by_category unless @category.nil?\n @partial = partial_by_site_storage unless @json_data[:site_storage].nil?\n end",
"def scrape_etsy(url)\n data = Net::HTTP.get(url)\n parsed_data = JSON(data)\n # count_listings(parsed_data)\n return parsed_data\nend",
"def rating(food)\n url = 'https://thereportoftheweek-api.herokuapp.com/reports'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n result = JSON.parse(response)\n puts result[7]['product']\n \n end",
"def category\n ts_deals = Deal.filtered_search(\n :category => params[:name] == \"all\" ? nil : params[:name],\n :lat => params[:lat],\n :lon => params[:long],\n :range => params[:range] || Deal::MAX_RANGE,\n :age => Deal::MAX_SEARCH_AGE.days,\n :page => params[:page],\n :limit => 50)\n\n \n @deals = Array.new\n ts_deals.map do |deal|\n if deal.hidden == false\n @deals.push deal\n end\n end\n \n options = { :minimal => true }\n options[:current_user] = current_user if current_user\n render :json => @deals.compact.as_json(options)\n end",
"def budget_categories_data\n # @budget.budget_items.collect { |budget_item| budget_item.category.name.to_s }.to_json\n categories = Category.for_budget.to_a\n categories << Category.find_by_name(\"Miscellaneous\")\n return categories.collect { |category| category.name.to_s }.to_json\n end",
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def get_urls_to_retrieve(d1)\n urls = []\n\n if (d1==nil || d1 ==\"\")\n t = DateTime.now\n d = t.strftime(\"%Y/%m/%d\")\n else\n d = d1\n end\n pt1 = \"http://www.bbc.co.uk/\"\n pt2 = \"/programmes/schedules/\"\n\n channel = \"bbcone\"\n url = \"#{pt1}#{channel}#{pt2}london/#{d}.json\"\n urls.push(url)\n\n channel = \"bbctwo\"\n url = \"#{pt1}#{channel}#{pt2}england/#{d}.json\"\n urls.push(url)\n\n channel = \"bbcthree\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbcfour\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbchd\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"cbeebies\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"cbbc\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"parliament\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbcnews\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio4\"\n url = \"#{pt1}#{channel}#{pt2}fm/#{d}.json\"\n\n channel = \"radio1\"\n url = \"#{pt1}#{channel}#{pt2}england/#{d}.json\"\n\n channel = \"1extra\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio2\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio3\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"5live\" \n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"5livesportsextra\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"6music\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"asiannetwork\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"worldservice\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n return urls\n end",
"def get_from_reddit\n #no parameters needed. We're just going to return the data from the json file.\n route = 'http://www.reddit.com/.json'\n raw_response = RestClient.get route\n response = JSON.load raw_response\n response[\"data\"][\"children\"].map do |story|\n story_hash = {\n title: story[\"data\"][\"title\"],\n score: story[\"data\"][\"score\"],\n category: story[\"data\"][\"subreddit\"],\n author: story[\"data\"][\"author\"]\n }\n end\nend",
"def get_json(url)\n @response = RestClient.get url\n while @response.nil? do\n if @response.code == 200\n @response = RestClient.get url\n end\n end\n @json_file = JSON.parse(@response)\n end",
"def get_from_mashable\n route = 'http://mashable.com/stories.json'\n raw_response = RestClient.get route\n response = JSON.load raw_response\n response[\"hot\"].map do |story|\n story_hash = {\n title: story[\"title\"],\n score: story[\"shares\"][\"total\"],\n category: story[\"channel\"],\n author: story[\"author\"]\n }\n end\nend",
"def download(county)\n puts \" F95BA #{county}\"\n results = @client.find :all, {\n class: '1', # 1 Residential\n query: \"(246=|A),(61=|#{county})\", #246 ListingStatus\n #A ActiveAvailable\n #61 County\n select: '157,881,10,922,924,137,261,129,246,80,61,25,1424,102,214,314,96,1,131,1329,sysid', \n search_type: 'Property'\n }\n puts \"F95BA #{results.size} listings\"\n #puts \"F95BA saving\"\n pg_save(results)\n results\n end",
"def get_category_list\n ret_hash = Rails.cache.fetch(\"zaim_api/category\", expired_in: 1.day) do\n json_categories = self.zaim_api.category\n tmp_ret_hash = {}\n json_categories['categories'].each do |value|\n tmp_ret_hash[value['id']] = value['name']\n end\n tmp_ret_hash\n end\n ret_hash\n end",
"def job_data\n fetch_data('https://www.themuse.com/api/public/jobs?&category=Engineering&category=Project+%26+Product+Management&level=Mid+Level&level=Entry+Level&location=Boston%2C+MA&location=New+York%2C+NY&location=San+Francisco%2C+CA&page=1&descending=true')[\"results\"]\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def list\n categories = Meal.distinct.pluck(:category)\n meal_list = []\n categories.each { |category|\n obj = {\n groupName: category.capitalize,\n options: Meal.where(category: category).select(:id, :name)\n }\n meal_list.push(obj)\n }\n\n render json: meal_list\n end",
"def download_people_data\n print \"Getting IDs of articles about people...\\n\"\n PeopleGetter.new([MEN_URL, WOMEN_URL]).result\n end",
"def get_random_content\n random_content = []\n fetch_all_categories.each do |link_to_send|\n random_content = link_to_send.url\n\n end\n random_content.sample\n end",
"def fetchCats(dataDir, minConfidence)\n return NellELoad.allCategories(dataDir, minConfidence, NellE::STRICT_TRAINING_CAT_FILENAMES)\nend",
"def collect1 pages\n id = 'joshuabaer'\n results = []\n 1.upto pages do |page|\n results += http_get id, page\n end\n results\nend",
"def look_up(url)\n all = RestClient.get(url)\n hash = JSON.parse(all)\nend",
"def get_movie_characters_from_api(movie)\nmovie_hash = make_search('http://www.swapi.co/api/films/')\ncharacters_array = []\n movie_hash[\"results\"].each do |item|\n if item[\"title\"].downcase == movie\n item[\"characters\"].each do |character| #urls \n character_info_hash = make_search(character)\n characters_array << character_info_hash\n end \n end\n end \n #characters_array #all the info on films an array of hashes\n parse_movie_character(characters_array)\nend",
"def get_data(flag, url)\n data = \"\"\n response = 0\n if flag == true\n response = RestClient.get(url)\n data = JSON.load response\n end\n return data\nend",
"def fetch_json_from_url(url_of_search)\n Net::HTTP.get(URI.parse(url_of_search))\n end",
"def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end",
"def buy_food(id,food_units)\r\n my_port = 8082\r\n store_message = \"/store/#{id}/#{$light}/#{$suit}/#{$wealth}/#{$sword}/#{$amulet}/#{$axe}/#{$food}/#{food_units}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{store_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n\r\n $light = my_json['light']\r\n $suit = my_json['suit']\r\n $wealth = my_json['wealth']\r\n $sword = my_json['sword']\r\n $amulet = my_json['amulet']\r\n $axe = my_json['axe']\r\n $food = my_json['food']\r\n puts(\"#{my_json['text']}\\n\")\r\nend",
"def get_tags( file , ofile, format )\n File.open( file ) do |f|\n File.open( ofile, 'w' ) do |of|\n while line = f.gets\n #begin\n batch, id, hash, url =* line.split(/\\s+/)\n puts \"#{id}, #{hash}, #{url}\"\n api_url = \"curl https://lifidea:1275dkjy@api.del.icio.us/v1/posts/suggest?url=#{url}\"\n puts api_url\n content = `#{api_url}`#Net::HTTP.get(URI.parse(api_url))\n of.puts \"#{hash}\\t#{content.size}\\t#{url}\"\n #Dir.mkdir(format) if !File.exist?(format)\n File.open( \"tags/#{hash}.#{format}\",'w'){|of2|of2.puts content}\n #rescue Exception => e\n # puts \"Error in [#{line}]\",e\n #end\n sleep(1)\n end\n end\n end\nend",
"def show\n @category =\n Category.includes(:companies).find(params[:id])\n if @category\n @keyword = String.new\n @keyword << @category.name << \" \"\n @coms = @category.companies.paginate(:page => params[:page],\n :per_page => 15)\n unless @category.leaf?\n @children = @category.children.sort! {|a,b| a.name<=>b.name}\n @children.each do |child|\n @keyword << child.name << \" \"\n end\n end\n if @category.child?\n @category.ancestors.each do |ac|\n ariane.add ac.name, category_path(ac)\n end\n end\n unless @category.companies.blank?\n @json = @category.companies.to_gmaps4rails\n @coms_max = @category.companies.maximum(:updated_at)\n end\n ariane.add @category.name, @category\n else\n flash.now[:error] = \"Category not found.\"\n end\n end",
"def download_all_data(url)\n next_data_indices = {}\n\n while next_data_indices\n html = Downloader.read_page(url)\n\n # Sometimes Pandora returns the same next_data_indices as the previous page.\n # If we don't check for this, an infinite loop occurs.\n # This problem occurs with tconrad.\n prev_next_data_indices = next_data_indices\n next_data_indices = @parser.get_next_data_indices(html)\n next_data_indices = false if prev_next_data_indices == next_data_indices\n\n url = yield(html, next_data_indices)\n end\n end",
"def get_character_movies_from_api(character)\n #make the web request\n all_characters = RestClient.get('http://www.swapi.co/api/people/') # web request\n character_hash = JSON.parse(all_characters)\n\n arr = nil\n character_hash[\"results\"].each do |key|\n if key[\"name\"] == character\n arr = key[\"films\"]\n end\n end\narr\nend",
"def write_v3_champ_data(api_key, filename)\n\n url = \"https://na1.api.riotgames.com/lol/static-data/v3/champions\"\n url += \"/?api_key=\" + api_key\n response = HTTParty.get(url)\n case response.code\n when 200\n response_data = response[\"data\"]\n puts response_data.keys\n puts response_data[\"Annie\"]\n when 404\n puts \"error 404\"\n end\n data = []\n write_champ_data(filename, data)\nend",
"def download_page(page_number)\n print '.'\n JSON.parse(Net::HTTP.get(URI(@url + \"page/#{page_number}/\")))\n end",
"def generate_data_files\n files = {}\n\n # extracted data\n @classes.each do |category|\n files[category] = {}\n folder = File.join(@res, 'data', category.to_s, 'extracted')\n\n files[category][:extracted] = File.join(folder, \"#{category}.json\")\n end\n\n # divided data\n @classes.each do |category|\n files[category][:divided] = {}\n folder = File.join(@res, 'data', category.to_s, 'divided')\n\n @subsets.each do |subset|\n files[category][:divided][subset] = File.join(folder,\n \"#{category}_#{subset}.json\")\n end\n end\n\n # preprocessed data\n @classes.each do |category|\n files[category][:preprocessed] = {}\n\n @preproc.each do |preprocess|\n folder = File.join(\n @res, 'data', category.to_s, 'preprocessed', preprocess.to_s)\n\n files[category][:preprocessed][preprocess] = {}\n\n @subsets.each do |subset|\n files[category][:preprocessed][preprocess][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n\n # transformed data\n if @trans.size > 0\n @classes.each do |category|\n files[category][:transformed] = {}\n\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'transformed', ctrans.to_s)\n\n files[category][:transformed][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:transformed][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n\n # classified data\n if @classifs.size > 0\n @classes.each do |category|\n files[category][:classified] = {}\n\n @classifs.each do |classifier|\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{classifier}_#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'classified', ctrans.to_s)\n\n files[category][:classified][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:classified][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n end\n files\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 pages(time)\n\n response = HTTParty.get(\"https://api.pushshift.io/reddit/search/submission/?subreddit=#{$subreddit}&sort=desc&sort_type=created_utc&size=#{$max_per_page}&search?before=#{time}\")\n json = JSON.parse(response.body)\n\n json[\"data\"].each do |f|\n $urls << [f[\"created_utc\"], f[\"url\"]] if f[\"url\"].match?($img_formats) && f[\"url\"].match?($valid_urls)\n end\n\n if $page < $max_page\n sleep(rand(2..5))\n $page += 1\n pages($urls.last[0])\n else\n write_file\n end\n\nend",
"def parse_category_pages(db_category, group_name_ru)\n products_request_url = 'https://catalog.api.onliner.by/search/' + db_category.name\n response_json = special_request(products_request_url)\n quantity = JSON.parse(response_json)['page']['last'].to_i\n 1.upto(quantity) do |page_number|\n print \"\\r#{group_name_ru}/#{db_category.name} : #{page_number}/#{quantity}\"\n page_url = products_request_url + '?page=' + page_number.to_s\n get_products_from_page(page_url, db_category)\n sleep(2)\n end\n puts\n end",
"def get_from_digg\n raw_response = RestClient.get('http://digg.com/api/news/popular.json')\n response = JSON.load(raw_response)\n\n response[\"data\"][\"feed\"].map do |story|\n story_hash = {\n title: story[\"content\"][\"title_alt\"],\n author: story[\"content\"][\"author\"],\n score: story[\"digg_score\"],\n category: story[\"content\"][\"tags\"].map {|tag| tag[\"display\"]}\n }\n end\n\n\nend",
"def get_character_movies_from_api(character_name)\n #make the web request\n\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n response_hash = JSON.parse(response_string)\n\n counter = 1\n films = []\n\n\n while films.size <= 1 do\n\n response_hash[\"results\"].find do |item_name|\n\n if item_name[\"name\"].downcase == character_name.downcase\n films = item_name[\"films\"]\n puts \"Film found\"\n films.collect! do |film_url|\n response_film_url = RestClient.get(film_url)\n response_film_url_hash = JSON.parse(response_film_url)\n response_film_url_hash[\"title\"]\n end\n puts \"Film Convert\"\n return films\n elsif response_hash[\"next\"] == nil\n return puts \"Character not found.\"\n end\n\n counter += 1\n\n response_string = RestClient.get(response_hash[\"next\"])\n response_hash = JSON.parse(response_string)\n end\nend\n\n\n #films = []\n #response_hash[\"results\"].find do |item_name|\n #\n # if item_name[\"name\"].downcase == character_name.downcase\n # films = item_name[\"films\"]\n # end\n #end\n\n #if response_hash[\"results\"][0][\"name\"].downcase == character_name\n # films = response_hash[\"results\"][0][\"films\"]\n #end\n\n #films.collect! do |film_url|\n # response_film_url = RestClient.get(film_url)\n # response_film_url_hash = JSON.parse(response_film_url)\n # response_film_url_hash[\"title\"]\n #end\n\n\n\n\n # iterate over the response hash to find the collection of `films` for the given\n # `character`\n # collect those film API urls, make a web request to each URL to get the info\n # for that film\n # return value of this method should be collection of info about each film.\n # i.e. an array of hashes in which each hash reps a given film\n # this collection will be the argument given to `print_movies`\n # and that method will do some nice presentation stuff like puts out a list\n # of movies by title. Have a play around with the puts with other info about a given film.\nend",
"def fetch_drink_page(name, url, size, milk)\n doc = Hpricot Curl::Easy.http_get(url).body_str\n key = nil\n data = {}\n\n (doc.at('#nutrition')/:td).each do|td|\n value = td.inner_text.gsub(/\\(.*\\)/,'').strip\n if key.nil?\n key = value\n else\n data[CaribouToDB[key]] = value if CaribouToDB.key?(key)\n key = nil\n end\n end\n data[:name] = ((doc.at(\"#content h1\").inner_text) || name).cleanstr\n data[:size] = size\n data[:milk] = milk\n data\nend",
"def get_characters_from_api\n #establish initial url from api\n url = 'http://www.swapi.co/api/people/'\n #get all data from first page of API\n page_of_characters = JSON.parse(RestClient.get(url))\n all_characters = page_of_characters\n \n next_call = page_of_characters[\"next\"]\n\n while next_call do\n next_page = next_call\n next_page_of_characters = JSON.parse(RestClient.get(next_page))\n (all_characters[\"results\"] << next_page_of_characters[\"results\"])\n next_call = next_page_of_characters[\"next\"]\n end\n\n all_characters\nend",
"def download_chaptered_from_ffnet(location)\r\n @chapter_contents = []\r\n if location.match(/^(.*fanfiction\\.net\\/s\\/[0-9]+\\/)([0-9]+)(\\/.*)$/i)\r\n urlstart = $1\r\n urlend = $3\r\n chapnum = 1\r\n Timeout::timeout(STORY_DOWNLOAD_TIMEOUT) {\r\n loop do\r\n url = \"#{urlstart}#{chapnum.to_s}#{urlend}\"\r\n body = download_with_timeout(url)\r\n if body.nil? || chapnum > MAX_CHAPTER_COUNT || body.match(/FanFiction\\.Net Message/)\r\n break\r\n end\r\n @chapter_contents << body\r\n chapnum = chapnum + 1\r\n end\r\n }\r\n end\r\n return @chapter_contents\r\n end",
"def get_subcategories\r\n sub_categories = Taxonomy.get_subcategories\r\n render json: sub_categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def combine_data\n results = []\n (1...15).each do |i|\n puts i\n f = File.read(\"data/#{i}.json\") #read the file\n h = JSON.parse(f) # parse json\n h['results'].each do |result|\n results << result # append results to an array\n end\n end\n puts results.length\n File.write(\"combined.json\", results)\nend",
"def index\n @categories = Category.all\n @categories.each do |category|\n authorize! :read, category\n end\n render json: @categories\n end",
"def get_character_movies_from_api(character)\n #make the web request\n all_characters = RestClient.get('http://www.swapi.co/api/people/')\n character_hash = JSON.parse(all_characters)\n film_urls = get_film_urls(character_hash, character)\n\n parse_character_movies(parse_films(film_urls))\nend",
"def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend",
"def build_json_from_params \n #Construct array for holding categories\n arr = [] \n get_categories.each do |cat| #Meow\n #For each category create a map {}\n new_cat = {}\n new_cat[\"name\"] = cat[0]\n new_cat[\"steps\"] = []\n get_steps(cat).each do |step|\n #For each step create a map {}\n new_cat_step = {}\n new_cat_step[\"name\"] = step[2]\n #get options returns a list of maps of options\n new_cat_step[\"options\"] = get_options(step) \n new_cat[\"steps\"] << new_cat_step\n end \n arr << new_cat\n end\n json = {\"categories\" => arr, \"prompt\" => params[:prompt]}\n return json\n end",
"def create_songs\n 5.times do |i|\n url = \"https://stg-resque.hakuapp.com/songs.json?album_id=#{i+1}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n songs = JSON.parse(response)\n\n songs.each do |song|\n Song.create!(song.except('id'))\n end\n end\nend",
"def index\n @urls = Url.get_top(25)\n # render json: @urls\n end",
"def news\n @sub_categories = SubCategory.all\n @urls = Url.all\n @categories = Category.all\n @bookmarks = Bookmark.all\n @bookmarks_api = []\n \n \n\n @bookmarks.each do |bookmark|\n @bookmarks_api_inner_hash = {\"Type\" => \"Bookmark\"}\n @bookmarks_api_inner_hash.merge!(\"id\" => bookmark.id)\n @bookmarks_api_inner_hash.merge!(\"Name\" => bookmark.name)\n @bookmarks_api_inner_hash.merge!(\"Categories Count\" => bookmark.categories.count)\n \n @bookmarks_api << (@bookmarks_api_inner_hash)\n end\n \n \n @categories.each do |category|\n @categories_inner_hash = {\"Type\" => \"Category\"}\n @categories_inner_hash.merge!(\"id\" => category.id)\n @categories_inner_hash.merge!(\"Name\" => category.name)\n @categories_inner_hash.merge!(\"Number of Sub Categories\" => category.sub_categories.count)\n @categories_inner_hash.merge!(\"Number of Urls\" => category.urls.count)\n \n @bookmarks_api << (@categories_inner_hash)\n end\n\n @sub_categories.each do |sub_category|\n @sub_categories_inner_hash = {\"Type\" => \"Sub Category\"}\n @sub_categories_inner_hash.merge!(\"id\" => sub_category.id)\n @sub_categories_inner_hash.merge!(\"Name\" => sub_category.name)\n @sub_categories_inner_hash.merge!(\"Number of Urls\" => sub_category.urls.count)\n \n @bookmarks_api << (@sub_categories_inner_hash)\n end\n \n @finalapi = @bookmarks_api\n\n\n \n render :json => @finalapi\n\n end",
"def client_choose(offset = 10, limit = 20)\n response = Net::HTTP.get(\n URI(\"https://pokeapi.co/api/v2/pokemon/?offset=#{offset}&limit=#{limit}\")\n )\n \n JSON.parse(response)\nend"
] |
[
"0.6801513",
"0.5988172",
"0.5903828",
"0.5830827",
"0.5759682",
"0.5666592",
"0.5636708",
"0.5636708",
"0.5636708",
"0.5636708",
"0.5621296",
"0.56193566",
"0.5569264",
"0.55605793",
"0.55453724",
"0.5523555",
"0.5501333",
"0.54920936",
"0.548831",
"0.5474963",
"0.5446883",
"0.5426167",
"0.54176795",
"0.5406848",
"0.53983665",
"0.53808707",
"0.53805196",
"0.53691316",
"0.5368137",
"0.536469",
"0.5364368",
"0.5344233",
"0.53328145",
"0.53314054",
"0.5329233",
"0.5314179",
"0.530508",
"0.5297998",
"0.52960044",
"0.5290231",
"0.52862537",
"0.5285648",
"0.5277094",
"0.52701503",
"0.5265801",
"0.52615243",
"0.5256551",
"0.52556354",
"0.5254493",
"0.5250736",
"0.52465117",
"0.52383137",
"0.52351743",
"0.5233389",
"0.5227119",
"0.52168804",
"0.5201823",
"0.5200264",
"0.52000433",
"0.51941437",
"0.51939005",
"0.51884645",
"0.51884645",
"0.51884645",
"0.51884645",
"0.5182394",
"0.51652455",
"0.51625437",
"0.5162375",
"0.5161631",
"0.51605606",
"0.5158043",
"0.51565886",
"0.51447785",
"0.512841",
"0.5121503",
"0.51208764",
"0.5118504",
"0.5116545",
"0.5115802",
"0.5111532",
"0.51107574",
"0.5110588",
"0.51090515",
"0.51075083",
"0.51074755",
"0.51030695",
"0.5099305",
"0.5098969",
"0.50891227",
"0.5086121",
"0.50829357",
"0.5062816",
"0.5061666",
"0.50601536",
"0.5059773",
"0.5044068",
"0.5039469",
"0.5037257",
"0.50371075",
"0.50361955"
] |
0.0
|
-1
|
Parses an HTTP header string (from the second line on) and returns a hash.
|
def parse_header(raw)
header = {}
field = nil
raw.each_line do |line|
case line
when /^([A-Za-z0-9!\#$%&'*+\-.^_`|~]+):\s*(.*?)\s*\z/om
field, value = $1, $2
header[field] = value
when /^\s+(.*?)\s*\z/om
value = $1
fail "bad header '#{line}'." unless field
header[field][-1] << ' ' << value
else
fail "bad header '#{line}'."
end
end
header.each do |key, value|
value.strip!
value.gsub!(/\s+/, ' ')
end
header
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parse_header(line)\n if (match = line.match(/^(.+?):\\s*(.+)#{@nl}$/))\n key = match[1].downcase\n set_header_special_values(key, match[2])\n parse_normal_header(line, key, match[1], match[2])\n elsif (match = line.match(/^HTTP\\/([\\d\\.]+)\\s+(\\d+)\\s+(.+)$/))\n @response.code = match[2]\n @response.http_version = match[1]\n @http2.on_content_call(@args, line)\n else\n raise \"Could not understand header string: '#{line}'.\"\n end\n end",
"def get_http_header line\n return nil if not is_http_header? line\n parts = line.split(':')\n {parts[0].strip => parts[1].strip}\n end",
"def parse_header_string(header_string)\n status, headers = nil, {}\n return [status, headers] unless header_string\n\n header_string.split(/\\r\\n/).each do |header|\n if header =~ %r|^HTTP/1.[01] \\d\\d\\d (.*)|\n status = $1\n else\n parts = header.split(':', 2)\n unless parts.empty?\n parts[1].strip! unless parts[1].nil?\n if headers.has_key?(parts[0])\n headers[parts[0]] = [headers[parts[0]]] unless headers[parts[0]].kind_of? Array\n headers[parts[0]] << parts[1]\n else\n headers[parts[0]] = parts[1]\n end\n end\n end\n end\n\n [status, headers]\n end",
"def cgi_parse_header(line)\n parts = _cgi_parseparam(';' + line)\n key = parts.next\n pdict = {}\n\n begin\n while p = parts.next\n i = p.index('=')\n if i\n name = p[0...i].strip.downcase\n value = p[i+1..-1].strip\n if value.length >= 2 && value[0] == '\"' && value[-1] == '\"'\n value = value[1...-1]\n value = value.gsub('\\\\\\\\', '\\\\').gsub('\\\\\"', '\"')\n end\n pdict[name] = value\n end\n end\n rescue StopIteration\n end\n\n [key, pdict]\n end",
"def cgi_parse_header(line); end",
"def parse_headers\n headers = {}\n @request.lines[1..-1].each do |line|\n # puts line.inspect\n # puts line.split.inspect\n return headers if line == \"\\r\\n\" # Because HTTP header's last line will be /r/n we return bc we're done\n header, value = line.split\n header = normalize(header)\n headers[header] = value\n end\n \n return headers\n end",
"def header_to_hash data\n header = {}\n data = data.split(@opts[:delimiter])\n self.req[\"Verb\"], self.req[\"Url\"], self.req[\"Version\"] = data.shift.split(\" \", 3)\n data.each do |line|\n k,v = line.split(\":\", 2)\n if !@opts[:header_bl] || !(HEADER_BLACKLIST.include? k)\n header[k] = v.lstrip\n end\n end\n header\n end",
"def parse_first_header(line)\n\n # split the line into: METHOD URI PROTOCOL\n # eg: GET / HTTP/1.1\n parsed = line.split(' ')\n\n # a correct request has three parts\n return bad_parsing unless parsed.size == 3\n\n @http_request_method, uri, @http_protocol = parsed\n\n # optional query string\n @http_request_uri, @http_query_string = uri.split('?')\n end",
"def parse_header(line)\n case line\n when /^#%checkm/\n match = /^#%checkm_(\\d+)\\.(\\d+)/.match line\n @version = \"#{match[1]}.#{match[2]}\" if match\n when /^#%eof/\n @eof = true\n when /^#%fields/\n list = line.split('|')\n list.shift\n @fields = list.map { |v| v.strip.downcase }\n when /^#%prefix/, /^#%profile/\n # do nothing\n end\n end",
"def parseHeaders(request) \n headers = {};\n\n # Loop through headers\n request.lines[1..-1].each do |line|\n # If we are moving to the next line, return what we currently have\n return headers if line == \"\\r\\n\"\n\n # Structure data\n header, value = line.split\n header = header.gsub(\":\", \"\").downcase.to_sym\n headers[header] = value\n end\nend",
"def headers_hash\n @headers_hash ||= Hash[@http_headers.split(\"\\x00\").map{|x| x.split(': ',2)}]\n end",
"def parse_header_line(header_str)\n @headers = header_str.split(',')\n @headers.map! do |h|\n h.gsub!('\"','')\n h.strip!\n h.underscore.to_sym\n end\n @headers\n end",
"def parse_headers(headers_hash)\n header_string = \"\"\n for header in headers_hash.select { |k,v| k.match(\"^HTTP.*\") } do\n header_string += header[0]+\":\"+header[1]+\"|\"\n end\n return header_string\n end",
"def parse_headers raw_headers\n\t\theaders = Hash.new\n\n\t\t# Store values as hash, but don't include duplicate values\n\t\tremove_fws(raw_headers).map do |line|\n\t\t\tkey, value = line.split(\": \", 2)\n\t\t\theaders[key] ||= []\n\t\t\theaders[key] << value unless headers[key].include? value\n\t\tend\n\n\t\t# Pop value from array if there's only one value\n\t\theaders.each{ |key, value| headers[key] = value.pop if value.length == 1 }\n\tend",
"def parse_headers(raw_headers)\n headers = {}\n raw_headers.each do |h|\n if h =~ /^# *([a-zA-Z_]+) *:(.*)/\n h_key = $1.downcase.intern\n h_value = $2.split(\",\").collect { |v| v.strip }\n if h_value.length > 0 # ignore empty headers\n headers[h_key] = h_value.length > 1 ? h_value : h_value[0]\n end\n end\n end\n \n return headers\n end",
"def parse_header(line, opts = {})\n host = opts[:host]\n if host\n line = line.gsub(/^(Host:\\s+).*$/, \"\\\\1#{host}\")\n line = line.gsub(/^(Referer:\\s+https?:\\/\\/)[^\\/]*(.*)$/, \"\\\\1#{host}\\\\2\")\n end\n @headers << line\n line = line.downcase\n if line.start_with? 'content-length: '\n @content_length = line.gsub(/^\\S+\\s+(\\d+)\\s*$/, '\\1').to_i\n elsif line.start_with? 'transfer-encoding: '\n encodings = line.gsub(/^\\S+\\s+(.*)$/, '\\1')\n @transfer_encodings = encodings.split(/\\s*,\\s*/).map {|e| e.strip.to_sym}\n end\n end",
"def hashify_header(hash, line)\n return nil if line.nil? || line.strip.empty?\n key, value = line.split(':')\n hash[convert_key(key)] = value.strip.chomp\n end",
"def parse_header_lines\n if @parsed_values[\"\"].nil? || @parsed_values[\"\"][1].nil?\n @parsed_values[\"\"] = {}\n return\n end\n\n headers = {}\n # Heading lines may have escaped newlines in them\n @parsed_values[\"\"][1].split(/\\\\n/).each do |line|\n next if line.size == 0\n\n if line =~ /(.*?):(.*)/\n key, value = $1, $2\n if headers[key] && headers[key].size > 0\n @errors << [\"Duplicate header line: #{line}\"]\n elsif key =~ /#-#-#-#-#/\n @errors << [\"Marker in header line: #{line}\"]\n else\n headers[key] = value\n end\n else\n @errors << [\"Malformed header #{line}\"]\n end\n end\n\n @parsed_values[\"\"] = headers\n end",
"def parse_header( data )\n k,v = data.split(\"\\0\", 2)\n return [k, v.delete(\"\\0\")]\n end",
"def parse_header_contents; 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 parse_status_and_headers(headers_str)\n status_and_headers = headers_str.split(\"\\r\\n\")\n status_line = status_and_headers.shift\n \n # TODO: there is no support for repeating headers (like Cookie:)\n header_hash = status_and_headers.each_with_object({}) do | header, h|\n split_at = header.index(':')\n key, value = header[0...split_at], header[(split_at + 1)..-1]\n h[key] = value.strip\n end\n raise \"Invalid response status line #{status_line}\" unless status_line =~ STATUS_PAT\n \n http_version, status_code, status = $1, $2, $3\n [status_code.to_i, header_hash]\n end",
"def get_header\n file_in_handle = open_in_file @file_in_path\n file_in_handle.seek FILE_HEADER_MAGIC_KEY_BYTES\n header_data = file_in_handle.read FILE_HEADER_DATA_BYTES\n file_in_handle.close\n\n crypto = Mcrypt.new(:'blowfish-compat', :ecb, HEADER_DECRYPTION_KEY)\n plaintext = crypto.decrypt(header_data)\n\n header_hash = {}\n URI.decode_www_form(plaintext).each { |key_value_array| header_hash[key_value_array[0]] = key_value_array[1] unless key_value_array[0].empty? }\n header_hash\n end",
"def parse_rfc822_header(input)\n headers = Hash.new\n previous = nil\n input.each_line do |line|\n line = line.chomp\n break if line.empty? # Stop at first blank line\n case line\n when /^([^: \\t]+):\\s+(.*)$/\n raise \"Multiple definitions of header '#{$1}'.\" if headers.has_key?($1)\n headers[previous = $1] = $2\n when /^\\s+(.*)$/\n if not previous.nil? and headers.has_key?(previous)\n headers[previous] << \"\\n\" + $1.lstrip\n else\n raise \"Invalid header continuation.\"\n end\n else\n raise \"Invalid header format.\"\n end\n end\n return headers.empty? ? nil : headers\nend",
"def headers\n list = @response.header_str.split(/[\\r\\n]+/).map(&:strip)\n Hash[list.flat_map{ |s| s.scan(/^(\\S+): (.+)/) }.map { |pair|\n [pair.first.to_s.camelcase, pair.second]\n }]\n end",
"def parse!\n if /^(?<key>.*?):(?<value>.*)/m =~ @raw\n @key = key.strip\n @value = value.strip\n else\n raise \"Unable to parse Header: #{@raw}\"\n end\n end",
"def _extract_headers(str)\n \n asa = str.split(AMP)\n @headers = {}\n esa = nil\n hv = nil\n asa.each do |hdr|\n esa = hdr.split(EQL)\n hname = SipperUtil.methodize(esa[0])\n if esa[1]\n \n if esa[1] =~ DQ\n hv = esa[1][1...-1]\n else\n hv = esa[1]\n end\n hv = CGI.unescape(hv)\n @headers[hname] = SipperUtil.find_parser_and_parse(hname, hv, true)\n end \n end \n end",
"def header(nheaders,hname)\n\t\t\tnheaders.each_line do |lh|\n\t\t\t\tn,v = lh.split(\": \")\n\t\t\t\tif n == hname\n\t\t\t\t\treturn v\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn hstr\n\t\tend",
"def parse_header(string)\n {\n # identificação do registro header (conteúdo 0)\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # código da empresa no bradesco\n :codigo_empresa => string[26..45].strip,\n # razão social da empresa\n :razao_social => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => convert_date(string[94..99]),\n # brancos\n #:brancos1 => string[100..107],\n # número aviso bancário\n :numero_aviso_bancario => string[108..112],\n # brancos\n #:brancos2 => string[113..378],\n # data de crédito dos lançamentos\n :data_credito => convert_date(string[379..384]),\n # brancos\n #:brancos3 => string[385..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def parse_header(io)\n\t variable_name = nil\n\t parse_pairs io do |code, value|\n\t\tcase code\n\t\t when '0' then next\n\t\t when '9'\n\t\t\tvariable_name = value\n\t\t else\n\t\t\theader[variable_name] = value\n\t\tend\n\t end\n\tend",
"def find_header(header)\n {}.tap do |returning|\n contents.scan(header_with_content_regexp(header)).flatten.first.split(\"\\n\").each do |setting|\n name, value = *setting.split('=').map(&:strip)\n returning[name] = value\n end\n end\n end",
"def header\n @raw.split(\"--\" + boundary)[0]\n end",
"def response_headers_hash\n return {} unless response_headers\n result = {}\n prev = nil\n response_headers.each_line do |line|\n next if line.blank?\n if line[0..0].blank?\n raise HeaderParseError.new('Leading whitespace on first header line') unless prev\n prev << line.lstrip\n else\n key, value = line.split(':', 2)\n raise HeaderParseError.new('Missing header name') if key.blank?\n key = NORMALIZED_HEADERS[key.downcase] || key\n prev = value.lstrip!\n result[key] = prev\n end\n end\n result\n end",
"def extract_header(content)\n return \"\" if content.blank?\n content.split(/\\r\\n\\r\\n|\\n\\n/).first\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def header(str)\n # {{{\n if @output_started\n raise \"HTTP-Headers are already send. You can't change them after output has started!\"\n end\n unless @output_allowed\n raise \"You just can set headers inside of a Rweb::out-block\"\n end\n if str.is_a?Array\n str.each do | value |\n self.header(value)\n end\n\n elsif str.split(/\\n/).length > 1\n str.split(/\\n/).each do | value |\n self.header(value)\n end\n\n elsif str.is_a? String\n str.gsub!(/\\r/, \"\")\n\n if (str =~ /^HTTP\\/1\\.[01] [0-9]{3} ?.*$/) == 0\n pattern = /^HTTP\\/1.[01] ([0-9]{3}) ?(.*)$/\n\n result = pattern.match(str)\n self.setstatus(result[0], result[1])\n elsif (str =~ /^status: [0-9]{3} ?.*$/i) == 0\n pattern = /^status: ([0-9]{3}) ?(.*)$/i\n\n result = pattern.match(str)\n self.setstatus(result[0], result[1])\n else\n a = str.split(/: ?/, 2)\n\n @header[a[0].downcase] = a[1]\n end\n end\n # }}}\n end",
"def http_auth_header\n if header['Authorization'].present?\n return header['Authorization'].split(' ').last\n end\n raise(ExceptionHandler::MissingToken, 'Missing_token') #should be refactored into a singleton class man \n end",
"def parse_header_contents\n text = @src[\"contents\"]\n text.rstrip!\n id_match = HEADER_ID.match(text)\n if id_match\n id = id_match[\"id\"]\n text = text[0...-id_match[0].length]\n text.rstrip!\n end\n [text, id]\n end",
"def parse(text)\n text.split(\"\\n\").each do |line|\n if line =~ /^.*\\:.*$/\n s = line.split(\":\")\n \n key = s[0].strip\n value = s[1].strip\n \n @headers[key] = value\n else\n s = line.split\n \n @http_version = s[0]\n @status = s[1].to_i\n @response_text = s[2]\n end\n end\n end",
"def header(string, replace=true, http_response_code=nil)\n name, value = string.split(': ', 2)\n headers[name] = value\n end",
"def header_raw(str)\n raise \"No HTTP-session attached to this thread.\" if !_httpsession\n raise \"HTTP-session not active.\" if !_httpsession.resp\n Php4r.header(str)\n return nil\n end",
"def header(buf)\n peek = buf.getbyte\n buf.seek(-1, IO::SEEK_CUR)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def get_header_and_body\n headers, body = {}, \"\"\n until line = @socket.gets and line.chomp.empty?\n if (kv = line.chomp.split(/:\\s+/,2)).size == 2\n headers.store *kv\n end\n end\n if (content_length = headers[\"Content-Length\"].to_i) > 0\n Log.debug \"content_length is #{content_length}, grabbing from socket\"\n body << @socket.read(content_length)\n end\n headers.merge(\"body\" => body.strip)\n end",
"def from_string(header) # rubocop:disable Metrics/CyclomaticComplexity:\n return DEFAULT if header.nil? || header.empty?\n\n hash = header.split(',').each_with_object({}) do |member, memo|\n member.strip!\n kv = member.split('=')\n k, v = *kv\n next unless kv.length == 2 && VALID_KEY.match?(k) && VALID_VALUE.match?(v)\n\n memo[k] = v\n end\n return DEFAULT if hash.empty?\n\n new(hash)\n end",
"def header(name)\n rack_header = \"http-#{name}\".upcase!.tr('-', '_')\n\n hdr = @env[rack_header]\n\n # Only return the value if it is not an empty string\n hdr if hdr != ''\n end",
"def parse_http_meta text\n headers = {}\n status = 200\n size = 0\n parts = text.split /^---$/\n if parts.length > 1\n for part in parts.last.split \"\\n\"\n if Oaf::Util.is_http_header? part\n headers.merge! Oaf::Util.get_http_header part\n elsif Oaf::Util.is_http_status? part\n status = Oaf::Util.get_http_status part\n else next\n end\n size += size == 0 ? 2 : 1 # compensate for delimiter\n end\n end\n [headers, status, size]\n end",
"def read_mt_header_string(bytes, skip)\n\tb = []\n\tbytes_to_read = 4\n\twhile true\n data = get_bytes(bytes_to_read)\n b += data\n if b.length < 4\n error(\"unexpected EOF while trying to read header string #{s}\")\n end\n\n # See if we found the bytes we're looking for\n return if b == bytes\n\n if skip\t\t# Try again with the next char\n i = b[1..-1].index(bytes[0])\n if i.nil?\n b = []\n bytes_to_read = 4\n else\n b = b[i..-1]\n bytes_to_read = 4 - i\n end\n else\n error(\"header string #{bytes.collect{|b| b.chr}.join} not found\")\n end\n\tend\n end",
"def is_http_header? line\n line.split(':').length == 2\n end",
"def parse_response_headers\n return {} if response_headers.empty?\n\n lines = response_headers.split(\"\\n\")\n\n lines = lines[1..(lines.size - 1)] # Remove Status-Line and trailing whitespace.\n\n # Find only well-behaved HTTP headers.\n lines.map do |line|\n header = line.split(':', 2)\n header.size != 2 ? nil : header\n end.compact.to_h\n end",
"def decode_captured_headers(string)\n string.split('|', -1).map! { |header| unescape(header) }\n end",
"def decode_captured_headers(string)\n string.split('|', -1).map! { |header| unescape(header) }\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.find do |_t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end\n\n fail CompressionError unless header[:type]\n\n header[:name] = integer(buf, type[:prefix])\n\n case header[:type]\n when :indexed\n fail CompressionError if (header[:name]).zero?\n header[:name] -= 1\n when :changetablesize\n header[:value] = header[:name]\n else\n if (header[:name]).zero?\n header[:name] = string(buf)\n else\n header[:name] -= 1\n end\n header[:value] = string(buf)\n end\n\n header\n end",
"def actual_header\n data.lines.first.chomp\n end",
"def header_for_string string\n header = string.length << 1 # make room for a low bit of 1\n header = header | 1 # set the low bit to 1\n pack_int header\n end",
"def http_auth_header\n if headers['Authorization'].present?\n return headers['Authorization'].split(' ').last\n else\n errors.add(:token, 'Missing Token')\n end\n nil\n end",
"def verify_auth_header_components headers\n auth_header = headers.find { |x| x[0] == \"Authorization\" }\n raise MalformedAuthorizationError, \"Authorization header is missing\" if auth_header.nil? || auth_header[1] == \"\"\n auth_hash = ::Signet::OAuth1.parse_authorization_header(\n auth_header[1]\n ).each_with_object({}) { |(key, val), acc| acc[key.downcase] = val; }\n\n auth_hash\n end",
"def split_request_message(message)\n header_and_body = message.split(/\\n\\n/)\n if header_and_body[0]\n message_type = header_and_body[0].split(/\\n/)[0]\n header_element = header_to_hash(header_and_body[0])\n end\n return message_type, header_element, header_and_body[1]\n end",
"def parse_header(string)\n {\n # identificação do registro header\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # agência mantenedora da conta\n :agencia => string[26..29],\n # complemento de registro\n :zeros => string[30..31],\n # número da conta corrente da empresa\n :conta => string[32..36],\n # dígito de auto-conferência ag/conta empresa\n :dac => string[37..37],\n # complemento do registro\n #:brancos1 => string[38..45],\n # nome por extenso da \"empresa mãe\"\n :nome_empresa => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => string[94..99],\n # unidade de densidade\n :densidade => string[100..104],\n # densidade de gravação do arquivo\n :unidade_densidade => string[105..107],\n # número sequencial do arquivo retorno\n :numero_sequencial_arquivo_retorno => string[108..112],\n # data de crédito dos lançamentos\n :data_credito => string[113..118],\n # complemento do registro\n #:brancos2 => string[119..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def seperate_headers()\n\t\t@stream.split(\"\\n\\n\")[0].split(\"\\n\", 2)[1]\n\tend",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def http_auth_header\n if headers['Authorization'].present?\n return headers['Authorization'].split(' ').last\n end\n\n raise(ExceptionHandler::MissingToken, Message.missing_token)\n end",
"def encode_header(s); s; end",
"def verify_header\n # normal header like sample ==> Authorization 'ddd$$%gggrghHFDSS.HHJHTTGGR'\n if headers['Authorization'].present?\n headers['Authorization'].split(' ').last\n else\n errors.add(:token, 'Missing Token')\n nil\n end\n end",
"def http_auth_header\n\t \tif headers['Authorization'].present?\n\t \t\treturn headers['Authorization'].split(' ').last\n\t \tend\n\t \traise MissingToken.new(message:\"Missing token. Please provide a security token.\")\n\tend",
"def header(h, buffer = \"\")\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def headers\n\t\t\thdr = @curb.header_str\n\t\t\tself.class.recode(log?, @curb.content_type, hdr) ?\n\t\t\t\tself.class.parse_headers(hdr) :\n\t\t\t\tself.class.parse_headers(@curb.header_str) # recode failed\n\t\tend",
"def header(prev_header)\n Bitcoin.double_sha256(filter_hash.htb + prev_header.htb).bth\n end",
"def convert_header(h)\n changed_header = h.to_s.downcase.gsub('-', '').gsub(' ','_')\n (User::HEADERS[changed_header].present? ? User::HEADERS[changed_header] : changed_header).intern\n end",
"def parse_header(header_line)\n check_element_size(header_line.length)\n\n @name = header_line[0]\n @domain_x = DataDomain.new(header_line[1], header_line[2], \\\n header_line[3], header_line[4])\n @domain_y = DataDomain.new(header_line[5], header_line[6], \\\n header_line[7], header_line[8])\n\n check_and_create_third_domain(header_line)\n end",
"def header(h, buffer = Buffer.new)\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def hash!(str)\n data = str.split(\" \")\n\n result = Hash.new\n\n result[:first] = data.first\n\n result[:last] = data.last\n\n if data[2]\n result[:middle] = data[1]\n end\n\n result\n end",
"def header; message[:header]; end",
"def from_s(header)\n reset\n\n # ghettoooooo!\n # If we don't have any newlines..., put one there.\n if (header.size > 0 && header !~ /\\r\\n/)\n header << \"\\r\\n\"\n end\n\n # put the non-standard line terminations back to normal\n # gah. not having look behinds suck,\n header.gsub!(/([^\\r])\\n/n,'\\1' + \"\\r\\n\")\n\n # undo folding, kinda ugly but works for now.\n header.gsub!(/:\\s*\\r\\n\\s+/smni,': ')\n\n # Extract the command string\n self.cmd_string = header.slice!(/.+\\r\\n/)\n\n # Extract each header value pair\n header.split(/\\r\\n/mn).each { |str|\n if (md = str.match(/^(.+?)\\s*:\\s*(.+?)\\s*$/))\n if (self[md[1]])\n self[md[1]] << \", \" + md[2]\n else\n self[md[1]] = md[2]\n end\n end\n }\n end",
"def parse_header(header_line)\n entries = delete_special_chars(header_line)\n # switch entries for geo coordinates since latitude comes before longitude\n geo_coordinate = Entity::Coordinate.new(entries[6].to_f, entries[5].to_f)\n @grid_data = Entity::GridPoint.new(entries[8].to_f, entries[9].to_f,\n entries[12].to_f, entries[11].to_f)\n # special case for multi word locations\n station_name = entries[0].sub(\"_\", \" \")\n @station = Entity::Station.new(station_name, entries[3], entries[13].to_f,\n geo_coordinate)\n nil\n end",
"def split_header_string(header_string)\n range_spec, *params = header_string.split(';')\n [range_spec.strip, params.map { |s| s.strip }]\n end",
"def parser(line)\n return Hash[line.split(\"\\t\").map{|f| f.split(\":\", 2)}]\n end",
"def parse_setext_header; end",
"def get_header(name)\n headers.each do |key,value|\n if key.casecmp(name) == 0\n return value\n end\n end\n nil\n end",
"def parse_header\n @snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = self.sequence_id.split(\" \") \n @type = @type.to_sym\n if @in\n @in = @in.to_sym == :exon \n else\n @exon = false\n end\n\n if @polymorphism.to_sym == :homoeologous\n @homoeologous = true\n else\n @homoeologous = false\n end\n @parsed = true\n @orientation = @orientation.to_sym\n end",
"def test_data_headers(string)\n\n\t\theaders = test_data_response(string).headers\n\n\tend",
"def header(key)\n return false unless headers.key?(key)\n\n headers.fetch(key).first.to_s\n end",
"def rhdr\n b = rbyte\n code, value = b & 7, b >> 3\n case value\n when 0..22\n return code, value\n when 23...31\n return code, rlongint(value-22)\n else\n n = renc\n return code, rlongint(n)\n end\n end",
"def parse_oauth_headers\n # Pull headers and return blank hash if no header variables found\n headers = env['AUTHORIZATION']; result = {};\n return result unless headers && headers[0,5] == 'OAuth'\n # Headers found. Go ahead and match 'em\n headers.split(/,\\n*\\r*/).each do |param|\n phrase, key, value = param.match(/([A-Za-z0-9_\\s]+)=\"([^\"]+)\"/).to_a.map{|v| v.strip}\n result[(key[\"OAuth\"])? :realm : key.to_sym] = value\n end\n result\n end",
"def split_header_value(str)\n str.scan(/((?:\"(?:\\\\.|[^\"])+?\"|[^\",]+)+)\n (?:,\\s*|\\Z)/xn).collect{|v| v[0] }\nend",
"def parse_headers(raw_headers)\n # raw headers from net_http have an array for each result. Flatten them out.\n raw_headers.inject({}) do |remainder, (k, v)|\n remainder[k] = [v].flatten.first\n remainder\n end\n end",
"def parse_digest(digest)\n # protect against missing data\n needed_parts = { 'nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1 }\n data = {}\n\n digest.scan(/(\\w+)=(?:(?:\")([^\"]+)\"|([^\\s,$]+))/) do |m1, m2, m3|\n data[m1] = m2 ? m2 : m3\n needed_parts.delete m1\n end\n\n needed_parts.any? ? nil : data\n end",
"def parse_line(line)\n host_ip, date, method_file_protocol, http_code, _ = @line_regex.match(line).captures\n file = @mfp_regex.match(method_file_protocol).captures[0]\n ip_token = host_ip.split(':')[1]\n\n date = Time.strptime(date, '%d/%b/%Y:%H:%M:%S %z').iso8601\n query_params = CGI::parse(URI(file).query)\n\n return {\n access_date: date,\n ip_token: ip_token,\n page_number: query_params[\"seq\"] || -1,\n http_code: http_code,\n volume_id: query_params[\"id\"]\n }\n end",
"def extract_parts_hash\n parts_hash = {}\n\n @header_string.sub!(/\\ARange:\\s*/, '')\n\n range_spec_string, params_strings = split_header_string(@header_string)\n\n parts_hash.merge! extract_range_spec_hash(range_spec_string)\n parts_hash.merge! extract_params_hash(params_strings)\n\n return parts_hash\n end",
"def _extract_params(str)\n @uri_params = SipperUtil.parameterize_header(str)[1] \n end",
"def headerName(header)\n begin\n header.split(\" \")[0]\n rescue\n \"\"\n end\nend",
"def http_auth_header\n request.headers['Authorization'].present? ? request.headers['Authorization'].split(' ').last : nil\n end",
"def get_header(socket, header = \"\")\n\t(line = socket.gets) == \"\\r\\n\" ? header : get_header(socket, header + line)\n end",
"def get_header_section(dns_query)\n header_section = {}\n HEADER_FIELD_INDEX.each do |header, index|\n header_section[header] = dns_query[index[0], index[1]].unpack(\"n\")[0]\n end\n return header_section\n end",
"def headers=(hash); end",
"def headers=(hash); end",
"def parse_heading(heading)\n captures = { \"version\" => nil, \"url\" => nil, \"date\" => nil }\n\n @heading_structures.each do |regexp|\n matches = Regexp.new(regexp).match(heading)\n if matches\n captures.merge!(Hash[matches.names.zip(matches.captures)])\n break\n end\n end\n\n captures\n end",
"def get_headers\nheader_values = {}\n i = 1\n # while !params[:header][:type_.to_s + \"#{i}\"].nil?\n while !params[:header_values_.to_s + \"#{i}\"].nil?\n\t value = params[:header_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n \theader_values[params[:header][:type_.to_s + \"#{i}\"]] = value\n i += 1\n end\n header_values\nend",
"def hashify(string)\n hash = Hash.new\n if string != nil\n string = string.split(/\\n(?=\\{)/)\n string.each do |section|\n hash[ ( section.slice(/[\\w\\d\\_\\#]+(?=\\})/) ) ] = section[(section.index('}')+1)..-1].strip\n end\n end\n return hash\nend",
"def header(name)\n @response[name]\n end",
"def separate_header(header)\n xsc, non_xsc, xsc_key = {}, \"\", nil\n\n header.split(\"\\n\").each do |line|\n if line =~ /^X-SC-([^:]+):(.*)/i\n xsc_key = $1.downcase\n xsc[xsc_key] = $2.to_s.strip\n\n elsif line =~ /^\\s/ && xsc_key\n xsc[xsc_key] += \" \" + line\n\n else\n xsc_key = nil\n non_xsc += line + \"\\n\"\n end\n end\n return [xsc, non_xsc]\n end"
] |
[
"0.77940863",
"0.7784196",
"0.74535525",
"0.73659676",
"0.7275645",
"0.7240513",
"0.7186212",
"0.6995989",
"0.69778246",
"0.69268936",
"0.68458",
"0.6817888",
"0.68014413",
"0.678655",
"0.67348224",
"0.67158926",
"0.6677246",
"0.66378576",
"0.65972626",
"0.6594826",
"0.65682685",
"0.65626496",
"0.6544277",
"0.65333533",
"0.6513985",
"0.6498506",
"0.6464791",
"0.63783956",
"0.6361949",
"0.6338874",
"0.62937117",
"0.6268264",
"0.6257841",
"0.6256986",
"0.6256398",
"0.62444854",
"0.621713",
"0.6195703",
"0.6194376",
"0.61719704",
"0.61674947",
"0.6149985",
"0.6120978",
"0.60823536",
"0.6054457",
"0.60379934",
"0.6037452",
"0.60334736",
"0.6007252",
"0.60068643",
"0.60068643",
"0.5966897",
"0.5963746",
"0.5961709",
"0.5935961",
"0.59195",
"0.59021544",
"0.58946925",
"0.5892012",
"0.58770716",
"0.5869563",
"0.584916",
"0.5830572",
"0.5818726",
"0.5794195",
"0.5752523",
"0.57494885",
"0.57096636",
"0.5685245",
"0.5661754",
"0.56531656",
"0.5647826",
"0.56459653",
"0.5631243",
"0.56243306",
"0.5623974",
"0.56105226",
"0.56095",
"0.5602928",
"0.5584066",
"0.5574427",
"0.5574069",
"0.5571583",
"0.55711293",
"0.5564429",
"0.55564684",
"0.5556332",
"0.55496895",
"0.5541965",
"0.5533023",
"0.5525479",
"0.5522642",
"0.5512012",
"0.55005145",
"0.55005145",
"0.5492357",
"0.54626197",
"0.5462317",
"0.5459895",
"0.54580516"
] |
0.69974273
|
7
|
Decrement the integer value of a key by the given number.
|
def decrby(key, decrement)
send_command([:decrby, key, Integer(decrement)])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _dec(key,value)\n _set(key, (_get(key) || 0) - value)\n end",
"def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], proc: T_INT\n end\n end",
"def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], :proc => T_INT\n end\n end",
"def decrby(key, decrement); end",
"def decrby(key, decrement); end",
"def decrement(key)\n msg = 'Trying to reduce count below zero.'\n raise RangeError, msg if @counter[key] == 0\n @counter[key] -= 1\n end",
"def decrement(key, offset=1)\n ret, value = Lib.memcached_decrement(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end",
"def decrease key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] -= amount\n end\n end",
"def decrement(key, amount = 1, options = {})\n increment(key, -amount, options)\n end",
"def decrby(key, decrement)\n node_for(key).decrby(key, decrement)\n end",
"def decrement\n @value -= 1\n end",
"def decr(key); end",
"def decr(key); end",
"def decrement(key, value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.decrement(#{key}, #{value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.decrement(key, value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: decrement: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end",
"def decrement(key, amount = 1, options = {})\n invoke(:decrement, key) do |store|\n alter(store, key, -amount, options)\n end\n end",
"def decr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"DECRBY #{key} #{increment}\\r\\n\"\n else\n write \"DECR #{key}\\r\\n\"\n end \n integer_reply\n }\n end",
"def decrement(by=1, &block)\n allow_expiration do\n val = redis.decrby(key, by).to_i\n block_given? ? rewindable_block(:increment, by, val, &block) : val\n end\n end",
"def dec(key)\n \n end",
"def decrement(k, amount = 1, ignored_options = nil)\n increment k, -amount\n end",
"def decrement!\n @value -= @increment\n \n self\n end",
"def decrement\n @counter = @counter - 1\n end",
"def decr(key)\n node_for(key).decr(key)\n end",
"def decrease(counter)\r\n counter - 1\r\nend",
"def remove(num)\n @count -= 1\n self[num].delete(num)\n end",
"def -(key)\n\t\t\tif key.is_a?(Integer) && key > 0\n\t\t\t\treturn key.times { undial! }\n\t\t\telse\n\t\t\t\treturn undial!(*key)\n\t\t\tend\n\t\tend",
"def decrement_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} - 1\", \"#{primary_key} = #{id}\"\n end",
"def dec(v = 1)\n sync { @v -= v }\n end",
"def lrem(key, count, value)\n send_command([:lrem, key, Integer(count), value])\n end",
"def decrease(counter)\n counter - 1\nend",
"def decrease(counter)\n counter - 1\nend",
"def decrease(counter)\n counter - 1\nend",
"def decrease(counter)\n counter - 1\nend",
"def decrease(counter)\n counter - 1\nend",
"def decrement!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be decremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n redis.decr(field_key(name), amount)\n end",
"def decrement(name, amount = 1, options = nil)\n key = expand_key(name)\n\n begin\n amount.times do |v|\n @gibson.dec key\n end\n rescue\n\n end\n end",
"def decrease(counter)\n counter -= 1\nend",
"def decrement_counter(counter_name, id)\n rec = collection.findOne({:_id => id})\n rec[counter_name] -= 1\n collection.save(rec)\n end",
"def decrement_count(current_count)\n current_count.to_i - 1\n end",
"def decrement(node)\n change_by node, -1\n end",
"def zdecr(key, member, score = 1)\n mon_synchronize do\n perform [\"zdecr\", key, member, score], proc: T_INT\n end\n end",
"def decrement_counter(counter_name, id)\n update_counters(id, counter_name.to_sym => -1)\n end",
"def zdecr(key, member, score = 1)\n mon_synchronize do\n perform [\"zdecr\", key, member, score], :proc => T_INT\n end\n end",
"def decr_by major, minor, value\n def_zero major, minor\n @stats[major][minor] -= value\n end",
"def delete(key)\n @succ.delete key\n end",
"def lrem(key, count, value); end",
"def lrem(key, count, value); end",
"def decrement_counter(counter_name, id, by: 1, touch: nil)\n update_counters(id, counter_name => -by, touch: touch)\n end",
"def remove(key)\n \txk = key % 10001 \n xk = (xk + 1) % 10001 while @arr[xk].first != nil && @arr[xk].first != key \n @arr[xk] = [nil, -1] if @arr[xk].first == key\n end",
"def decrement(by: 1)\n return increment(by: -by.to_i)\n end",
"def decrement!(attribute, by = 1, touch: nil)\n increment!(attribute, -by, touch: touch)\n end",
"def lrem(key, count, value)\n node_for(key).lrem(key, count, value)\n end",
"def decr(key, amt = 1, ttl = nil, default = nil)\n check_positive!(amt)\n\n perform(:decr, key, amt.to_i, ttl_or_default(ttl), default)\n end",
"def decrement!(attribute, by = 1)\n increment!(attribute, -by)\n end",
"def subtract(key, value)\n update_array(key, value, :subtract)\n end",
"def decrease(counter)\n counter[0] -= 1\nend",
"def remove(key)\n unless get(key) == -1\n @count -= 1\n bucket = @map[key.hash % @size]\n bucket.reject! {|k, v| k == key}\n end\n end",
"def decrement(attribute, by = 1)\n increment(attribute, -by)\n end",
"def delete(key)\n key = key.key if key.respond_to?(:key)\n\n unless (idx = @indicies[key]).nil?\n @indicies.delete(key)\n @indicies.each { |k,v| @indicies[k] = v -= 1 if v > idx }\n @lines.delete_at(idx)\n end\n end",
"def delete key\n slot = _find_slot(key)\n return nil if !@data[slot]\n value = @data[slot+1]\n @data[slot] = DELETED\n @data[slot+1] = nil\n\n # Unlink record\n n = @data[slot+2]\n prev = @data[slot+3]\n if prev\n @data[prev+2] = n\n end\n if n\n @data[n+3] = prev\n end\n if @first == slot\n @first = n\n end\n if @last == slot\n @last = prev\n end\n\n # FIXME: It fails without this, which indicates a bug.\n #@length -= 1\n value\n end",
"def get(key)\n ret = @values[key]\n return -1 unless ret\n\n @values.delete(key)\n @values[key] = ret\n ret\n end",
"def decrement(attribute, by = 1)\n increment(attribute, -by)\n end",
"def decr_counter!(name, decr = 1)\n counter = self.send(name.to_sym)\n counter.decr(val)\n save\n counter.reconcile!\n end",
"def decr(att)\n raise ArgumentError unless counters.include?(att)\n write_local(att, db.decr(key(att)))\n end",
"def decrement(att, count = 1)\n increment(att, -count)\n end",
"def call_dec(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n val = reg.word.to_i - get_mem_addr(addr, i_reg)\n reg.word.from_int(val)\n end",
"def decrement(name, amount = 1, expires_in: nil, initial: nil, **_options)\n instrument :decrement, name, amount: amount do\n failsafe :decrement do\n key = normalize_key(name, options)\n res = collection.binary.decrement(\n key, ::Couchbase::Options::Decrement(delta: amount, expiry: expires_in, initial: initial)\n )\n @last_mutation_token = res.mutation_token\n res.content\n end\n end\n end",
"def decrement(name, amount = 1, options = nil) # :nodoc:\n options = merged_options(options)\n response = instrument(:decrement, name, :amount => amount) do\n @data.decrby(namespaced_key(name, options), amount)\n end\n rescue => e\n logger.error(\"Error decrementing cache entry in redis: #{e}\") if logger\n nil\n end",
"def decrement\n with_update { with_progressables(:decrement) }\n end",
"def decrement(name, amount = 1, options = nil)\n options ||= {}\n name = expanded_key name\n\n if ttl = options.delete(:expires_in)\n options[:ttl] ||= ttl\n end\n options[:create] = true\n instrument(:decrement, name, options) do |payload|\n payload[:amount] = amount if payload\n @data.decr(name, amount, options)\n end\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end",
"def decrement(name, amount = T.unsafe(nil), options = T.unsafe(nil)); end",
"def subtract(key, value)\n run { conf.subtract(key, value, config_params) }\n end",
"def remove(value)\n connection.zrem(key_label, value)\n end",
"def decrement(field, amount = 1)\n increment(field, -amount)\n end",
"def decrement!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be decremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n store.update_count(field_key(name), -amount)\n end",
"def delete(key)\n response = request(:delete, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n else\n nil\n end\n end",
"def decrement(name, amount = 1, options = nil)\n options = merged_options(options)\n instrument(:decrement, name, amount: amount) do\n rescue_error_with nil do\n @data.with { |c| c.decr(normalize_key(name, options), amount, options[:expires_in], 0) }\n end\n end\n end",
"def decrease(rectangle, player, decrement=1)\n # Decrement counter\n increase(rectangle, player, -decrement)\n end",
"def subtract( key, reader_writer_accessor )\n \n # figure out actual subtraction value\n existing_status = self[ key ]\n \n result_value = status_minus_other_status( existing_status, reader_writer_accessor )\n\n if actual_status = status_minus_other_status( reader_writer_accessor, result_value )\n \n # if we have an actual value we are subtracting, do so directly (no hooks)\n if new_status = status_minus_other_status( existing_status, actual_status )\n store_without_hooks( key, new_status )\n elsif existing_status\n delete( key )\n end\n \n # update corresponding structures for subtraction (pass actually-subtracted value)\n unless @without_hooks\n update_for_subtraction( key, actual_status )\n end\n \n end\n \n return result_value\n \n end",
"def down\n self.x = (x+1)%10\n end",
"def Subtract(val)\n self.value -= val\n end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def decrement(labels = {}, by = 1)\n label_set = label_set_for(labels)\n synchronize do\n @values[label_set] ||= 0\n @values[label_set] -= by\n end\n end",
"def item_remover(hash, item, quantity = 1)\n hash[item] -= quantity\n if hash[item] <= 0\n hash.delete(item) \n end\n hash\nend",
"def remove(num)\n self[num].delete(num) if include?(num)\n end",
"def decr major, minor\n decr_by major, minor, 1\n end",
"def key=(value)\n raise TypeError, 'key must respond to #to_i' unless value.respond_to?(:to_i)\n \n @key = value.to_i\n end",
"def -(value)\n check_pre((\n (value.int?)\n ))\n\n from_index(normalize_index(to_index - value))\n end",
"def deduct(num)\n @balance -= num\n end",
"def decrement(name, amount = 1, options = {})\n instrument :decrement, name, amount: amount do\n failsafe :decrement do\n options = merged_options(options)\n key = normalize_key(name, options)\n\n with do |c|\n c.decrby(key, amount).tap do\n write_key_expiry(c, key, options)\n end\n end\n end\n end\n end",
"def remove(key)\n\n if include?(key)\n self[key].delete(key)\n @count -= 1\n end\n\n end",
"def decrement\n cache_updated_successfully =\n with_cache_store do |store|\n begin\n store.decr(cache_key) ||\n store.add(cache_key, value_in_db - 1) ||\n raise(ConcurrentCacheWriteError, \"Failing not to enter a race condition while writing a value for the key #{cache_key}\")\n rescue store.error_class => e\n false\n end\n end\n\n begin\n if cache_updated_successfully\n on_error_rollback_by(:increment_in_cache)\n\n decrement_in_db_later\n else\n decrement_in_db\n end\n rescue => e\n raise e\n end\n end",
"def decrease_key(key, new_key = nil)\n if node = search_key(key)\n if new_key && node.key < new_key \n puts \"the new key is greater than the old one, cause error.\"\n else\n new_key ? node.key = new_key : node.key = get_new_smaller_key(key)\n parent = node.parent\n if parent && node.key < parent.key\n cut(self, node, parent)\n cascading_cut(parent)\n end\n @min = node if node.key < min.key\n end\n node\n else\n puts \"Cannot find that key in heap.\"\n end\n end",
"def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_index\n end\n end\n deleted_index\n end",
"def decrement\n @mutex.synchronize {\n raise 'Counter already at 0' if @cnt == 0\n @cnt -= 1\n @cond_var.broadcast if @cnt == 0\n }\n end",
"def delete(key)\n self.map_var.each_with_index do |pair, idx|\n if pair[0] == key \n first_half = self.map_var[0...idx] \n second_half = self.map_var[idx+1..-1]\n self.map_var = first_half + second_half\n break\n end \n end\n end",
"def delete_key(key)\n end",
"def delete(key)\r\n if record = touch(key)\r\n @store.delete(key)\r\n @head = @tail = nil if @store.length.zero?\r\n record[:value]\r\n end\r\n end",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def subtract(input_number)\n $number -= input_number\n return $number\nend"
] |
[
"0.7788995",
"0.77010024",
"0.76765805",
"0.76502395",
"0.76502395",
"0.755122",
"0.7349987",
"0.7339793",
"0.730003",
"0.6898535",
"0.68906945",
"0.6843618",
"0.6843618",
"0.6828622",
"0.67729133",
"0.6768649",
"0.6758973",
"0.6705658",
"0.65518355",
"0.6509683",
"0.64989954",
"0.6497126",
"0.64624685",
"0.64603466",
"0.64481527",
"0.64095557",
"0.6378707",
"0.63706064",
"0.6337724",
"0.6337724",
"0.6337724",
"0.6337724",
"0.6337724",
"0.6296377",
"0.6283172",
"0.6239832",
"0.62222785",
"0.61940753",
"0.61836624",
"0.6166086",
"0.6158739",
"0.6152216",
"0.61504483",
"0.61315525",
"0.61070466",
"0.61070466",
"0.61030996",
"0.6091994",
"0.6056666",
"0.60517323",
"0.6034727",
"0.60081244",
"0.5987325",
"0.59830135",
"0.59705067",
"0.5967355",
"0.59602326",
"0.59560555",
"0.5907177",
"0.59059525",
"0.58945644",
"0.588676",
"0.58495903",
"0.58458006",
"0.5829825",
"0.5794742",
"0.57939214",
"0.57796764",
"0.57766527",
"0.57263684",
"0.5722384",
"0.57117784",
"0.5711546",
"0.5671201",
"0.5661839",
"0.5643257",
"0.5641665",
"0.56232005",
"0.5612527",
"0.55982494",
"0.5597264",
"0.5597264",
"0.559506",
"0.55661803",
"0.5565172",
"0.5562695",
"0.554169",
"0.55335695",
"0.5524816",
"0.5519467",
"0.5516183",
"0.55106175",
"0.5509586",
"0.55071795",
"0.5500292",
"0.5498924",
"0.5485619",
"0.5476918",
"0.54738826",
"0.5468258"
] |
0.7205911
|
9
|
Increment the integer value of a key by one.
|
def incr(key)
send_command([:incr, key])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end",
"def increment(key)\n @counter[key] += 1\n end",
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def incr(key); end",
"def incr(key); end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def incr(key)\n node_for(key).incr(key)\n end",
"def inc(key)\n \n end",
"def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], proc: T_INT\n end\n end",
"def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], :proc => T_INT\n end\n end",
"def increment_counter(key)\n if @counters.key?(key)\n @counters[key] += 1\n else\n @counters[key] = 1\n end\n end",
"def incrby(key, increment)\n node_for(key).incrby(key, increment)\n end",
"def increase key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] += amount\n end\n end",
"def hincrby(key, field, increment); end",
"def hincrby(key, field, increment); end",
"def incr\n add(1)\n end",
"def incrby(key, increment)\n send_command([:incrby, key, Integer(increment)])\n end",
"def increment(key, val)\n self[key] += _floatify(val)\n end",
"def zincrby(key, increment, member); end",
"def zincrby(key, increment, member); end",
"def increment key\n @statsd_client.increment [@options[:env], @options[:prefix], key].join(\".\")\n end",
"def hincrby(key, field, increment)\n node_for(key).hincrby(key, field, increment)\n end",
"def increment(key, amount=1, &block)\n if block.nil?\n key_to_use = key\n else\n key_to_use = self.keys.detect { |k| block.call(key, k) } \n end\n \n if self[key_to_use].nil?\n self[key_to_use] = amount\n else\n self[key_to_use] += amount\n end\n end",
"def increment\n @value += 1\n end",
"def incr(x) x + 1 end",
"def increment(key, offset=1)\n ret, value = Lib.memcached_increment(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end",
"def incr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"INCRBY #{key} #{increment}\\r\\n\"\n else\n write \"INCR #{key}\\r\\n\"\n end \n integer_reply\n }\n end",
"def incrbyfloat(key, increment); end",
"def incrbyfloat(key, increment); end",
"def hincrby(key, field, increment)\n send_command([:hincrby, key, field, Integer(increment)])\n end",
"def incr(key, timestamp, set_name)\n redis.zadd(set_name, timestamp, key)\n redis.incr(key).to_i\n end",
"def hash_data_add(hash, key)\n if hash.has_key?(key)\n hash[key] = hash[key] + 1\n else \n hash[key] = 1\n end\n end",
"def update_counting_hash(hash, key)\n hash[key] ? hash[key] += 1 : hash[key] = 1\n hash\nend",
"def increment(k, amount = 1, ignored_options = nil)\n handle_fork\n new_v = _get(k).to_i + amount\n _set k, new_v, 0\n new_v\n end",
"def zincrby(key, increment, member)\n node_for(key).zincrby(key, increment, member)\n end",
"def increment(key, amount = 1, options = {})\n invoke(:increment, key) do |store|\n alter(store, key, amount, options)\n end\n end",
"def update_counting_hash(hash, key)\n if hash[key] \n hash[key] += 1\n else\n hash[key] = 1\n end\n hash\nend",
"def increment!(subject, val = 1)\n $redis.incrby(key(subject), val)\n end",
"def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end",
"def increment(att, count = 1)\n key[:counters].call(\"HINCRBY\", att, count)\n end",
"def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], :proc => T_INT\n end\n end",
"def increment!\n @value += @increment\n \n self\n end",
"def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], proc: T_INT\n end\n end",
"def increment(key, inc_value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.increment(#{key}, #{inc_value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.increment(key, inc_value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: increment: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end",
"def inc(v = 1)\n sync { @v += v }\n end",
"def increment(node)\n change_by node, 1\n end",
"def increment(v = 1)\n if @value.kind_of?(String)\n @value = (to_f_or_i(@value) + v).to_s if to_f_or_i(@value)\n else\n @value += v\n end\n end",
"def incr(att)\n raise ArgumentError unless counters.include?(att)\n write_local(att, db.incr(key(att)))\n end",
"def increment_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} + 1\", \"#{primary_key} = #{id}\"\n end",
"def increment_counter\n unless self.count.nil?\n self.count += 1\n else\n self.count = 1\n end\n end",
"def increment\n self.class.increment(self)\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end",
"def increment\n @counter = @counter + 1\n end",
"def increment(name)\n update(name)\n end",
"def incr_count\n @count ||= 0\n @count += 1\n end",
"def increment_counter(counter)\n\tcounter += 1\n\treturn counter\nend",
"def zincrby(key, increment, member)\n call(key, [:zincrby, key, increment, member], transform: Redis::Floatify)\n end",
"def incr_counter!(name, val = 1)\n counter = self.send(name.to_sym)\n counter.incr(val)\n save\n counter.reconcile!\n end",
"def inc_value(iIncrement = 1)\n super\n end",
"def hincrbyfloat(key, field, increment); end",
"def hincrbyfloat(key, field, increment); end",
"def test_increment_existing_numeric\n @cache.add('Key', '100', 0, Time.now.to_i + 60)\n result = @cache.increment('Key', '1')\n cache = @cache.get('Key').args\n\n assert_true result.success\n assert_equal 'STORED', result.message.chomp.split(\"\\s\")[0]\n assert_equal 101, cache.data\n end",
"def increment(metric, value = 1)\n @adapter.increment metric, value\n end",
"def incr(key, amt = 1, ttl = nil, default = nil)\n check_positive!(amt)\n\n perform(:incr, key, amt.to_i, ttl_or_default(ttl), default)\n end",
"def increment_count(current_count)\n current_count.to_i + 1\n end",
"def incr(key, window=@max_window)\n key = key.to_s\n now = Time.now.to_f\n @redis.multi do\n @redis.zadd(key, now, SecureRandom.uuid)\n @redis.expire(key, @max_window.ceil)\n do_get(key, now, window)\n end.last\n end",
"def increment_counter(counter_name, id)\n rec = collection.findOne({:_id => id})\n rec[counter_name] += 1\n collection.save(rec)\n end",
"def increment!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be incremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n redis.incr(field_key(name), amount)\n end",
"def increment(by=1, &block)\n allow_expiration do\n val = redis.incrby(key, by).to_i\n block_given? ? rewindable_block(:decrement, by, val, &block) : val\n end\n end",
"def incrbyfloat(key, increment)\n node_for(key).incrbyfloat(key, increment)\n end",
"def increase(attr)\n raise NoMethodError, \"undefined method `#{attr}` for #{self}\" unless self.respond_to?(attr)\n raise NotCounterbleError, \"not countable attributs `#{attr}` for #{self}\" unless countable.include? attr\n self.send(\"#{attr}=\", self.send(attr).send(:+, 1))\n end",
"def increment \n\t\t@counter = @counter + 1\n\tend",
"def increment_counter(counter_name, id)\n update_counters(id, counter_name.to_sym => 1)\n end",
"def key=(value)\n raise TypeError, 'key must respond to #to_i' unless value.respond_to?(:to_i)\n \n @key = value.to_i\n end",
"def increment(name, amount = 1, options = nil)\n key = expand_key(name)\n\n begin\n amount.times do |v|\n @gibson.inc key\n end\n rescue\n\n end\n end",
"def increment list, entry\n if list[entry].class != NilClass\n list[entry] += 1\n end\nend",
"def increment_integer(user_id)\n user = User.find user_id\n user.integer_value += 1\n user.save\n\n user\n end",
"def increase_item_count(index)\n current_value = @item_counts[index] ||= 0\n\n @item_counts[index] = current_value + 1\n end",
"def increment(prob_hash, key)\n di = key[0,2]\n freq_arr = prob_hash[di]\n if !freq_arr\n prob_hash[di] = [[key[-1,1], 1]]\n else\n target_letter = key[-1,1]\n freq = freq_arr.assoc(target_letter)\n if !freq then freq_arr << [target_letter, 1] else freq[1] += 1 end\n end\nend",
"def inc( date ) \n rounded_date = round( date ) \n begin\n @sequence[ rounded_date ] += 1\n rescue NoMethodError # can't add one to nil\n self << rounded_date # sweeps cache\n retry\n else \n @values = nil # sweep cache \n end \n end",
"def add(value)\n @q.unshift(value)\n if @h1[value]\n @h1[value] = @h1[value] + 1\n else\n @h1[value] = 1\n end \n end",
"def increment(*)\n @build += 1\n end",
"def add(number)\n if @map.key?(number)\n @map[number] += 1\n else\n @map[number] = 1\n end\n end",
"def increment(value, score=1, session=nil)\n start_kvs_session(session) do |kvs|\n kvs.sorted_sets[key_name(Time.now)].increment(value, score).to_i\n end\n end",
"def increment(field, amount = 1)\n #value = (self[field] || 0) + amount\n #self[field] = value\n #if !@parse_object_id\n # # TODO - warn that the object must be stored first\n # return nil\n #end\n\n body = {field => Parse::Increment.new(amount)}.to_json\n data = Parse.client.request(self.uri, :put, body)\n parse data\n self\n end",
"def increment_for(obj)\n # decide the time of event asap\n ts = Time.now.ceil.to_i\n\n if obj.class.ancestors.include?MongoMapper::Document\n args = obj.key_attributes.collect { |k,v| v.to_s }\n cache_key = generate_key(ts, obj.class.name, *args)\n\n val = Cequel::Record.redis.get(cache_key)\n if val.nil?\n val = 1\n else\n val = val.to_i + 1\n end\n\n ttl = (time_window + 1) * 60\n\n # Update a sharded counter\n MongoMapper::Document.redis.setex(cache_key, ttl, val)\n\n # Optionally, update the index\n index_key = generate_index_key(ts, obj.class.name, *args)\n index_present = MongoMapper::Document.redis.get(index_key).try(:to_i)\n if index_present != 1\n MongoMapper::Document.redis.setex(index_key, ttl, 1)\n end\n end\n\n end",
"def increment(n = 1)\n @quantity += n\n end",
"def incr_by major, minor, value\n def_zero major, minor\n @stats[major][minor] += value\n end",
"def increment_processed_items\n processed_items = $redis.hgetall(redis_key)['processed_items'].to_i\n processed_items += 1\n\n $redis.hset(redis_key, :processed_items, processed_items)\n end",
"def increment *args\n accumulators.incr(scope(*args))\n end",
"def inc\n $i + 1\n end",
"def mutate(num)\n num += 1\n end",
"def increment(request_id, value)\n unless has_request_id? request_id\n self.counts[actor][\"total\"] += value\n self.counts[actor][\"requests\"] << request_id\n end\n end",
"def INC\n operand = unwrap_integer evaluation_stack.pop\n evaluation_stack.push operand + 1\n end",
"def increment_counter(counter_name, id, by: 1, touch: nil)\n update_counters(id, counter_name => by, touch: touch)\n end",
"def increment_map(map, key, age)\n if map.key?(key)\n map[key] = map[key]+1/2**(age/HALF_LIFE)\n else\n map[key] = 1/2**(age/HALF_LIFE)\n end\nend",
"def increment_and_save!\n update_and_save { self.last_value = (last_value || 0) + 1 }\n end",
"def increment\n topic.increment(1)\n end"
] |
[
"0.8546398",
"0.8440538",
"0.83541155",
"0.81469995",
"0.81469995",
"0.81236756",
"0.81236756",
"0.80572253",
"0.80104357",
"0.79280925",
"0.79027927",
"0.7857353",
"0.77896583",
"0.76560795",
"0.75172895",
"0.75172895",
"0.7464603",
"0.7452834",
"0.739074",
"0.7318309",
"0.7318309",
"0.73065007",
"0.72683907",
"0.7252519",
"0.7245109",
"0.7173039",
"0.7121843",
"0.7058932",
"0.7009341",
"0.7009341",
"0.6995533",
"0.69885504",
"0.6976954",
"0.6973796",
"0.6946009",
"0.6912917",
"0.68867165",
"0.688141",
"0.67904395",
"0.67662555",
"0.6761216",
"0.67052835",
"0.6691687",
"0.6671489",
"0.6646648",
"0.6645432",
"0.66220367",
"0.66077244",
"0.6603109",
"0.6598424",
"0.6586564",
"0.65689194",
"0.6563136",
"0.6563136",
"0.656018",
"0.6545948",
"0.6507855",
"0.65073824",
"0.6475257",
"0.6447205",
"0.6442522",
"0.6432929",
"0.6432929",
"0.6419416",
"0.64120173",
"0.638168",
"0.6369532",
"0.6352642",
"0.6337125",
"0.6326166",
"0.632098",
"0.6316957",
"0.6306285",
"0.6286336",
"0.6285287",
"0.62617105",
"0.6260461",
"0.62479615",
"0.6237789",
"0.62216586",
"0.62060595",
"0.6189112",
"0.61889225",
"0.61795956",
"0.6172594",
"0.61568385",
"0.6153585",
"0.6150161",
"0.6146709",
"0.61254346",
"0.6115829",
"0.61034906",
"0.6097422",
"0.6086323",
"0.6084861",
"0.60680133",
"0.60661405",
"0.60631156",
"0.60591304",
"0.60564536"
] |
0.76643014
|
13
|
Increment the integer value of a key by the given integer number.
|
def incrby(key, increment)
send_command([:incrby, key, Integer(increment)])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end",
"def increment(key)\n @counter[key] += 1\n end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def incr(key); end",
"def incr(key); end",
"def incr(key)\n node_for(key).incr(key)\n end",
"def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], proc: T_INT\n end\n end",
"def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], :proc => T_INT\n end\n end",
"def incrby(key, increment)\n node_for(key).incrby(key, increment)\n end",
"def inc(key)\n \n end",
"def incr(key)\n send_command([:incr, key])\n end",
"def increase key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] += amount\n end\n end",
"def increment_counter(key)\n if @counters.key?(key)\n @counters[key] += 1\n else\n @counters[key] = 1\n end\n end",
"def hincrby(key, field, increment); end",
"def hincrby(key, field, increment); end",
"def increment(key, val)\n self[key] += _floatify(val)\n end",
"def increment(key, amount=1, &block)\n if block.nil?\n key_to_use = key\n else\n key_to_use = self.keys.detect { |k| block.call(key, k) } \n end\n \n if self[key_to_use].nil?\n self[key_to_use] = amount\n else\n self[key_to_use] += amount\n end\n end",
"def incr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"INCRBY #{key} #{increment}\\r\\n\"\n else\n write \"INCR #{key}\\r\\n\"\n end \n integer_reply\n }\n end",
"def zincrby(key, increment, member); end",
"def zincrby(key, increment, member); end",
"def increment key\n @statsd_client.increment [@options[:env], @options[:prefix], key].join(\".\")\n end",
"def hincrby(key, field, increment)\n node_for(key).hincrby(key, field, increment)\n end",
"def increment(key, offset=1)\n ret, value = Lib.memcached_increment(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end",
"def increment(k, amount = 1, ignored_options = nil)\n handle_fork\n new_v = _get(k).to_i + amount\n _set k, new_v, 0\n new_v\n end",
"def hincrby(key, field, increment)\n send_command([:hincrby, key, field, Integer(increment)])\n end",
"def incr(x) x + 1 end",
"def incrbyfloat(key, increment); end",
"def incrbyfloat(key, increment); end",
"def incr\n add(1)\n end",
"def incr(key, timestamp, set_name)\n redis.zadd(set_name, timestamp, key)\n redis.incr(key).to_i\n end",
"def increment\n @value += 1\n end",
"def increment(key, amount = 1, options = {})\n invoke(:increment, key) do |store|\n alter(store, key, amount, options)\n end\n end",
"def zincrby(key, increment, member)\n node_for(key).zincrby(key, increment, member)\n end",
"def set_nr(key, val)\n db.putnr key, val if val\n end",
"def add(number)\n if @map.key?(number)\n @map[number] += 1\n else\n @map[number] = 1\n end\n end",
"def hash_data_add(hash, key)\n if hash.has_key?(key)\n hash[key] = hash[key] + 1\n else \n hash[key] = 1\n end\n end",
"def key=(value)\n raise TypeError, 'key must respond to #to_i' unless value.respond_to?(:to_i)\n \n @key = value.to_i\n end",
"def update_counting_hash(hash, key)\n hash[key] ? hash[key] += 1 : hash[key] = 1\n hash\nend",
"def increment_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} + 1\", \"#{primary_key} = #{id}\"\n end",
"def update_counting_hash(hash, key)\n if hash[key] \n hash[key] += 1\n else\n hash[key] = 1\n end\n hash\nend",
"def increment_counter(counter)\n\tcounter += 1\n\treturn counter\nend",
"def increment(att, count = 1)\n key[:counters].call(\"HINCRBY\", att, count)\n end",
"def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], :proc => T_INT\n end\n end",
"def increment!(subject, val = 1)\n $redis.incrby(key(subject), val)\n end",
"def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], proc: T_INT\n end\n end",
"def increment(n = 1)\n @quantity += n\n end",
"def incr(att)\n raise ArgumentError unless counters.include?(att)\n write_local(att, db.incr(key(att)))\n end",
"def increment(v = 1)\n if @value.kind_of?(String)\n @value = (to_f_or_i(@value) + v).to_s if to_f_or_i(@value)\n else\n @value += v\n end\n end",
"def incr(key, window=@max_window)\n key = key.to_s\n now = Time.now.to_f\n @redis.multi do\n @redis.zadd(key, now, SecureRandom.uuid)\n @redis.expire(key, @max_window.ceil)\n do_get(key, now, window)\n end.last\n end",
"def increment(key, inc_value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.increment(#{key}, #{inc_value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.increment(key, inc_value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: increment: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end",
"def incr(key, amt = 1, ttl = nil, default = nil)\n check_positive!(amt)\n\n perform(:incr, key, amt.to_i, ttl_or_default(ttl), default)\n end",
"def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end",
"def increment_count(current_count)\n current_count.to_i + 1\n end",
"def incr_counter!(name, val = 1)\n counter = self.send(name.to_sym)\n counter.incr(val)\n save\n counter.reconcile!\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end",
"def increment(name)\n update(name)\n end",
"def mutate(num)\n num += 1\n end",
"def increment\n @counter = @counter + 1\n end",
"def increment(node)\n change_by node, 1\n end",
"def inc(v = 1)\n sync { @v += v }\n end",
"def increment_counter(counter_name, id)\n rec = collection.findOne({:_id => id})\n rec[counter_name] += 1\n collection.save(rec)\n end",
"def inc_value(iIncrement = 1)\n super\n end",
"def increment!\n @value += @increment\n \n self\n end",
"def test_increment_existing_numeric\n @cache.add('Key', '100', 0, Time.now.to_i + 60)\n result = @cache.increment('Key', '1')\n cache = @cache.get('Key').args\n\n assert_true result.success\n assert_equal 'STORED', result.message.chomp.split(\"\\s\")[0]\n assert_equal 101, cache.data\n end",
"def add_integer(key, value)\n int = QueuedEmailInteger.find_by(queued_email_id: id, key: key.to_s)\n unless int\n int = QueuedEmailInteger.new\n int.queued_email_id = id\n int.key = key.to_s\n end\n int.value = value.to_i\n int.save\n int\n end",
"def increment_counter(counter_name, id)\n update_counters(id, counter_name.to_sym => 1)\n end",
"def zincrby(key, increment, member)\n call(key, [:zincrby, key, increment, member], transform: Redis::Floatify)\n end",
"def increment(metric, value = 1)\n @adapter.increment metric, value\n end",
"def increase_item_count(index)\n current_value = @item_counts[index] ||= 0\n\n @item_counts[index] = current_value + 1\n end",
"def hincrbyfloat(key, field, increment); end",
"def hincrbyfloat(key, field, increment); end",
"def increment!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be incremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n redis.incr(field_key(name), amount)\n end",
"def incr_count\n @count ||= 0\n @count += 1\n end",
"def incrbyfloat(key, increment)\n node_for(key).incrbyfloat(key, increment)\n end",
"def next_number(number)\n return number += 1\nend",
"def call_inc(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n val = get_mem_addr(addr, i_reg) + reg.word.to_i\n reg.word.from_int(val)\n end",
"def increment(by=1, &block)\n allow_expiration do\n val = redis.incrby(key, by).to_i\n block_given? ? rewindable_block(:decrement, by, val, &block) : val\n end\n end",
"def increment_counter(counter_name, id, by: 1, touch: nil)\n update_counters(id, counter_name => by, touch: touch)\n end",
"def increment_integer(user_id)\n user = User.find user_id\n user.integer_value += 1\n user.save\n\n user\n end",
"def increment(name, amount = 1, options = nil)\n key = expand_key(name)\n\n begin\n amount.times do |v|\n @gibson.inc key\n end\n rescue\n\n end\n end",
"def next_number(num)\n return num += 1\nend",
"def increase(attr)\n raise NoMethodError, \"undefined method `#{attr}` for #{self}\" unless self.respond_to?(attr)\n raise NotCounterbleError, \"not countable attributs `#{attr}` for #{self}\" unless countable.include? attr\n self.send(\"#{attr}=\", self.send(attr).send(:+, 1))\n end",
"def increment_counter\n unless self.count.nil?\n self.count += 1\n else\n self.count = 1\n end\n end",
"def add_ten(number)\n number += 10\nend",
"def next_number(number)\n number.to_i\n return number+=1\nend",
"def increment_quantity(purchase, n)\n entry = find_or_create_item(purchase)\n set_quantity(purchase, (entry.quantity || 0) + n.to_i, entry)\n end",
"def increment_map(map, key, age)\n if map.key?(key)\n map[key] = map[key]+1/2**(age/HALF_LIFE)\n else\n map[key] = 1/2**(age/HALF_LIFE)\n end\nend",
"def increment\n self.class.increment(self)\n end",
"def increment \n\t\t@counter = @counter + 1\n\tend",
"def increment(request_id, value)\n unless has_request_id? request_id\n self.counts[actor][\"total\"] += value\n self.counts[actor][\"requests\"] << request_id\n end\n end",
"def +(n) self.class.from_integer(to_i + n) end",
"def increment(field, amount = 1)\n #value = (self[field] || 0) + amount\n #self[field] = value\n #if !@parse_object_id\n # # TODO - warn that the object must be stored first\n # return nil\n #end\n\n body = {field => Parse::Increment.new(amount)}.to_json\n data = Parse.client.request(self.uri, :put, body)\n parse data\n self\n end",
"def increment_by amount, *args\n accumulators.incrby(scope(*args), amount)\n end",
"def add_item(hash, item, quantity)\n hash[item] = hash[item].to_i + quantity\n hash\nend",
"def increment(value, score=1, session=nil)\n start_kvs_session(session) do |kvs|\n kvs.sorted_sets[key_name(Time.now)].increment(value, score).to_i\n end\n end",
"def increment(attribute, by = 1)\n self[attribute] ||= 0\n self[attribute] += by\n self\n end",
"def add(number)\n set_value(@value + number.to_i)\n end"
] |
[
"0.83145404",
"0.8208279",
"0.8077446",
"0.8077446",
"0.79672027",
"0.79084706",
"0.79084706",
"0.7875213",
"0.7846512",
"0.7824136",
"0.77706105",
"0.76563656",
"0.76446706",
"0.7642724",
"0.76345533",
"0.7325844",
"0.7325844",
"0.72343284",
"0.71754074",
"0.7137071",
"0.71256804",
"0.71256804",
"0.70782655",
"0.7075923",
"0.6983102",
"0.6955377",
"0.69442135",
"0.6938599",
"0.6895523",
"0.6895523",
"0.6862037",
"0.67904025",
"0.67665076",
"0.6746911",
"0.6742393",
"0.6733716",
"0.6731961",
"0.6715083",
"0.6702277",
"0.66242874",
"0.6613286",
"0.65641814",
"0.6540139",
"0.64910495",
"0.64901704",
"0.64874023",
"0.64592683",
"0.64491993",
"0.64471346",
"0.6439139",
"0.6439088",
"0.64311445",
"0.64234465",
"0.64017993",
"0.63842463",
"0.63814676",
"0.63686043",
"0.63686043",
"0.63533986",
"0.6337956",
"0.6334027",
"0.6317792",
"0.630961",
"0.6301794",
"0.62546027",
"0.6251371",
"0.6247626",
"0.62406486",
"0.62317157",
"0.6222392",
"0.62104696",
"0.62077785",
"0.62058914",
"0.62058914",
"0.62022316",
"0.6192783",
"0.6192293",
"0.619067",
"0.6178318",
"0.6168438",
"0.6167742",
"0.6167372",
"0.61646277",
"0.6106309",
"0.6106064",
"0.60916775",
"0.6086748",
"0.6085868",
"0.60844165",
"0.6071341",
"0.6065914",
"0.60498834",
"0.6027534",
"0.60133016",
"0.59962744",
"0.5982127",
"0.5978095",
"0.5971531",
"0.59673923",
"0.5966194"
] |
0.76418406
|
14
|
Increment the numeric value of a key by the given float number.
|
def incrbyfloat(key, increment)
send_command([:incrbyfloat, key, Float(increment)], &Floatify)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def incrbyfloat(key, increment); end",
"def incrbyfloat(key, increment); end",
"def incrbyfloat(key, increment)\n node_for(key).incrbyfloat(key, increment)\n end",
"def increment(key, val)\n self[key] += _floatify(val)\n end",
"def hincrbyfloat(key, field, increment); end",
"def hincrbyfloat(key, field, increment); end",
"def hincrbyfloat(key, field, increment)\n node_for(key).hincrbyfloat(key, field, increment)\n end",
"def hincrbyfloat(key, field, increment)\n send_command([:hincrbyfloat, key, field, Float(increment)], &Floatify)\n end",
"def increase key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] += amount\n end\n end",
"def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def incr(key); end",
"def incr(key); end",
"def incr(key)\n node_for(key).incr(key)\n end",
"def incrby(key, increment)\n node_for(key).incrby(key, increment)\n end",
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def increment(key)\n @counter[key] += 1\n end",
"def increment(key, amount=1, &block)\n if block.nil?\n key_to_use = key\n else\n key_to_use = self.keys.detect { |k| block.call(key, k) } \n end\n \n if self[key_to_use].nil?\n self[key_to_use] = amount\n else\n self[key_to_use] += amount\n end\n end",
"def process_incrbyfloat(command)\n key = command.first\n add_value = command[1]\n\n @connection.execute_udf(as_key(key), REDIS_UDF, 'incrbyfloat',\n [::Aerospike::StringValue.new(@bin),\n ::Aerospike::StringValue.new(add_value.to_s)\n ]).to_s\n end",
"def inc(key)\n \n end",
"def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], :proc => T_INT\n end\n end",
"def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], proc: T_INT\n end\n end",
"def increment key\n @statsd_client.increment [@options[:env], @options[:prefix], key].join(\".\")\n end",
"def incrby(key, increment)\n send_command([:incrby, key, Integer(increment)])\n end",
"def incrbyfloat(by=1.0, &block)\n allow_expiration do\n val = redis.incrbyfloat(key, by).to_f\n block_given? ? rewindable_block(:decrbyfloat, by, val, &block) : val\n end\n end",
"def incr(key)\n send_command([:incr, key])\n end",
"def set_first_value_as_key_in_float_format\n FLOAT_VALUES.each {|key| @hash[key] = round_up_to_tenth(@hash[key][0])}\n end",
"def zincrby(key, increment, member); end",
"def zincrby(key, increment, member); end",
"def hincrby(key, field, increment); end",
"def hincrby(key, field, increment); end",
"def zincrby(key, increment, member)\n call(key, [:zincrby, key, increment, member], transform: Redis::Floatify)\n end",
"def increment(key, offset=1)\n ret, value = Lib.memcached_increment(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end",
"def increment(key, amount = 1, options = {})\n invoke(:increment, key) do |store|\n alter(store, key, amount, options)\n end\n end",
"def increment_map(map, key, age)\n if map.key?(key)\n map[key] = map[key]+1/2**(age/HALF_LIFE)\n else\n map[key] = 1/2**(age/HALF_LIFE)\n end\nend",
"def increment_counter(key)\n if @counters.key?(key)\n @counters[key] += 1\n else\n @counters[key] = 1\n end\n end",
"def increment(k, amount = 1, ignored_options = nil)\n handle_fork\n new_v = _get(k).to_i + amount\n _set k, new_v, 0\n new_v\n end",
"def hash_data_add(hash, key)\n if hash.has_key?(key)\n hash[key] = hash[key] + 1\n else \n hash[key] = 1\n end\n end",
"def hincrby(key, field, increment)\n node_for(key).hincrby(key, field, increment)\n end",
"def zincrby(key, increment, member)\n node_for(key).zincrby(key, increment, member)\n end",
"def increment(v = 1)\n if @value.kind_of?(String)\n @value = (to_f_or_i(@value) + v).to_s if to_f_or_i(@value)\n else\n @value += v\n end\n end",
"def incr(x) x + 1 end",
"def incr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"INCRBY #{key} #{increment}\\r\\n\"\n else\n write \"INCR #{key}\\r\\n\"\n end \n integer_reply\n }\n end",
"def incr(key, timestamp, set_name)\n redis.zadd(set_name, timestamp, key)\n redis.incr(key).to_i\n end",
"def incr(key, amt = 1, ttl = nil, default = nil)\n check_positive!(amt)\n\n perform(:incr, key, amt.to_i, ttl_or_default(ttl), default)\n end",
"def incr\n add(1)\n end",
"def increment\n @value += 1\n end",
"def inc_value(iIncrement = 1)\n super\n end",
"def add(number)\n set_value(@value + number.to_i)\n end",
"def put(key, value)\n value = value.to_f\n @queue_values[key] ||= []\n @queue_values[key] << value\n @smallest_seen_values[key] ||= 0.0\n if @largest_seen_values[key] == nil or @smallest_seen_values[key] > @largest_seen_values[key]\n @largest_seen_values[key] = @smallest_seen_values[key] + 1.0\n end\n @smallest_seen_values[key] = value if value < @smallest_seen_values[key]\n @largest_seen_values[key] = value if value > @largest_seen_values[key]\n end",
"def speed_incr _value\n send_cmd(\"speed_incr #{_value}\")\n end",
"def increase_size(per, hash)\n\thash.each { |key, value| hash[key] = (value * (1 + (per * 0.01))).round }\nend",
"def increment(key, inc_value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.increment(#{key}, #{inc_value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.increment(key, inc_value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: increment: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end",
"def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], :proc => T_INT\n end\n end",
"def hincrby(key, field, increment)\n send_command([:hincrby, key, field, Integer(increment)])\n end",
"def num_converter_update(num_to_convert,key)\n\tnum_to_convert % key\nend",
"def round_up_number(float)\n float.to_i + 1\nend",
"def incr_by major, minor, value\n def_zero major, minor\n @stats[major][minor] += value\n end",
"def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], proc: T_INT\n end\n end",
"def increment(name, amount = 1, options = nil)\n key = expand_key(name)\n\n begin\n amount.times do |v|\n @gibson.inc key\n end\n rescue\n\n end\n end",
"def student_add( students_hash)\n students_hash.each do |key,value|\n\n students_hash[key] = (value + (value * 5.0)/100).round(0)\n #puts \"#{value+20}\" #(value * 5.0)/100\n # puts (\"#{key}: #{value} students\")\n end\n end",
"def vm_do_increment\r\n inc_raw = self.pop\r\n\r\n unless (inc_value = inc_raw.to_foorth_n)\r\n error \"F40: Cannot convert a #{inc_raw.foorth_name} to a Numeric instance\"\r\n end\r\n\r\n if inc_value > 0\r\n inc_value\r\n else\r\n error \"F41: Invalid loop increment value: #{inc_value}\"\r\n end\r\n end",
"def increment(prob_hash, key)\n di = key[0,2]\n freq_arr = prob_hash[di]\n if !freq_arr\n prob_hash[di] = [[key[-1,1], 1]]\n else\n target_letter = key[-1,1]\n freq = freq_arr.assoc(target_letter)\n if !freq then freq_arr << [target_letter, 1] else freq[1] += 1 end\n end\nend",
"def update_counting_hash(hash, key)\n hash[key] ? hash[key] += 1 : hash[key] = 1\n hash\nend",
"def incr(key, window=@max_window)\n key = key.to_s\n now = Time.now.to_f\n @redis.multi do\n @redis.zadd(key, now, SecureRandom.uuid)\n @redis.expire(key, @max_window.ceil)\n do_get(key, now, window)\n end.last\n end",
"def inc(v = 1)\n sync { @v += v }\n end",
"def test_increment_existing_numeric\n @cache.add('Key', '100', 0, Time.now.to_i + 60)\n result = @cache.increment('Key', '1')\n cache = @cache.get('Key').args\n\n assert_true result.success\n assert_equal 'STORED', result.message.chomp.split(\"\\s\")[0]\n assert_equal 101, cache.data\n end",
"def increment(item, amount = 1)\n @items[item] ||= {:value => 0}\n @normalized = false\n @items[item][:value] += amount\n end",
"def set_nr(key, val)\n db.putnr key, val if val\n end",
"def add_item(hash, item, quantity)\n hash[item] = hash[item].to_i + quantity\n hash\nend",
"def set_add(key, value)\n perform_update(:set_add, key, value.to_s)\n end",
"def update_counting_hash(hash, key)\n if hash[key] \n hash[key] += 1\n else\n hash[key] = 1\n end\n hash\nend",
"def increment!\n @value += @increment\n \n self\n end",
"def increment!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be incremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n redis.incr(field_key(name), amount)\n end",
"def add(number)\n if @map.key?(number)\n @map[number] += 1\n else\n @map[number] = 1\n end\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end",
"def increment(transaction, value)\n self.counts[actor][\"txns\"][transaction] = value\n end",
"def increment(n = 1)\n @quantity += n\n end",
"def increment(name, amount = 1, options = nil)\n options ||= {}\n name = expanded_key name\n\n if ttl = options.delete(:expires_in)\n options[:ttl] ||= ttl\n end\n options[:create] = true\n instrument(:increment, name, options) do |payload|\n payload[:amount] = amount if payload\n @data.incr(name, amount, options)\n end\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end",
"def number1=(val)\n self.number('number1','key1',val)\n end",
"def increment(name, amount = 1, options = nil)\n options = merged_options(options)\n instrument(:increment, name, amount: amount) do\n rescue_error_with nil do\n @data.with { |c| c.incr(normalize_key(name, options), amount, options[:expires_in], amount) }\n end\n end\n end",
"def metric_increment(metric_name)\n metric.increment(metric_name)\n end",
"def inc( date ) \n rounded_date = round( date ) \n begin\n @sequence[ rounded_date ] += 1\n rescue NoMethodError # can't add one to nil\n self << rounded_date # sweeps cache\n retry\n else \n @values = nil # sweep cache \n end \n end",
"def increment(name)\n update(name)\n end",
"def key=(value)\n raise TypeError, 'key must respond to #to_i' unless value.respond_to?(:to_i)\n \n @key = value.to_i\n end",
"def increment(node)\n change_by node, 1\n end",
"def increment(metric, value = 1)\n @adapter.increment metric, value\n end",
"def op_increment!(field, amount = 1)\n unless amount.is_a?(Numeric)\n raise ArgumentError, \"Amount should be numeric\"\n end\n operate_field! field, { __op: :Increment, amount: amount.to_i }.freeze\n end",
"def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end",
"def increment(name, amount = 1, expires_in: nil, initial: nil, **options)\n instrument :increment, name, amount: amount do\n failsafe :increment do\n key = normalize_key(name, options)\n res = collection.binary.increment(\n key, ::Couchbase::Options::Increment(delta: amount, expiry: expires_in, initial: initial)\n )\n @last_mutation_token = res.mutation_token\n res.content\n end\n end\n end",
"def increment(field, amount = 1)\n #value = (self[field] || 0) + amount\n #self[field] = value\n #if !@parse_object_id\n # # TODO - warn that the object must be stored first\n # return nil\n #end\n\n body = {field => Parse::Increment.new(amount)}.to_json\n data = Parse.client.request(self.uri, :put, body)\n parse data\n self\n end",
"def increment(value, score=1, session=nil)\n start_kvs_session(session) do |kvs|\n kvs.sorted_sets[key_name(Time.now)].increment(value, score).to_i\n end\n end",
"def add_item(hash, item, qty)\n\n if hash.has_key?(item)\n hash[ item ] += qty\n else\n hash[ item ] = qty\n end\n\nend",
"def float(key, opts={})\n @attrs[key.to_sym] = Attributes::FloatAttr.new(key, opts)\n end",
"def update(hash, item, qty)\n hash[item] = qty\nend",
"def update(hash, item, qty)\n hash[item] = qty\nend",
"def increment(name, amount = 1, options = {})\n instrument :increment, name, amount: amount do\n failsafe :increment do\n options = merged_options(options)\n key = normalize_key(name, options)\n\n with do |c|\n c.incrby(key, amount).tap do\n write_key_expiry(c, key, options)\n end\n end\n end\n end\n end",
"def increment!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be incremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n store.update_count(field_key(name), amount)\n end"
] |
[
"0.89294297",
"0.89294297",
"0.87088376",
"0.8641977",
"0.8132191",
"0.8132191",
"0.7913796",
"0.7734302",
"0.75416577",
"0.75007063",
"0.7265617",
"0.7265617",
"0.71622664",
"0.71622664",
"0.7102625",
"0.70946944",
"0.70680773",
"0.6973783",
"0.6945841",
"0.6931626",
"0.69190174",
"0.6750281",
"0.6738554",
"0.66431427",
"0.6598058",
"0.65256995",
"0.6476931",
"0.6473227",
"0.6444135",
"0.6444135",
"0.6434771",
"0.6434771",
"0.64241636",
"0.6385809",
"0.63832104",
"0.63471687",
"0.6317396",
"0.62961584",
"0.62435746",
"0.62364686",
"0.6219158",
"0.6210612",
"0.6202003",
"0.61432016",
"0.6136517",
"0.6117315",
"0.60757387",
"0.6032182",
"0.6008136",
"0.6004749",
"0.5984308",
"0.5983078",
"0.5975989",
"0.59737396",
"0.59671694",
"0.59461707",
"0.5946087",
"0.59446305",
"0.5941569",
"0.59411985",
"0.5935204",
"0.59290093",
"0.59030914",
"0.58948326",
"0.58534557",
"0.5849657",
"0.5847828",
"0.58284515",
"0.5794074",
"0.5779894",
"0.5766185",
"0.57532215",
"0.57528126",
"0.575269",
"0.57479954",
"0.5740276",
"0.57380384",
"0.57380384",
"0.57316583",
"0.5729063",
"0.57245356",
"0.5720892",
"0.5719338",
"0.57121235",
"0.5710719",
"0.570677",
"0.5700664",
"0.5696322",
"0.56903213",
"0.5689926",
"0.56646836",
"0.56439734",
"0.56398636",
"0.5604045",
"0.5585785",
"0.556616",
"0.5561721",
"0.5561721",
"0.55567914",
"0.5551227"
] |
0.8462094
|
4
|
Set the string value of a key.
|
def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil)
args = [:set, key, value.to_s]
args << "EX" << Integer(ex) if ex
args << "PX" << Integer(px) if px
args << "EXAT" << Integer(exat) if exat
args << "PXAT" << Integer(pxat) if pxat
args << "NX" if nx
args << "XX" if xx
args << "KEEPTTL" if keepttl
args << "GET" if get
if nx || xx
send_command(args, &BoolifySet)
else
send_command(args)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key=(value)\n raise TypeError, 'key must be a String or respond to #to_s' unless value.is_a?(String) || respond_to?(:to_s)\n \n @key = value.to_s\n end",
"def key=(value)\n @key = value.to_s\n end",
"def []=(key, value)\n setValueForKey(key.to_s, value.to_s)\n end",
"def key=(key)\n if (!key.kind_of?(String))\n raise ArgumentError, \"Expected String, but #{key.class} provided.\"\n end\n @key = key\n end",
"def set(key, value=nil)\n @data[key.to_s] = value\n end",
"def set(key, value)\n value = JSON.dump(value) unless value.is_a?(String)\n @hash[key] = value\n end",
"def []=(key,value)\n ruby_set(key&&key.to_s, value)\n end",
"def set(key, value)\n @namehash[key.to_sym][0] = value\n end",
"def set( key, value )\n unless key.is_a?( Key )\n k = UniMap.str_to_key( key )\n unless k\n raise IndexError, \"No Key named #{key.inspect} in UniMap.KEY_SPACE\"\n end\n key = k\n end\n set_k( key, value )\n end",
"def set(key, value)\n end",
"def set(key, value); end",
"def set(key, value); end",
"def set(key, value)\n Lib.set @path, @no_follow, key.to_s, value.to_s\n end",
"def []=(key, value)\n @data[key.to_s]=value\n end",
"def key=(value)\n @key = value.nil? ? nil : value.to_s\n end",
"def []=(key, value)\n\n set_field(key.to_s, value)\n end",
"def set(key, value)\n @value[key.to_sym] = value if key\n end",
"def []=(key, value)\n return nil unless key\n if @data[key.to_s]\n @data[key.to_s] = value\n elsif @data[key.to_sym]\n @data[key.to_sym] = value\n else\n @data[key] = value\n end\n end",
"def []=(key, value)\n @hash[key.to_s] = value\n end",
"def set_value(key, value)\n @store_[key] = value\n YakvdConstants.success\n end",
"def set(key, value)\n self.data ||= {}\n self.data[key.to_s] = value\n self.save!\n end",
"def set(key, value)\n change(:set, key, value)\n end",
"def set_key_value(key, val, options={})\n # metadata = get_key_metadata(key, options)\n key_value = val.nil? ? nil : val.to_s.strip\n self.value[key] = key_value\n key_value\n end",
"def []=(key, value)\n raise TypeError, \"String expected\" unless key.is_a? String\n raise TypeError, \"String or Hash expected\" unless value.is_a? String or value.is_a? Hash\n \n @inihash[key] = value\n end",
"def set(key, value)\n @content[key] = value\n end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def set(key, value)\n peek[key.to_sym] = value\n end",
"def set(key, value)\n response = db.put_item(@table_name, {'id' => {'S' => key}, 'value' => {'S' => value}})\n true\n end",
"def key=(value)\n @key = value\n end",
"def key=(value)\n @key = value\n end",
"def set(key, value)\n settings.send :\"#{key}=\", value\n end",
"def []= key, value\n @hash[key.to_s] = value\n end",
"def set(key, value)\n @content[key] = value\n end",
"def []=(key, value)\n\t\tself.store(key.downcase.strip, value.strip)\n\tend",
"def set( key, value )\n fail NotImplementedError\n end",
"def []=(key_name, value)\n set(key_name, value)\n end",
"def set(key, value)\n update(key) { |option| @data[option.name] = cast(value, option.type) }\n end",
"def set(key, value)\n @store[key] = value\n end",
"def []=(key, value)\n @metadata[key.to_s] = value\n end",
"def []=(key, value)\n @metadata[key.to_s] = value\n end",
"def set_field(key, value)\n @form_fields.setField key.to_s, value.to_s\n end",
"def set(key, value)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def set(key, value)\n case key\n when Symbol\n return instance_variable_set(\"@#{key}\", value)\n when String\n return instance_variable_set(\"@#{key}\", value)\n end\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def set(key, value)\n @metadata[key] = value\n end",
"def set(key, value)\n @json_dict[key] = value\n end",
"def key=(new_key)\n @key = new_key\n end",
"def liner_set(key, value)\n key = key.to_sym\n with_valid_attribute(key) do\n instance_variable_set \"@#{key}\", value\n end\n end",
"def set(key, value)\n raise NotImplementedError\n end",
"def []=( key, value )\n _meta_data[key.to_s] = value\n end",
"def []=(key, value)\n object = @bucket.get_or_new sanitize_key(key)\n object.raw_data = Marshal.dump(value)\n object.content_type = \"application/x-ruby-marshal\"\n object.store\n value\n end",
"def value=(v)\n connection.set(key, v)\n end",
"def set_tag(key, value)\n tags[key] = value.to_s\n self\n end",
"def set_tag(key, value)\n tags[key] = value.to_s\n self\n end",
"def key=(value); end",
"def []= key, value\n super(key.to_s, value)\n end",
"def put(key, value)\n \n end",
"def update(key, value)\n set(key.to_sym => value)\n end",
"def key=(value)\n attributes['key'] = value\n end",
"def getset(key, value)\n send_command([:getset, key, value.to_s])\n end",
"def set(key, value)\n @content[key] = ActiveSupport::SafeBuffer.new(value.to_s)\n end",
"def []=(key, value)\n @data[key.to_sym] = convert value\n end",
"def set(key, value, **options); end",
"def []=( key, value )\n context.store(key.to_s, value)\n end",
"def value=(new_value)\n key_escaped = Object.escape_key(@key)\n\n response = @s3.request_put(\"/#{@bucket.name}/\" +\n \"#{key_escaped}\", new_value)\n @s3.error?(response)\n \n return new_value\n end",
"def set(key, value)\n return nil if not key\n\n key = key.to_sym if key.class == String\n section = ForjDefault.get_meta_section(key)\n\n return @oConfig.set(key, value) if not section\n return nil if readonly?(key)\n _set(section, key, value)\n end",
"def []=(key, value)\n key = key.to_s if key.is_a? Symbol\n self.old_store(key, value)\n end",
"def set(key, value)\n messages[key] = value\n end",
"def []=(key, value)\n @_hash[key.to_sym] = value\n end",
"def set(key, value)\n @manager.store(key, value)\n { key => value }\n end",
"def []=(key, value)\n @adapter[key.to_s] = value\n end",
"def set_field(key, value)\n\n Ruote.set(h.fields, key, value)\n end",
"def set_KeyValue(value)\n set_input(\"KeyValue\", value)\n end",
"def get_and_set(key, value); end",
"def write(key, value)\n perform_update(:write, key, value.to_s)\n end",
"def set_k( key, value )\n HTMapHelper.set_map( self, key, value )\n end",
"def []=(key, value)\n self.put(key, value)\n end",
"def set k,v\n key = k.to_s.to_sym\n v = (v.is_a?(ASObj) ? v.finish : v) unless v == nil\n @_[key] = v unless v == nil\n @_.delete key if v == nil\n end",
"def set(key, value)\n messages[key] = value\n end",
"def set(key, value)\n messages[key] = value\n end",
"def []=( key, val )\n\t\t@form[ key.to_s ] = val\n\tend",
"def set(key, value)\n mon_synchronize do\n perform [\"set\", key, value], proc: T_BOOL\n end\n end",
"def []=( key, value )\n raise \"key must be a Symbol or String\" unless key.is_a?( Symbol ) || key.is_a?( String )\n\n self.of(@section).store( key, value)\n self.save if @instant_save\n value\n end",
"def []=(key, value)\n self.attributes[key.to_sym] = value\n save\n value\n end",
"def set_value(key, value)\n database[key] = value\n removed_keys.delete(key)\n end",
"def field_set!(key, value)\n send \"_#{key}_set\", value\n end",
"def []=(key, value)\n set(key, value)\n end",
"def set_property(key, value)\n end",
"def put(key, value); end",
"def []=(key, value)\n regular_writer(convert_key(key), convert_value(value))\n end",
"def set(key, value)\n @variables[key.to_sym] = value\n end",
"def []=(key, value)\n set(key, :val => value)\n end",
"def write_attribute(key, value)\n @hash[key.to_s] = value\n end",
"def []=(key, value=nil) \n\n # If we are assigning something to nil, let's remove it\n if value.nil?\n delete(key)\n sleep @key_sleep.to_f\n nil\n else\n\t persistent = (value[:persistent].nil? ? 0 : (value[:persistent] ? 1 : 0))\n\t \n Klass.addKey(@handle, key.to_s, value[:value].to_s, persistent)\n sleep @key_sleep.to_f\n value[:value].to_s\n end\n end",
"def []=(key, value)\n key = namespaced_key(key)\n @keys << key\n set(key, value)\n end",
"def []=(key, value)\n put(key, value)\n end",
"def []=(key, value)\n super(convert(key), value)\n end",
"def []=(key, val)\n self.setObject(val, forKey: key.to_s)\n self.synchronize\n end",
"def set(k, v)\n settings[k.to_sym] = v\n end"
] |
[
"0.83226436",
"0.77962935",
"0.77581835",
"0.7731623",
"0.76726204",
"0.7500018",
"0.7454675",
"0.74425685",
"0.7367446",
"0.7357871",
"0.7342931",
"0.7342931",
"0.73147106",
"0.7252742",
"0.7252604",
"0.7227737",
"0.7189322",
"0.71102804",
"0.70913905",
"0.7074253",
"0.7068562",
"0.7065319",
"0.70423526",
"0.6928404",
"0.69095623",
"0.6900722",
"0.6891507",
"0.688924",
"0.6889201",
"0.6889201",
"0.68757564",
"0.6871653",
"0.68710583",
"0.68588585",
"0.68238527",
"0.6816605",
"0.68037885",
"0.6777856",
"0.674961",
"0.674961",
"0.6748931",
"0.6736883",
"0.67195463",
"0.6680119",
"0.6680119",
"0.66785276",
"0.6673026",
"0.66581786",
"0.66301024",
"0.6629582",
"0.66271305",
"0.6610294",
"0.6604261",
"0.65923095",
"0.65809643",
"0.65809643",
"0.6557063",
"0.6555415",
"0.6550945",
"0.65475804",
"0.6544557",
"0.65422446",
"0.654162",
"0.6539297",
"0.65181947",
"0.65171504",
"0.6511344",
"0.6507909",
"0.6507757",
"0.65066075",
"0.6496878",
"0.64918846",
"0.64742917",
"0.6473793",
"0.6459847",
"0.6449266",
"0.64438146",
"0.6443288",
"0.64429945",
"0.64375335",
"0.64359665",
"0.64359665",
"0.6434464",
"0.6433635",
"0.6417411",
"0.64071083",
"0.6407063",
"0.6405406",
"0.6401621",
"0.64000636",
"0.6383567",
"0.6373748",
"0.63644785",
"0.63637656",
"0.636347",
"0.63582987",
"0.63575387",
"0.63519007",
"0.6349885",
"0.63457537",
"0.63342994"
] |
0.0
|
-1
|
Set the time to live in seconds of a key.
|
def setex(key, ttl, value)
send_command([:setex, key, Integer(ttl), value.to_s])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_timer(key, time)\n transaction.timers[key] = time\n end",
"def expire(key, seconds, **kwargs); end",
"def ttl=(seconds)\n self.shared_max_age = age + seconds\n end",
"def expire(key, seconds)\n # no-op\n end",
"def []=(key, value)\n v = TimedObject.new(value, Time.now + timeout)\n @store[key] = v\n end",
"def set(key, value, options = {})\n time = options[:time] || timeout\n \n # we can technically do away with checking against Integer explicitly since\n # the to_int call will take care of it for us through Integer#to_int returning\n # self, but it's here for the sake of clarity, mostly.\n #\n # on the other hand, the #to_time call is necessary, since, for some reason,\n # Time#to_time only exists if you require \"time\".\n time = case time\n when Integer\n Time.now + time\n when Time\n time\n else\n if time.respond_to?(:to_int)\n Time.now + time.to_int\n elsif time.respond_to?(:to_time)\n time.to_time\n end\n end\n \n raise(ArgumentError, \"time argument #{time.inspect} could not be converted to a time\") if time.nil?\n \n return nil if time <= Time.now\n \n v = TimedObject.new(value, time)\n @store[key] = v\n \n value\n end",
"def ttl(key); end",
"def ttl(key); end",
"def ttl_in_seconds= value\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def touch(key, exptime)\n set(key, :exptime => exptime)\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def expire_time(key)\n @store[key].expires_at\n end",
"def set(key, value, expires_in = 0)\n\n end",
"def clear_now(key)\n now = Time.now.public_send(_kind)\n set(key, now, nil)\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def set(key, value, ttl = 0)\n stats[:set] += 1\n handler.set key, value, ttl\n end",
"def ttl(key)\n send_command([:ttl, key])\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def expire(key, seconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def expireat(key, unix_time, **kwargs); end",
"def setex(key, ttl, value); end",
"def setex(key, ttl, value); end",
"def pexpire(key, milliseconds, **kwarg); end",
"def mark_start_time key\n @start_time[key] = Time.now\n end",
"def tag_time_to_live_in_seconds=(value)\n @tag_time_to_live_in_seconds = value\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration if ttl_in_seconds\n ttl_in_seconds\n end",
"def set(key, value, timestamp)\n \n end",
"def expire(key, seconds, **kwargs)\n node_for(key).expire(key, seconds, **kwargs)\n end",
"def []=(key, value)\n value = [ Time.now, value ]\n super\n end",
"def pexpireat(key, ms_unix_time, **kwarg); end",
"def expire(key, seconds)\n call(key, [:expire, key, seconds], transform: Redis::Boolify)\n end",
"def set(key, value, ttl: ShopifyClient.config.cache_ttl)\n raise NotImplementedError\n end",
"def expires_at=(time)\n self.expiry_option = :on\n self[:expires_at] = time\n end",
"def time=(new_time)\n @time = new_time\n end",
"def time_to_live=(new_time_to_live)\n @time_to_live = new_time_to_live.round\n @time_to_live = 30.minutes if @time_to_live < 30.minutes\n end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def ttl(key)\n key = add_namespace(key)\n @redis.ttl(key)\n end",
"def ttl(key)\n call(key, [:ttl, key], read: true)\n end",
"def keep_alive_key(key)\n return false unless @keys.key? key\n @mutex.synchronize do\n @keys[key][:st] = Time.now.to_i\n puts \"Keep Alive called for Key: #{key}\"\n end\n true\n end",
"def value=(v)\n # AKK: 0 is no TTL\n connection.set(key, v, 0, false)\n end",
"def autoexpire\n redis.expire(key, timespan)\n end",
"def expire=(_); end",
"def expiry(t)\n Time.now.to_i + t\n end",
"def setex(key, ttl, value)\n node_for(key).setex(key, ttl, value)\n end",
"def expire(key)\n true\n end",
"def client_ttl=(seconds)\n self.max_age = age + seconds\n end",
"def add_pair_with_expire(key, value, expire_time)\r\n @redis.set(key, value)\r\n @redis.expire(key, expire_time) \r\n end",
"def psetex(key, ttl, value); end",
"def psetex(key, ttl, value); end",
"def refresh_expiry\n self.expires_at = Time.now + ttl\n end",
"def pexpire(key, milliseconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def setTime(time)\n\t\t@time = time\n\tend",
"def put(key, value, lifetime: 2**32)\n synchronized do\n @hash[key] = {\n value: value,\n start: Time.now,\n lifetime: lifetime\n }\n end\n end",
"def seconds=(new_seconds)\n\t\t@seconds = new_seconds\n\tend",
"def extend(time)\n self.expires_on += time\n self\n end",
"def expire\n update_attribute :expires_at, 1.minute.ago\n end",
"def lazy_sec=(newsec)\n newsec = newsec.to_i\n \n if newsec > 60 or newsec < 0\n mins = (newsec.to_f / 60.0).floor\n newsec -= (mins * 60)\n self.add_mins(mins)\n end\n \n @t_sec = newsec\n end",
"def initialize(key, expiration_time = 10.minutes)\n @key = key\n @expiration_time = expiration_time\n end",
"def set(key, value, expires_in = 0)\n remove(key)\n expires = nil\n if expires_in > 0\n expires = Time.now.utc + expires_in\n end\n @store.push({ key: build_key(key), value: value, expires: expires})\n end",
"def setTime\n\t\t\t@time=0\n\tend",
"def expire!\n\t\tself.expires = Time.at(0)\n\tend",
"def expires_in\n Gitlab::Redis::SharedState.with do |redis|\n redis.ttl(key)\n end\n end",
"def expire!\n self.last_retrieved = Time.mktime(1970).gmtime\n self.save\n end",
"def expires_at=(value)\n self[:expires_at] = value\n end",
"def time=(value)\n @time = value\n end",
"def sec=(newsec)\n newsec = newsec.to_i\n raise ArgumentError, \"Invalid second: '#{newsec}'.\" if newsec < 0 or newsec > 60\n @t_sec = newsec.to_i\n end",
"def delay_time=(seconds)\n end",
"def cache_set(key, data, from_now = nil)\n true\n end",
"def tag_time_to_live_in_seconds\n @tag_time_to_live_in_seconds ||= 60\n end",
"def update!(**args)\n @expire_time = args[:expire_time] if args.key?(:expire_time)\n @ttl = args[:ttl] if args.key?(:ttl)\n end",
"def expireat(key, unix_time, **kwargs)\n node_for(key).expireat(key, unix_time, **kwargs)\n end",
"def set(event, time)\n key[:schedule].zadd time.to_f, event\n end",
"def ttl(key)\n node_for(key).ttl(key)\n end",
"def set(key, value, expires_in = DEFAULT_TTL)\n k = build_key(key)\n\n v = if value.nil? || (value.is_a?(String) && value.strip.empty?)\n nil\n else\n serialize(value)\n end\n\n expiry_int = Integer(expires_in)\n expire_value = expiry_int.positive? ? expiry_int : Integer(DEFAULT_TTL)\n\n with_client do |client|\n client.multi do\n client.set(k, v)\n\n client.expire(k, expire_value)\n end\n end\n end",
"def expireat(key, unix_time, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def ttl\n Goalkeeper.redis.ttl(key)\n end",
"def change_time(hike_instance)\n system 'clear'\n puts \"-----MY HIKES-----\"\n hours = @prompt.ask(\"Enter time in hours: \", required: true, convert: :int) {|input| input.in('0-24')}\n minutes = 61\n while minutes > 60 || minutes < 0\n minutes = @prompt.ask(\"Enter time in minutes: \", required: true, convert: :int) {|input| input.in('0-60')}\n end\n hike_instance.time_hiked = (hours * 3600) + (minutes * 60)\n hike_instance.save\n puts \"New time saved.\"\n @prompt.keypress(\"Press any key to continue\")\n end",
"def simulate_expire; end",
"def set_data(key, value, expire_at: nil)\n key = key.to_sym\n ts = expire_at ? expire_at.to_i : nil\n\n (@data[key] = [value, ts]).first\n end",
"def update_generate(\n key,\n seconds = @options[:seconds],\n length = @options[:length],\n charpool = @options[:charpool],\n excluded = @options[:exclude]\n )\n get(key, seconds) if update(key, generator(length, charpool, excluded))\n end",
"def watch=(seconds)\n @watch = seconds.to_i\n end",
"def expires_in=(duration)\n self.expires_at = duration.from_now\n end",
"def replace(key, value, ttl=nil, options=nil)\n set(key, value, ttl, options) if @store.has_key?(key)\n end",
"def ttl(key)\n pttl = @redis.pttl(\"SimpleRedisLock:#{key}\")\n return nil if pttl == -2\n\n pttl.to_f / 1000\n end",
"def expires_in(seconds, options = T.unsafe(nil)); end",
"def ttl_duration\n 900\n end",
"def cache_set(key, data, from_now = nil)\n _expire = from_now ? from_now.minutes.from_now : nil\n cache_write(key, [data, _expire])\n Merb.logger.info(\"cache: set (#{key})\")\n true\n end",
"def set(key, value, expiry_time = nil)\n do_with_logging(:set, key) do\n retryable do\n self.adapter.set(key, adapter.marshal(value), calculate_expiry_time(expiry_time))\n end\n end\n end",
"def update_activity_time\n session[:expires_at] = 15.minutes.from_now\n end",
"def psetex(key, ttl, value)\n send_command([:psetex, key, Integer(ttl), value.to_s])\n end",
"def touch(key, ttl = nil)\n resp = perform(:touch, key, ttl_or_default(ttl))\n resp.nil? ? nil : true\n end",
"def update_kase_expires_at\n if self.kase && self.kase.expires_at.nil? && self.expires_at && !self.has_expired?\n self.kase.class.transaction do \n self.kase.lock!\n self.kase.update_attribute(:expires_at, self.expires_at) if self.kase.expires_at.nil?\n end\n end\n end",
"def time=(value)\n @values['time'] = value\n end",
"def refresh_time\n self.update_column( :expires, Time.zone.now + TOKEN_LIFE )\n end",
"def cache_set(key, data, from_now = nil)\n _expire = from_now ? from_now.minutes.from_now.to_i : 0\n @memcache.set(key, data, _expire)\n cache_start_tracking(key)\n Merb.logger.info(\"cache: set (#{key})\")\n true\n end",
"def pexpire(key, milliseconds)\n call(key, [:pexpire, key, milliseconds], transform: Redis::Boolify)\n end",
"def put(key, value, timeout = @default_timeout)\n @store.synchronize do\n @store.put(key, value, timeout) unless value.nil?\n end\n end",
"def expire_cache(key)\n end"
] |
[
"0.7033809",
"0.6994046",
"0.6849151",
"0.68432796",
"0.68292415",
"0.6708266",
"0.6637561",
"0.6637561",
"0.66218823",
"0.66203856",
"0.66160643",
"0.66160643",
"0.66160643",
"0.65959114",
"0.6570283",
"0.6565751",
"0.65489846",
"0.6545847",
"0.65303",
"0.6516957",
"0.6505246",
"0.6495766",
"0.64943063",
"0.64943063",
"0.6473886",
"0.644208",
"0.63994133",
"0.63647175",
"0.6331961",
"0.62831277",
"0.62804145",
"0.61711174",
"0.61659855",
"0.6159525",
"0.6150033",
"0.6143429",
"0.6131532",
"0.61257845",
"0.6124818",
"0.612452",
"0.6111017",
"0.605732",
"0.6033585",
"0.6024755",
"0.60234857",
"0.6021711",
"0.6007265",
"0.59874135",
"0.5967089",
"0.5955501",
"0.5955501",
"0.59519523",
"0.5940731",
"0.5932253",
"0.59276915",
"0.59201115",
"0.589773",
"0.58931637",
"0.5884237",
"0.58837914",
"0.58583146",
"0.5847171",
"0.58382744",
"0.5830296",
"0.58142924",
"0.58105314",
"0.57943094",
"0.5793646",
"0.57903594",
"0.5786845",
"0.57849",
"0.57817215",
"0.57764256",
"0.5774274",
"0.5773684",
"0.5766064",
"0.5740683",
"0.57356805",
"0.57356447",
"0.572132",
"0.5720031",
"0.57099986",
"0.57066494",
"0.5703236",
"0.5700517",
"0.56890154",
"0.56815726",
"0.56655264",
"0.5664152",
"0.5653265",
"0.56532264",
"0.56485903",
"0.56403214",
"0.5636838",
"0.56270415",
"0.56232136",
"0.5617957",
"0.5616923",
"0.56161386",
"0.5608562"
] |
0.60496616
|
42
|
Set the time to live in milliseconds of a key.
|
def psetex(key, ttl, value)
send_command([:psetex, key, Integer(ttl), value.to_s])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_timer(key, time)\n transaction.timers[key] = time\n end",
"def []=(key, value)\n v = TimedObject.new(value, Time.now + timeout)\n @store[key] = v\n end",
"def set(key, value, options = {})\n time = options[:time] || timeout\n \n # we can technically do away with checking against Integer explicitly since\n # the to_int call will take care of it for us through Integer#to_int returning\n # self, but it's here for the sake of clarity, mostly.\n #\n # on the other hand, the #to_time call is necessary, since, for some reason,\n # Time#to_time only exists if you require \"time\".\n time = case time\n when Integer\n Time.now + time\n when Time\n time\n else\n if time.respond_to?(:to_int)\n Time.now + time.to_int\n elsif time.respond_to?(:to_time)\n time.to_time\n end\n end\n \n raise(ArgumentError, \"time argument #{time.inspect} could not be converted to a time\") if time.nil?\n \n return nil if time <= Time.now\n \n v = TimedObject.new(value, time)\n @store[key] = v\n \n value\n end",
"def pexpire(key, milliseconds, **kwarg); end",
"def mark_start_time key\n @start_time[key] = Time.now\n end",
"def expire_time(key)\n @store[key].expires_at\n end",
"def set(key, value, timestamp)\n \n end",
"def pexpire(key, milliseconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def clear_now(key)\n now = Time.now.public_send(_kind)\n set(key, now, nil)\n end",
"def touch(key, exptime)\n set(key, :exptime => exptime)\n end",
"def set(key, value, expires_in = 0)\n\n end",
"def expireat(key, unix_time, **kwargs); end",
"def pexpireat(key, ms_unix_time, **kwarg); end",
"def expire(key, seconds, **kwargs); end",
"def expire(key, seconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def set(key, value, ttl = 0)\n stats[:set] += 1\n handler.set key, value, ttl\n end",
"def setex(key, ttl, value); end",
"def setex(key, ttl, value); end",
"def ttl(key); end",
"def ttl(key); end",
"def []=(key, value)\n value = [ Time.now, value ]\n super\n end",
"def ttl(key)\n send_command([:ttl, key])\n end",
"def expire(key, seconds)\n # no-op\n end",
"def time=(new_time)\n @time = new_time\n end",
"def cache_set(key, data, from_now = nil)\n true\n end",
"def autoexpire\n redis.expire(key, timespan)\n end",
"def pexpireat(key, ms_unix_time, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def pexpire(key, milliseconds)\n call(key, [:pexpire, key, milliseconds], transform: Redis::Boolify)\n end",
"def cache_set(key, data, from_now = nil)\n _expire = from_now ? from_now.minutes.from_now.to_i : 0\n @memcache.set(key, data, _expire)\n cache_start_tracking(key)\n Merb.logger.info(\"cache: set (#{key})\")\n true\n end",
"def time_upd(hash = nil)\n self[:time] = (hash.time if hash.is_a?(Upd)) || now_msec\n verbose { ___time_text(hash ? 'Updated' : 'Generated') }\n self\n end",
"def setTime(time)\n\t\t@time = time\n\tend",
"def expireat(key, unix_time, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def set(key, value, mtime)\n @cache[key] = {\n value: value,\n mtime: mtime\n }\n end",
"def ttl=(seconds)\n self.shared_max_age = age + seconds\n end",
"def cache_set(key, data, from_now = nil)\n _expire = from_now ? from_now.minutes.from_now : nil\n cache_write(key, [data, _expire])\n Merb.logger.info(\"cache: set (#{key})\")\n true\n end",
"def expires_at=(time)\n self.expiry_option = :on\n self[:expires_at] = time\n end",
"def set(event, time)\n key[:schedule].zadd time.to_f, event\n end",
"def ttl_in_seconds= value\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def put(key, value, lifetime: 2**32)\n synchronized do\n @hash[key] = {\n value: value,\n start: Time.now,\n lifetime: lifetime\n }\n end\n end",
"def add_pair_with_expire(key, value, expire_time)\r\n @redis.set(key, value)\r\n @redis.expire(key, expire_time) \r\n end",
"def value=(v)\n # AKK: 0 is no TTL\n connection.set(key, v, 0, false)\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def initialize(key, expiration_time = 10.minutes)\n @key = key\n @expiration_time = expiration_time\n end",
"def expire=(_); end",
"def expireat(key, unix_time, **kwargs)\n node_for(key).expireat(key, unix_time, **kwargs)\n end",
"def set(key, value, expires_in = 0)\n remove(key)\n expires = nil\n if expires_in > 0\n expires = Time.now.utc + expires_in\n end\n @store.push({ key: build_key(key), value: value, expires: expires})\n end",
"def keep_alive_key(key)\n return false unless @keys.key? key\n @mutex.synchronize do\n @keys[key][:st] = Time.now.to_i\n puts \"Keep Alive called for Key: #{key}\"\n end\n true\n end",
"def expire(key)\n true\n end",
"def pexpire(key, milliseconds, **kwarg)\n node_for(key).pexpire(key, milliseconds, **kwarg)\n end",
"def set(key, value, ttl: ShopifyClient.config.cache_ttl)\n raise NotImplementedError\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def extend(time)\n self.expires_on += time\n self\n end",
"def setex(key, ttl, value)\n send_command([:setex, key, Integer(ttl), value.to_s])\n end",
"def setex(key, ttl, value)\n node_for(key).setex(key, ttl, value)\n end",
"def time=(value)\n @time = value\n end",
"def ttl(key)\n key = add_namespace(key)\n @redis.ttl(key)\n end",
"def set(key, value, expiry_time = nil)\n do_with_logging(:set, key) do\n retryable do\n self.adapter.set(key, adapter.marshal(value), calculate_expiry_time(expiry_time))\n end\n end\n end",
"def simulate_expire; end",
"def set_data(key, value, expire_at: nil)\n key = key.to_sym\n ts = expire_at ? expire_at.to_i : nil\n\n (@data[key] = [value, ts]).first\n end",
"def expire!\n self.last_retrieved = Time.mktime(1970).gmtime\n self.save\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def setTime\n\t\t\t@time=0\n\tend",
"def set_clocks(mtime=1)\n @m = mtime\n @t = 4*mtime\n nil\n end",
"def time=(value)\n @values['time'] = value\n end",
"def time_to_live=(new_time_to_live)\n @time_to_live = new_time_to_live.round\n @time_to_live = 30.minutes if @time_to_live < 30.minutes\n end",
"def psetex(key, ttl, value); end",
"def psetex(key, ttl, value); end",
"def set(time)\n reset\n @offset = now - time\n end",
"def set_time(time)\n @time = time.getutc\n return self\n end",
"def delay_time=(seconds)\n end",
"def expire(key, seconds, **kwargs)\n node_for(key).expire(key, seconds, **kwargs)\n end",
"def expiry(t)\n Time.now.to_i + t\n end",
"def set(key, value, expiry = adapter.configuration.retrieve(:default_expiry, 0))\n do_with_logging(:set, key) do\n expiry = calculate_expiry_time(expiry)\n adapter.set(key.to_s, marshall(value), expiry.to_i)\n logger.info('', '', :expiry, cache_name, key, expiry.to_i)\n value\n end\n end",
"def expires_at=(value)\n self[:expires_at] = value\n end",
"def pexpireat(key, ms_unix_time, **kwarg)\n node_for(key).pexpireat(key, ms_unix_time, **kwarg)\n end",
"def put(key, value, timeout = @default_timeout)\n @store.synchronize do\n @store.put(key, value, timeout) unless value.nil?\n end\n end",
"def append(key, time)\n Sidekiq.redis do |conn|\n conn.lpush(namespace_key(key), time.to_i)\n end\n end",
"def set(key, value, expires_in = DEFAULT_TTL)\n k = build_key(key)\n\n v = if value.nil? || (value.is_a?(String) && value.strip.empty?)\n nil\n else\n serialize(value)\n end\n\n expiry_int = Integer(expires_in)\n expire_value = expiry_int.positive? ? expiry_int : Integer(DEFAULT_TTL)\n\n with_client do |client|\n client.multi do\n client.set(k, v)\n\n client.expire(k, expire_value)\n end\n end\n end",
"def refresh_expiry\n self.expires_at = Time.now + ttl\n end",
"def set(value)\n @value = value\n time = Time.now\n @timestamp = time.to_i\n @timestamp_nsec = time.nsec\n @timestamp_tiebreaker = @tiebreaker\n end",
"def cache_set(key, data, from_now = nil)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n cache_directory = File.dirname(cache_file)\n FileUtils.mkdir_p(cache_directory)\n _expire = from_now ? from_now.minutes.from_now : nil\n cache_write(cache_file, Marshal.dump([data, _expire]))\n Merb.logger.info(\"cache: set (#{key})\")\n true\n end",
"def expire\n update_attribute :expires_at, 1.minute.ago\n end",
"def ttl(key)\n call(key, [:ttl, key], read: true)\n end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration if ttl_in_seconds\n ttl_in_seconds\n end",
"def utime=(*) end",
"def expire!\n\t\tself.expires = Time.at(0)\n\tend",
"def update_generate(\n key,\n seconds = @options[:seconds],\n length = @options[:length],\n charpool = @options[:charpool],\n excluded = @options[:exclude]\n )\n get(key, seconds) if update(key, generator(length, charpool, excluded))\n end",
"def expire_cache(key)\n end",
"def set_expire\n tag[id].setex timeout, id\n tag[:pull_list][id].expire timeout\n end",
"def update!(**args)\n @expire_time = args[:expire_time] if args.key?(:expire_time)\n @ttl = args[:ttl] if args.key?(:ttl)\n end",
"def time_s=(time)\n self.time = s_to_time(time)\n end",
"def refresh_time\n self.update_column( :expires, Time.zone.now + TOKEN_LIFE )\n end",
"def change_time(hike_instance)\n system 'clear'\n puts \"-----MY HIKES-----\"\n hours = @prompt.ask(\"Enter time in hours: \", required: true, convert: :int) {|input| input.in('0-24')}\n minutes = 61\n while minutes > 60 || minutes < 0\n minutes = @prompt.ask(\"Enter time in minutes: \", required: true, convert: :int) {|input| input.in('0-60')}\n end\n hike_instance.time_hiked = (hours * 3600) + (minutes * 60)\n hike_instance.save\n puts \"New time saved.\"\n @prompt.keypress(\"Press any key to continue\")\n end",
"def mtime(key)\n rec = @hash[key]\n rec.nil? ? Time.now : rec[:start]\n end",
"def set_Time(value)\n set_input(\"Time\", value)\n end",
"def set(key, flags, expiration, length, data)\n storage[key] = {\n expiration: expiration,\n flags: flags,\n value: data\n }\n\n 'STORED'\n end",
"def expires_in\n Gitlab::Redis::SharedState.with do |redis|\n redis.ttl(key)\n end\n end",
"def set(key, value = nil, lifetime = nil)\n\t\t\tlifetime = Picombo::Config.get('cache.'+@@group+'.lifetime').to_i if lifetime == nil\n\t\t\tunless key.is_a? Hash\n\t\t\t\tkey = {key => value}\n\t\t\tend\n\n\t\t\t@@driver.set(key, lifetime)\n\t\tend"
] |
[
"0.7197187",
"0.70529664",
"0.70327383",
"0.68871564",
"0.675136",
"0.67206305",
"0.67123795",
"0.666408",
"0.66620487",
"0.6641866",
"0.6570745",
"0.65438426",
"0.6517914",
"0.65075564",
"0.65042424",
"0.6491647",
"0.6453056",
"0.6453056",
"0.6443655",
"0.6443655",
"0.6379153",
"0.622502",
"0.6204145",
"0.61933726",
"0.61858207",
"0.6135869",
"0.6124011",
"0.6119798",
"0.61082906",
"0.6099096",
"0.6090095",
"0.6087996",
"0.60848945",
"0.6077226",
"0.6069227",
"0.6060895",
"0.6052471",
"0.6036085",
"0.60172486",
"0.6003138",
"0.6000344",
"0.5997716",
"0.59822094",
"0.59822094",
"0.59822094",
"0.5951328",
"0.5943219",
"0.5941817",
"0.5936556",
"0.5924919",
"0.59211177",
"0.5913492",
"0.59042084",
"0.58940554",
"0.5886447",
"0.58818144",
"0.5867736",
"0.58617735",
"0.5856553",
"0.58480406",
"0.58456385",
"0.58370554",
"0.5828946",
"0.5828388",
"0.5821913",
"0.58150023",
"0.5812526",
"0.57967633",
"0.5795066",
"0.5795066",
"0.57908756",
"0.57654667",
"0.5761453",
"0.57578725",
"0.57576835",
"0.57553643",
"0.5753815",
"0.5752885",
"0.57439125",
"0.5742743",
"0.5732399",
"0.5729912",
"0.5724204",
"0.57223886",
"0.5695884",
"0.56922895",
"0.5683864",
"0.5675969",
"0.5672026",
"0.5668909",
"0.5655285",
"0.56533223",
"0.56410617",
"0.5640143",
"0.5629407",
"0.5627374",
"0.562082",
"0.56151825",
"0.56043655",
"0.5596848",
"0.5590802"
] |
0.0
|
-1
|
Set the value of a key, only if the key does not exist.
|
def setnx(key, value)
send_command([:setnx, key, value.to_s], &Boolify)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set(key, value=nil)\n @data[key.to_s] = value\n end",
"def set_default key, value\n return false if has_key?(key)\n self[key] = value\n end",
"def put(key, value)\n #if key exists\n if a_hash[key] != nil\n a_hash[key] = value\n end\n end",
"def set( key, value )\n fail NotImplementedError\n end",
"def set(key, value); end",
"def set(key, value); end",
"def set(key, value)\n end",
"def set_value(key, value)\n database[key] = value\n removed_keys.delete(key)\n end",
"def set(key, val)\n return unless val\n db[key] = val\n end",
"def set( key, value )\n unless key.is_a?( Key )\n k = UniMap.str_to_key( key )\n unless k\n raise IndexError, \"No Key named #{key.inspect} in UniMap.KEY_SPACE\"\n end\n key = k\n end\n set_k( key, value )\n end",
"def []=(key, value=nil) \n\n # If we are assigning something to nil, let's remove it\n if value.nil?\n delete(key)\n sleep @key_sleep.to_f\n nil\n else\n\t persistent = (value[:persistent].nil? ? 0 : (value[:persistent] ? 1 : 0))\n\t \n Klass.addKey(@handle, key.to_s, value[:value].to_s, persistent)\n sleep @key_sleep.to_f\n value[:value].to_s\n end\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def set(key, value)\n mon_synchronize do\n perform [\"set\", key, value], proc: T_BOOL\n end\n end",
"def update(key, value)\n if @hash.has_key?(key)\n @hash.set(key, value)\n else\n raise ArgumentError, \"Cannot update nonexistent key: #{key}\"\n end\n end",
"def set_unless_exists(key, val)\n val = redis_marshal(val)\n timeout_retry(3, 3){\n write \"SETNX #{key} #{val.to_s.size}\\r\\n#{val}\\r\\n\"\n integer_reply == 1\n }\n end",
"def store_value_simply key, value\n @@key_value_storage[key] ||= value if key\n end",
"def set(key, value)\n @value[key.to_sym] = value if key\n end",
"def set(key, value)\n Lib.set @path, @no_follow, key.to_s, value.to_s\n end",
"def set(key, value)\n raise NotImplementedError\n end",
"def set(key, value)\n peek[key.to_sym] = value\n end",
"def ensure_value_exists!(k)\n @values[k] = nil unless @values.has_key?(k)\n end",
"def set k,v\n key = k.to_s.to_sym\n v = (v.is_a?(ASObj) ? v.finish : v) unless v == nil\n @_[key] = v unless v == nil\n @_.delete key if v == nil\n end",
"def set(key, value)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def set_value(key, value)\n @store_[key] = value\n YakvdConstants.success\n end",
"def set(key, value)\n response = db.put_item(@table_name, {'id' => {'S' => key}, 'value' => {'S' => value}})\n true\n end",
"def set(key, value)\n mon_synchronize do\n perform [\"set\", key, value], :proc => T_BOOL\n end\n end",
"def set(key, value)\n\t\t\t\t# TODO This could be a bit more efficient:\n\t\t\t\tself.delete(key)\n\t\t\t\tself.add(key, value)\n\t\t\tend",
"def set(key, value)\n self.data ||= {}\n self.data[key.to_s] = value\n self.save!\n end",
"def set(key, value)\n return nil if not key\n\n key = key.to_sym if key.class == String\n section = ForjDefault.get_meta_section(key)\n\n return @oConfig.set(key, value) if not section\n return nil if readonly?(key)\n _set(section, key, value)\n end",
"def set(key, value)\n change(:set, key, value)\n end",
"def []=(key, value)\n if RUBY_ENGINE == 'opal'\n @hash[key] = value\n else\n @mutex.synchronize { @hash[key] = value }\n end\n end",
"def key=(value)\n @key = value.nil? ? nil : value.to_s\n end",
"def []=(key, value)\n if RUBY_ENGINE == 'opal'\n @hash[key] = value\n else\n @mutex.synchronize { @hash[key] = value }\n end\n end",
"def set_if_nil(hash, key)\n hash[key] = true if hash[key].nil?\n end",
"def set k,v\n key = k.to_s.to_sym\n v = (v.is_a?(JrdObj) ? v.finish : v) unless v == nil\n @_[key] = v unless v == nil\n @_.delete key if v == nil\n end",
"def []=(_key, _value)\n false\n end",
"def set(key, value = nil, options = nil)\n @hash[key] = value\n end",
"def set(key, value)\n @namehash[key.to_sym][0] = value\n end",
"def put(key, value)\n obj = KeyValue.find_by_key(key)\n if obj\n KeyValue.update(obj.id, :value=>value)\n else\n KeyValue.create(:key=>key, :value=>value)\n end\n end",
"def put(key, value); end",
"def put(key, value=nil)\n\n stash_put(fei, key, value)\n end",
"def set(key, value)\n @store[key] = value\n end",
"def []=(key, value)\n return super if has_key?(key)\n alt = alternate_key(key)\n has_key?(alt) ? super(alt, value) : super\n end",
"def set_key_value(key, val, options={})\n # metadata = get_key_metadata(key, options)\n key_value = val.nil? ? nil : val.to_s.strip\n self.value[key] = key_value\n key_value\n end",
"def set(key, value)\n @map[key] = value\n end",
"def []=(key, value)\n put(key, value, :replace => true)\n end",
"def get_and_set(key, value); end",
"def []=(key,value)\n ruby_set(key&&key.to_s, value)\n end",
"def put(key, value)\n \n end",
"def set(key, value)\n updated = false\n if self.map_var[0].empty?\n self.map_var[0] = [key, value]\n updated = true\n else \n self.map_var.each do |pair| \n if pair[0] == key \n pair[1] = value \n updated = true\n end\n end \n end\n self.map_var << [key, value] if !updated\n updated \n end",
"def put(key, value = nil)\n @root = _put(@root, key, value)\n end",
"def set(key, val = nil)\n @statistics[:set] += 1\n with_branch_for(key) do |branch|\n branch.set key, val\n end\n end",
"def []= key, value\n @hash[key.to_s] = value\n end",
"def set(key, value)\n @json_dict[key] = value\n end",
"def set key_name, key_value\n raise ArgumentError, \"Cannot set a Nil (section)\" if @section.nil?\n raise ArgumentError, \"Cannot set a Nil key name.\" if key_name.nil?\n raise ArgumentError, \"Cannot set a Nil key value\" if key_value.nil?\n create_entry( @section, key_name, key_value )\n end",
"def check_or_create_for!(hash, key)\n hash[key] = \"\" unless hash.include?(key)\n end",
"def []=(key, value)\n @mutex.synchronize { @hash[key] = value }\n end",
"def []=(key, value)\n @mutex.synchronize { @hash[key] = value }\n end",
"def []=(key, value)\n @mutex.synchronize { @hash[key] = value }\n end",
"def key=(key)\n key = key.to_s\n\n if registered?\n bibliography.entries.delete(@key)\n key = register(key)\n end\n\n @key = key\n rescue => e\n raise BibTeXError, \"failed to set key to #{key.inspect}: #{e.message}\"\n end",
"def set(key, value)\n arr_pos = to_hash(key)\n list = @array[array_pos]\n node = list.find_by_key(key)\n if node\n node.data = value\n else\n self.put(key, value)\n end\n end",
"def []=(key,arg)\n @hash[key] = arg\n end",
"def key=(value)\n @key = value\n end",
"def key=(value)\n @key = value\n end",
"def write_key(key, value)\n raise RuntimeError.new(\"write_key not implemented!\")\n end",
"def []=(key, value)\n @hash[key.to_s] = value\n end",
"def put(key, value)\n @first.put(key, value)\n end",
"def set(key, value)\n self.data[key] = { value: value, timestamp: Time.now.to_i }\n self.data[key][:value]\n end",
"def []=(key, value)\n self.put(key, value)\n end",
"def set(tag, value, key=nil)\n if value.nil? then\n key ? datastore.hdel(tag, key) : datastore.rem(tag) \n else\n key ? datastore.hset(tag, key, value) : datastore.set(tag, value)\n end\n end",
"def []=(key, value)\n @mutex.synchronize{@hash[key] = value}\n end",
"def []=(key, value)\n _data[key] = value\n end",
"def set(key, value, opts = {})\n unless value == get(key)\n save(setup_commit_options({:message => \"set '#{key}'\"}.merge(opts))) do |index|\n index.add(key_for(key), encode(value))\n end\n end\n end",
"def set(key, value, opts = {})\n unless value == get(key)\n save(setup_commit_options({:message => \"set '#{key}'\"}.merge(opts))) do |index|\n index.add(key_for(key), encode(value))\n end\n end\n end",
"def update(key, value)\n set(key.to_sym => value)\n end",
"def []=(key, value)\n data[key] = value\n end",
"def []=(key, value)\n data[key] = value\n end",
"def []=(key, value)\n ks = key.to_sym\n if @hash.has_key? ks\n ns = @hash[ks]\n ns[:value] = value\n ns[:trigger].call(value) if ns[:trigger].respond_to?(:call)\n elsif existing = get(key)\n option(existing[:doc].to_s.dup, key, value)\n else\n raise(ArgumentError, \"No key for %p exists\" % [key])\n end\n end",
"def set(key , value)\n index = key_index(key)\n if( index )\n self.keys.set(index , value)\n else\n self.keys.push(key)\n self.values.push(value)\n end\n value\n end",
"def []=(key, value)\n invalidate_caches\n @keys[key.to_sym] = value\n end",
"def []=(key, value)\n set(key, value)\n end",
"def []=(key_name, value)\n set(key_name, value)\n end",
"def put(key, value)\n return if @cap <= 0\n fav = @c[key]\n if fav\n return\n end\n \n end",
"def setnx(key, value)\n node_for(key).setnx(key, value)\n end",
"def []=(key, value)\n @hash[key] = value\n end",
"def []=(key, value)\n put(key, value)\n end",
"def put (key, value)\n !table.include?(key)\n end",
"def set(key, value)\n @cache[key] = value\n end",
"def key=(key); end",
"def []=(key, value)\n @mutex.synchronize{ hash[key] = value }\n end",
"def []=(key, value)\n @_hash[key.to_sym] = value\n end",
"def set(key , value)\n index = key_index(key)\n if( index )\n @i_values.set(index , value)\n else\n @i_keys.push(key)\n @i_values.push(value)\n end\n value\n end",
"def []=(key, value)\n hash[key] = value\n end",
"def []=(key, entry)\n key = key_for(key) unless valid_key?(key)\n @hash[key] = entry if key\n end",
"def set(key, value)\n value = JSON.dump(value) unless value.is_a?(String)\n @hash[key] = value\n end",
"def []=(arg, value)\n arg = arg.to_sym\n value = !!value\n \n if @keys.include?(arg)\n if value\n add_keys!([arg])\n else\n remove_keys!([arg])\n end\n else\n IntegerFu.raise_undefined_key_error(arg)\n end\n end",
"def field_set!(key, value)\n send \"_#{key}_set\", value\n end",
"def []= key, value\n @data[key] = value\n end",
"def []= key, value\n @data[key] = value\n end",
"def set(key, value)\n @metadata[key] = value\n end"
] |
[
"0.7479501",
"0.7344384",
"0.72144693",
"0.71791166",
"0.7061458",
"0.7061458",
"0.7013134",
"0.7011545",
"0.70092756",
"0.7006719",
"0.6981302",
"0.69521904",
"0.69521904",
"0.693599",
"0.69106865",
"0.6896844",
"0.68796885",
"0.68794984",
"0.6877824",
"0.6877667",
"0.68167984",
"0.6802395",
"0.6796888",
"0.67899704",
"0.67744726",
"0.67505866",
"0.674993",
"0.6741417",
"0.67305607",
"0.6710894",
"0.66853386",
"0.66835296",
"0.66572165",
"0.6652597",
"0.66273534",
"0.6623723",
"0.6620736",
"0.6620514",
"0.6619309",
"0.66041213",
"0.66002434",
"0.6581731",
"0.65754133",
"0.65731984",
"0.65719616",
"0.65548825",
"0.65519387",
"0.6545941",
"0.65434664",
"0.6538439",
"0.6512189",
"0.6508831",
"0.65068406",
"0.6497757",
"0.6490666",
"0.648931",
"0.6485391",
"0.6484707",
"0.6454475",
"0.6454475",
"0.645318",
"0.6446915",
"0.6410937",
"0.64102614",
"0.64102614",
"0.64099324",
"0.6406263",
"0.6396842",
"0.63674134",
"0.63605696",
"0.63593817",
"0.63408595",
"0.63357264",
"0.6334639",
"0.6334639",
"0.6332773",
"0.63327515",
"0.6330423",
"0.632985",
"0.6317062",
"0.6316074",
"0.6311052",
"0.63106567",
"0.63036144",
"0.6288482",
"0.6288418",
"0.6276979",
"0.627019",
"0.6265235",
"0.62639993",
"0.6258197",
"0.62517774",
"0.6247303",
"0.6241558",
"0.62366104",
"0.62353134",
"0.6234167",
"0.6224121",
"0.62217754",
"0.62217754",
"0.6221071"
] |
0.0
|
-1
|
Set one or more values.
|
def mset(*args)
send_command([:mset] + args)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set(values); end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def set(values: nil,\n **_kwargs)\n # subclasses will generally want to call Client.munge_to_array()\n # on values before calling super()\n Cisco::Logger.debug(\"values: #{values})\") \\\n unless values.nil? || values.empty?\n # to be implemented by subclasses\n end",
"def set_values(*items)\r\n items = *items\r\n @value = [nil]\r\n items.each do |item|\r\n @value.push(item)\r\n end\r\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def values=(values)\n if values.respond_to?(:[])\n @@values = values\n else\n raise ArgumentError, 'values must be respond to [] method for validations.'\n end\n end",
"def set(*args, &block)\n update(*args, &block)\n end",
"def set(path, *values)\n values.flatten.each { |v| set_internal(path, v) }\n end",
"def set v\n if multiple?\n raise \"wrong number of values (#{v.length} for #{@min_count}..#{@max_count})\" if (v.length < min_count) || (max_count != :unlimited && v.length > max_count)\n @value = v.map {|w| single_value w }\n else\n @value = single_value v\n end\n self\n end",
"def []= name, value\n set_all name => value\n end",
"def update!(**args)\n @value = args[:value] if args.key?(:value)\n @values = args[:values] if args.key?(:values)\n end",
"def set(*args)\n run \"set #{OptArg.parse(*args)}\"\n nil\n end",
"def set!(*args)\n end",
"def set(value)\n execute_only(:set, value)\n end",
"def set(fields)\n @set.call(fields)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n @denied_values = args[:denied_values] if args.key?(:denied_values)\n @inherit_from_parent = args[:inherit_from_parent] if args.key?(:inherit_from_parent)\n @suggested_value = args[:suggested_value] if args.key?(:suggested_value)\n end",
"def set_multiple(keys, values)\n @mutex.synchronize do\n raise \"Invalid size #{keys}=#{values}\" unless keys.size == values.size\n # pp keys,values\n keys.zip(values).each do |var, val|\n do_set(var,val) unless var.nil? or val.nil?\n end\n end\n end",
"def update!(**args)\n @default_value = args[:default_value] if args.key?(:default_value)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @default_value = args[:default_value] if args.key?(:default_value)\n @values = args[:values] if args.key?(:values)\n end",
"def set_multiple(options)\n options.each do |option, value|\n set(option, value)\n end\n end",
"def values=(value)\n @values = value\n end",
"def values=(value)\n @values = value\n end",
"def values=(value)\n @values = value\n end",
"def set(object, value); end",
"def set(*args)\n json_op(:set, self, *path_value_args(args))\n end",
"def set_all **kwargs\n kwargs.each { |name, value|\n set_var(name.to_s, value)\n }\n end",
"def set(options)\n options.each do |k, v|\n send(\"#{k}=\", v) if respond_to? \"#{k}=\"\n end\n end",
"def set_values(values)\n case @type\n when /Dword/ # n .. n, step size: n\n if values =~ /(\\d+)\\s*\\.\\.\\s*(\\d+)\\s*,\\s*step size:\\s*(\\d+)/\n @min = $1.to_f\n @max = $2.to_f\n @step = $3.to_f\n else\n puts \"-E- Unrecognized value format: #{values}\"\n end\n when /Choice/ # 'choice 1'[val1], ......, 'choice n'[valn]\n @choices = Hash.new\n values.scan(/\\s*'([^']+)'\\[([^\\]]+)\\]/) do |c, v|\n @choices[v] = c\n end\n when /Button/\n # do nothing\n when /Boolean/\n # do nothing\n else\n puts \"-E- Unrecognized control type #{@type}\"\n end\n end",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @range = args[:range] if args.key?(:range)\n @value = args[:value] if args.key?(:value)\n end",
"def set_properties(*values)\n if values.size == 1 && values.first.is_a?(Hash)\n # We are dealing with a hash\n values.first.each do |key, index|\n self.set_property(key, value)\n end\n else\n # We are dealing with a list/array\n values.flatten.each_with_index do |value, index|\n self.set_property(index, value)\n end\n end\n end",
"def set_value( value )\n @value = value \n end",
"def set(index, val)\n \n end",
"def set(key, value, **options); end",
"def set(value)\n execute(:set, value)\n end",
"def value=(v)\n set(v)\n end",
"def set(values, labels = {})\n values.each do |name, value|\n metrics[name][labels].set(value)\n end\n end",
"def set(params = {})\n params.each do |k,v|\n self.class.attributes k.to_s\n send(k.to_s+\"=\",v)\n end\n end",
"def set(*args)\n case args.size\n when 1\n configure(args[0])\n when 2\n configure(args[0] => args[1])\n else\n raise ArgumentError\n end\n end",
"def update_values(values)\n before_update_values\n this.update(set_values(values))\n end",
"def set_values(opts)\n opts = check_params(opts,[:create_instances_if_needed,:class_instance_keys,:field_instance_names,:values])\n super(opts)\n end",
"def values= values\n updated_values = self.values\n updated_values[0,values.length] = values\n @ole_tablerow.Range.Value = [updated_values]\n values\n rescue WIN32OLERuntimeError\n raise TableError, \"could not set values #{values.inspect}\\n#{$!.message}\"\n end",
"def values= values\n updated_values = self.values\n updated_values[0,values.length] = values\n @ole_tablerow.Range.Value = [updated_values]\n values\n rescue WIN32OLERuntimeError\n raise TableError, \"could not set values #{values.inspect}\\n#{$!.message}\"\n end",
"def set(key, *value)\n run { conf.set(key, value, config_params) }\n end",
"def update!(**args)\n @default_value = args[:default_value] if args.key?(:default_value)\n @max_value = args[:max_value] if args.key?(:max_value)\n @min_value = args[:min_value] if args.key?(:min_value)\n end",
"def update!(**args)\n @default_value = args[:default_value] if args.key?(:default_value)\n @max_value = args[:max_value] if args.key?(:max_value)\n @min_value = args[:min_value] if args.key?(:min_value)\n end",
"def set(args, auto_compute=true)\n initialize_text(args[:value]) if args && args[:value]\n super(args, auto_compute)\n end",
"def params=(values)\n values.each do |param, value|\n value.delete_if { |v| v.blank? } if value.is_a?(Array)\n next if value.blank?\n send(\"#{param}=\", value)\n end\n end",
"def set(x, y)\n @x, @y = x, y\n end",
"def set(*indices, value)\n set_root @config, value, *indices\n end",
"def set=(_arg0); end",
"def update!(**args)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n @denied_values = args[:denied_values] if args.key?(:denied_values)\n end",
"def set(value)\n raise NotImplementedError\n end",
"def update!(**args)\n @double_value = args[:double_value] if args.key?(:double_value)\n @int_value = args[:int_value] if args.key?(:int_value)\n @string_value = args[:string_value] if args.key?(:string_value)\n end",
"def update!(value:, **)\n @value = value\n self\n end",
"def _save_set_values(h)\n @values = h\n end",
"def _save_set_values(h)\n @values = h\n end"
] |
[
"0.77182424",
"0.767537",
"0.767537",
"0.7433163",
"0.7401008",
"0.73431075",
"0.7341954",
"0.7341954",
"0.72341347",
"0.71834",
"0.7044045",
"0.69730467",
"0.6967741",
"0.6938582",
"0.6851271",
"0.68064076",
"0.67670006",
"0.67586756",
"0.6704054",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.67040294",
"0.6692783",
"0.6689236",
"0.66861016",
"0.66861016",
"0.66860497",
"0.6667359",
"0.6667359",
"0.6667359",
"0.6650208",
"0.66433454",
"0.66161984",
"0.66075164",
"0.6575569",
"0.65502656",
"0.6470919",
"0.64603496",
"0.64534926",
"0.64350986",
"0.6433947",
"0.6433526",
"0.6406104",
"0.64031065",
"0.63961685",
"0.63940305",
"0.63745165",
"0.63585126",
"0.63585126",
"0.6350542",
"0.6340952",
"0.6340952",
"0.6332097",
"0.63195187",
"0.6310191",
"0.6299218",
"0.6298668",
"0.6293007",
"0.6283202",
"0.6277819",
"0.62700975",
"0.62638205",
"0.62638205"
] |
0.0
|
-1
|
Set one or more values, only if none of the keys exist.
|
def msetnx(*args)
send_command([:msetnx, *args], &Boolify)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_multiple(keys, values)\n @mutex.synchronize do\n raise \"Invalid size #{keys}=#{values}\" unless keys.size == values.size\n # pp keys,values\n keys.zip(values).each do |var, val|\n do_set(var,val) unless var.nil? or val.nil?\n end\n end\n end",
"def set(values); end",
"def set(values: nil,\n **_kwargs)\n # subclasses will generally want to call Client.munge_to_array()\n # on values before calling super()\n Cisco::Logger.debug(\"values: #{values})\") \\\n unless values.nil? || values.empty?\n # to be implemented by subclasses\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def set_values(*items)\r\n items = *items\r\n @value = [nil]\r\n items.each do |item|\r\n @value.push(item)\r\n end\r\n end",
"def do_set current, keys, value\n if keys.blank?\n current[:value] = value\n return current\n end\n\n keys = [keys] unless keys.is_a? Array\n current_key = keys.shift.to_sym\n if current[current_key].blank?\n current[current_key] = {:value => {}}\n end\n \n if keys.size > 0\n current[current_key] = do_set(current[current_key], keys, value)\n else\n current[current_key][:value] = value \n end\n \n current\n end",
"def test_set_values\n ogg = dummy()\n\n assert !ogg.has_tag?(\"A\")\n\n ogg.set_values(\"A\", \"B\")\n assert_equal Set[\"B\"], ogg['A']\n\n ogg.set_values(\"A\", \"C\", \"D\")\n assert_equal Set[\"C\", \"D\"], ogg['A']\n\n # This will remove the tag\n ogg.set_values(\"A\", *[])\n assert !ogg.has_tag?(\"A\")\n end",
"def set_properties(*values)\n if values.size == 1 && values.first.is_a?(Hash)\n # We are dealing with a hash\n values.first.each do |key, index|\n self.set_property(key, value)\n end\n else\n # We are dealing with a list/array\n values.flatten.each_with_index do |value, index|\n self.set_property(index, value)\n end\n end\n end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @value = args[:value] if args.key?(:value)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @default_value = args[:default_value] if args.key?(:default_value)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @default_value = args[:default_value] if args.key?(:default_value)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n @denied_values = args[:denied_values] if args.key?(:denied_values)\n @inherit_from_parent = args[:inherit_from_parent] if args.key?(:inherit_from_parent)\n @suggested_value = args[:suggested_value] if args.key?(:suggested_value)\n end",
"def update!(**args)\n @keys = args[:keys] unless args[:keys].nil?\n end",
"def set(path, *values)\n values.flatten.each { |v| set_internal(path, v) }\n end",
"def set(key, value, **options); end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @values = args[:values] if args.key?(:values)\n end",
"def set(key, value); end",
"def set(key, value); end",
"def set v\n if multiple?\n raise \"wrong number of values (#{v.length} for #{@min_count}..#{@max_count})\" if (v.length < min_count) || (max_count != :unlimited && v.length > max_count)\n @value = v.map {|w| single_value w }\n else\n @value = single_value v\n end\n self\n end",
"def update(values)\n values.each do |key, value|\n if self[key].is_a?(self.class)\n unless value.respond_to?(:to_hash)\n raise ArgumentError, \"#{value.inspect} is not a valid setting value\"\n end\n\n self[key].update(value.to_hash)\n else\n self[key] = value\n end\n end\n self\n end",
"def set_only(hash, *only)\n set_restricted(hash, only.flatten, false)\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def ensure_value_exists!(k)\n @values[k] = nil unless @values.has_key?(k)\n end",
"def set_all **kwargs\n kwargs.each { |name, value|\n set_var(name.to_s, value)\n }\n end",
"def set(v, invalid: false, nil_default: false, **)\n unless v.nil?\n @value = normalize(v)\n @value = nil unless valid?(@value)\n Log.warn { \"#{type}: #{v.inspect}: not in #{values}\" } if @value.nil?\n end\n @value ||= (v if invalid) || (default unless nil_default)\n end",
"def set(*args)\n unless(args.size > 1)\n raise ArgumentError,\n 'Set requires at least one key and a value'\n end\n value = args.pop\n set_key = args.pop\n leaf = args.inject(self) do |memo, key|\n unless(memo[key].is_a?(Hash))\n memo[key] = Smash.new\n end\n memo[key]\n end\n leaf[set_key] = value\n value\n end",
"def update!(**args)\n @conditional_values = args[:conditional_values] if args.key?(:conditional_values)\n @default_value = args[:default_value] if args.key?(:default_value)\n end",
"def generic_set(key, value)\n modify(key, value) || uncomment(key, value) || add_new(key, value)\n end",
"def values=(values)\n if values.respond_to?(:[])\n @@values = values\n else\n raise ArgumentError, 'values must be respond to [] method for validations.'\n end\n end",
"def set(key, value)\n end",
"def []=(*key_list, value)\n store_with_init(Array(key_list).flatten, value)\n end",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @range = args[:range] if args.key?(:range)\n @value = args[:value] if args.key?(:value)\n end",
"def []=(arg, value)\n arg = arg.to_sym\n value = !!value\n \n if @keys.include?(arg)\n if value\n add_keys!([arg])\n else\n remove_keys!([arg])\n end\n else\n IntegerFu.raise_undefined_key_error(arg)\n end\n end",
"def reducx(*values)\n @assign = values.compact.reduce({ }, :merge).keep_if &value_present\n self\n end",
"def set_unless_exists(key, val)\n val = redis_marshal(val)\n timeout_retry(3, 3){\n write \"SETNX #{key} #{val.to_s.size}\\r\\n#{val}\\r\\n\"\n integer_reply == 1\n }\n end",
"def set_values(values)\n s = str_columns\n vals = values.inject({}) do |m, kv| \n k, v = kv\n k = case k\n when Symbol\n k\n when String\n # Prevent denial of service via memory exhaustion by only \n # calling to_sym if the symbol already exists.\n raise(Error, \"all string keys must be a valid columns\") unless s.include?(k)\n k.to_sym\n else\n raise(Error, \"Only symbols and strings allows as keys\")\n end\n m[k] = v\n m\n end\n vals.each {|k, v| @values[k] = v}\n vals\n end",
"def set_multiple(options)\n options.each do |option, value|\n set(option, value)\n end\n end",
"def set(*args)\n assert_exists\n assert_writable\n\n @element.clear\n @element.send_keys(*args)\n end",
"def initialize_set(h)\n set(h) unless h.empty?\n end",
"def initialize_set(h)\n set(h) unless h.empty?\n end",
"def []=(*names)\n values = names.pop\n values = [values] unless Array === values\n names.each_with_index do |name, i|\n use name => (values[i] || values.last)\n end\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value = args[:value] if args.key?(:value)\n end"
] |
[
"0.77332973",
"0.7168097",
"0.70538497",
"0.67479897",
"0.67458564",
"0.67458564",
"0.6615992",
"0.6613405",
"0.64248836",
"0.6272163",
"0.6233832",
"0.6233832",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.62101066",
"0.6189659",
"0.6188805",
"0.6188805",
"0.61239624",
"0.6103924",
"0.6059592",
"0.6018975",
"0.6014791",
"0.59880036",
"0.59880036",
"0.59724313",
"0.5965456",
"0.5959462",
"0.59525645",
"0.59525645",
"0.5943891",
"0.59139454",
"0.5871382",
"0.5830403",
"0.57702607",
"0.5768561",
"0.57670665",
"0.57475",
"0.5717832",
"0.5695392",
"0.56934625",
"0.56813705",
"0.5680355",
"0.5679492",
"0.5676891",
"0.56729203",
"0.5665716",
"0.5665716",
"0.56656337",
"0.56354076",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956",
"0.56353956"
] |
0.0
|
-1
|
Get the value of a key.
|
def get(key)
send_command([:get, key])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_value(key)\n self[key]\n end",
"def getValue(key)\r\n \r\n return @aHash[key]\r\n end",
"def value(key)\n @hash[key]\n end",
"def get(key)\n @hash.get(key)\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def get(key)\n @hash[key]\n end",
"def get_value (key)\r\n @redis.get key\r\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def get(key)\n index = key_index(key)\n if( index )\n self.values.get(index)\n else\n nil\n end\n end",
"def get_key_value(key)\n if v = storage.get(key.object_id)\n return key.object_id, v\n end\n storage.get_candidates(key.hash).find do |k,v|\n candidate_key = get_object(k) or next\n candidate_key.eql? key\n end\n end",
"def get(key)\n position = search(key)\n return nil if (key <=> @keys[position]) != 0\n @values[position]\n end",
"def get(key)\n return do_get(key, false)\n end",
"def get(key)\n position = find(key)\n if position != nil\n @values[position]\n else\n nil\n end\n end",
"def get_value_for_key(opts = {})\n data, _status_code, _headers = get_value_for_key_with_http_info(opts)\n data\n end",
"def [](key)\n @monitor.synchronize do\n _, value = get(key)\n value\n end\n end",
"def get(key)\n v = Nvmkv::kv_get(@kv_id, @pool_id, key)\n return (v != nil ? NVMKVValue.new(v) : nil)\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def get_key_value_\n @redis.hget @url, 'key'\n end",
"def get key\n deserialize backend.get key.to_s rescue nil\n end",
"def get(key)\n index = key_index(key)\n if( index )\n @i_values.get(index)\n else\n nil\n end\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key, default=nil)\n find = KeyValue.find_by_key(key)\n find ? find.value : default\n end",
"def get(key)\n end",
"def get(key)\n self.data[key] && self.data[key][:value]\n end",
"def get(key)\n @map[key]\n end",
"def get key\n @redis.get key\n end",
"def [](key)\n find_value(key)\n end",
"def get(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key \n return ele[1]\n end\n end\n end",
"def fetch_value( oid, key )\n\t\toid = normalize_oid( oid )\n\t\tkey = normalize_key( key )\n\t\tdata = @storage[ oid ] or return nil\n\n\t\treturn data[ key ]\n\tend",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def [](key)\n @hash[key.to_s]\n end",
"def get(key)\n ensure_connected\n json_to_value(redis_handler.get key.to_s)\n end",
"def get_value(section, key)\n if section.nil?\n raise TypeError.new('nil not allowed')\n end\n section = 'default' if section.empty?\n get_key_string(section, key)\n end",
"def get(key)\n end",
"def [](key)\n begin\n rv = self.fetch(key)\n rescue IndexError\n rv = nil\n end\n if (rv == nil)\n begin\n rv = self.dcase_hash[key.downcase]\n rescue IndexError\n rv = nil\n end\n end\n\n return rv\n end",
"def get(key)\n node = get_rec(@root, key, 0)\n return nil if node.nil?\n return node.value\n end",
"def get(key)\n data = request_data(:get, key_uri(key))\n return nil unless data\n if nodes = data[S_NODE][S_NODES]\n nodes.each_with_object({}) do |node, acc|\n acc[node[S_KEY]] = node[S_VALUE]\n end\n else\n data[S_NODE][S_VALUE]\n end\n end",
"def get(key)\n node_for(key).get(key)\n end",
"def get(key)\n response = request(:get, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n if data.is_a?(Array)\n data.each_with_object({}) do |e, acc|\n acc[e[S_KEY]] = e[S_VALUE]\n end\n else\n data[S_VALUE]\n end\n else\n nil\n end\n end",
"def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end",
"def get(key)\n node = _get(@root, key)\n return nil unless node\n node.value\n end",
"def get(key)\n get_all(key).first\n end",
"def obtain!(key)\n raise \"Missing key #{key}\" unless @hash.key?(key)\n @hash[key]\n end",
"def get(key)\n \n end",
"def [](key)\n result = default(key)\n result ? result.value : nil\n end",
"def get_from_key(key)\n @bucket_key_map[key]\n end",
"def getValue(hash, key)\n key.to_s.split('.').inject(hash) { |h, k| h[k] unless h.nil? }\n end",
"def get(key)\n _get_from_params(key) || _get_from_values(key)\n end",
"def get(key)\n @first.get(key)\n end",
"def get key\n storage[key]\n end",
"def value_by_key(hash, key)\n hash[key.to_s] || hash[key.to_sym]\n end",
"def get(key)\n self.map_var.each do |pair|\n return pair[1] if pair[0] == key\n end\n nil\n end",
"def get(key, options = nil)\n @hash[key]\n end",
"def [](key)\n @hash[key]\n end",
"def [](key)\n @hash[key]\n end",
"def [](key)\n @hash[key]\n end",
"def [](key)\n @hash[key]\n end",
"def get_from_key(key)\n @bucket_key_map[key]\n end",
"def generic_get(key)\n data[key]\n end",
"def [](key)\n self.get(key)\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def get(key)\n @semaphore.synchronize do\n return @hashed_storage[key]&.value\n end\n end",
"def get(key)\n (self.data ||= {})[key.to_s]\n end",
"def value_of(key)\n @root.value_of(key)\n end",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def get_item(key)\n self[key]\n end",
"def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end",
"def []( key )\n hash = load_hash\n hash[key]\n end",
"def [](key)\n if self.class.key_transformer\n @hash[self.class.key_transformer.call(key)]\n else\n @hash[key]\n end\n end",
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def get(key)\n run_hook(:before_get, key)\n value = db[key]\n run_hook(:after_get, key, value)\n value\n end",
"def get(key)\n self.send(key)\n end",
"def [] key\n return @hash[key.to_s]\n end",
"def [](key)\n @values[key]\n end",
"def [](key)\n @lock.synchronize do\n rkey = ref_key(key)\n @values[rkey] if rkey\n end\n end",
"def getvalue(key)\r\n return @@params[key] if (key != nil)\r\n return nil\r\n end",
"def [](key)\n if RUBY_ENGINE == 'opal'\n @hash[key]\n else\n @mutex.synchronize { @hash[key] }\n end\n end",
"def [](key)\n @mutex.synchronize { @hash[key] }\n end",
"def [](key)\n @mutex.synchronize { @hash[key] }\n end",
"def get(key)\n if @data.has_key?(key)\n return @data[key]\n else\n return false\n end\n end",
"def get(vault, key)\n @redis.get value_key(vault, key)\n end",
"def get(key)\n key = normalize(key) or return\n table[key]\n end",
"def [](key)\n @mutex.synchronize { @hash[key] }\n end",
"def [](key)\n if RUBY_ENGINE == 'opal'\n @hash[key]\n else\n @mutex.synchronize { @hash[key] }\n end\n end",
"def get_value(collection, key)\n @data[collection][key]\n end",
"def get(key)\n Lib.get @path, @no_follow, key.to_s\n end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def get(key)\n a_hash[key] || -1 \n end",
"def [](key)\n data[key.to_s]\n end",
"def [](key)\n key = key_for(key, false)\n @hash[key] if key\n end",
"def get(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n return @a[row][column][1] \n else\n return -1\n end\n end",
"def [](key)\n hash = to_h\n if hash.has_key?(key)\n hash[key]\n else\n default(key)\n end\n end",
"def get(key)\n bucket = @map[key.hash % @size]\n pair = bucket.find {|k, v| k == key}\n if pair \n pair[1]\n else\n -1\n end\n end",
"def value(key = :value)\n @record.send key\n end",
"def [](key)\n fetch(key)\n end"
] |
[
"0.847488",
"0.8341601",
"0.83121467",
"0.81285393",
"0.8101179",
"0.8035877",
"0.7854947",
"0.783024",
"0.76814353",
"0.76214576",
"0.7608665",
"0.7581845",
"0.75672245",
"0.75189567",
"0.746768",
"0.7452492",
"0.7426756",
"0.7412703",
"0.73887944",
"0.7380335",
"0.73132586",
"0.73132586",
"0.73132586",
"0.73132586",
"0.73040557",
"0.7257271",
"0.72453713",
"0.7240156",
"0.7217002",
"0.72145647",
"0.72107345",
"0.7209582",
"0.72078764",
"0.7197539",
"0.7197539",
"0.7174413",
"0.7158606",
"0.71552473",
"0.7124042",
"0.7109647",
"0.71053493",
"0.7083055",
"0.7071041",
"0.70594096",
"0.70566857",
"0.70505667",
"0.70471126",
"0.70254487",
"0.6991094",
"0.69889957",
"0.6985192",
"0.6978859",
"0.69769335",
"0.6970919",
"0.6969723",
"0.6966513",
"0.69618994",
"0.69578683",
"0.6931104",
"0.6931104",
"0.6931104",
"0.6931104",
"0.6930482",
"0.69299585",
"0.692762",
"0.6927248",
"0.6921886",
"0.69177145",
"0.69169587",
"0.6911272",
"0.6911272",
"0.69095635",
"0.69055295",
"0.69028914",
"0.6876225",
"0.6874884",
"0.68741184",
"0.68704635",
"0.6853931",
"0.6839372",
"0.6831954",
"0.68198943",
"0.68183726",
"0.6812774",
"0.6812774",
"0.6812059",
"0.6806379",
"0.6801674",
"0.6796992",
"0.6789852",
"0.6786107",
"0.6783158",
"0.67821276",
"0.6774241",
"0.6773805",
"0.677018",
"0.6769388",
"0.6755695",
"0.674992",
"0.6748508",
"0.6746887"
] |
0.0
|
-1
|
Get the values of all the given keys.
|
def mget(*keys, &blk)
keys.flatten!(1)
send_command([:mget, *keys], &blk)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def values_at(*keys)\n values = []\n keys.each {|key| values << fetch(key) }\n values\n end",
"def values_at(*keys)\n transaction do |y|\n keys.map{|k| y[k]}\n end\n end",
"def values_at(*keys)\n keys.map { |k| lookup(k) }\n end",
"def multiget(keys)\n data = @client.get_multi(keys)\n keys.map { |k| Marshal.load data[k] }\n end",
"def get_all\n @hash.each do |k,v|\n v.get_all do |e|\n yield [k].push(*e)\n end\n end\n end",
"def values_at(*keys)\n @hash.values_at(*keys)\n end",
"def values_at(*key_list)\n key_list.map { |key| self[key] }\n end",
"def _get_all(keys)\r\n\t\treq = VoldemortRequest.new\r\n\t\treq.should_route = true\r\n\t\treq.store = @store_name\r\n\t\treq.type = RequestType::GET_ALL\r\n req.getAll = GetAllRequest.new\r\n\t\tfor key in keys\r\n\t\t\treq.getAll.keys << key\r\n end\r\n\r\n\t\t# send request\r\n\t\t_send_request(@connection, req.serialize_to_string())\r\n\r\n\t\t# read and parse response\r\n\t\tresp_str = _receive_response(@connection)\r\n\t\tresp = GetAllResponse.new\r\n\t\tresp = resp.parse_from_string(resp_str)\r\n\t\t_check_error(resp)\r\n\t\tvalues = {}\r\n\t\tfor key_val in resp.values\r\n\t\t\tvalues[key_val.key] = _extract_versions(key_val.versions)\r\n end\r\n\t\treturn values\r\n end",
"def mget(*keys)\n keys.flatten!(1)\n mapped_mget(*keys).values_at(*keys)\n end",
"def values\n keys.map {|key| self[key] }\n end",
"def values_at(*keys); end",
"def mget(*keys); end",
"def get_many_with_keys(keys)\n keys.map {|key| get_with_key(key)}\n end",
"def values_at *keys\n fetch_values(*keys) {|key| nil }\n end",
"def gets(keys)\n get(keys, true)\n end",
"def values\n vals = []\n each{|k,v| vals << v}\n vals\n end",
"def get(*keys)\n get_from_params(*keys) || get_from_values(*keys)\n end",
"def fetch_values(*key_list, &block)\n if array_index?(key_list)\n key_list.map { |key| fetch(key, &block) }\n elsif block_given?\n __fetch_values__(*key_list) { |key| yield(key) }\n else\n __fetch_values__(*key_list)\n end\n end",
"def key_values(tf = true)\n keys(tf).zip(values(tf))\n end",
"def fetch_items(*keys, **kwargs)\n keys.flatten.map do |key|\n fetch_item(key, method: :all, **kwargs)\n end.flatten\n end",
"def all\n @hash.values\n end",
"def values_at(*keys)\n keys.map! { |key| convert_key(key) }\n super\n end",
"def get_multi(*keys)\n codes = @backend.get(keys)\n return [] if codes.empty?\n parser.decode_multi(codes.values)\n rescue ::Memcached::Error\n nil\n end",
"def me_mget_p( *keys )\n ftr = []\n pipelined { keys.each{ |key| ftr << me_get( key ) } }\n ftr\n end",
"def values_at(*indices)\n indices.collect {|key| self[convert_key(key)]}\n end",
"def values_at(*arguments)\n arguments.map do |key|\n get key\n end\n end",
"def all\n unless @all_loaded\n @all = keys.map { |key| get(key) }\n @all_loaded = true\n end\n\n @all\n end",
"def mget(*keys, &blk); end",
"def values_at(*keys)\n convert_value_to_parameters(@parameters.values_at(*keys))\n end",
"def values_at(*indices)\n indices.collect {|key| self[key]}\n end",
"def comp(*keys)\n result = keys.map { |key| get(key) }\n yield(*result) if result.all? if block_given?\n result\n end",
"def mapped_mget(*keys); end",
"def values(key)\n Array.wrap(self[key]).compact\n end",
"def values\n @hash.values\n end",
"def all\n @keys\n end",
"def keys\n keys = []\n each_pair {|k,v| keys << k}\n keys\n end",
"def mapped_mget(*keys)\n mget(*keys) do |response|\n result = {}\n response.each do |value|\n key = keys.shift\n result.merge!(key => value) unless value.nil?\n end\n yield result if block_given?\n end\n end",
"def me_mget( *keys )\n pipelined { keys.each{ |key| me_get( key ) } }\n end",
"def get_all(key)\n build_if_necessary\n agent.set_query(key)\n [].tap do |results|\n while @trie.predictive_search(agent)\n results << agent_key_value(agent)\n end\n end\n end",
"def values_at(*keys)\n @table_with_original_keys.values_at *keys\n end",
"def values\n sub_result = []\n i = 0\n while i < @hash.length do\n if @hash[i] != nil && @hash[i].length > 0\n @hash[i].map { |k, v| sub_result.push(v) }\n end\n i += 1\n end\n return sub_result.uniq\n end",
"def subset(*keys)\n keys = keys.flatten\n map {|h| h.subset(keys) }\n end",
"def values_at(*keys)\n super(*keys.map(&method(:convert_key)))\n end",
"def keys(*args)\n @params.keys(*args)\n end",
"def keys(*args)\n @params.keys(*args)\n end",
"def getKeys(data_keys)\r\n data_keys[0].keys\r\n end",
"def fetch_keys_for(keys = EMPTY_ARRAY)\n return [\n with_prefixes_namespaces_targets_key_for(keys),\n with_namespaces_targets_key_for(keys),\n with_prefixes_namespaces_key_for(keys),\n with_namespaces_key_for(keys),\n with_prefixes_key_for(keys),\n with_key_for(keys)\n ]\n end",
"def fetch_keys_for(keys = EMPTY_ARRAY)\n return [\n with_prefixes_namespaces_targets_key_for(keys),\n with_namespaces_targets_key_for(keys),\n with_prefixes_namespaces_key_for(keys),\n with_namespaces_key_for(keys),\n with_prefixes_key_for(keys),\n with_key_for(keys)\n ]\n end",
"def [](*keys)\n if value = get(*keys)\n value.is_a?(Hash) ? value[:value] : value\n end\n end",
"def values\n @hash.values\n end",
"def get_all(*names)\n set = Set.new\n names.each { |name| set.merge(get(name)) }\n set\n end",
"def values(key)\n h = hash(key)\n\n hoff = @hashes[(h % 256)*2]\n hlen = @hashes[(h % 256)*2 + 1]\n\n return [] if hlen == 0\n off = (h / 256) % hlen\n\n vals = []\n\n # FIXME: Is this potentially an infinite loop (if full)?\n # Easy to avoid by exiting if off reaches the same value twice.\n\n while\n (slot = read(hoff + off * hashref_size .. hoff + off * hashref_size + hashref_size - 1)) &&\n (dslot = ary_unpack(slot,2)) && dslot[1] != 0\n\n if dslot[0] == h\n pos = dslot[1]\n\n rkey, value = read_entry(pos)\n if rkey == key\n vals << value\n end\n end\n off = (off + 1) % hlen\n end\n return vals\n end",
"def param_values(key = nil)\n params(key).map { |param| param.value }\n end",
"def keys\n @values.keys\n end",
"def keys\n @values.keys\n end",
"def pluck(*keys)\n keys = keys.flatten\n map {|h| h.pluck(keys)}\n # if keys.count > 1\n # map {|h| keys.map {|k| h[k]}}\n # else\n # map {|h| h[keys.first]}\n # end\n end",
"def keys\n list = []\n each_key{|key| list << key}\n list\n end",
"def keys\n @values.keys\n end",
"def esponi(*keys)\n return self if keys.none?\n self.select { |key, value| key.in? keys }\n end",
"def find_all *keys\n ensure_service!\n lookup_res = service.lookup(*Array(keys).flatten.map(&:to_grpc),\n transaction: @id)\n LookupResults.from_grpc lookup_res, service, nil, @id\n end",
"def get(k)\n a = []\n each do |e|\n a << e.get(k)\n end\n a\n end",
"def array_of_values(name_hash)\n name_hash.collect do |key, value|\n value\n end\nend",
"def mapped_mget(*keys)\n result = {}\n mget(*keys).each do |value|\n key = keys.shift\n result.merge!(key => value) unless value.nil?\n end\n result\n end",
"def keys\n @values.keys\n end",
"def keys\n @values.keys\n end",
"def all(k, opt = {})\n real_get(k, opt)\n end",
"def all(k, opt = {})\n real_get(k, opt)\n end",
"def array_of_keys(key)\n n = query(@connection, key)\n if n.nil?\n []\n else\n a = []\n n.each do |value|\n a.push(value.key.gsub(key, ''))\n end\n a\n end\n end",
"def indexes(*keys)\n r = []\n keys.each do |key|\n if has_key? key then\n r << self[key]\n else\n r << self.default\n end\n end\n return r\n end",
"def hvals(key); end",
"def hvals(key); end",
"def fetch_multi(*keys)\n keys.flatten!(1)\n return {} if keys.empty?\n\n result = if should_use_cache?\n fetch_in_batches(keys.uniq) do |missed_keys|\n results = yield missed_keys\n results.map { |e| map_cached_nil_for(e) }\n end\n else\n results = yield keys\n Hash[keys.zip(results)]\n end\n\n result.each do |key, value|\n result[key] = unmap_cached_nil_for(value)\n end\n\n result\n end",
"def extract_from_params(*keys)\n res = []\n\n keys.each do |key|\n next unless value = param(key.to_sym)\n res << \":#{key} => #{RubyLess.translate_string(self, value)}\"\n end\n\n res.empty? ? nil : res\n end",
"def all_keys\r\n keys = dispatch('33').split(',')\r\n #the reponse is \"1,field1,field2,....\" where 1 is success and rest are avail feilds.\r\n keys = keys[1..(keys.length)]\r\n end",
"def value_by_keys(*attrs)\n attr_count = attrs.size\n current_val = self\n for i in 0..(attr_count-1)\n attr_name = attrs[i]\n return current_val[attr_name] if i == (attr_count-1)\n return nil if current_val[attr_name].nil?\n current_val = current_val[attr_name]\n end\n return nil\n end",
"def collect_values(name_hash)\n name_hash.collect do |key, value|\n value \n end\nend",
"def entry_values(include_all = true)\n keys = entry_keys(include_all)\n keys.convert_to_hash {|k| item_value(find_item(k)) }\n end",
"def slice *keys\n missing = {}\n values = fetch_values(*keys) {|key| missing[key] = nil }\n\n result = {}\n values.each_with_index do |val, i|\n key = keys[i]\n next if missing.key? key\n next if result.key? key\n result[key] = val\n end\n result\n end",
"def keys\n return self.keySet.to_a\n end",
"def values\n iterator = @form_fields.keySet.iterator\n set = []\n set << field(iterator.next.toString) while iterator.hasNext\n set\n end",
"def value_array(hash, *keys)\n return unless hash.is_a?(Hash)\n keys.flatten!\n keys.map { |v| [v, nil] }.to_h.merge(hash).slice(*keys).values\n end",
"def get_all\n verify_connection_url\n\n output = {}\n list.each { |key| output[key.to_sym] = get key }\n output\n end",
"def fetch_all(key); end",
"def batch_get(keys, bin_names = nil, options = nil)\n policy = create_policy(options, BatchPolicy, default_batch_policy)\n results = Array.new(keys.length)\n info_flags = INFO1_READ\n\n case bin_names\n when :all, nil, []\n info_flags |= INFO1_GET_ALL\n bin_names = nil\n when :none\n info_flags |= INFO1_NOBINDATA\n bin_names = nil\n end\n\n if policy.use_batch_direct\n key_map = BatchItem.generate_map(keys)\n execute_batch_direct_commands(policy, keys) do |node, batch|\n BatchDirectCommand.new(node, batch, policy, key_map, bin_names, results, info_flags)\n end\n else\n execute_batch_index_commands(policy, keys) do |node, batch|\n BatchIndexCommand.new(node, batch, policy, bin_names, results, info_flags)\n end\n end\n\n results\n end",
"def mapped_mget(*keys)\n keys.flatten!(1)\n keys.group_by { |k| node_for k }.inject({}) do |results, (node, subkeys)|\n results.merge! node.mapped_mget(*subkeys)\n end\n end",
"def keys(*) end",
"def retrieve_values(hash1, hash2, key)\n return [hash1[key], hash2[key]]\nend",
"def slice(*keys)\n FlexHash[keys.map { |key| [key, fetch(key)] }]\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def all\n # Accessing the store requires a transaction \n @store.transaction do\n # Create an array with the values for each key \n @store.roots.map { |id| @store[id] }\n end\n end",
"def cars(keys, values)\n\tkeys + values\nend",
"def keys\n map(&:key)\n end",
"def get_hashpipe_status_values(redis, skey, *hkeys)\n hkeys.flatten.map! do |hk|\n sval = redis.hget(hk, skey)\n block_given? ? yield(sval) : sval\n end\nend",
"def slice(*keys)\n self.select { |k,v| keys.include?(k) }\n end",
"def keys\n @values.values.uniq.sort_by(&:value).map { |e| e.keys.sort }.flatten\n end",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def get_values(path)\n keys = nil\n Vault.with_retries(Vault::HTTPConnectionError, Vault::HTTPError) do |attempt, e|\n Tiller::log.warn(\"#{self} : Received exception #{e} from Vault\") if e\n keys = Vault.logical.list(path)\n end\n\n values = {}\n if keys.is_a? Array\n keys.each do |k|\n Tiller::log.debug(\"#{self} : Fetching value at #{path}/#{k}\")\n Vault.with_retries(Vault::HTTPConnectionError, Vault::HTTPError) do |attempt, e|\n Tiller::log.warn(\"#{self} : Received exception #{e} from Vault\") if e\n values[k] = Vault.logical.read(File.absolute_path(k,path)).data[@vault_config['json_key_name']]\n end\n end\n values\n else\n {}\n end\n end"
] |
[
"0.7813698",
"0.78041685",
"0.7443069",
"0.73216224",
"0.7283312",
"0.72797334",
"0.7167697",
"0.7149225",
"0.7141335",
"0.70829386",
"0.7058574",
"0.70196956",
"0.70095587",
"0.6987541",
"0.6796313",
"0.6780957",
"0.6769271",
"0.67485785",
"0.6666559",
"0.662742",
"0.6623182",
"0.65578127",
"0.65505546",
"0.65300506",
"0.6492171",
"0.64836067",
"0.6433312",
"0.6407815",
"0.63607657",
"0.6338311",
"0.6321625",
"0.6304097",
"0.6298108",
"0.6292365",
"0.628995",
"0.6275159",
"0.62597746",
"0.62551373",
"0.62506795",
"0.6200203",
"0.619562",
"0.619539",
"0.61620367",
"0.6149067",
"0.6149067",
"0.61339635",
"0.61217123",
"0.61217123",
"0.61156106",
"0.609554",
"0.608761",
"0.6085516",
"0.6080414",
"0.606446",
"0.606446",
"0.60490924",
"0.60480744",
"0.60426176",
"0.5991278",
"0.5988571",
"0.5988496",
"0.59600973",
"0.5959489",
"0.5950503",
"0.5950503",
"0.5936821",
"0.5936821",
"0.5929901",
"0.5908158",
"0.5906217",
"0.5906217",
"0.5901834",
"0.58930004",
"0.5883914",
"0.5851072",
"0.58488286",
"0.5842709",
"0.58224666",
"0.5818803",
"0.5771198",
"0.5764298",
"0.57592446",
"0.5743409",
"0.57240283",
"0.5690271",
"0.568795",
"0.56863165",
"0.5682903",
"0.567836",
"0.567836",
"0.567836",
"0.56672645",
"0.5658087",
"0.5652576",
"0.5632909",
"0.56327814",
"0.5623989",
"0.5610077",
"0.5610077",
"0.5609863"
] |
0.57133937
|
84
|
Overwrite part of a string at key starting at the specified offset.
|
def setrange(key, offset, value)
send_command([:setrange, key, Integer(offset), value.to_s])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_string(offset, value)\n @contents.pos = offset\n @contents << value\n end",
"def new_string_offset\n last_string_index = @data[last_string_index_offset, 4].unpack1('V')\n offset = @offset + @string_start + last_string_index\n\n u16len, o16 = ResStringPool.utf16_len(@data[offset, 4])\n # To insert a new string at the end of the string section, we need to start at the current\n # last string entry, and add o16 (number of length bytes), u16len * 2(number of string bytes),\n # and 2 bytes for the terminating null-bytes.\n offset + o16 + u16len * 2 + 2\n end",
"def insert(str, offset, fragment)\n str.replace(str.unpack(\"U*\").insert(offset, fragment.unpack(\"U*\")).flatten.pack(\"U*\"))\n end",
"def edit(ciphertext, key, offset, new_text)\n plaintext = AES_128.decrypt(ciphertext, key, :mode => :CTR)\n plaintext[offset % plaintext.size, new_text.size] = new_text[0..plaintext.size] # Modulo so it wraps around to imitate a fixed-size buffer, such as a disk.\n\n AES_128.encrypt(plaintext, key, :mode => :CTR)\nend",
"def edit(offset: ,with: )\n previous = ciphertext[0...offset]\n after = ciphertext[(offset + with.bytesize)..-1]\n edited = with.encrypt_ctr(nonce: nonce,\n key: key,\n start_counter: offset)\n previous + edited + after\n end",
"def []=(pos, value)\n if pos < 0\n pos += self.length\n end\n b = self[0, pos]\n a = self[pos+1..-1]\n self.replace([b, value, a].join(''))\n end",
"def replace_in_string(str, replace, start, finish)\n str[start..finish] = replace * (finish + 1 - start)\n str\n end",
"def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n end",
"def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n end",
"def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n end",
"def setrange(key, offset, value); end",
"def setrange(key, offset, value); end",
"def translate_offset(str, byte_offset)\n chunk = str[0..byte_offset]\n begin\n chunk.unpack(\"U*\").length - 1\n rescue ArgumentError # we damaged a character\n chunk = str[0..(byte_offset+=1)]\n retry\n end\n end",
"def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n @position_line_offsets = nil\n end",
"def normalize_offset(offset); end",
"def update(string)\n #This is a stub, used for indexing\n end",
"def update(string)\n #This is a stub, used for indexing\n end",
"def []=(offset, value)\n iterator = self.iterator\n iterator[offset] = value\n end",
"def shiftText(text, offset)\n result = \"\"\n text.length.times do |index|\n result += (text.getbyte(index) + offset).chr\n end\n result\n end",
"def update!(**args)\n @offset = args[:offset] if args.key?(:offset)\n end",
"def char_offset(offset)\n raise \"Should not be called\"\n end",
"def write_to_disk(offset, new_text)\n edit(encryption_oracle, AES_KEY, offset, new_text)\nend",
"def update_array_at_with (array, i, char)\n array[i] = X\nend",
"def replace_at(pos, val)\n if pos < 0\n pos = size + pos\n end\n if has_size? && size <= pos\n expand(pos - size + 1)\n end\n replace_access(pos, val)\n return self\n end",
"def prepend(key, length, data)\n end",
"def set_offset(offset)\n @offset = offset\n self\n end",
"def offset!(offset)\n @offset = offset || 0\n self\n end",
"def abbrev_key(key_str)\n key_str[0, 5] + ' ' + key_str[5, 5] + ' ' +key_str[10, 5]\nend",
"def prepend(str)\n @buffer.insert(0, str)\n @range.first -= str.bytesize\n str.bytesize\n end",
"def set_char at , char\n raise \"char not fixnum #{char}\" unless char.kind_of? Fixnum\n index = range_correct_index(at)\n internal_object_set( index + 1 , char )\n end",
"def _rl_overwrite_rubout(count, key)\r\n if (@rl_point == 0)\r\n rl_ding()\r\n return 1\r\n end\r\n\r\n opoint = @rl_point\r\n\r\n # L == number of spaces to insert\r\n l = 0\r\n count.times do\r\n rl_backward_char(1, key)\r\n l += rl_character_len(@rl_line_buffer[@rl_point,1], @rl_point) # not exactly right\r\n end\r\n\r\n rl_begin_undo_group()\r\n\r\n if (count > 1 || @rl_explicit_arg)\r\n rl_kill_text(opoint, @rl_point)\r\n else\r\n rl_delete_text(opoint, @rl_point)\r\n end\r\n # Emacs puts point at the beginning of the sequence of spaces.\r\n if (@rl_point < @rl_end)\r\n opoint = @rl_point\r\n _rl_insert_char(l, ' ')\r\n @rl_point = opoint\r\n end\r\n\r\n rl_end_undo_group()\r\n\r\n 0\r\n end",
"def to_offset(text, position); end",
"def []=(i,val)\n entry_length = struct_class_length\n \n unless (0...(length / entry_length)).include? i\n raise ArgumentError, \"index out of range: #{i}\"\n end\n \n unless val.length == entry_length\n raise ArgumentError, \"wrong entry length: #{val.length} != #{entry_length}\"\n end\n \n _old_replace_substr(entry_length * i, entry_length, val)\n end",
"def []=(key, value)\n offset = append(key, value)\n index(key, offset)\n end",
"def appendCharacters (string, stringNo)\n\n\tstring.each { | key, value | \n\t\ttemp = {stringNo + key =>value}\n\t\tstring.delete(key)\n\t\tstring = string.merge(temp)\n\t}\n\n\treturn string\n\nend",
"def inject_original_value (data,data_record,key,new_name)\n log.debug \"injecting original \", key\n\n if (data_record.length > 2)\n separator = SEPARATOR\n else\n separator = ''\n end\n # by inserting the details into the start of the string we only need to find the initial bracket\n # there is no need to parse the structure, worry about escaped characters etc\n data_record.insert(data_record.index('{')+1, '\"'+new_name+'\":'+data[key].to_s + separator)\n return data_record\n end",
"def pos=(n)\n n += @string.length if n.negative?\n raise RangeError, \"index out of range\" if n.negative?\n raise RangeError, \"index out of range\" if n > @string.length\n\n @current = n\n end",
"def offset= offset\n @value = nil\n @offset = offset\n end",
"def replace(word, letter, ind)\n (word[0...ind] || '') << letter << (word[ind+1..-1] || '')\nend",
"def set_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def char_replace!(str, hash)\n\n str.each_char.with_index do |char, idx|\n if hash.has_key?(char)\n str[idx] = hash[char]\n else\n str[idx] = char\n end\n end\n\n str\nend",
"def value=(new_value)\n new_value = new_value[0...(self.strings.size)] + 0.chr #limit the size, add 0-byte\n new_value.bytes.each_with_index do |byte,index|\n self.strings[index].value = byte.chr\n end\n end",
"def prepend(input, string); end",
"def calculateOffset(index, offset)\n index += offset\n index -= 26 while index >= 26 # keep subtracting until we get to the right range\n index\n end",
"def license_key_formatting(s, k)\n s = s.upcase.delete('-')\n\n i = s.length - 1\n\n until i < 0\n k.times do\n i-= 1\n end\n s[i] += '-' if i >= 0\n end\n\n s\n\nend",
"def fix(value)\n value.concat('!')\n value = value.upcase\n value << 'xyz'\nend",
"def mod_shift(chr, offset)\n @alph[(@alph.index(chr) + offset) % @alph.length]\n end",
"def update!(**args)\n @begin_offset = args[:begin_offset] if args.key?(:begin_offset)\n @content = args[:content] if args.key?(:content)\n end",
"def offset(value)\n merge(offset: value.to_s)\n end",
"def []=( index, value )\r\n @ary[index + @offset] = value\r\n end",
"def parse_and_set_offset(offset)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.RunEditor_parse_and_set_offset(@handle.ptr, offset)\n result\n end",
"def setbit(key, offset, value); end",
"def setbit(key, offset, value); end",
"def insert_string(str, pos)\n StringInserter.new(self, str, pos).insert_string\n end",
"def insert_string(str)\n bytes = str.codepoints << 0\n # To keep the alignment we need to pad the new string we're inserting.\n # In total, we're adding the string bytes + 2 bytes string length + 4 bytes string index.\n padding = (4 - (bytes.size * 2 + 2 + 4) % 4) % 4\n padding_bytes = [0] * padding\n next_string_offset = new_string_offset\n\n string_bytes = ResStringPool.utf16_str_len(str.codepoints) + bytes.pack('v*') + padding_bytes.pack('C*')\n\n # Write string data into the string data section.\n @data.insert(next_string_offset, string_bytes)\n # Insert new string index entry. The offset needs to be relative to the start of the string data section.\n @data.insert(last_string_index_offset + 4, [next_string_offset - (@offset + @string_start)].pack('V'))\n\n # We added the bytes of the string itself + a new string index entry\n string_bytes.size + 4\n end",
"def encrypt(content, offset)\n # Decrypting and crypting contains more or less the exact same code.\n # The difference between those two methods is that decrypting by default takes a positive offset\n # as negative in its calculations. That is why we, when calling the decrypting method, turn our offset\n # around. With that being said, we go from + to - or - to + before executing our method call.\n # As our encrypting method is supposed to return the encrypted content uppercase, \n # and decrypt returns the decrypted content lowercase, we call string's member method upcase.\n\n return decrypt(content, offset * -1).upcase\nend",
"def setValue(row, str, value, offset = 0)\n\t\tif(!row)\n\t\t\traise 'row is nil'\n\t\tend\n\t\t@headerH[str] ||= addHeaders([str])\n\t\tindex = @headerH[str] + offset\n\t\t#参照先の値も変更できるように、破壊メソッドを使う。row[@headerH[str]] = valueでは、参照先が切り替わってしまうので、値の置き換えにならない。\n\t\t#findなどで取得したrowに対して処理を行う際に必要な変更。\n\t\tif(row[index].class == String)\n\t\t\trow[index].sub!(/^.*$/, value)\n\t\telse\n\t\t\t#raise('not string error.')\n\t\t\t#todo 強烈なバグな気もするが、例外を回避し値を代入2010年12月15日\n\t\t\tbegin\n\t\t\t\trow[index] = value.to_s\n\t\t\trescue\n\t\t\t\trow[index] = ''\n\t\t\tend\n\t\tend\n\tend",
"def update!(position:, keys:)\n initial_value = metadata.dig(*keys)\n return unless initial_value\n\n new_value = _update!(initial_value, position, keys)\n\n update_metadata(keys: keys, value: new_value)\n nil\n end",
"def mask(key, from = 4)\n str = key.dup\n if str && str.length > from\n str[from...str.length] = \"X\" * (str[from...str.length].length)\n end\n\n str\n end",
"def decrypt(content, offset)\n content = content.dup\n\n raise ArgumentError, 'String must not be empty' if content.empty?\n\n raise ArgumentError, 'Offset must not be zero' if offset == 0\n\n content.upcase!\n\n # We create an instance of a Hash to eazily access values and keys in our algorithm.\n # The reason to why I decided to go with a Hash over an array was simple, it makes us able to go\n # from character => index, index => character instead of an array where its index => character. \n\n character_hash = {\"A\" => 0, \"B\" => 1, \"C\" => 2, \"D\" => 3, \"E\" => 4, \"F\" => 5,\n \"G\" => 6, \"H\" => 7, \"I\" => 8, \"J\" => 9, \"K\" => 10, \"L\" => 11,\n \"M\" => 12, \"N\" => 13, \"O\" => 14, \"P\" => 15, \"Q\" => 16, \"R\" => 17,\n \"S\" => 18, \"T\" => 19, \"U\" => 20, \"V\" => 21, \"W\" => 22, \"X\" => 23,\n \"Y\" => 24, \"Z\" => 25}\n\n # We iterate over each character in the content variable.\n # For each character we move it by the offset variable's value within the character_hash interval.\n # Then we replace the character with the new character.\n\n content.split(\"\").each_with_index do |character, index|\n if character == \" \"\n next\n end\n \n # Get the character's value in character_hash\n character_hash_index = character_hash[character]\n \n # Calculate new value for the character within the character_hash interval relative to offset.\n character_hash_index = interval_value(character_hash_index, character_hash.size, offset)\n # Replace the character with the character we calculated in the character_hash interval.\n content[index] = character_hash.invert[character_hash_index]\n end\n\n # Return the decrypted variable content in small characters.\n return content.downcase\nend",
"def pad_key(plaintext, key)\n key += key while key.size < plaintext.size\n key = key.slice(0, plaintext.size) if key.size > plaintext.size\n [plaintext, key]\n end",
"def overwrite_metadata(metadata, section, key, value)\n return unless key.is_a?(String) || key.is_a?(Symbol)\n\n metadata[section] ||= {}\n metadata[section][key] = value\n end",
"def offset_on_line(offset)\n end",
"def kesha_maker(arr)\n arr.each { |str| str[2] = \"$\" }\nend",
"def update!(**args)\n @partition_key = args[:partition_key] if args.key?(:partition_key)\n end",
"def offset!(obj, len) #@todo V should be nil not ''\n [_offset_from_length(obj, len), (obj.slice!(0..len-1) || '')].reverse\n end",
"def _patch_part(text_part, text_orig, sline, eline)\n lines = text_orig.split(\"\\n\", -1)\n lines[(sline -1) ..(eline-1)] = text_part.split(\"\\n\", -1)\n lines.join(\"\\n\")\n end",
"def lset(key, index, value); end",
"def lset(key, index, value); end",
"def update!(**args)\n @byte_offset = args[:byte_offset] if args.key?(:byte_offset)\n @index = args[:index] if args.key?(:index)\n end",
"def char_replace!(str, hash)\n\nend",
"def write_key(*key); end",
"def replace_first(input, string, replacement = T.unsafe(nil)); end",
"def fill_with char\n fill_from_with(0 , char)\n end",
"def pad_string(str)\n str.scan(/..../).reverse.join.dup.insert(0,'*****').insert(9,'*').insert(18,'*').insert(27,'*').insert(36,'*').insert(41,'*****')\n end",
"def write(path, str, offset = 0, opts = {})\n mode = (offset || 0) > 0 ? 'r+' : (opts[:mode] || 'w')\n\n file.open(path, mode, opts[:perm] || 0o644) do |io|\n io.pos = offset if offset != 0\n io.write(str)\n end\n end",
"def update!(**args)\n @char_offset = args[:char_offset] if args.key?(:char_offset)\n @confidence = args[:confidence] if args.key?(:confidence)\n @time_offset = args[:time_offset] if args.key?(:time_offset)\n end",
"def macPatchValue(info, key, newValue)\n\tindex1 = info.index(\"<key>\" + key + \"</key>\", 0)\n\tindex1 = info.index(\"<string>\", index1)\n\tindex1 = index1 + 7\n\tindex2 = info.index(\"</string>\", index1)\n\tinfo = info[0..index1] + newValue + info[index2..-1]\nend",
"def text_at(location, offset, length)\n line = lines[location[0] - 1]\n line[location[1] + offset, length]\n end",
"def LetterChanges(input_string, offset)\n\n\talphabet = ('a'..'z').to_a\n\tnew_word = []\n\tstring = input_string.split(\"\")\n\n\tstring.each do |letter|\n\n\t\tcurrent_letter_index = alphabet.find_index(letter)\n\t\tcounter = 0\n\n\t\twhile counter < offset\n\t\t\tif current_letter_index < (alphabet.length - 1)\n\t\t\t\tcurrent_letter_index = current_letter_index + 1\n\t\t\t\tcounter += 1 \n\t\t\telse\n\t\t\t\tcurrent_letter_index = 0\n\t\t\t\tcounter += 1\n\t\t\tend\n\t\tend\n\n\t\tnew_word << alphabet[current_letter_index]\n\n\tend\n\n\n\treturn new_word.join(\"\")\n \nend",
"def append_without_prefix(string); end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @end_offset = args[:end_offset] if args.key?(:end_offset)\n @start_offset = args[:start_offset] if args.key?(:start_offset)\n end",
"def replace_nth(text, n, old_value, new_value)\n\tif n <= 0\n\t\treturn text\n\tend\n\n\tget_instances = text.split(\"\").each_with_index.select {|char, index| char === old_value}.each_with_index.select{|char_instance, index| (index + 1) % n === 0}.map {|entry| entry[0][1]}\n\tnew_text = text.split(\"\")\n\t\n\tfor instance in 0...get_instances.length\n\t\tnew_text[get_instances[instance]] = new_value\n\tend\n\n\treturn new_text.join(\"\")\nend",
"def update!(**args)\n @bolded = args[:bolded] if args.key?(:bolded)\n @byte_offset_begin = args[:byte_offset_begin] if args.key?(:byte_offset_begin)\n @byte_offset_end = args[:byte_offset_end] if args.key?(:byte_offset_end)\n @section = args[:section] if args.key?(:section)\n @token_pos = args[:token_pos] if args.key?(:token_pos)\n end",
"def encrypt(input_text, offset)\n # Error messages for: empty strings & offset == 0.\n raise ArgumentError, 'String must not be empty' if input_text == ''\n raise ArgumentError, 'Offset must not be zero' if offset == 0\n\n # Makes the input text uppercase letters only.\n input_text = input_text.upcase\n\n # Will hold all letters from input_text.\n text_list = []\n\n # Defines each letter with a number using index.\n letter_index = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n\n # The encrypted text goes here.\n encrypted_text = ''\n\n # Stopping infinite loops.\n counter = 0\n\n # Sends each character in the input text in to their own element in an array(text_list).\n while counter < input_text.length\n text_list << input_text[counter]\n counter += 1\n end\n\n # Resets the counter.\n counter = 0\n\n # Goes through each character in the list.\n while counter < text_list.size\n # Resets the new_letter.\n new_letter = ''\n\n # Goes through the alphabet for comparison reasons.\n letter_index.each { |x|\n\n # Error message for: current element in array == nil.\n raise ArgumentError, 'Element must not be nil' if text_list[counter] == nil\n\n # Checks if current element in text_list is = to currently selected letter in the alphabet.\n if text_list[counter] == x\n\n # Declares a temporary variable to hold the new offset.\n temp = letter_index.index(text_list[counter]) + offset\n\n # Makes sure that the offset for a new letter isn't a value that is bigger than the lenght of the alphabet.\n if temp > letter_index.size - 1\n temp = temp - letter_index.size\n end\n\n # Declares which new letter whom is to be added to the encrypted text.\n new_letter = letter_index[temp]\n end\n }\n\n # Makes sure to keep spaces so the text don't get messy.\n if new_letter == ''\n new_letter = text_list[counter]\n end\n\n # Adds the new letter to the end of the encrypted text.\n encrypted_text += new_letter\n\n # Increments the counter.\n counter += 1\n end\n\n # Returns the encrypted text.\n return encrypted_text\nend",
"def caesar_cipher(sentence, raw_offset)\r\n offset = raw_offset % 26\r\n sentence.gsub(/([a-zA-Z])/){|char| shift_the_letter(char.ord, offset).chr}\r\nend",
"def offset(value)\n merge(sroffset: value.to_s)\n end",
"def set_hash_offset(opts)\n opts = check_params(opts,[:offsets])\n super(opts)\n end",
"def fix(value)\n value << 'xyz'\n value = value.upcase\n value.concat('!')\nend",
"def set_Offset(value)\n set_input(\"Offset\", value)\n end",
"def set_Offset(value)\n set_input(\"Offset\", value)\n end",
"def write_string_to(key, string, mtime: nil)\n mtime ||= Time.now\n copy_io_to(key, StringIO.new(string), Digest::MD5.base64digest(string), string.length, mtime: mtime)\n end",
"def copy_string(start_pos, end_pos)\n res = @str[start_pos...end_pos]\n res.gsub!(/\\000/, '')\n res\n end",
"def set_data_from(strt_index,raw_arr)\n $test_logger.log(\"Set data from location #{strt_index}\")\n @data.fill(strt_index,raw_arr.size) {|i|\n \n @data[i] = BioPacket.swap_dword(raw_arr[i-strt_index]) \n }\n #@data.concat(raw_arr)\n build_cmd\n end",
"def get_note_at_offset(note, offset)\n note = note.to_s\n # If the note ends with a number, increase it by offset and add it on again.\n if note.end_with?(\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\")\n octave = note[note.length - 1].to_i + offset\n return note.chop + octave.to_s\n else\n # Otherwise, just use the number 4 (default)\n return note + (offset + 4).to_s\n end\n end",
"def append_object_from_string(bucket_name, key, data, options={})\n data_md5 = Digest::MD5.base64digest(data)\n append_object(bucket_name, key, data, options['offset'], data_md5, data.bytesize, options)\n end",
"def fill_key_name\n self.key_name = key_name&.parameterize(separator: '_')\n end",
"def ltrim(key, start, stop); end",
"def ltrim(key, start, stop); end",
"def replace(line)\n # get the actual offset\n start = @buffer.get_iter_at_offset(@@offset)\n\n # Delete all\n @buffer.delete(start, @buffer.end_iter)\n\n # Save the new offset\n @@offset = @buffer.end_iter.offset\n\n # insert the old command\n @buffer.insert(@buffer.end_iter, line)\n end"
] |
[
"0.69160527",
"0.6080193",
"0.6005277",
"0.57910573",
"0.568737",
"0.5649233",
"0.5616926",
"0.5605164",
"0.5605164",
"0.5605164",
"0.5599434",
"0.5599434",
"0.55837566",
"0.5574692",
"0.55335915",
"0.55315244",
"0.55315244",
"0.543442",
"0.5410416",
"0.54051703",
"0.5392307",
"0.53503615",
"0.5337714",
"0.5316347",
"0.5257776",
"0.51962304",
"0.51914567",
"0.51646584",
"0.51496255",
"0.5141121",
"0.5133912",
"0.5127226",
"0.51245695",
"0.512265",
"0.5104219",
"0.5103104",
"0.50869375",
"0.5074727",
"0.5064173",
"0.50464076",
"0.5011819",
"0.49845737",
"0.49806148",
"0.4969895",
"0.49691385",
"0.49469212",
"0.49453261",
"0.494243",
"0.4919268",
"0.4911975",
"0.49114913",
"0.490811",
"0.490811",
"0.49062052",
"0.49012825",
"0.48982167",
"0.4896052",
"0.4892557",
"0.48903573",
"0.48893255",
"0.48789325",
"0.48782727",
"0.48701125",
"0.4860194",
"0.485831",
"0.48565492",
"0.4826386",
"0.48169857",
"0.48169857",
"0.4800094",
"0.4787486",
"0.47840658",
"0.47679007",
"0.47621235",
"0.47620112",
"0.47557104",
"0.47529548",
"0.47510943",
"0.47440907",
"0.47434846",
"0.47348902",
"0.47340792",
"0.47319746",
"0.47220767",
"0.4717609",
"0.4711851",
"0.4710493",
"0.47089624",
"0.47032464",
"0.46960396",
"0.46960396",
"0.46934137",
"0.46875453",
"0.4685509",
"0.4682412",
"0.46819192",
"0.46802238",
"0.46771336",
"0.46771336",
"0.4676083"
] |
0.534628
|
22
|
Get a substring of the string stored at a key.
|
def getrange(key, start, stop)
send_command([:getrange, key, Integer(start), Integer(stop)])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [](key)\n if path_portion = fragment.split(\"/\").find {|i| i.include?(key.to_s)}\n return path_portion.sub(\"#{key}=\", \"\")\n end\n \n nil\n end",
"def get_string(key)\n get(key, \"Z\")\n end",
"def get(key, *si)\n raise(ArgumentError, \"Argument 'key' must be a String or an Array of Strings.\") unless key.is_a?(String) || key.nil? || key.is_a?(Array) && key.grep(String).length == key.length\n return key.map{ |k| self.[](k, *si) } if key.is_a?(Array) # Allow batch translation of strings\n value = (@strings[key] || key).to_s.clone\n # Substitution of additional strings.\n si.compact.each_with_index{ |s, i|\n value.gsub!(/\\%#{i}/, s.to_s)\n }\n value.gsub!(/\\%\\%/,\"%\")\n return value.chomp\n end",
"def segment(str, key_len)\n\tstr_arr = str.split(//)\n\tparts = str_arr.each_slice(key_len).to_a\n\treturn parts\nend",
"def protocol_value_for_key_in_string(key, string)\n string.split(/#{key}:\\t*/)[1].to_s.split(\"\\n\").first\n end",
"def extract_string(str, key, &block)\n block.(key, str)\n end",
"def get(key)\n raise 'key must be a String' unless key.is_a?(String)\n shard_for(key.to_s).find_by(distkey => key)\n end",
"def sub_hash(hash, key); end",
"def get_string(key)\n @strings ||= {}\n if @strings.key?(key)\n result = @strings[key]\n else\n str = QueuedEmailString.find_by(queued_email_id: id, key: key.to_s)\n result = @strings[key] = str ? str.value.to_s : nil\n end\n result\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def substring(str, substr)\n\nend",
"def substring_at(index, length: length)\n bytes.to_a[index, length].map(&:chr).join\n end",
"def parse_key(key)\n key.split(/[\\[\\]]/).select { |str| !str.empty? }\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def fetch(key)\n @root.fetch(key.upcase.split(\"\"))\n end",
"def get(key)\n @content[key]\n end",
"def get(key)\n @content[key]\n end",
"def get(key)\n parts = key.split('.')\n curs = self\n while p = parts.shift\n curs = curs.send(p)\n end\n curs\n end",
"def substring(string, beg_idx, end_idx = beg_idx)\n string[beg_idx..end_idx]\nend",
"def get_from_key(key)\n @bucket_key_map[key]\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def closest_string_in_front(key_string, sub_string)\n\n\t\tpositions = []\n\t\tlast_pos = nil\n\t\tmy_string = \" \" + to_str\n\t\tkey_pos = my_string.index(key_string)\n\t\tif key_pos.nil?\n\t\t\t#puts \"WARNING: closest_string_in_front PASSED A string THAT DID NOT INCLUDE key_string\"\n\t\t\treturn nil\n\t\telse\n\t\t\tmy_string = my_string.slice(0..key_pos+1)\n\t\tend\n\n\t\twhile (last_pos = my_string.index(sub_string, (last_pos ? last_pos + 1 : 0)))\n\t\t\tpositions << last_pos\n\t\tend\n\n\t\tif positions != []\n\t\t\treturn_string = my_string[key_pos-positions.map{|p| (p-key_pos).abs}.min..key_pos-1]\n\t\t\treturn return_string.match(sub_string).to_s\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def get(key)\n @content[key]\n end",
"def get_from_key(key)\n @bucket_key_map[key]\n end",
"def take(key)\n return do_get(key, true)\n end",
"def [] key\n return @hash[key.to_s]\n end",
"def get(key)\n Lib.get @path, @no_follow, key.to_s\n end",
"def get(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key \n return ele[1]\n end\n end\n end",
"def getValue(hash, key)\n key.to_s.split('.').inject(hash) { |h, k| h[k] unless h.nil? }\n end",
"def get key\n deserialize backend.get key.to_s rescue nil\n end",
"def fetch(key)\n return @body.fetch(key.upcase, nil)\n end",
"def get_string(key=nil)\n if key.class == String && block_given?\n @j_del.java_method(:getString, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(key,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling get_string(#{key})\"\n end",
"def get(key)\n b = get_as_bytes(key)\n\n return nil if b.nil?\n\n b.pack(\"U*\").strip\n end",
"def string(key) # :nodoc:\n Tree.string_table[key.to_s]\n end",
"def string_include_key?(string, key)\n return true if string == key\n l = string.length\n k_l = key.length\n i = 0\n while i < (l - k_l)\n # return true if string[i ... i + k_l] == key\n return true if string_include_key?(string[i ... i+k_l], key)\n # val = string_include_key?(string[0 ... i], key)\n i += 1\n end\n false\nend",
"def rest_of_key(namespace)\n return nil if @key == namespace\n\n key = @key.to_s\n\n index = key.index(namespace.to_s) && (namespace.to_s.length + 1)\n key[index, key.length].to_sym if index\n end",
"def get(namespace, key); end",
"def part_of_word\n @str[@first_letter..@last_letter]\n end",
"def get_single_key(key)\n key = @size+key if key < 0\n r = @results[key]\n unless r.nil? && key < @size\n r\n else\n retrieve_for_index(key)\n @results[key]\n end\n end",
"def get(key)\n subkeys = key.split('.')\n lastkey = subkeys.pop\n subhash = subkeys.inject(@config) do |hash, k|\n hash[k]\n end\n return nil if subhash.nil?\n\n subhash.key?(lastkey) ? subhash[lastkey] : nil\n end",
"def get_value_from_combined_key(key, field)\n index = BlacklightBrowseNearby::Engine.config.combined_key_pattern.split(delimiter).map{|p|p.strip}.index(field)\n key.split(delimiter)[index].strip\n end",
"def []( key )\n raise \"Key must be a Symbol or String\" unless key.is_a?( Symbol ) || key.is_a?( String )\n\n res = self.of(@section)[key]\n res = res.dup? ? res.dup : res\n res\n end",
"def parse_key(key)\n key.to_s.split(\"[\").map {|component|component.gsub(/]/,\"\")}\n end",
"def get(key)\n end",
"def get(key)\n get_all(key).first\n end",
"def on_call_substring(context, haystack, start, length = nil)\n haystack_str = on_call_string(context, haystack)\n start_index = on_call_number(context, start).to_i - 1\n\n if length\n length_int = on_call_number(context, length).to_i - 1\n stop_index = start_index + length_int\n else\n stop_index = -1\n end\n\n return haystack_str[start_index..stop_index]\n end",
"def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end",
"def [](key)\n @raw[utf8(key)]\n end",
"def string_include_key?(string, key)\n return true if key.length == 0\n return false if string.length == 0\n\n if string[0] == key[0]\n string_include_key?(string[1..-1], key[1..-1])\n else\n string_include_key?(string[1..-1], key)\n end\nend",
"def substring(startIndex,endIndex=-1)\n begin\n if(endIndex==-1)\n substr= @container[startIndex..@container.length] \n elsif(endIndex!=0)\n substr=@container[startIndex..(endIndex-1)]\n else\n substr=\"\"\n end\n rescue\n substr=nil\n end\n return substr \n end",
"def string_include_key?(string, key)\n return true if key.length == 0\n\n next_key_char = key.chars.first\n key_index = string.index(next_key_char)\n\n return false if key_index.nil?\n string_include_key?(string[key_index+1..-1], key[1..-1])\nend",
"def parse_key(key)\n end",
"def get(key)\n end",
"def get_str(offset, len)\n @buf[offset..offset+len-1]\n end",
"def substring_remainder\n if @matches.nil?\n @buffer\n else\n start_index = substring_up_to_match.length\n @buffer[start_index..-1]\n end\n end",
"def [](key)\n old_bracket(key).chomp.split(PROTEIN_DELIMITER)\n end",
"def getvalue(key)\n\n\t\tpath = \"/etc/libvirt/qemu/\" #Debian/ubuntu path for qemu's xml files\n\t\textension = \".xml\"\n\t\targuments = [key, path + resource[:name] + extension]\n\t\tline = grep arguments\n\t\n\t\treturn line.split('>')[1].split('<')[0]\t\n\n\tend",
"def middle_substring(str)\n mid = str.length / 2\n str.length.even? ? str[mid-1..mid] : str[mid]\nend",
"def parse_key(key)\n array = key.split(\"[\")\n array.map do |i| \n if i.include?(\"]\") \n i.chop\n else\n i\n end\n end\n end",
"def fetch(key); end",
"def get(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n return @a[row][column][1] \n else\n return -1\n end\n end",
"def split_and_parse_key(key)\n key.split(/(?<!\\\\)\\./).reject(&:empty?).map do |key_part|\n case key_part\n when /^\\.\\$/ # For keys in the form of .$key\n key_part.gsub(/^\\./, '')\n when /\\A[-+]?[0-9]+\\z/\n key_part.to_i\n else\n key_part.gsub('\\\\', '')\n end\n end.reject { |k| k == '$body' }\n end",
"def [](key)\n\t\treturn self.fetch(key.downcase, nil)\n\tend",
"def [](key)\n entry = find_entry(key)\n return(entry.nil? ? nil : entry[1])\n end",
"def get key\n @redis.get key\n end",
"def substrings_at_start(str)\n str.each_char.map.with_index do |char, index|\n str[0..index]\n end\nend",
"def middle_substring(str)\n length = str.length\n if length.odd?\n str[length/2]\n else\n str[length/2-1,2]\n end\nend",
"def get(key)\n send_command([:get, key])\n end",
"def get(key)\n key = normalize(key) or return\n table[key]\n end",
"def [](key)\n @hash[key.to_s]\n end",
"def from_simple_key(key)\n key\n end",
"def get key; call key; end",
"def middle_substring(str)\n mid = str.length / 2\n str.length.odd? ? str[mid] : str[mid-1..mid]\nend",
"def get(key)\n response = db.get_item(@table_name, {'HashKeyElement' => {'S' => key}})\n get_item_from_body(response.body)\n end",
"def get(key)\n s3_read key\n end",
"def middle_substring(str)\n mid = str.length/2\n if str.length%2==0\n return str[mid-1..mid]\n else\n return str[mid]\n end\nend",
"def [](key)\n @data[key.to_s]\n end",
"def [](key)\n\n lookup(key.to_s)\n end",
"def get_key_value_for_param(key_value, service_params)\n return nil if key_value.nil?\n params_index = service_params.index(key_value)\n return nil if params_index.nil?\n params_index = service_params.index('=', params_index)\n return nil if params_index.nil?\n params_index += 1\n end_index = service_params.index(',', params_index)\n if end_index.nil?\n end_index = params_index\n return nil if end_index >= service_params.length\n end_index = service_params.length\n end\n service_params[params_index...end_index]\n end",
"def fetch(*key); end",
"def val_for key\n split(\"\\n\").grep(\n key.is_a?(Regexp) ? key : /(^|^[^\\w]*\\s+)#{Regexp.escape(key)}\\b/\n ).map {|l|\n l.sub(/^[^\\w]*\\s+/, '').\n sub(key.is_a?(Regexp) ? key : /^#{Regexp.escape(key)}\\b\\s*[:=]?/, '').\n sub(/[;,]\\s*$/, '').\n strip\n }.first || ''\n end",
"def substrings_at_start(str)\n str.chars.map.with_index { |_, idx| str[0, idx + 1] }\nend",
"def split_key(str)\n if (str =~ /^(.+?)\\\\(.*)$/)\n [ $1, $2 ]\n else\n [ str, nil ]\n end\n end",
"def parse_key(key)\n key.split(\"[\").each {|string| string.gsub!(\"]\",\"\")}\n end",
"def t(hash, key)\n key.split('.').inject(hash) { |r, seg| r[seg] if r }\n end",
"def substrings_at_start(str)\n str.chars.map.with_index do |_, i|\n str[0..i]\n end\nend",
"def _get(key)\r\n\t\treturn _get_with_connection(@connection, @store_name, key, true)\r\n end",
"def abbrev_key(key_str)\n key_str[0, 5] + ' ' + key_str[5, 5] + ' ' +key_str[10, 5]\nend",
"def get_key(line)\n line.match(/-k ([^ ]+)/)[1]\n end",
"def parse_key(key)\n key.split(/\\]\\[|\\[|\\]/).reject(&:empty?)\n end",
"def extract(key_value)\n return *key_value\n end",
"def substrings(string)\r\n \r\nend",
"def parse_key(key)\n key.dup.split(/\\]\\[|\\[|\\]/)\n end",
"def [](key)\n data[key.to_s]\n end",
"def [](*key)\n get(*key)\n end",
"def [](key)\n value = @sdbm[key.to_s]\n return nil unless value\n\n if value =~ /\\A~(\\d+)\\z/\n value = $1.to_i.times.map do |idx|\n @sdbm[\"#{key}~#{idx}\"] || @sdbm[\"#{key}---#{idx}\"] ||\n raise(\"missing key: \" + \"#{key}~#{idx}\".inspect)\n end.join\n end\n\n Marshal.load(value)\n end",
"def get(key)\n \txk = key % 10001 \n \ttheend = (xk + 10000) % 10001\n xk = (xk + 1) % 10001 while @arr[xk].first != key && xk != theend\n return @arr[xk].last if @arr[xk].first == key\n -1\n end",
"def [](key)\n (start, length) = @index[key]\n return nil unless start\n @io.seek(start)\n string = @io.read(length)\n string.chomp!\n string.split(\"\\t\")\n end"
] |
[
"0.66220564",
"0.657902",
"0.6445188",
"0.6444402",
"0.6265102",
"0.6218933",
"0.6081815",
"0.606387",
"0.60474527",
"0.60285056",
"0.5937909",
"0.5891969",
"0.5852809",
"0.5843318",
"0.58313644",
"0.579623",
"0.579623",
"0.57638097",
"0.57410693",
"0.57177776",
"0.57171756",
"0.57171756",
"0.57171756",
"0.57171756",
"0.56992036",
"0.568143",
"0.5668954",
"0.5666985",
"0.5651174",
"0.5624377",
"0.56222904",
"0.560874",
"0.56004053",
"0.5582808",
"0.55782384",
"0.55574405",
"0.5551878",
"0.55454236",
"0.5543409",
"0.55412304",
"0.5525206",
"0.55193007",
"0.55091983",
"0.54930794",
"0.5491595",
"0.54860556",
"0.54668546",
"0.54477626",
"0.5446832",
"0.5428259",
"0.5424689",
"0.5422708",
"0.5411736",
"0.5408731",
"0.5386999",
"0.5382853",
"0.5379657",
"0.53735334",
"0.53598934",
"0.5353346",
"0.53419244",
"0.53386843",
"0.5337741",
"0.5331216",
"0.5330793",
"0.5325816",
"0.53241944",
"0.5321581",
"0.5318095",
"0.53174454",
"0.53075135",
"0.53054774",
"0.5301006",
"0.5298908",
"0.5298323",
"0.52940243",
"0.5290226",
"0.5289206",
"0.5287031",
"0.52833366",
"0.5282896",
"0.52799547",
"0.52732",
"0.5267114",
"0.5260767",
"0.52604395",
"0.52585727",
"0.52573127",
"0.5256058",
"0.52499795",
"0.5248478",
"0.5247602",
"0.5242841",
"0.5242777",
"0.524229",
"0.5242066",
"0.52347994",
"0.52317464",
"0.5230736",
"0.52255255",
"0.5224607"
] |
0.0
|
-1
|
Append a value to a key.
|
def append(key, value)
send_command([:append, key, value])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def append(key, value)\n perform(:append, key, value.to_s)\n end",
"def append(key, value); end",
"def append(key, value); end",
"def append(key, value)\n node_for(key).append(key, value)\n end",
"def add(key, value)\n\t\t\t\tself[key] = value\n\t\t\tend",
"def append value\n add_idx = empty? ? 0 : last_key + 1\n self[add_idx] = value\n end",
"def add(key, value)\n @hash[key] = value\n self\n end",
"def add(key, value)\n end",
"def append!(key, value); end",
"def append!(key, value); end",
"def set_add(key, value)\n perform_update(:set_add, key, value.to_s)\n end",
"def add(key, value); end",
"def add(key, value)\n change(:add, key, value)\n end",
"def add(key, value)\n update_array(key, value, :add)\n end",
"def []= key, value\n @internal_hash[key].push value\n value\n end",
"def <<(value)\n connection.rpush key_label, value\n end",
"def add(key, value)\n context.add(key, value)\n end",
"def append_to_hash (key, intermediatekey, value )\n if not self.has_key?(key)\n self[key] = Hash.new(false)\n end\n (self[key])[intermediatekey] = value\n end",
"def add(key, value)\n @hash[key] = value\n @reverse[value] ||= []\n @reverse[value] << key\n end",
"def append_attribute(key_, value_)\n attribute(key_, value_, :append)\n end",
"def add(keyvalue)\n if keyvalue.is_a? String\n @hash[keyvalue] = nil\n else\n keyvalue.each do |key, value|\n @hash[key] = value #create key-value pair in @hash\n end\n end\n end",
"def put(key, value)\n \n end",
"def put(key, value)\n position = search(key)\n if (key <=> @keys[position]) == 0\n @values[position] = value\n else\n @keys.insert(position, key)\n @values.insert(position, value)\n end\n end",
"def add_pair(key, value)\r\n @redis.set(key, value)\r\n end",
"def put(key, value); end",
"def []= key, value\n @hash[key.to_s] = value\n end",
"def lpush(key, value)\n node_for(key).lpush(key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, hash, value)\n @hash[key] = value\n @key_hash.add(key, hash)\n end",
"def add_data(key, value)\n @data[key] = value\n end",
"def _addElement( key, value )\n @token.addElement( key, value )\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def put(key, value)\n #if key exists\n if a_hash[key] != nil\n a_hash[key] = value\n end\n end",
"def put(key, value)\n @root = put_rec(@root, key, value, 0)\n end",
"def put(key, value)\n idx, bucket = find_bucket_and_index(key)\n if idx\n bucket[idx] = [key, value]\n else\n bucket << [key, value]\n end\n end",
"def append2_to_hash (key, intermediatekey, value )\n if not self.has_key?(key)\n self[key] = Hash.new(Array.new)\n end\n self[key].append(intermediatekey,value)\n end",
"def add_key(key)\n keys.add(key)\n end",
"def []=(key, value)\n offset = append(key, value)\n index(key, offset)\n end",
"def new_key(list, key, value)\n\tlist[key] = value\nend",
"def set(key , value)\n index = key_index(key)\n if( index )\n self.keys.set(index , value)\n else\n self.keys.push(key)\n self.values.push(value)\n end\n value\n end",
"def []=(key, value)\n new_entry = entry_to_modify(key, value)\n new_entry[:key] = key\n new_entry[:value] = value\n end",
"def put(key, value)\n @first.put(key, value)\n end",
"def lpush(key, value); end",
"def lpush(key, value); end",
"def add(key, value, placer = AppendPlacer.new)\n element = placer.new_element(self)\n element[:key] = key\n element[:value] = value\n element[:operation] = :add\n end",
"def add(k, v)\n\t\titem = Item.new(k, v)\n\t\t@h.add(item)\n\t\treturn\n\tend",
"def addkey(key, value, school)\n school[key] = value\nend",
"def add(key, value)\n if key.empty?\n @value = value\n else\n letter = key.shift\n if !@children[letter]\n @children[letter] = Node.new()\n end\n @children[letter].add(key, value)\n end\n end",
"def add_extra(key, value)\n @extras[key] = value\n end",
"def set(key, value)\n @value[key.to_sym] = value if key\n end",
"def add(key, value)\n #recursive\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root.add(key.to_s.upcase.split(\"\"), value)\n return self\n end",
"def []=(key, value)\n @hash[key.to_s] = value\n end",
"def add(key, value, ttl=nil, options=nil)\n set(key, value, ttl, options) unless @store.has_key?(key)\n end",
"def add_hash(hash, key, value)\n return hash[key] = value\nend",
"def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current]\n # update new value if key exists\n current_and_parent_pair[:current].value = value\n else\n new_node = TreeNode.new(key,value)\n parent = current_and_parent_pair[:parent]\n link_node_to_parent(parent, new_node)\n end\n end",
"def []=(key, value)\n self.put(key, value)\n end",
"def add(key, value)\n index = key_index(key)\n\n # Only happens if we didn't check the presence before calling this method\n return nil if index == -1\n\n rehash_step if rehashing?\n\n hash_table = rehashing? ? rehashing_table : main_table\n entry = hash_table.table[index]\n\n entry = entry.next while entry && entry.key != key\n\n if entry.nil?\n entry = DictEntry.new(key, value)\n entry.next = hash_table.table[index]\n hash_table.table[index] = entry\n hash_table.used += 1\n else\n raise \"Unexpectedly found an entry with same key when trying to add #{ key } / #{ value }\"\n end\n end",
"def []=(key, value)\n entry = find_entry(key)\n @dirty = true\n if entry.nil?\n @entries << [key, value]\n else\n entry[1] = value\n end\n end",
"def add_value(section, key, value)\n check_modify\n (@data[section] ||= {})[key] = value\n end",
"def add_to_url(key, value, params)\n params.merge(key => (params.fetch(key, []) | [value]))\n end",
"def rpush(key, value); end",
"def rpush(key, value); end",
"def add_key_value?(key, val)\n hash = load_hash\n return false if hash.key? key\n hash[key] = val\n store_hash hash\n true\n end",
"def set(key, value=nil)\n @data[key.to_s] = value\n end",
"def put(key, value)\n obj = KeyValue.find_by_key(key)\n if obj\n KeyValue.update(obj.id, :value=>value)\n else\n KeyValue.create(:key=>key, :value=>value)\n end\n end",
"def rpush(key, value)\n node_for(key).rpush(key, value)\n end",
"def add_key(key,value) \n\t\tSCHOOL[key]=[value]\n\tend",
"def update(key, value)\n set(key.to_sym => value)\n end",
"def append(key, value)\n # Requires memcached 1.2.4\n check_return_code(\n Lib.memcached_append(@struct, key, value.to_s, IGNORED, IGNORED),\n key\n )\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end",
"def newkey(key, value, schoolvar)\n\tschoolvar[key] = value \nend",
"def set(key, value)\n\t\t\t\t# TODO This could be a bit more efficient:\n\t\t\t\tself.delete(key)\n\t\t\t\tself.add(key, value)\n\t\t\tend",
"def set(key, value)\n peek[key.to_sym] = value\n end",
"def []=(key, value)\n key = namespaced_key(key)\n @keys << key\n set(key, value)\n end",
"def append(name, val)\n name = name.to_sym\n val = val.to_s\n if @values.key?(name)\n @values[name] << val\n else\n self[name]= val\n end\n val\n end",
"def store_value(timestamp, key, value)\n # Prepend the timestamp so we always have unique values\n @redis.zadd(key, timestamp, \"#{timestamp}:#{value}\")\n end",
"def add(key, value = key)\n @store.append(HeapNode.new(key, value))\n curr = @store.length - 1\n\n curr = heap_up(curr)\n end",
"def put(key, value)\n row = key >> 10\n puts \"Insert: #{key},#{value} => row = #{row}\" if @d\n column = @a[row].index{|(i,v)| i == key}\n\n if column\n @a[row][column][1] = value\n else\n @a[row].push([key, value])\n end\n end",
"def []=(key, value=nil) \n\n # If we are assigning something to nil, let's remove it\n if value.nil?\n delete(key)\n sleep @key_sleep.to_f\n nil\n else\n\t persistent = (value[:persistent].nil? ? 0 : (value[:persistent] ? 1 : 0))\n\t \n Klass.addKey(@handle, key.to_s, value[:value].to_s, persistent)\n sleep @key_sleep.to_f\n value[:value].to_s\n end\n end",
"def append!(key, value)\n super\n @fiber.resume if @waiting_for == key\n end",
"def []= key, value\n @data[key] = value\n end",
"def []= key, value\n @data[key] = value\n end",
"def write(key, value)\n perform_update(:write, key, value.to_s)\n end",
"def put(key, value)\n node = node_for_key(key)\n node.write(value)\n end",
"def put(key, value)\n @root = put_node(@root, key, value, 0)\n end",
"def add(key)\n @internal_hash[key] = true\n end",
"def add_node(key, val)\n @store.append(key, val)\n end",
"def []=(key, value)\n hash[key] = value\n end",
"def set(key, value, expires_in = 0)\n remove(key)\n expires = nil\n if expires_in > 0\n expires = Time.now.utc + expires_in\n end\n @store.push({ key: build_key(key), value: value, expires: expires})\n end",
"def add(key, *value)\n run { conf.add(key, value, config_params) }\n end",
"def []=(key, value)\n self[key].value = value\n end",
"def []=(key, value)\n self[key].value = value\n end",
"def insert(key, val)\n (0..key.size-1).each do |i|\n @hash[key[0..i]] ||= {}\n @hash[key[0..i]][key] = val\n end\n end",
"def lpushx(key, value)\n node_for(key).lpushx(key, value)\n end",
"def set(key, value)\n @namehash[key.to_sym][0] = value\n end",
"def []=(key, value)\n @hash[key] = value\n end",
"def handle_key_append(key, value, cfg_dir, list_keys, path_keys, cfg)\n this_value = handle_key(key, value, cfg_dir, list_keys, path_keys, cfg)\n cfg[key] = [] unless cfg.has_key?(key)\n\n begin\n cfg[key].concat(this_value).uniq!\n rescue NoMethodError\n end\n end"
] |
[
"0.84017235",
"0.8304687",
"0.8304687",
"0.828599",
"0.8084607",
"0.7937106",
"0.79326266",
"0.78343666",
"0.7794228",
"0.7794228",
"0.762247",
"0.75847954",
"0.75204664",
"0.7502489",
"0.742414",
"0.739131",
"0.7365538",
"0.7352885",
"0.7317122",
"0.7270993",
"0.720927",
"0.713306",
"0.7127067",
"0.7115191",
"0.7102521",
"0.7095286",
"0.70899504",
"0.7018106",
"0.7018106",
"0.7018106",
"0.7018106",
"0.6991254",
"0.6981972",
"0.69623905",
"0.6931417",
"0.6921647",
"0.6914594",
"0.6903958",
"0.68904436",
"0.6877925",
"0.68475556",
"0.6834898",
"0.6834718",
"0.68181396",
"0.6818011",
"0.6815882",
"0.6815882",
"0.68033355",
"0.6801321",
"0.67996925",
"0.67956245",
"0.6794986",
"0.6776449",
"0.6765171",
"0.6760072",
"0.6754619",
"0.6740998",
"0.67398685",
"0.6709365",
"0.66975206",
"0.66972786",
"0.6693865",
"0.667999",
"0.66770685",
"0.66720307",
"0.66720307",
"0.6671398",
"0.66710204",
"0.66512054",
"0.6648489",
"0.66434795",
"0.6639435",
"0.6632687",
"0.6621208",
"0.66160566",
"0.66145384",
"0.6604952",
"0.66042095",
"0.6584712",
"0.6581353",
"0.65760005",
"0.6575254",
"0.6573851",
"0.6573506",
"0.6573506",
"0.657193",
"0.6568391",
"0.65548176",
"0.6541065",
"0.6507454",
"0.6502714",
"0.6499357",
"0.6498078",
"0.6489124",
"0.6489124",
"0.6487402",
"0.64812285",
"0.6481042",
"0.64664984",
"0.6456473"
] |
0.7856952
|
7
|
Set the string value of a key and return its old value.
|
def getset(key, value)
send_command([:getset, key, value.to_s])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key=(value)\n raise TypeError, 'key must be a String or respond to #to_s' unless value.is_a?(String) || respond_to?(:to_s)\n \n @key = value.to_s\n end",
"def []=(key, value)\n setValueForKey(key.to_s, value.to_s)\n end",
"def []=(key,value)\n ruby_set(key&&key.to_s, value)\n end",
"def set(key, value=nil)\n @data[key.to_s] = value\n end",
"def key=(value)\n @key = value.to_s\n end",
"def get_and_set(key, value); end",
"def set_key_value(key, val, options={})\n # metadata = get_key_metadata(key, options)\n key_value = val.nil? ? nil : val.to_s.strip\n self.value[key] = key_value\n key_value\n end",
"def set(key, value); end",
"def set(key, value); end",
"def set_value(key, value)\n @store_[key] = value\n YakvdConstants.success\n end",
"def value=(new_value)\n key_escaped = Object.escape_key(@key)\n\n response = @s3.request_put(\"/#{@bucket.name}/\" +\n \"#{key_escaped}\", new_value)\n @s3.error?(response)\n \n return new_value\n end",
"def key=(key)\n if (!key.kind_of?(String))\n raise ArgumentError, \"Expected String, but #{key.class} provided.\"\n end\n @key = key\n end",
"def set(key, value)\n @value[key.to_sym] = value if key\n end",
"def []=(key, value)\n\n set_field(key.to_s, value)\n end",
"def set(key, value)\n value = JSON.dump(value) unless value.is_a?(String)\n @hash[key] = value\n end",
"def set(key, value)\n end",
"def []=(key, value)\n @data[key.to_s]=value\n end",
"def set( key, value )\n unless key.is_a?( Key )\n k = UniMap.str_to_key( key )\n unless k\n raise IndexError, \"No Key named #{key.inspect} in UniMap.KEY_SPACE\"\n end\n key = k\n end\n set_k( key, value )\n end",
"def []=(key, value)\n @hash[key.to_s] = value\n end",
"def key=(value)\n @key = value.nil? ? nil : value.to_s\n end",
"def []=(key, value)\n return nil unless key\n if @data[key.to_s]\n @data[key.to_s] = value\n elsif @data[key.to_sym]\n @data[key.to_sym] = value\n else\n @data[key] = value\n end\n end",
"def set(key, value)\n peek[key.to_sym] = value\n end",
"def set(key, value)\n Lib.set @path, @no_follow, key.to_s, value.to_s\n end",
"def []= key, value\n @hash[key.to_s] = value\n end",
"def []=(key, value)\n key = key.to_s if key.is_a? Symbol\n self.old_store(key, value)\n end",
"def set(key, value)\n @namehash[key.to_sym][0] = value\n end",
"def set(key, value)\n change(:set, key, value)\n end",
"def set(key, value)\n self.data ||= {}\n self.data[key.to_s] = value\n self.save!\n end",
"def []=(key, value)\n\t\tself.store(key.downcase.strip, value.strip)\n\tend",
"def []=(key, value)\n coerced_value = coercion(key).present? ? coercion(key).call(value) : value\n old_setter(key, coerced_value)\n end",
"def set(key, value)\n case key\n when Symbol\n return instance_variable_set(\"@#{key}\", value)\n when String\n return instance_variable_set(\"@#{key}\", value)\n end\n end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def []=(key, value)\n object = @bucket.get_or_new sanitize_key(key)\n object.raw_data = Marshal.dump(value)\n object.content_type = \"application/x-ruby-marshal\"\n object.store\n value\n end",
"def set(key, value)\n @store[key] = value\n end",
"def set( key, value )\n fail NotImplementedError\n end",
"def key=(new_key)\n @key = new_key\n end",
"def []=(key, value)\n self.attributes[key.to_sym] = value\n save\n value\n end",
"def set(key, value)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def value=(v)\n connection.set(key, v)\n end",
"def []=(key, value=nil) \n\n # If we are assigning something to nil, let's remove it\n if value.nil?\n delete(key)\n sleep @key_sleep.to_f\n nil\n else\n\t persistent = (value[:persistent].nil? ? 0 : (value[:persistent] ? 1 : 0))\n\t \n Klass.addKey(@handle, key.to_s, value[:value].to_s, persistent)\n sleep @key_sleep.to_f\n value[:value].to_s\n end\n end",
"def []=(key_name, value)\n set(key_name, value)\n end",
"def set_value(key, value)\n database[key] = value\n removed_keys.delete(key)\n end",
"def update(key, value)\n set(key.to_sym => value)\n end",
"def []=(key, value)\n set(key, :val => value)\n end",
"def set(key, value)\n settings.send :\"#{key}=\", value\n end",
"def change_key=(value)\n @change_key = value\n end",
"def key=(value)\n @key = value\n end",
"def key=(value)\n @key = value\n end",
"def field_set(key, value)\n field = self.class.fetch_field(key.to_sym)\n send \"#{key}=\", field.coerce(value)\n end",
"def []=(key, value)\n self.put(key, value)\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def set(key, value)\n @manager.store(key, value)\n { key => value }\n end",
"def setting(key)\n @hash[key]\n end",
"def []=(key, value)\n put(key, value, :replace => true)\n end",
"def set(key, value)\n self.data[key] = { value: value, timestamp: Time.now.to_i }\n self.data[key][:value]\n end",
"def []=(key, value)\n raise TypeError, \"String expected\" unless key.is_a? String\n raise TypeError, \"String or Hash expected\" unless value.is_a? String or value.is_a? Hash\n \n @inihash[key] = value\n end",
"def []=(key, val)\n self.setObject(val, forKey: key.to_s)\n self.synchronize\n end",
"def key=(value); end",
"def []=(key, value)\n set(key, value)\n end",
"def []=(key, value)\n put(key, value)\n end",
"def []=(key, value)\n set(key, value)\n end",
"def []=(key, value)\n set(key, value)\n end",
"def []=(key, value)\n @data[key.to_sym] = convert value\n end",
"def set(key, value)\n raise NotImplementedError\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def set(key, value)\n update(key) { |option| @data[option.name] = cast(value, option.type) }\n end",
"def []=(key, value)\n self[key].value = value\n end",
"def []=(key, value)\n self[key].value = value\n end",
"def set_field(key, value)\n @form_fields.setField key.to_s, value.to_s\n end",
"def set(key, val)\n return unless val\n db[key] = val\n end",
"def set(key, value)\n run_hook(:before_set, key, value)\n db[key] = value\n run_hook(:after_set, key, value)\n value\n end",
"def []=(key, value)\n return @data[key] = value\n end",
"def set(key, value)\n @json_dict[key] = value\n end",
"def set(key, value)\n @content[key] = value\n end",
"def []=( key, value )\n context.store(key.to_s, value)\n end",
"def []=( key, val )\n\t\t@form[ key.to_s ] = val\n\tend",
"def []=(key, value)\n @metadata[key.to_s] = value\n end",
"def []=(key, value)\n @metadata[key.to_s] = value\n end",
"def []= key, value\n super(key.to_s, value)\n end",
"def set(key, value)\n return nil if not key\n\n key = key.to_sym if key.class == String\n section = ForjDefault.get_meta_section(key)\n\n return @oConfig.set(key, value) if not section\n return nil if readonly?(key)\n _set(section, key, value)\n end",
"def set(key, value)\n messages[key] = value\n end",
"def put(key, value)\n \n end",
"def []=(key , value)\n set(key, value)\n end",
"def []=(key, value)\n store(key, value)\n end",
"def []=(key, value)\n store(key, value)\n end",
"def []=(key, value)\n store(key, value)\n end",
"def []=(key, value)\n data[key] = value\n end",
"def []=(key,value)\n key = lookup_key(key)\n @new_info[key.to_s] = value\n end",
"def set(key, value)\n @content[key] = value\n end",
"def updateKey; @key = getKey; self end",
"def []=(key, value)\n data[key] = value\n end",
"def set(key, value)\n\t\t\t\t# TODO This could be a bit more efficient:\n\t\t\t\tself.delete(key)\n\t\t\t\tself.add(key, value)\n\t\t\tend",
"def []=(key, value)\n return super if has_key?(key)\n alt = alternate_key(key)\n has_key?(alt) ? super(alt, value) : super\n end",
"def []=(key, value)\n super(convert(key), value)\n end",
"def []=(key, value)\n\t\t\traise_on_undeclared(key)\n\t\t\traise_on_value(key, value)\n\t\t\t\n\t\t\treturn @storage.delete(key) if value.nil?\n\t\t\treturn @storage[key] = value\n\t\tend",
"def []=(key, value)\n stored = false\n\n self.each_key { |k|\n if (k.downcase == key.downcase)\n self.store(k, value)\n stored = true\n end\n }\n\n self.store(key, value) if (stored == false)\n self.dcase_hash[key.downcase] = value\n end",
"def []=(key, value)\n store(key, value)\n end",
"def getset(key, value); end"
] |
[
"0.7275936",
"0.7059648",
"0.7056077",
"0.70361114",
"0.6950887",
"0.69140714",
"0.6758175",
"0.6754377",
"0.6754377",
"0.67415184",
"0.6726618",
"0.66994923",
"0.66890574",
"0.6664882",
"0.6651859",
"0.6650504",
"0.6598903",
"0.6589563",
"0.65787095",
"0.65645856",
"0.6547675",
"0.654181",
"0.6528943",
"0.6505327",
"0.64847463",
"0.64509225",
"0.64436656",
"0.640415",
"0.62759995",
"0.6275325",
"0.62625295",
"0.6253353",
"0.6251452",
"0.6251025",
"0.6235197",
"0.6230991",
"0.62285537",
"0.621659",
"0.6208671",
"0.61807626",
"0.615854",
"0.61473364",
"0.6124978",
"0.61247396",
"0.6117937",
"0.61064816",
"0.60991144",
"0.60991144",
"0.60809803",
"0.60803926",
"0.60800445",
"0.60800445",
"0.6070755",
"0.6059301",
"0.6057396",
"0.6054266",
"0.60429645",
"0.6028781",
"0.60205567",
"0.6019363",
"0.60176516",
"0.60144395",
"0.60144395",
"0.60073054",
"0.60028297",
"0.59829926",
"0.59829926",
"0.5982235",
"0.59744143",
"0.59744143",
"0.5968604",
"0.59684634",
"0.5963401",
"0.5948034",
"0.5945274",
"0.5945212",
"0.59438664",
"0.59344",
"0.59333366",
"0.59333366",
"0.59249794",
"0.5910611",
"0.5910412",
"0.5908584",
"0.5906286",
"0.59005004",
"0.59005004",
"0.59005004",
"0.5900283",
"0.5893939",
"0.5893813",
"0.58907604",
"0.5888679",
"0.5886343",
"0.58824587",
"0.5879767",
"0.58779854",
"0.58711815",
"0.5869043",
"0.5858243"
] |
0.6317226
|
28
|
Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success.
|
def getdel(key)
send_command([:getdel, key])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete key\n rv = self[key]\n self.removeField key\n return rv\n end",
"def delete(key)\n response = request(:delete, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n else\n nil\n end\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def getdel(key); end",
"def getdel(key); end",
"def delete(key)\n\n end",
"def delete(key)\n value = self[key]\n\n @memcached.delete key\n\n value\n end",
"def delete(key)\n perform_delete(:delete, key)\n end",
"def delete_key(key)\n end",
"def delete(key, args={})\n data = request_data(:delete, key_uri(key), args)\n return nil unless data\n data[S_PREV_NODE][S_VALUE]\n end",
"def delete(key)\n pop if change_key(key, nil, true)\n end",
"def delete key\n write_data_entry key, nil, true\n @keydict[key] = nil\n\n sync\n end",
"def delete(key)\n v = @store.delete(key)\n v ? v.value : v\n end",
"def delete key\n @internal_hash[key].clear\n end",
"def delete\n redis.del key\n end",
"def delete(key)\n return Nvmkv::kv_delete(@kv_id, @pool_id, key)\n end",
"def delete(key)\n @hash.delete(key.to_s)\n end",
"def delete(key)\n @succ.delete key\n end",
"def del(key)\n @first.del(key)\n end",
"def remove(key, options = {})\n fetch({:method => :delete, :key => key, :body_to_params => true, :body => options}).parsed_response\n end",
"def delete(key)\n\n # FIXME: insert code that connects to the backend and affects the delete\n # operation\n #\n # - This delete should be done atomically\n # - Convert any exceptions into a failed status result with a meaningful\n # error message.\n #\n\n { :result => false, :err_msg => 'FIXME: not implemented' }\n end",
"def delete(key)\r\n if record = touch(key)\r\n @store.delete(key)\r\n @head = @tail = nil if @store.length.zero?\r\n record[:value]\r\n end\r\n end",
"def remove(key); end",
"def getdel(key)\n node_for(key).getdel(key)\n end",
"def delete _key\n store.transaction() { |s| s.delete(prepare_key(_key)) }\n end",
"def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end",
"def delete(key)\n data.delete(key)\n @deleted_hash[key] = nil\n end",
"def del(key)\n position = find(key)\n if position != nil\n # delete\n value = @values[position]\n @slots[position] = nil\n @values[position] = nil\n value\n else\n nil\n end\n end",
"def delete(key)\n dummy = Pair.new(key,nil)\n pair = @tree.remove(dummy)\n return nil unless pair\n return pair.value\n end",
"def delete(key)\n @hash.delete key\n @key_hash.delete key\n end",
"def remove(key)\n Lib.remove @path, @no_follow, key.to_s\n end",
"def delete(key)\n unimplemented\n end",
"def delete(key)\n @internal_hash.delete(key)\n end",
"def unset_value(key)\n database.delete(key)\n removed_keys << key\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def remove(key)\n\n end",
"def delete(key = nil)\n key ? self.data.delete(key) : self.data.clear\n end",
"def delete(key = nil)\n key ? self.data.delete(key) : self.data.clear\n end",
"def delete( key )\n fail NotImplementedError\n end",
"def delete_pair(key)\r\n @redis.del key \r\n end",
"def delete(key)\n timeout_retry(3, 3){\n write \"DEL #{key}\\r\\n\"\n integer_reply == 1\n }\n end",
"def delete(key)\n @data.delete(key)\n @key_size.delete(key)\n end",
"def delete( key )\n context.delete(key.to_s)\n end",
"def rem(key, value)\n log(\"get :Deltas, #{key}, #{cache_name(value)}\")\n timestamp = connection.get(:Deltas, key, cache_name(value))\n\n log(\"remove :Deltas, #{key} -> #{timestamp_name(timestamp)}\")\n connection.remove(:Deltas, key, timestamp_name(timestamp))\n\n log(\"remove :Deltas, #{key} -> #{cache_name(value)}\")\n connection.remove(:Deltas, key, cache_name(value))\n end",
"def delete key\n slot = _find_slot(key)\n return nil if !@data[slot]\n value = @data[slot+1]\n @data[slot] = DELETED\n @data[slot+1] = nil\n\n # Unlink record\n n = @data[slot+2]\n prev = @data[slot+3]\n if prev\n @data[prev+2] = n\n end\n if n\n @data[n+3] = prev\n end\n if @first == slot\n @first = n\n end\n if @last == slot\n @last = prev\n end\n\n # FIXME: It fails without this, which indicates a bug.\n #@length -= 1\n value\n end",
"def delete(key)\n transaction do |y|\n y.delete(key)\n end\n end",
"def unset key\n storage.delete key\n end",
"def delete(key)\n result = @rarray.get(key)\n if result\n @rarray.delete(result)\n store\n else\n raise ArgumentError,'Cannot delete - no matching id', caller \n end\n end",
"def delete(key, options = nil)\n @hash.delete(key)\n end",
"def delete(key)\n key = alternate_key(key) unless has_key?(key)\n super\n end",
"def delete(value)\n @hash.delete(value) && @hash.send(:convert_key, value)\n end",
"def decr(key); end",
"def decr(key); end",
"def clear_by_key(key)\n delete(key)\n end",
"def delete key\n\t\tdata = @data_base.delete key\n\t\tupdate_database\n\t\tdata\n\tend",
"def delete(key)\n if value = @hash[key]\n @reverse[value].delete(key)\n @reverse.delete value if @reverse[value].empty?\n @hash.delete key\n end\n end",
"def del\n connection.del(key_label)\n end",
"def delete(key, options = {})\n old_key_present = key_exists?(key)\n value = @data[key]\n @data.delete(key)\n @key_access_store.delete(key)\n @cache_size -= compute_value_size(value) if @cache_size > 0 && old_key_present\n end",
"def remove(value)\n connection.zrem(key_label, value)\n end",
"def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end",
"def remove(key)\n with_client do |client|\n client.del(build_key(key))\n end\n end",
"def del(key)\n ensure_connected\n num = redis_handler.del(key.to_s)\n fail ArgumentError, \"Unknown key, cannot delete\" if num == 0\n end",
"def delete key, opts ={}\n return if readonly?\n response.delete_cookie key, opts\n end",
"def delete(key)\n raise NotImplementedError\n end",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def delete_data(key)\n @data.delete(key)\n end",
"def delete(key, &block); end",
"def delete(key)\n @redis.delete(key)\n end",
"def delete(key)\n rv = @data.has_key?(key)\n @data.delete(key)\n rv\n end",
"def delete_entry(key, **options)\n rescue_error_with(false) { @data.with { |c| c.delete(key) } }\n end",
"def delete(key)\n super(convert_key(key))\n end",
"def shell_registry_deletekey(key, view)\n key = normalize_key(key)\n # REG DELETE KeyName [/v ValueName | /ve | /va] [/f]\n shell_registry_cmd_result(\"delete \\\"#{key}\\\" /f\", view)\n end",
"def delete(key)\n raise NotImplementedError\n end",
"def delete(key)\n raise NotImplementedError\n end",
"def delete(key)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def delete(key)\n storage.transaction {storage.delete(key)}\n end",
"def delete(key)\n put(key, nil) if servers?\n end",
"def del(key)\n @meta.delete(key.to_sym) if key\n end",
"def remove\n heroku.remove_key(args.first)\n display \"Key #{args.first} removed.\"\n end",
"def remove\n heroku.remove_key(args.first)\n display \"Key #{args.first} removed.\"\n end",
"def delete(key)\n super(convert_key(key))\n end",
"def delete_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").delete\n nil\n end",
"def delete(key)\n position = search(key)\n return if (key <=> @keys[position]) != 0\n @keys.delete_at(position)\n @values.delete_at(position)\n end",
"def delete(key)\n return unless in?(key)\n\n hash_index = hasher(key, @keys.size)\n\n if @keys[hash_index] == key\n @keys[hash_index] = nil\n @values[hash_index] = nil\n else\n next_key_index = rehash(hash_index, @keys.size)\n\n while @keys[next_key_index] != nil and @keys[next_key_index] != key\n next_key_index = rehash(next_key_index, @keys.size)\n end\n\n @keys[next_key_index] = nil\n @values[next_key_index] = nil\n end\n end",
"def pop\n conn.rpop key\n end",
"def delete_entry(key, options)\n @hash.delete(key)\n end",
"def delete\n @mapper.delete(@remote_key)\n\n forget\n end",
"def delete\n connection.delete(\"/#{URI.escape(@key)}\", @bucket_name)\n end",
"def delete(key)\n @monitor.synchronize do\n entry = @stash.delete(key)\n if entry\n @expires_at.delete(entry)\n entry.value\n else\n nil\n end\n end\n end",
"def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n end",
"def delete(key)\n return if @no_update == true\n @store.transaction do\n @store.delete(key)\n end\n end",
"def delete(key)\n db.delete(key)\n end",
"def destroy\n @key.destroy\n end"
] |
[
"0.78800714",
"0.7846711",
"0.78098875",
"0.78098875",
"0.78098875",
"0.78098875",
"0.78098875",
"0.7728809",
"0.7728809",
"0.76398957",
"0.7554374",
"0.75538796",
"0.75500077",
"0.7517569",
"0.7509904",
"0.74682623",
"0.74482524",
"0.74388283",
"0.742984",
"0.7425656",
"0.738342",
"0.73713225",
"0.73369205",
"0.728345",
"0.72653466",
"0.72578514",
"0.722619",
"0.7225999",
"0.72248495",
"0.7221387",
"0.7208284",
"0.7195041",
"0.7167323",
"0.7166123",
"0.7153199",
"0.713452",
"0.7128831",
"0.71287555",
"0.71149683",
"0.71149683",
"0.71149683",
"0.71067595",
"0.7090754",
"0.7090754",
"0.70837075",
"0.7078794",
"0.7060979",
"0.70604604",
"0.7028153",
"0.7027272",
"0.70262015",
"0.70227915",
"0.7006631",
"0.700183",
"0.69959307",
"0.6981857",
"0.69645464",
"0.69624406",
"0.69624406",
"0.69580805",
"0.69478214",
"0.6936666",
"0.69365966",
"0.69129646",
"0.6903349",
"0.69016576",
"0.68973315",
"0.689182",
"0.68902606",
"0.68832284",
"0.68789434",
"0.68789434",
"0.6876738",
"0.6874888",
"0.68595463",
"0.6856647",
"0.68414843",
"0.68377894",
"0.6831454",
"0.68269724",
"0.68269724",
"0.6822079",
"0.68207383",
"0.6817627",
"0.68127257",
"0.68055326",
"0.68055326",
"0.67749363",
"0.67669594",
"0.6752597",
"0.6750855",
"0.6735183",
"0.6734405",
"0.6729373",
"0.67251277",
"0.67152584",
"0.6712558",
"0.67046404",
"0.6701498",
"0.67010736"
] |
0.80624545
|
0
|
Get the value of key and optionally set its expiration. GETEX is similar to GET, but is a write command with additional options. When no options are provided, GETEX behaves like GET.
|
def getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false)
args = [:getex, key]
args << "EX" << Integer(ex) if ex
args << "PX" << Integer(px) if px
args << "EXAT" << Integer(exat) if exat
args << "PXAT" << Integer(pxat) if pxat
args << "PERSIST" if persist
send_command(args)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def getex(key, **options); end",
"def get(key, expires_in = 0, &block)\n\n end",
"def getex(key, **options)\n node_for(key).getex(key, **options)\n end",
"def get(key, expires_in = 0)\n k = build_key(key)\n\n value = with_client do |client|\n client.get(k)\n end\n\n if !value.nil? && value.strip.empty?\n value = nil\n else\n value = deserialize(value) unless value.nil?\n end\n\n if value.nil? && block_given?\n value = yield\n set(key, value, expires_in)\n end\n\n value\n end",
"def fetch(key, options = {})\n value = $redis.get(key)\n value = JSON(value) if value\n\n unless value\n value = yield\n # TODO: why not setex\n $redis.pipelined do\n $redis.set(key, value.to_json) if value.present?\n $redis.expire(key, options[:ttl] || 600)\n end\n end\n value\n end",
"def get(key, req_options = nil)\n perform(:get, key, req_options)\n end",
"def fetch key, exp=60, &block\n get(key) or block.().tap {|x| set(key, x, exp)}\n end",
"def get(key, options = nil)\n @hash[key]\n end",
"def get(key)\n return do_get(key, false)\n end",
"def setex(key, ttl, value)\n send_command([:setex, key, Integer(ttl), value.to_s])\n end",
"def get(key)\n send_command([:get, key])\n end",
"def fetch(key, options = {})\n options ||= {}\n value = read(key, options) unless options[:force]\n\n if value.nil? && block_given?\n value = yield(key)\n write(key, value, options)\n end\n\n value\n end",
"def cache_store(key, value, options = {})\n ttl = options[:ttl] || @options[:expires_in]\n\n @client.setex(key, ttl, ::Marshal.dump(value))\n\n return value\n end",
"def psetex(key, ttl, value)\n send_command([:psetex, key, Integer(ttl), value.to_s])\n end",
"def get(key, ttl=60)\n if !enabled?\n return (block_given? ? yield : nil)\n end\n k = namespaced key\n cached = @r[k]\n return JSON.parse(cached) if cached\n if block_given?\n val = yield\n put(key, val, ttl)\n val\n else\n nil\n end\n end",
"def set(key, value, expires_in = 0)\n\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def write(key, value, options = nil)\n value = value.to_s if options && options[:raw]\n ttl = options ? (options[:ttl] || options[:expires_in] || @default_ttl) : @default_ttl\n raw = options ? options[:raw] : nil\n if options && options[:unless_exist]\n add(key, value, ttl, raw)\n else\n set(key, value, ttl, raw)\n end\n end",
"def get(key, expires_in = 0, &block)\n\n #look for the cache item in the store\n items = @store.select { |i| i[:key] == build_key(key) }\n item = if !items.empty? then items[0] else nil end\n #check if a valid item was found in the store\n if item == nil || (item[:expires] != nil && item[:expires] <= Time.now.utc)\n #a valid item wasn't found so check if a hydration block was specified.\n if block_given?\n #create the item from the block\n value = yield\n #put the item in the store\n set(build_key(key), value, expires_in)\n return value\n else\n #no hydration block was specified\n\n #check if an expired item was found\n if item != nil\n #remove the expired item from the store\n remove(build_key(key))\n end\n return nil\n end\n end\n\n #return the item\n return item[:value]\n end",
"def get(key, *args, &block)\n raise ArgumentError, 'block required by not given' unless block_given?\n digest = hashed_key_and_args(key, *args)\n client.get(digest) || set(key, *args, &block)\n end",
"def psetex(key, ttl, value); end",
"def psetex(key, ttl, value); end",
"def get(key, lifetime: 2**32, dirty: false, &block)\n if block_given?\n return @hash[key][:value] if (dirty || @dirty) && locked? && expired?(key) && @hash.key?(key)\n synchronized { calc(key, lifetime, &block) }\n else\n rec = @hash[key]\n if expired?(key)\n return rec[:value] if dirty || @dirty\n @hash.delete(key)\n rec = nil\n end\n raise 'The key is absent in the cache' if rec.nil?\n rec[:value]\n end\n end",
"def expire(key, seconds, nx: nil, xx: nil, gt: nil, lt: nil)\n args = [:expire, key, Integer(seconds)]\n args << \"NX\" if nx\n args << \"XX\" if xx\n args << \"GT\" if gt\n args << \"LT\" if lt\n\n send_command(args, &Boolify)\n end",
"def get(key)\n end",
"def get(key, timestamp)\n \n end",
"def fetch(key, options = {})\n @logger_off = true\n if !options[:force] && value = read(key, options)\n @logger_off = false\n log(\"hit\", key, options)\n value\n elsif block_given?\n @logger_off = false\n log(\"miss\", key, options)\n\n value = nil\n seconds = Benchmark.realtime { value = yield }\n\n @logger_off = true\n write(key, value, options)\n @logger_off = false\n\n log(\"write (will save #{'%.5f' % seconds})\", key, nil)\n\n value\n end\n end",
"def psetex(key, ttl, value)\n node_for(key).psetex(key, ttl, value)\n end",
"def get(key)\n mon_synchronize do\n perform [\"get\", key]\n end\n end",
"def get(key)\n mon_synchronize do\n perform [\"get\", key]\n end\n end",
"def setex(key, ttl, value); end",
"def setex(key, ttl, value); end",
"def setex(key, ttl, value)\n node_for(key).setex(key, ttl, value)\n end",
"def call(key, ttl: ShopifyClient.config.cache_ttl, &block)\n value = get(key)\n\n if value.nil?\n value = block.()\n\n set(key, value, ttl: ttl)\n end\n\n value\n end",
"def set(key, value, options={})\n body = {:value => value}\n if ttl = options[:ttl]\n body[:ttl] = ttl\n end\n response = request(:post, uri(key), body: body)\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n end",
"def get(key, mtime)\n return nil unless @cache.key?(key)\n\n if @cache[key][:mtime] >= mtime\n @cache[key][:value]\n else\n delete(key)\n nil\n end\n end",
"def _get(key)\r\n\t\treturn _get_with_connection(@connection, @store_name, key, true)\r\n end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def gat(key, ttl = nil)\n perform(:gat, key, ttl_or_default(ttl))\n end",
"def get(key)\n Lib.get @path, @no_follow, key.to_s\n end",
"def get(key)\n end",
"def get(key, opt = {})\n if (attrs = real_get(key, opt)).empty?\n nil\n else\n new(key, attrs)\n end\n end",
"def get(key, opt = {})\n if (attrs = real_get(key, opt)).empty?\n nil\n else\n new(key, attrs)\n end\n end",
"def read(key, options = {})\n synchronize_block do\n set_key_access_strategy(key)\n return @data[key] ? dup_value(@data[key]) : nil\n end\n end",
"def get(key)\n \n end",
"def fetch(key, ttl = nil, req_options = nil)\n req_options = req_options.nil? ? CACHE_NILS : req_options.merge(CACHE_NILS) if cache_nils\n val = get(key, req_options)\n return val unless block_given? && not_found?(val)\n\n new_val = yield\n add(key, new_val, ttl_or_default(ttl), req_options)\n new_val\n end",
"def set(key, value, expires_in = DEFAULT_TTL)\n k = build_key(key)\n\n v = if value.nil? || (value.is_a?(String) && value.strip.empty?)\n nil\n else\n serialize(value)\n end\n\n expiry_int = Integer(expires_in)\n expire_value = expiry_int.positive? ? expiry_int : Integer(DEFAULT_TTL)\n\n with_client do |client|\n client.multi do\n client.set(k, v)\n\n client.expire(k, expire_value)\n end\n end\n end",
"def expire_time(key)\n @store[key].expires_at\n end",
"def expire(key, seconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def getset(key, value)\n send_command([:getset, key, value.to_s])\n end",
"def get(key, default=nil, &block)\n value = options[key]\n value = default if value.nil?\n value = block.call if value.nil? && block\n return value\n end",
"def get!(key)\n record = object(key)\n return nil unless record\n record.rewrite_cache\n record.value\n end",
"def get_and_set(key, value); end",
"def cache key\n begin\n if expired?(key)\n content = Proc.new { yield }.call\n set( key, content )\n end\n content ||= get( key )\n return content\n rescue LocalJumpError\n return nil\n end\n end",
"def set(key, value, ttl: ShopifyClient.config.cache_ttl)\n raise NotImplementedError\n end",
"def get_or_cache(key, expiry = 0, &block)\n return block.call(key) unless servers?\n get(key) || put(key, block.call(key))\n end",
"def key=(key)\n options[:key] = key\n end",
"def get(key, value = nil, *)\n if head && blob = head.commit.tree / key_for(key)\n decode(blob.data)\n end\n end",
"def get(key, value = nil, *)\n if head && blob = head.commit.tree / key_for(key)\n decode(blob.data)\n end\n end",
"def expire(key, seconds, **kwargs); end",
"def getex(key, ex: T.unsafe(nil), px: T.unsafe(nil), exat: T.unsafe(nil), pxat: T.unsafe(nil), persist: T.unsafe(nil)); end",
"def cache_store(key, value, options = {})\n options[:expires] = options.delete(:ttl) || @options[:expires_in]\n @moneta.store(key, value, options)\n end",
"def get(key, log: true)\n key = key&.to_sym\n if @value.key?(key)\n @value[key]\n elsif (meth = option_method(key))\n @value[key] = send(meth)\n elsif log\n Log.warn(\"#{self.class}[#{key.inspect}]: invalid key\")\n end\n end",
"def get(key)\n @manager.retrieve(key)\n end",
"def store(key, value, options = {})\n # todo What's the best way to run these two calls at once, given that it's very much one-at-a-time\n exp = options[:expires_in] ? (Time.now + options[:expires_in]) : nil\n @mongo_collection.update({ '_id' => key }, { '_id' => key, 'data' => value, 'expires' => exp }, { :upsert => true }) # upsert is the best technical term ever.\n \n unless options.has_key?(:bypass_memcache)\n args = [key, value, options[:expires_in] || @options[:memcache_default_expire]].compact\n @memcache.set(*args)\n end\n \n value\n end",
"def write(name, value, options = nil)\n # check :unless_exist option\n return nil if options && options[:unless_exist] && exist?(name)\n\n # create wrapper with expiry data\n wrapper = if options && options[:expires_in]\n { :value => value, :expires_at => expires_in(options).from_now }\n else\n { :value => value }\n end\n\n # call ActiveSupport::Cache::MemoryStore#write\n super(name, wrapper, options)\n end",
"def [](key)\n val = @store[key]\n \n if val\n if val.expired?\n prune\n nil\n else\n val.value\n end\n else\n nil\n end\n end",
"def store(key, value, options = {})\n expiration = options[:expire_after] || @default_expiration\n value = Marshal.dump(value)\n redis_key = prefix(key)\n if expiration > 0\n @redis.setex(redis_key, expiration, value)\n else\n @redis.set(redis_key, value)\n end\n value\n end",
"def getset(key, value); end",
"def getset(key, value); end",
"def get(key)\n raise NotImplementedError\n end",
"def get\n self.class.cast_from_redis redis.get(self.key), @options\n end",
"def cached(key:, ttl: 5.minutes)\n redis = CertManager::Configuration.redis_client\n redis_key = \"User_#{id}_#{key}\"\n value = redis.get(redis_key)\n value = JSON.parse(value) if value\n unless value\n value = yield\n redis.setex(redis_key, ttl, value.to_json)\n end\n value\n end",
"def generic_get(key)\n data[key]\n end",
"def get!(key, default=nil, &block)\n value = get key, default, &block\n raise \"Nil value found for option: #{key}, #{default}\" if value.nil?\n return value\n end",
"def get!(key)\n get(key) || raise(Cooler::KeyNotFound)\n end",
"def get_key_value_\n @redis.hget @url, 'key'\n end",
"def get(key)\n run_hook(:before_get, key)\n value = db[key]\n run_hook(:after_get, key, value)\n value\n end",
"def [](key)\n\t\tget key\n\tend",
"def write(key, value, expires_in: nil)\n @cache[key] = value\n @expires[key] = Faulty.current_time + expires_in unless expires_in.nil?\n end",
"def read(key)\n return if @expires[key] && @expires[key] < Faulty.current_time\n\n @cache[key]\n end",
"def get(key)\n result = connection.query(\"TREG\", \"GET\", key)\n\n Result.parse(result)\n end",
"def get_value (key)\r\n @redis.get key\r\n end",
"def get key; call key; end",
"def write(key, value, options = nil)\n super\n method = options && options[:unless_exist] ? :add : :set\n # memcache-client will break the connection if you send it an integer\n # in raw mode, so we convert it to a string to be sure it continues working.\n value = value.to_s if raw?(options)\n response = @data.send(method, key, value, expires_in(options), raw?(options))\n response == Response::STORED\n rescue MemCache::MemCacheError => e\n logger.error(\"MemCacheError (#{e}): #{e.message}\")\n false\n end",
"def set(key, value, expiry = adapter.configuration.retrieve(:default_expiry, 0))\n do_with_logging(:set, key) do\n expiry = calculate_expiry_time(expiry)\n adapter.set(key.to_s, marshall(value), expiry.to_i)\n logger.info('', '', :expiry, cache_name, key, expiry.to_i)\n value\n end\n end",
"def set key, value, exp\n @redis.setex key, exp, value\n end",
"def set(key, value, **options); end",
"def set(key, value, opts = nil)\n value = parser.encode(value)\n @backend.set(key, value, get_expiry(opts))\n rescue ::Memcached::Error\n nil\n end",
"def fetch(key, default = nil)\n return default unless entry = @cache[\"#{@cache_name}:#{key}\"]\n return entry[:value] if entry[:expires].nil? || entry[:expires] > Time.now\n @cache.delete(\"#{@cache_name}:#{key}\")\n default\n end",
"def expires_value(options, default = config.expires)\n case value = options[:expires]\n when 0, false\n false\n when nil\n default ? default.to_r : nil\n when Numeric\n value = value.to_r\n raise ArgumentError, \":expires must be a positive value, got #{value}\" if value < 0\n value\n else\n raise ArgumentError, \":expires must be Numeric or false, got #{value.inspect}\"\n end\n end",
"def write_entry(key, value, options) # :nodoc:\n method = if options[:unless_exists] || options[:unless_exist]\n :add\n else\n :set\n end\n if ttl = options.delete(:expires_in)\n options[:ttl] ||= ttl\n end\n @data.send(method, key, value, options)\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end",
"def process_setex(command)\n key = command[0]\n seconds = command[1]\n val = command[2]\n options = {:expiration => seconds }\n @connection.put(as_key(key), {@bin => val}, options)\n return 'OK'\n end",
"def add(key, value, ttl=nil, options=nil)\n set(key, value, ttl, options) unless @store.has_key?(key)\n end",
"def get key\n @redis.get key\n end",
"def write(key, value, options = nil)\r\n super\r\n method = (options && options[:unless_exist]) ? :add : :set\r\n @cache.send(method, valid_key(key), value, expires_in(options), marshal?(options))\r\n true\r\n rescue Memcached::Error => e\r\n log_error(e)\r\n false\r\n end",
"def [] (key)\n get(key)\n end"
] |
[
"0.6949803",
"0.66357166",
"0.65973264",
"0.6281269",
"0.62269014",
"0.62249666",
"0.60985285",
"0.60868347",
"0.60264266",
"0.59986705",
"0.5956625",
"0.5946595",
"0.5924147",
"0.5887354",
"0.58578724",
"0.5819998",
"0.5744547",
"0.5744547",
"0.5744547",
"0.5744547",
"0.572396",
"0.5718779",
"0.5708348",
"0.5701041",
"0.5701041",
"0.5672996",
"0.5670442",
"0.5670077",
"0.5668014",
"0.5666829",
"0.5661899",
"0.5655081",
"0.5655081",
"0.56516623",
"0.56516623",
"0.56379855",
"0.56340593",
"0.5595179",
"0.5587378",
"0.5575696",
"0.5561795",
"0.5559552",
"0.5559061",
"0.5556674",
"0.5543356",
"0.5543356",
"0.5533374",
"0.5517441",
"0.5503583",
"0.54720616",
"0.54716706",
"0.5449655",
"0.5446557",
"0.5440916",
"0.5421043",
"0.54152113",
"0.541305",
"0.5405609",
"0.53946656",
"0.5391685",
"0.5381686",
"0.5381686",
"0.5371199",
"0.53416115",
"0.533984",
"0.5327749",
"0.5301332",
"0.5289185",
"0.52624404",
"0.52611405",
"0.5256688",
"0.5255191",
"0.5255191",
"0.52377176",
"0.5233664",
"0.5231035",
"0.52269083",
"0.5223982",
"0.52238965",
"0.5214217",
"0.5212546",
"0.519537",
"0.51944464",
"0.5194192",
"0.51894546",
"0.5182408",
"0.5172115",
"0.51643556",
"0.5162556",
"0.51555216",
"0.51488763",
"0.51451635",
"0.51373607",
"0.5135819",
"0.51307124",
"0.5129858",
"0.51215357",
"0.5120656",
"0.5118695",
"0.5115165"
] |
0.56581837
|
31
|
Get the length of the value stored in a key.
|
def strlen(key)
send_command([:strlen, key])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_length\n key.unpack('b*').first.length\n end",
"def llen(key); end",
"def llen(key); end",
"def length()\n return @i_keys.get_length()\n end",
"def length()\n return self.keys.get_length()\n end",
"def xlen(key); end",
"def strlen(key)\n node_for(key).strlen(key)\n end",
"def llen(key)\n node_for(key).llen(key)\n end",
"def strlen(key); end",
"def strlen(key); end",
"def key_len\n @key_len ||= defaults[:key_len]\n end",
"def length\n @internal_hash.length\n end",
"def length\n keys.length\n end",
"def key_size\n @key_size ||= if (value = @node['keySize'])\n value.to_i\n end\n end",
"def key_size server, key\n server\n .debug(:object, key)\n .scan(/serializedlength:([0-9]+)/)\n .flatten.first.to_i\n end",
"def key_size\n compute_minimal_keys if not @key_length\n @key_length \n end",
"def size\n key.call(\"LLEN\")\n end",
"def length\n hash.keys.length\n end",
"def length\n value.length\n end",
"def length_of_longest_key\n keys = @hash.keys\n unless keys.empty?\n max_word = keys.max { |a, b| a.length <=> b.length }\n return max_word.length\n end\n end",
"def size\n @redis.llen @key\n end",
"def key_length(name); end",
"def hlen(key); end",
"def hlen(key); end",
"def get_token_length(key)\n get_option(key, :token_length)\n end",
"def length\n @val.length\n end",
"def value_length(value)\n value.length\n rescue NoMethodError\n value.to_s.length\n end",
"def _size(domain, key)\n dmid = get_dmid(domain)\n\n sql = <<-EOS\n SELECT length FROM file\n WHERE dmid = #{dmid} AND dkey = '#{@my.quote(key)}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n return res[0].to_i if res && res[0]\n raise MogileFS::Backend::UnknownKeyError\n end",
"def length\n return @ghash.length\n end",
"def size\n return @hash.length\n end",
"def length\n @driver_instance.count_list_value(@key)\n end",
"def size(key)\n @backend.respond_to?(:_size) and return @backend._size(domain, key)\n paths = get_paths(key) or return nil\n paths_size(paths)\n end",
"def size\n keys.size\n end",
"def key_handle_length\n registration_data_raw.byteslice(KEY_HANDLE_LENGTH_OFFSET).unpack('C').first\n end",
"def length\n Integer(connection.write(\"get_length\", false))\n rescue ArgumentError\n 0\n end",
"def length\n Integer(connection.write(\"get_length\", false))\n rescue ArgumentError\n 0\n end",
"def length\n Integer(connection.write(\"get_length\", false))\n rescue ArgumentError\n 0\n end",
"def length\n metadata[:length]\n end",
"def size\n @keys.size\n end",
"def llength(key)\n @client.sendmsg(\"LLENGTH #{key}\")\n read_response.to_i\n end",
"def xlen(key)\n send_command([:xlen, key])\n end",
"def digest_length\n decode[:length]\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def list_length(key)\n timeout_retry(3, 3){\n write \"LLEN #{key}\\r\\n\"\n case i = integer_reply\n when -2\n raise RedisError, \"key: #{key} does not hold a list value\"\n else\n i\n end\n }\n end",
"def length_of(member)\n self::MEMBERS_HASH[member].length\n end",
"def length\n @node[\"length\"]\n end",
"def redis_size(db, k)\n t = db.type(k)\n case t\n when 'string' then db.get(k).length\n when 'list' then db.lrange(k, 0, -1).size\n when 'zset' then db.zrange(k, 0, -1).size\n when 'set' then db.smembers(k).size\n else raise(\"Redis type '#{t}' not yet supported.\") # TODO accommodate more types\n end\nend",
"def length\n return @args[:data].length\n end",
"def size\n self.data.keys.size\n end",
"def slength(key)\n @client.sendmsg(\"SLENGTH #{key}\")\n read_response.to_i\n end",
"def size(key)\n raise \"subclass responsibility\"\n end",
"def length\n @length\n end",
"def size\n @hash_table.keys.length\n end",
"def length()\n return to_s.size\n end",
"def size\n val.size\n end",
"def length(include_deleted = false)\n values(include_deleted).length\n end",
"def length\n @length\n end",
"def length\n @length\n end",
"def length\n @length\n end",
"def size\n @store.keys.count { |k| Time.now - @store[k].stamp < @lifetime }\n end",
"def length\n self.to_s.length\n end",
"def length\n return @args[\"data\"].length\n end",
"def private_key_length\n #Kopal[:kopal_private_key_length] ||\n 2048\n end",
"def size\n @keys.length - 1\n end",
"def size\n BitCounter.count(@val)\n end",
"def length\n pack.length\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_array.length\n end",
"def length\n @_length ||= begin\n raw = _redis.llen(_batch_key)\n return 0 if raw.nil? || raw.zero?\n raise Inconsistency, @uid if raw < PREFIX_COUNT\n raw - PREFIX_COUNT\n end\n end",
"def length() end",
"def length() end",
"def length() end",
"def length() end",
"def size\n return nil if not @value\n return to_s.size\n end",
"def size\n value.size\n end",
"def length\n @results.keys.length\n end",
"def length\n to_s.length\n end",
"def key_count\n $capitals.keys.length\nend",
"def length\n @config[:length]\n end",
"def hlen(key)\n node_for(key).hlen(key)\n end",
"def length\n\n @cache.length\n end",
"def length\n\t\t@length\n\tend",
"def num_keys\n end",
"def length\n to_s.length\n end",
"def size_of attr\n @ref.size_of TRANSLATOR.cocoaify attr\n end",
"def length()\n obj_len = internal_object_length - 1\n return obj_len\n end",
"def length\n @redis.llen @redis_name\n end",
"def find_longest(sorted_data, key)\n keys = sorted_data.map { |h| h[key].to_s }\n return keys.max_by(&:length).length\n end",
"def size\n @hash.size + @converted.size\n end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def size\n @size ||= (@key_map || @row || []).size\n end",
"def length\n @count\n end"
] |
[
"0.8317144",
"0.81746495",
"0.81746495",
"0.80323046",
"0.7957185",
"0.78694016",
"0.7826855",
"0.7804281",
"0.765236",
"0.765236",
"0.7640324",
"0.7622893",
"0.7585785",
"0.75668055",
"0.75172657",
"0.74686134",
"0.7430591",
"0.7389715",
"0.7381224",
"0.7343596",
"0.73418075",
"0.73154354",
"0.7242759",
"0.7242759",
"0.7180002",
"0.7178032",
"0.7137009",
"0.71270883",
"0.70478",
"0.7028955",
"0.70222324",
"0.6999188",
"0.6956982",
"0.6940924",
"0.6903698",
"0.6903698",
"0.6903698",
"0.68582934",
"0.6854249",
"0.68450606",
"0.6817537",
"0.6814542",
"0.68034595",
"0.68034595",
"0.68034595",
"0.6798559",
"0.6690643",
"0.6676448",
"0.66533524",
"0.6635157",
"0.6628589",
"0.66264117",
"0.6622331",
"0.66076",
"0.6591528",
"0.6577355",
"0.6576136",
"0.65725243",
"0.6570363",
"0.6570363",
"0.6570363",
"0.65564936",
"0.65498614",
"0.65456367",
"0.6532058",
"0.65294236",
"0.65291584",
"0.6504424",
"0.64971155",
"0.64971155",
"0.64907956",
"0.6489892",
"0.6489892",
"0.6489892",
"0.6489892",
"0.6482277",
"0.64749163",
"0.6462754",
"0.64562064",
"0.6444021",
"0.64121217",
"0.64072967",
"0.6400348",
"0.6396076",
"0.63928515",
"0.63822204",
"0.63770384",
"0.63740456",
"0.6373699",
"0.63703173",
"0.63672173",
"0.63585645",
"0.63585645",
"0.63585645",
"0.63585645",
"0.63585645",
"0.63585645",
"0.63585645",
"0.63581705",
"0.63559157"
] |
0.7114492
|
28
|
To handle $~, $1, etc
|
def last_match=(match)
if parent
scope = self
while scope.parent
scope = scope.parent
end
scope.last_match = match
else
@last_match = match
end
match
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def preProcess(s)\n n = s.length().to_i\n if n==0\n return \"^$\"\n end\n ret = \"^\"\n (0..n-1).each do |re|\n ret += ('#' + s[re].to_s)\n end\n ret += '#$'\n return ret\nend",
"def regexp=(_arg0); end",
"def sanitize(name)\n #name.gsub(\".\", \"_\").gsub(/<.+>/, \"\")\n name.gsub(\".\", \"_\").gsub(\"$\", \"_\")\nend",
"def pre_match() end",
"def checkTypo(arg,regex)\r\n return !(arg=~regex)\r\nend",
"def get_dollar(prms,ends=nil) #prms='@0;@1;@2' from hot\n @mem_var.each do |k,v| #;p \"#{k}, #{v}\"\n prms.gsub!(k,v)\n if k[0,1]=='*' and Regexp.new(\"~([^~]+)~#{k}\".gsub('*','\\\\*')) =~ @new\n @new.gsub!($~.to_s,(v!='' ? v : $1)) \n else\n @new.gsub!(k,v)\n end\n end\n prms.gsub!(/\\\\\\\\/,'\u001e') #esc char \\\\\n prms.gsub!('\\}','\u001c') #esc char \\}\n prms.gsub!('\\;','\u001d') #esc char \\;\n prms = prms.split(';') #W2Tags::splitter(prms)\n new_prms = @new.scan(/\\$[0-9]/).uniq\n new_alls = @new.scan(/\\$\\*/) #;p 'rpl:',new_alls,new_prms,prms\n @new.gsub!($1,\"<%= \\\"#{$2}\\\" %>\") if /(==(\\$[0-9]))/ =~ @new\n @new.gsub!($1,\"<%= #{$2} %>\") if /(=(\\$[0-9]))/ =~ @new\n if /^@[0-9]$/ =~ prms[0]\n rpl = prms.shift.gsub('@','$')\n repeat = @new\n repeat.gsub!('$0',prms.shift) #repeat.gsub!('$*',rpl)\n @new = ''\n prms.each_with_index do |x,i| #;p \"$0 #{x} => #{repeat}\"\n @new += repeat.gsub(rpl,x)\n if i+1<prms.size\n @new += \"\\n\"+@spc+ends.join(\"\\n\") if ends \n @new += \"\\n\"+@spc \n end\n end\n p \"Rept1: #{@new}\" if @dbg[:parse] \n elsif new_alls==[] && new_prms.size==1 && prms.size>1 \n tmp = \"\"\n rpt = @rgx.to_s.gsub(@rgx[3]+\"\\n\",\"\")\n #multi key params(class,attribute,etc)\n classs = rpt[/([.:#].*\\{.*?\\}.*?) /,1] \n classs = rpt[/(\\{.*?\\}.*?) /,1] if !classs \n classs = rpt[/([.:#].*?) /,1] if !classs \n classs.sub!(/=$/,'') if classs\n clsmlt = classs.to_s.split(';')\n clscnt = clsmlt.length\n clsmlt+= clscnt==1 ? clsmlt*prms.length : ['']*prms.length\n prms.each_with_index do |x,i|\n y = x.strip\n if /^~[-%]/ =~ y\n tmp<< y[1,y.length-1]\n tmp<< \"\\n#{@spc}\" if i+1<prms.size\n else\n line = rpt+x #tmp<< @new.gsub(new_prms[0],x) \n #implement multi class params ^.d;.g canggh;bow\n line.gsub!(classs,clsmlt[i]) if classs\n tmp<< line\n tmp<< \"\\n#{@spc}\" if i+1<prms.size\n end\n end\n p \"Rept2: #{tmp}\" if @dbg[:parse] \n @new = tmp\n else\n i = new_prms.size - 1\n new_prms.sort.reverse.each do |x|\n while Regexp.new('\\\\'+x+':(\\d+)') =~ \"\\n#{@new}\" do\n idx = $1\n src = $~.to_s\n rpl = idx ? prms[i].split(':')[idx.to_i].to_s.strip : ''\n p \"Splt : #{prms[i]} => #{idx}\" if @dbg[:parse] \n @new.gsub!(src,rpl)\n end\n \n rgx = '\\\\'+x+'\\.([^~ ]+)~' #/\\$0\\.([^~ ]~)/ => fix: next-tag (~^)\n eva_v = Regexp.new(rgx) #Ex:$1.upcase~\n while eva_v=~ \"\\n#{@new}\" do\n src = \"#{x}.#{$1}~\" #p \"\\n#{@new} => #{src}\"\n evl = \"\\\"#{prms[i]}\\\".#{$1}\" #p \"====> #{evl} <==\"\n p \"Eval : #{evl}\" if @dbg[:parse] \n rpl = prms[i] ? eval(evl).to_s : \"\"\n @new.gsub!(src,rpl)\n end\n \n opt_v = Regexp.new('~([^$]*)\\\\' +x+'([^~]*)~') \n def_v = Regexp.new('~([^~]+)~\\\\'+x) \n if opt_v =~ @new #;p $1\n rpl = ''\n rpl = \"#{$1.to_s}#{prms[i]}#{$2.to_s}\" if prms[i] && prms[i].strip!=\"\"\n @new.gsub!(opt_v,rpl)\n #p \"options: #{rpl} >> #{@new}\"\n elsif def_v =~ @new #;p $1\n src = $~.to_s\n rpl = (prms[i] && prms[i].strip!=\"\" ? prms[i] : $1)\n @new.gsub!(src,rpl) \n #p \"default: #{@new}\"\n end\n #p \"rest: #{x} => #{prms[i].to_s}\"\n @new.gsub!(x,prms[i].to_s)\n i = i -1\n end\n @new.gsub!(/\\$\\*/,prms[new_prms.size,99].to_a.join(';') )\n @new.gsub!(/\\n\\t+$/,'') #remove line if only tabs\n end\n end",
"def fix_string(val)\n val.include?('${') ? FnSub(val) : val\n end",
"def start_re=(_); end",
"def parse_expression(expression)\n expression.scan(/\\$\\((\\w+)\\)/).map{|c,*_|c}.uniq\nend",
"def lex_en_interp_backslash_delimited=(_arg0); end",
"def lex_en_interp_backslash_delimited=(_arg0); end",
"def lex_en_interp_backslash_delimited=(_arg0); end",
"def =~(p0) end",
"def =~(p0) end",
"def =~(p0) end",
"def contains_special(str)\n if str.include? ('!') or str.include? ('#') or str.include? ('$')\n true\n else\n false\n end\nend",
"def substitute!(raw)\n if raw.kind_of?(String)\n scans = Array.new\n raw.scan(/[^\\$]*\\$(\\w+)+/) { |scan| scans << scan }\n scans.each do |scan|\n scan.each do |var|\n raw.gsub!('$' + var, @vars[var]) if @vars.include?(var)\n end\n end\n elsif raw.kind_of?(Array)\n raw.each { |i| substitute!(i) }\n elsif raw.kind_of?(Hash)\n raw.each { |k, v| substitute!(v) }\n end\n end",
"def interpolate_variables(raw_command)\n raw_command.scan(/[^\\\\]\\$[-_a-zA-Z]+\\$/).each do |match|\n match.strip!\n raw_command.gsub!(match, matched_variable(match))\n end\n raw_command.gsub(\"\\\\$\", \"$\")\n end",
"def interpolate_variables(raw_command)\n raw_command.scan(/[^\\\\]\\$[-_a-zA-Z]+\\$/).each do |match|\n match = match[0..0] == \"$\" ? match : match[1..(match.size - 1)]\n match.strip!\n raw_command.gsub!(match, matched_variable(match))\n end\n raw_command.gsub(\"\\\\$\", \"$\")\n end",
"def match=(_); end",
"def /(p0) end",
"def contains_special?(string)\n if string.include?(\"!\") || string.include?(\"#\") || string.include?(\"$\")\n true\n else\n false\n end\nend",
"def escape_regex\n gsub(/\\$/, '\\\\$')\n end",
"def bill_clean(bill) \n\tbill.gsub(/[a-zA-Z]/, \"\").gsub(\"$\", \"\").to_f\nend",
"def replace(p0) end",
"def replace(p0) end",
"def replace(p0) end",
"def re; end",
"def escape_regex\n self.gsub(/\\$/,\"\\\\$\")\n end",
"def does_not_contain_special(str)\n if str.include? ('!') or str.include? ('#') or str.include? ('$')\n false\n else\n true\n end\nend",
"def corrector=(_); end",
"def get_expr_and_escapeflag(matched)\n return matched[2], matched[1] == '$'\n end",
"def scan_for_dash(token); end",
"def pattern=(_arg0); end",
"def does_not_contain_special?(string)\n if string.include?(\"!\") || string.include?(\"#\") || string.include?(\"$\")\n false\n else\n true\n end\nend",
"def ^(arg0)\n end",
"def ^(arg0)\n end",
"def ^(arg0)\n end",
"def do_expression(expr, vars)\n parse_expression(expr).each do |k|\n expr = expr.gsub(\"$(#{k})\", vars[k])\n end\n expr\nend",
"def regexp; end",
"def regexp; end",
"def contains_special(string)\n if (string.include?('!') || string.include?('#') || string.include?('$'))\n true\n else\n false\n end\nend",
"def match(p0) end",
"def match(p0) end",
"def pre_match\n end",
"def containsSpecial(password)\n if password.include?(\"!\") || password.include?(\"$\") || password.include?(\"#\")\n puts \"true\"\n else\n puts \"false\"\n end\nend",
"def scan_for_dots(token); end",
"def sanitize_like_value(value)\n value.gsub(/[\\\\_%|]/) { |x| \"\\\\#{x}\" }\n end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def lex_en_interp_backslash_delimited; end",
"def lex_en_interp_backslash_delimited; end",
"def lex_en_interp_backslash_delimited; end",
"def contains_special(password)\n if password.include?(\"!\") || password.include?(\"#\") || password.include?(\"$\")\n puts \"Acceptable\"\n else \n puts \"Password must contain at least one of the following: !, #, or $\"\n end\nend",
"def filter_chars\n # In Python we apply a string to a regexp,\n # but in Ruby we apply a regexp to a string, that's why we don't have to append\n $stack.push($stack.pop().gsub(Regexp.compile('[\\W_]+'), ' ').downcase)\nend",
"def sanitize_similar_to_value(value)\n value.gsub(/[\\\\_%|*+?{}()\\[\\]]/) { |x| \"\\\\#{x}\" }\n end",
"def autofinish; end",
"def transform_control_title (title)\n title.gsub(/^\\(L1\\) /, '').gsub(/[()',.&:]/, '').gsub(/.scr/, '').gsub(/\\s+/, '_').gsub(/[\\\\%-]/, '_').gsub(/_+/,'_').downcase\nend",
"def populate_based_on match_data\n # We need to gsub three things:\n gsub_lambdas = {\n /(?<!\\$)\\$\\d+/ => lambda{ |m| match_data[m[1..-1].to_i] }, # Simple $1 => match 1\n /(?<!\\$)\\$\\(.*?\\)/ => lambda{ |m| match_data[m[2..-2].to_i] }, # Somewhat more complex $(1) => match 1\n '$$' => lambda{ |m| '$' } # Real simple $$ => $\n }\n\n return gsub_lambdas.reduce(replace){ |replace, (replace_this, with_this)| replace.gsub(replace_this, &with_this) }\n end",
"def prefix=(_arg0); end",
"def regex_proc_head_without_space\r\n \"(?<proc_head_>\\s*(\\#{1,}|\\-{2,}|\\/{2,}))?\"\r\n end",
"def show_regexp(a, re) \n if a =~ re \n \"#{$`}<<#{$&}>>#{$'}\" \n else \n \"no match - #{a} - #{re}\" \n end \nend",
"def predicate_string_term predicate\n if predicate[0] == '^'\n \"^<#{predicate[1..predicate.length-1]}>\"\n else\n \"<#{predicate}>\"\n end\nend",
"def /(value); end",
"def expected\n Regexp.new('\\A' << super.gsub('%', '.*').tr('_', '.') << '\\z')\n end",
"def discount(str)\n str.gsub(/\\$[0-9]+/){|x| price = x[/[0-9]+/].to_i; price = price - price*15/100; \"$#{price}\"}\nend",
"def backspace_compare(s, t)\r\n while s.include?(\"#\") do s.gsub!(/(^#+)|\\w#/, '') end\r\n while t.include?(\"#\") do t.gsub!(/(^#+)|\\w#/, '') end\r\n s == t\r\nend",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def reg(line)\r\n line.split(\" \")[1].to_sym\r\nend",
"def tr_s!(p0, p1) end",
"def prefix=(_); end",
"def variable_regex\n /\n \\$ # start tag\n ([a-zA-Z_][\\w_]*) # our variables are starting with $ and are followed by\n # upcase letters or _. We want to match the \n # variable name\n /xm\n end",
"def pre_match\n nil\n end",
"def sanitize_number(value)\n value.respond_to?(:gsub) ? value.gsub(/\\$|\\,|\\%/, '') : value\n end",
"def match(x)\n $look == x or expected(\"#{x}\")\n getChar\n skipWhite\nend",
"def strip!() end",
"def test_name_generator_with_valid_input\nresult = name_generator(\"SH&$3aw(,n\")\nassert_equal(\"xX_ShAwN_Xx\", result)\nend",
"def spy_alias(real_name)\r\n\treal_name.gsub!(/[aeiou]/, \"a\" => \"e\", \"e\" => \"i\", \"i\" => \"o\", \"o\" => \"u\", \"u\" => \"a\") \r\n\treal_name.gsub!(/[bcdfghjklm]/, \"b\" => \"c\", \"c\" => \"d\", \"d\" => \"f\", \"f\" => \"g\", \"g\" => \"h\", \"h\" => \"j\", \"j\" => \"l\", \"l\" => \"m\", \"m\" => \"n\") \r\n\treal_name.gsub!(/[npqrstvwxyz]/, \"n\" => \"p\", \"p\" => \"r\", \"r\" => \"s\", \"s\" => \"t\", \"t\" => \"v\", \"v\" => \"w\", \"w\" => \"x\", \"x\" => \"y\", \"y\" => \"z\", \"z\" => \"b\")\r\nend",
"def post_match() end",
"def find_exp(input, variable, expression); end",
"def lex_en_plain_backslash_delimited=(_arg0); end",
"def lex_en_plain_backslash_delimited=(_arg0); end",
"def lex_en_plain_backslash_delimited=(_arg0); end",
"def show_regexp(a, re)\n if a =~ re\n \"#{$`}<<#{$&}>>#{$'}\"\n else\n \"no match\"\n end\nend",
"def show_regexp(a, re)\n if a =~ re\n \"#{$`}<<#{$&}>>#{$'}\"\n else\n \"no match\"\n end\nend",
"def show_regexp(a, re)\n if a =~ re\n \"#{$`}<<#{$&}>>#{$'}\"\n else\n \"no match\"\n end\nend",
"def process_not(exp)\n term = process exp.shift\n return \"!(#{term})\"\n end",
"def does_not_contain_special str\n !(str.include?(\"#\") || str.include?(\"!\") || str.include?(\"$\"))\n end",
"def start_re; end",
"def SimpleSymbols(str)\n\n # code goes here\n possible = str.scan(/.?[a-z]./)\n matches = str.scan(/\\+[a-z]\\+/)\n if possible == matches\n true\n else\n false \n end\nend",
"def keep_file_regex; end",
"def __mongo_expression__\n start_with?(\"$\") ? self : \"$#{self}\"\n end",
"def literal_sub(s, fexp, wi)\n\n case s\n when /^\\$(?:variable|var|v):([^{}\\s\\$]+)$/\n fexp.lookup_variable($~[1])\n when /^\\$([^{}:\\s\\$]+)$/, /^\\$(?:field|fld|f):([^{}\\s\\$]+)$/\n Ruote.lookup(wi['fields'], $~[1])\n else\n s\n end\n end",
"def sub_tokens(script_params,var_string)\n write_to(\"Entered sub_tokens:\" + var_string)\n prop_val = var_string.match('rpm{[^{}]*}')\n while ! prop_val.nil? do\n var_string = var_string.sub(prop_val[0],script_params[prop_val[0][4..-2]])\n prop_val = var_string.match('rpm{[^{}]*}')\n end\n write_to(\"returning: \" + var_string)\n return var_string\nend",
"def regexps; end",
"def scan_for_commas(token); end"
] |
[
"0.59447324",
"0.5836503",
"0.5823134",
"0.5718691",
"0.5553685",
"0.55448914",
"0.5520433",
"0.55116326",
"0.5491959",
"0.5437016",
"0.5437016",
"0.5437016",
"0.5427665",
"0.5427665",
"0.5427665",
"0.54138696",
"0.540289",
"0.5374139",
"0.53678924",
"0.5364782",
"0.5360316",
"0.532374",
"0.5322182",
"0.53209597",
"0.53152007",
"0.53152007",
"0.53136",
"0.53040093",
"0.53016824",
"0.5293833",
"0.52642417",
"0.52392244",
"0.52366954",
"0.52229553",
"0.5184383",
"0.51670486",
"0.51670486",
"0.51670486",
"0.51608586",
"0.51597846",
"0.51597846",
"0.51589245",
"0.5156539",
"0.5156539",
"0.51287913",
"0.51286453",
"0.5107725",
"0.51076573",
"0.51047385",
"0.51047385",
"0.51047385",
"0.51047385",
"0.51047385",
"0.509783",
"0.509783",
"0.509783",
"0.5079303",
"0.50765854",
"0.5063994",
"0.5056507",
"0.50456345",
"0.5042171",
"0.5038448",
"0.50279796",
"0.5010359",
"0.5007901",
"0.5006218",
"0.4996171",
"0.49818453",
"0.49747434",
"0.4969978",
"0.4969978",
"0.4969978",
"0.4962154",
"0.49604577",
"0.49568588",
"0.4951643",
"0.49486193",
"0.49459913",
"0.49450237",
"0.49398947",
"0.4929421",
"0.4926564",
"0.49258217",
"0.49235472",
"0.49233884",
"0.49233884",
"0.49233884",
"0.49202335",
"0.49202335",
"0.49202335",
"0.49014276",
"0.4899063",
"0.48950005",
"0.48948398",
"0.48913854",
"0.4884174",
"0.48758757",
"0.48750028",
"0.48749402",
"0.48748747"
] |
0.0
|
-1
|
The Nth group of the last regexp match.
|
def nth_ref(n)
if lm = last_match()
return lm[n]
end
return nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nth_ref(n)\n if lm = @last_match\n return lm[n]\n end\n\n return nil\n end",
"def process_nth_ref(exp)\n n = exp.shift\n raise if n < 1 or n > 9\n resultify(\"(RegExp.$#{n} || #{@model.encode_nil})\")\n end",
"def retrieve_last_match_from_stderr(re, nth = 0)\n return unless $stderr.stat.file?\n $stderr.flush\n f = $stderr.dup\n matched = nil\n begin\n f.seek(0)\n f.each do |line|\n m = line.slice(re, nth)\n matched = m if m\n end\n ensure\n f.close\n end\n matched = matched.to_s.strip\n matched.empty? ? nil : matched\n end",
"def find_more\n return unless @last_regex\n ix = next_match @last_regex\n return unless ix\n #@oldindex = @current_index\n @current_index = ix[0]\n @curpos = ix[1]\n ensure_visible\n end",
"def find_more\n return unless @last_regex\n ix = next_match @last_regex\n return unless ix\n @oldindex = @current_index\n @current_index = ix[0]\n @curpos = ix[1]\n ensure_visible\n end",
"def [](n)\n @matched ? @matches[n] : nil\n end",
"def last_submatcher_run; end",
"def last\n RegexpSpecification.last_accessor(self).uniq\t\n end",
"def reduce_named_capture(_production, _range, _tokens, theChildren)\n name = theChildren[3].token.lexeme.dup\n return Regex::CapturingGroup.new(theChildren[1], name) unless theChildren[4]\n\n # Until semantic requires that the last pattern in capture to be lazy\n make_last_repetition_lazy(theChildren[1])\n group = Regex::CapturingGroup.new(theChildren[1], name)\n (_, until_expr) = theChildren[4]\n Regex::Concatenation.new(group, until_expr)\n end",
"def last(*n) end",
"def penultimate3(string)\n string.split[string.split.size - 2]\nend",
"def reduce_capture(_production, _range, _tokens, theChildren)\n return Regex::CapturingGroup.new(theChildren[1]) unless theChildren[2]\n\n # Until semantic requires that the last pattern in capture to be lazy\n make_last_repetition_lazy(theChildren[1])\n\n group = Regex::CapturingGroup.new(theChildren[1])\n (_, until_expr) = theChildren[2]\n Regex::Concatenation.new(group, until_expr)\n end",
"def nthNumber(s, n)\n pattern = /(?:\\D*\\d+\\D*){#{n-1}}0*(\\d+)/ # https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Grouping\n return pattern.match(s)[1]\nend",
"def at(n)\n return nil if n >= count\n first(n+1).pop\n end",
"def offset_after_match\n offset + match_length\n end",
"def last n=nil\n if n.nil? or n == 1\n return the_last\n elsif n <= 0\n return Cons[]\n else\n return nthcdr length-n\n end\n end",
"def find_nth_from_last(ll, n)\n\nend",
"def process_bracket_expression(regex, quantity)\n len = regex.length\n \n #check if a range\n if len == 3\n else\n return regex\n end\n \n return len\nend",
"def last(n = nil)\n if n\n self[-n..-1]\n else\n self[-1]\n end\n end",
"def third_to_last\n self[-3]\n end",
"def regexp_matcher regexp\n lambda do |string, index = 0, counts:|\n found = regexp.match(string, index)\n result_string = found.to_s\n\n if found && found.begin(0) == index && !result_string.empty?\n result_string\n end\n end\n end",
"def extract(regex)\n data = self.match(regex)\n return nil unless data\n if data.size > 2\n return *(data.to_a[1..-1])\n elsif data.size == 2\n return data[1]\n else\n return data[0]\n end\n end",
"def second_last\n return nil if (size-2) < 0\n self[size-2]\n end",
"def make_last_repetition_lazy(anExpr)\n sub_expr = anExpr\n loop do\n if sub_expr.is_a?(Regex::Repetition)\n # Make repetition lazy\n cardinality = sub_expr.multiplicity\n cardinality.instance_variable_set(:@policy, :lazy)\n break\n elsif sub_expr.kind_of?(Regex::PolyadicExpression)\n sub_expr = sub_expr.children.last\n elsif sub_expr.kind_of?(Regex::MonadicExpression)\n sub_expr = sub_expr.child\n elsif sub_expr.kind_of?(Regex::AtomicExpression)\n break\n end\n end\n end",
"def find_regex_token\n best_token = nil\n best_length = 0\n\n # I tried optimizing based on the first char, but it had\n # a slightly negative affect and was a good bit more complicated.\n TOKENS.regex_tokens.each do |token|\n if length = @scanner.match?(token.regex) and token.acceptable?(lexing_context)\n # We've found a longer match\n if length > best_length\n best_length = length\n best_token = token\n end\n end\n end\n\n return best_token, @scanner.scan(best_token.regex) if best_token\n end",
"def last(n = 1)\n return @history[-n] ;\n end",
"def next_match_number\n # This returns a PGresult object\n # [http://rubydoc.info/github/ged/ruby-pg/master/PGresult]\n result = Match.connection.execute(\"SELECT nextval('match_number_seq')\")\n result[0]['nextval']\n end",
"def last(n)\n @queue.last(n)\n end",
"def last_match\n self.current_season.round_actual.get_match(self)\n end",
"def last_two(array)\n array.last(2)\nend",
"def second_to_last\n self[-2]\n end",
"def next_regex regex\n if regex.is_a? Symbol\n regex = @text_patterns[regex]\n raise \"Pattern specified #{regex} does not exist in text_patterns \" unless regex\n end\n @last_regex = regex\n find_more\n end",
"def last(n=nil)\n return self[-1] if n.nil?\n \n start = length-n\n start = 0 if start < 0\n self[start, n]\n end",
"def return_next_match binding, *args\n first = nil\n ix = 0\n $view.each_with_index do |elem,ii|\n if binding.call(elem, *args)\n first ||= ii\n if ii > $cursor \n ix = ii\n break\n end\n end\n end\n return first if ix == 0\n return ix\nend",
"def return_next_match binding, *args\n first = nil\n ix = 0\n $view.each_with_index do |elem,ii|\n if binding.call(elem, *args)\n first ||= ii\n if ii > $cursor \n ix = ii\n break\n end\n end\n end\n return first if ix == 0\n return ix\nend",
"def last\n relationships = self.group_relations\n last_index = relationships.count - 1\n last_relationship = relationships.select { |child| child[:position] == last_index }.first\n return if last_relationship.nil?\n last_relationship.group\n end",
"def get_end(regex)\n if(regex =~ @row;@rgx = $~)\n if @rgx[1]=='~' \n @new = ''\n @new = multi_end(1) if @tg_end.size>0\n else\n case @rgx[1]\n when '!';@new = multi_end(nil)\n when ',';@new = multi_end(@tg_end.size)\n else ;@new = multi_end(@rgx[1].size)\n end\n end\n @doc_src = @row.gsub(@rgx.to_s,@new).split(\"\\n\")+@doc_src\n @row = ''\n end\n end",
"def penultimate(text)\n text.split[-2]\nend",
"def penultimate(str)\n arr = str.split\n arr[-2]\nend",
"def version_behind(input, n)\n input.each do |group|\n if group[\"versions\"].length > n\n return group[\"versions\"][n]\n end\n end\n end",
"def last(n = 1)\n return self.clone if n >= self.size\n return self[-1] if n == 1\n return self.reverse[0...n].reverse\n end",
"def last_specified_position\n tree.dimensions.length.downto(1) do |index|\n return index - 1 if conditions[tree.dimensions[index - 1]] != '*'\n end\n\n return -1\n end",
"def _find_next regex=@last_regex, start = @search_found_ix \n raise \"No previous search\" if regex.nil?\n #$log.debug \" _find_next #{@search_found_ix} : #{@current_index}\"\n fend = @list.size-1\n if start != fend\n start += 1 unless start == fend\n @last_regex = regex\n @search_start_ix = start\n regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case\n start.upto(fend) do |ix| \n row = @list[ix]\n m=row.match(regex)\n if !m.nil?\n @find_offset = m.offset(0)[0]\n @find_offset1 = m.offset(0)[1]\n @search_found_ix = ix\n return ix \n end\n end\n end\n fend = start-1\n start = 0\n if @search_wrap\n start.upto(fend) do |ix| \n row = @list[ix]\n m=row.match(regex)\n if !m.nil?\n @find_offset = m.offset(0)[0]\n @find_offset1 = m.offset(0)[1]\n @search_found_ix = ix\n return ix \n end\n end\n end\n return nil\n end",
"def last\n @routes[-1]\n end",
"def find_nth_from_end(n)\n list_length = self.length\n return nil if n > list_length - 1 || n < 0\n cursor = @tail\n n.times do\n cursor = cursor.prev\n end\n return cursor.data\n end",
"def penultimate(string)\n new_string = string.split[-2] \nend",
"def regex_token\n return if @chunk[0] != '/'\n length = heregex_token\n return length if length\n prev = @tokens[-1]\n return if prev && (prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX).include?(prev[0])\n return unless match = @chunk.match(REGEX)\n match, regex, flags = *match\n # Avoid conflicts with floor division operator.\n return if regex == '//'\n if regex[0..1] == '/*'\n raise_syntax_error! 'regular expressions cannot begin with `*`'\n end\n token(:REGEX, \"#{regex}#{flags}\", 0, match.size)\n match.size\n end",
"def next_match_title\n \"Match#{next_match_number}\"\n end",
"def penultimate(string)\n string.split[-2]\nend",
"def penultimate(string)\n string.split[-2]\nend",
"def penultimate(string)\n string.split[-2]\nend",
"def penultimate(string)\n string.split[-2]\nend",
"def penultimate(string)\n string.split[-2]\nend",
"def penultimate(string)\n string.split[-2]\nend",
"def last_position_from_expression(node)\n internal_heredoc = node.each_descendant(:str).select { |n| n.loc.respond_to?(:heredoc_end) }\n internal_heredoc.map { |n| n.loc.heredoc_end.end_pos }.max if internal_heredoc.any?\n end",
"def fourth\n at(3)\n end",
"def func_lastmatch(sender, dest, args)\r\n\t\tcount= 1\r\n\t\tcount= args[0].to_i() if args.size() >= 1\r\n\r\n\t\tres= @db.query(\"SELECT * FROM matchs WHERE (Type='t' OR Type='m' ) AND Etat='t' ORDER BY Date DESC LIMIT #{count}\")\r\n\t\tshowMatchFromQuery(res, sender)\r\n\t\tres.free()\r\n\tend",
"def match_score(val)\n if command_regex =~ val\n Regexp.last_match.size > 1 ? Regexp.last_match.begin(1) : Regexp.last_match.end(0)\n else\n -1\n end\n end",
"def penultimate(str)\n str.split[-2]\nend",
"def penultimate(str)\n str.split[-2]\nend",
"def penultimate(str)\n str.split[-2]\nend",
"def penultimate(string)\nwords = string.split\nwords[-2]\nend",
"def penultimate(string)\n words = string.split\n words[-2]\nend",
"def last_line(src)\n if n = src.rindex(\"\\n\")\n src[(n+1) .. -1]\n else\n src\n end\nend",
"def nthElementFromTheEnd(l, n)\n out, ln = [], l\n while ln do\n out.push ln.value\n ln = ln.next\n end\n return n > out.size ? -1 : out[out.size - n]\nend",
"def nth\n num = self.class.all_in_current_meeting.index(self)\n num ? num.ordinalize : nil\n end",
"def substring_up_to_match\n @matches.nil? ? nil : @buffer.match(expr_substring_to_match)[0]\n end",
"def last(*args)\n find(:last, *args)\n end",
"def last(*args)\n find(:last, *args)\n end",
"def substring_remainder\n if @matches.nil?\n @buffer\n else\n start_index = substring_up_to_match.length\n @buffer[start_index..-1]\n end\n end",
"def nthRun(_nth)\n case(_nth)\n when Run ; return _nth ;\n when Integer ; return @runList[_nth] ;\n when :first ; return @runList.first ;\n when :last ; return @runList.last ;\n else\n raise \"unknown _nth index type for @runList: \" + _nth.inspect ;\n end\n end",
"def reduce_grouping_parenthenses(_production, _range, _tokens, theChildren)\n Regex::NonCapturingGroup.new(theChildren[1])\n end",
"def split3(aPattern,aOccurence=0)\n\t\taString = self\n\t\tmatches = aString.scan_md(aPattern)\n\t\tmatch = matches[aOccurence]\n\t\tparts = (match ? [match.pre_match,match.to_s,match.post_match] : [aString,nil,''])\n\n\t\tif !block_given?\t# return head,match,tail\n\t\t\tparts\n\t\telse\t\t\t\t\t\t# return string\n\t\t\tparts[1] = yield *parts if match\n\t\t\tparts.join\n\t\tend\n\tend",
"def find_nth_file(basename, index = T.unsafe(nil)); end",
"def find_nth_from_end(n)\r\n # lead, nth = @head\r\n\r\n # n.times { lead = lead.next if lead }\r\n \r\n # while lead && lead.next && nth && nth.next\r\n # lead = lead.next\r\n # nth = nth.next\r\n # end\r\n\r\n # return nth&.data\r\n n = self.count.pred - n\r\n return if n < 0\r\n self.entries[n]\r\n end",
"def lex_groupend start_state, regexp, action = nil\n end_group\n lex_rule start_state, regexp, action\n end",
"def nth_occurrence(str, substr, n)\n pos = -1\n if n > 0 && str.include?(substr)\n i = 0\n while i < n do\n pos = str.index(substr, pos + substr.length) if pos != nil\n i += 1\n end\n end\n pos != nil && pos != -1 ? pos + 1 : -1\nend",
"def last *a; self.child(*a) + ':last-child' end",
"def match(rex, default=nil)\n m = rex.match self.stdout\n if m\n if m.length > 2\n m[1..-1]\n else\n m[1]\n end\n else\n default\n end\n end",
"def last_index(str, char)\n \tarry = []\n\tstr.split(\"\").map.with_index do|i, indx|\n\tif i == char\n arry << indx\n end\n end\n return arry[-1]\nend",
"def find_last_note(nb_notes)\n note = self\n (nb_notes.to_i - 1).times do\n note = note.succ\n end\n note\n end",
"def lastChar(str, l_index)\n if alpha(str[l_index])\n return str[l_index], l_index\n end\n lastChar(str, l_index -= 1)\n end",
"def penultimate(string)\n words = string.split(' ')\n words[-2]\nend",
"def nth(n)\n proc {|*args|args[n]}\n end",
"def return_next_match binding, *args\n first = nil\n ix = 0\n @view.each_with_index do |elem, ii|\n next unless binding.call(elem, *args)\n\n first ||= ii\n if ii > @cursor\n ix = ii\n break\n end\n end\n return first if ix == 0\n\n ix\nend",
"def lastElement\n return @stk[@count]\n end",
"def _find_prev regex=@last_regex, start = @search_found_ix \n raise \"No previous search\" if regex.nil?\n #$log.debug \" _find_prev #{@search_found_ix} : #{@current_index}\"\n if start != 0\n start -= 1 unless start == 0\n @last_regex = regex\n @search_start_ix = start\n regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case\n start.downto(0) do |ix| \n row = @list[ix]\n m=row.match(regex)\n if !m.nil?\n @find_offset = m.offset(0)[0]\n @find_offset1 = m.offset(0)[1]\n @search_found_ix = ix\n return ix \n end\n end\n end\n fend = start-1\n start = @list.size-1\n if @search_wrap\n start.downto(fend) do |ix| \n row = @list[ix]\n m=row.match(regex)\n if !m.nil?\n @find_offset = m.offset(0)[0]\n @find_offset1 = m.offset(0)[1]\n @search_found_ix = ix\n return ix \n end\n end\n end\n return nil\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def last_color_output\n return @output_array[-2]\n end",
"def binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end",
"def take(name, n)\n a = name[n..-1]\n return a\nend",
"def last(*args)\n find(:last, *args)\n end",
"def find_nth_from_end(n)\r\n list_length = self.length\r\n return nil if n > list_length - 1 || n < 0\r\n index = 1\r\n cursor = @head\r\n until (list_length - index) == n || !cursor.next\r\n index +=1\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end",
"def next(backreferences)\n\t\tif @fragment_spec[:backreference]\n\t\t\tif @index < 0\n\t\t\t\tb = @fragment_spec[:backreference]\n\t\t\t\t@current = backreferences[b - 1] # could be nil\n\t\t\telse\n\t\t\t\t@current = nil\n\t\t\tend\n\t\t\t@index += 1\n\t\telse\n\t\t\tif @index > @max_index\n\t\t\t\t@current = @@NO_MORE\n\t\t\telse\n\t\t\t\t@index += 1\n\t\t\t\t@current = @all[@index]\n\t\t\tend\n\t\tend\n\n\t\treturn @current\n\tend",
"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 binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end",
"def end_group(kind); end",
"def end_group(kind); end"
] |
[
"0.7311233",
"0.6590991",
"0.64058936",
"0.6100316",
"0.6100138",
"0.58060926",
"0.5659509",
"0.5657635",
"0.5489867",
"0.5486948",
"0.5441531",
"0.54292196",
"0.5419881",
"0.5405483",
"0.5402288",
"0.5325947",
"0.53171045",
"0.5288833",
"0.5286013",
"0.52855444",
"0.5268016",
"0.526263",
"0.52274925",
"0.51955044",
"0.5192522",
"0.51816595",
"0.5177144",
"0.5170607",
"0.5145007",
"0.51227206",
"0.51156795",
"0.5107904",
"0.50750405",
"0.50645655",
"0.50645655",
"0.5007355",
"0.4990494",
"0.4987241",
"0.4977562",
"0.49754936",
"0.4962106",
"0.49454874",
"0.49398604",
"0.49346963",
"0.49246004",
"0.49241793",
"0.49224472",
"0.49197382",
"0.49105924",
"0.49105924",
"0.49105924",
"0.49105924",
"0.49105924",
"0.49105924",
"0.49002627",
"0.48981768",
"0.48534268",
"0.48469594",
"0.48327395",
"0.48327395",
"0.48327395",
"0.48324504",
"0.48322564",
"0.4831708",
"0.4828891",
"0.48279697",
"0.48260653",
"0.48248693",
"0.48248693",
"0.4823016",
"0.48220906",
"0.4821548",
"0.48091513",
"0.48089534",
"0.480814",
"0.48051172",
"0.4796786",
"0.47941962",
"0.47898296",
"0.4789522",
"0.47850886",
"0.4782817",
"0.47722405",
"0.4770858",
"0.4765811",
"0.47623894",
"0.47583166",
"0.47552308",
"0.47552308",
"0.47552308",
"0.47552308",
"0.47538218",
"0.47514278",
"0.47493425",
"0.47400364",
"0.4734858",
"0.4727059",
"0.47247985",
"0.4723016",
"0.4723016"
] |
0.72483605
|
1
|
One of the special globals $&, $`, $' or $+.
|
def back_ref(kind)
if lm = last_match()
res = case kind
when :&
lm[0]
when :"`"
lm.pre_match
when :"'"
lm.post_match
when :+
lm.captures.last
end
return res
end
return nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def globals; end",
"def globals; end",
"def global_variables() end",
"def globals; list_all :global_variables; end",
"def global_var\n $global_var \n end",
"def global?; end",
"def encode_global_variable(name)\n raise if name.to_s[0,1] != '$'\n \"$\" + @global_name_generator.get(name.to_s)\n end",
"def global?; true end",
"def strict_variables=(_arg0); end",
"def global_var\n $global_var \nend",
"def local_variables() end",
"def initialize_globals(game)\n\n $available_letters = \"abcdefghijklmnopqrstuvwxyz\".split(\"\")\n $missed_letters = []\n\n if game.downcase == \"back\" \n\t$is_get_level = true\n\n elsif game.downcase == \"restart\"\n\t$is_get_level = false\n end\n\n $is_eof_game = false\n $guessed_word = [\"_\"]\n $word = \"\"\nend",
"def strict_variables; end",
"def global; end",
"def do_global_map\r\n $FOORTH_GLOBALS[@symbol]\r\n end",
"def active_locals; end",
"def insert_globals\n # match all global variables, every variable begins with an at (@).\n # variables can also end with a semicolon to have a safe declaration.\n @output = @output.gsub(/\\[{3}\\@(\\w+)\\]{3}/).each {\n match = Regexp.last_match[1]\n @globals[match] || \"\"\n }\n end",
"def global_decls; end",
"def amethod\n localvar = 10\n puts( localvar )\n puts( $globalvar )\nend",
"def are_only_global?\n self.keys.size == 1 && self.keys[0] == '*'\n end",
"def process_cvar(exp)\n # TODO: we should treat these as globals and have them in the top scope\n name = exp.shift\n return name.to_s\n end",
"def global?\n module_name.nil? || module_name == NAMESPACE_WILDCARD || module_name == ENVIRONMENT\n end",
"def local_global\n\t\t\they = \"hey there\" # Local - only accessible from certain methods\n\t\t\tputs hey\n\t\tend",
"def global_var=(var)\n $global_var = var\nend",
"def main_variable ; end",
"def global_vars\n @title = 'Wytwarzanie Pomocy Dydaktycznych: Pomoce dydaktyczne, szkolne i naukowe dla przedszkoli szkoł'\n @desription = ''\n @keywords = 'pomoce dydaktyczne, pomoce szkolne, pomoce naukowe, pomoce dydaktyczne dla szkół, pomoce dydaktyczne dla przedszkoli, radosna szkoła, Wytwarzanie Pomocy Dydaktycznych, wpd, wpd.pl'\n end",
"def global_var=(var)\n $global_var = var\n end",
"def setup_globals\n @banner = @opts.to_s\n result = @opts.to_hash\n @file1 = result[:file1]\n @file2 = result[:file2]\n end",
"def used_names=(_arg0); end",
"def foo\n local_variables = 10\n puts \"local variables: #{local_variables}\"\n puts defined?(local_variables)\nend",
"def global_const_defined? string\n begin\n eval string\n true\n rescue NameError\n false\n end\n end",
"def treat_reserved_as_conflict=(_arg0); end",
"def get_local_var\n p $local_var #this is different than...\n local_var = \"Local Var\"\n p local_var #...this.\nend",
"def give_opinion\r\n return \"I'm #{GOOD_MOOD}. I love ruby\" ### return global variable\r\n end",
"def validate_global_variables!\n return unless panel_contains_unsupported_vars?\n\n raise_error \"Prometheus must not include #{UNSUPPORTED_GRAFANA_GLOBAL_VARS}\"\n end",
"def global?\n @global\n end",
"def global_key?\n key_defined?('_global_')\n end",
"def strict_locals?\n strict_locals!\n end",
"def local?; !!@local end",
"def defined_in; end",
"def global_scope; @scope = :global end",
"def declare_global_init(variable,name, options = {})\r\n v = (name.include?(\"[\") ? \"\" : \"var \")\r\n unless options[:local_construction]\r\n @global_init << \"#{v}#{variable.assign_to(name)}\"\r\n else\r\n @global_init << \"#{v}#{name};\"\r\n @init << variable.assign_to(name)\r\n end\r\n end",
"def declared_in; end",
"def global(name)\n return @library.globals(true)[name.to_sym]\n end",
"def change\n $global = 99\nend",
"def sub_vars\n # Get list of variables, remove reserved\n get_var_names.each do |var, _sub|\n code.gsub!(var, \"$#{@rig.init_var(var)}\")\n end\n\n code\n end",
"def intern() end",
"def included_constants; end",
"def absolute_const\n @define_absolute_const = true\n '$$$'\n end",
"def global?\n @options[:global] || false\n end",
"def reserved_words=(_arg0); end",
"def anonymous?\n builtin == 2\n end",
"def var_names\n @var_names ||= eval \"local_variables\", get_binding\n end",
"def static_env=(_arg0); end",
"def static_env=(_arg0); end",
"def static_env=(_arg0); end",
"def alphabet\n\t\treturn @variables | @constants\n\tend",
"def local?; end",
"def strict_locals!\n if @strict_locals == NONE\n self.source.sub!(STRICT_LOCALS_REGEX, \"\")\n @strict_locals = $1\n\n return if @strict_locals.nil? # Magic comment not found\n\n @strict_locals = \"**nil\" if @strict_locals.blank?\n end\n\n @strict_locals\n end",
"def settt_global_var(value)\n\t# puts \"This is the val:#{value}\"\n\t$global_var = value\nend",
"def process_gvar(exp)\n gvar = exp.shift\n\n res = \n case gvar.to_s\n when \"$!\"\n # this is a special variable which holds the current exception \n exception_name() \n else\n gvar_name = @model.encode_global_variable(gvar)\n \"(typeof(#{gvar_name})=='undefined'?#{@model.encode_nil}:#{gvar_name})\"\n end\n\n resultify(res)\n end",
"def locals; list_all :local_variables; end",
"def variable_name? word\n word.start_with?('@') or word.start_with?('$')\n end",
"def intro_to_variables\n expression = \"Ruby is Elegant.\" #Local Varible\n puts expression\nend",
"def external_vars(opts={})\n if opts\n opts.each do |k,v|\n if v.include? \",\"\n if v.split(\",\")[0] == \"char\"\n ## default is 40 characters\n if v.split(\",\")[2]\n $external_vars << \"#{v.split(\",\")[0]}* #{k}[#{v.split(\",\")[2].lstrip}];\"\n else\n $external_vars << \"#{v.split(\",\")[0]} #{k}[40] = \\\"#{v.split(\",\")[1].lstrip}\\\";\"\n end\n else\n $external_vars << \"#{v.split(\",\")[0]} #{k} =#{v.split(\",\")[1]};\"\n end\n else\n if v.split(\",\")[0] == \"char\"\n $external_vars << \"#{v.split(\",\")[0]} #{k}[40];\"\n else\n\n $external_vars << \"#{v.split(\",\")[0]} #{k};\"\n end\n end\n # check chars work here\n $external_var_identifiers << k\n end\n end\n end",
"def global_variables_exist(text)\n\ttext.each_line do |line|\n\n\t\t# Only want the global variables, function lines come later.\n\t\tif lineHasGlobalVariable(line) and not lineIsFunctionStart(line)\n\n\t\t\t# puts line\n\t\t\treturn true\n\t\tend\n\tend\n\treturn false\nend",
"def mess_with_vars(_one, _two, _three)\n one = 'two'\n two = 'three'\n three = 'one'\nend",
"def underscore_vars\r\n self.gsub(/\\b[a-z][a-z]*(?:[A-Z][a-z]*)(?:[A-Z][a-z]*)*\\b/) {|word|\r\n word.underscore\r\n }\r\n end",
"def variable_name_expr; end",
"def constants() end",
"def reserved=(_arg0); end",
"def global key\n value = @__globals[key]\n value = value.value if LazyGlobal === value\n value\n end",
"def mess_with_vars2(one, two, three)\n one = \"two\"\n two = \"three\"\n three = \"one\"\nend",
"def mess_with_vars2(one, two, three)\n one = \"two\"\n two = \"three\"\n three = \"one\"\nend",
"def autofinish=(_arg0); end",
"def scope=(_); end",
"def global_modules\n node['rsyncd']['globals'].reduce({}) do |hash, (key, value)|\n hash[snake_to_space(key)] = value unless value.nil?\n hash\n end\n end",
"def restore_globals\n # Restore the original $LOAD_PATH to negate any changes made.\n $LOAD_PATH.replace @@load_path_org\n # Could restore the original $LOADED_FEATURES ($\"), but this worker process\n # acculumates many gems and modules over time and it's not practical to\n # reload them every time.\n # So, just deleting those in @sitelibbase or @sourcebase directory.\n $LOADED_FEATURES.reject! {|x| x.start_with?(@sitelibbase, @sourcebase)}\n end",
"def global_filter=(_arg0); end",
"def global_vars(to = $stdout)\n to.print \"<h1>Global variables</h1>\\n\"\n to.print \"<table class=\\\"global_variables list\\\">\\n\"\n to.print \"\\t<thead>\\n\"\n to.print \"\\t\\t<tr>\\n\"\n to.print \"\\t\\t\\t<th>Name</th>\\n\"\n to.print \"\\t\\t</tr>\\n\"\n to.print \"\\t</thead>\\n\"\n to.print \"\\t<tbody>\\n\"\n \n count = 0\n Kernel.global_variables.each do |name|\n count += 1\n \n #begin\n # global_var_ref = eval(name.to_s)\n #rescue => e\n # to.print \"\\t\\t<tr>\\n\"\n # to.print \"\\t\\t\\t<td>Error: #{Knj::Web.html(e.message)}</td>\\n\"\n # to.print \"\\t\\t</tr>\\n\"\n # \n # next\n #end\n \n #size = 0\n #size = Knj::Memory_analyzer::Object_size_counter.new(global_var_ref).calculate_size\n #size = size.to_f / 1024.0\n \n to.print \"\\t\\t<tr>\\n\"\n to.print \"\\t\\t\\t<td>#{Knj::Web.html(name)}</td>\\n\"\n to.print \"\\t\\t</tr>\\n\"\n end\n \n if count <= 0\n to.print \"\\t\\t<tr>\\n\"\n to.print \"\\t\\t\\t<td colspan=\\\"2\\\" class=\\\"error\\\">No global variables has been defined.</td>\\n\"\n to.print \"\\t\\t</tr>\\n\"\n end\n \n to.print \"\\t</tbody>\\n\"\n to.print \"</table>\\n\"\n end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def check_builtin(param)\n builtin_functions = {}\n param.scan(/\\\\g[\\<\\'](_\\w+_)[\\>\\']/) do | func_name |\n builtin_functions[func_name[0]] = true\n end\n if builtin_functions.keys.size > 0\n require 'regextest/front/builtin-functions'\n functions = Regextest::Front::BuiltinFunctions.new\n builtin_functions.keys.each do | func_name |\n if func_string = functions.find_func(func_name)\n param = param + func_string\n else\n raise \"invalid built-in function name (#{func_name})\"\n end\n end\n end\n param\n end",
"def define; end",
"def variable?\n not constant?\n end",
"def default_scope=(_arg0); end",
"def wellScoped(program) #global_env, stmt)\n unless program.is_a?(GCProgram)\n raise \"Input not supported\"\n end\n local_check = true\n global_check = true\n if program.is_a?(GCProgram)\n temp = program.scoped([],[],[],[])\n local_env = temp[0]\n local_vars = temp[1]\n global_env = temp[2]\n global_vars = temp[3]\n\n if not global_env.empty?\n global_check = global_vars.all? {|elem| global_env.include?(elem)}\n end\n if @@local_scoped\n local_check = local_vars.all? {|elem| local_env.include?(elem)}\n end\n return global_check && local_check\n end\n return false\n end",
"def var_name_ok?(varname)\n svar=varname.to_s\n if @@reserved_words.include?(svar)\n raise ArgumentError, \"Name \\\"#{svar}\\\" is a reserved word in Ruby.\"\n elsif @@reserved_vars.include?(svar)\n raise ArgumentError, \"Cannot override the #{svar} variable.\"\n elsif /\\A[a-zA-Z][a-zA-Z0-9_]*\\z/.match(svar)\n return svar\n else\n raise ArgumentError, \"Invalid variable name \\\"#{var}\\\": it must be a letter followed by any number of letters, numbers and underscores.\"\n end\n end",
"def defined?(name); end",
"def defined?(name); end",
"def use_implicit_variables; CurrentParser[:implicit_variables]=true; end",
"def forward_local_env(env_variable_patterns); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def SE02=(arg)",
"def global!(type, name)\n method_name = name.to_sym\n define_method(method_name) do\n get_global!(type, name)\n end\n module_function method_name\n\n method_name = \"#{name}=\".to_sym\n define_method(method_name) do |value|\n set_global!(type, name, value)\n end\n module_function method_name\n end",
"def getlocal() end",
"def RB_SPECIAL_CONST_P loc\n is_immediate = push_label\n\n __ = @fisk\n reg = @fisk.rax\n @fisk.mov(reg, loc)\n @fisk.test(reg, __.uimm(RUBY_IMMEDIATE_MASK))\n @fisk.jnz(is_immediate)\n @fisk.test(reg, __.imm(~Qnil))\n @fisk.jz(is_immediate)\n @fisk.mov(reg, __.uimm(0))\n @fisk.put_label(is_immediate.name)\n\n pop_label\n\n reg\n end",
"def stack_load_global(name)\n\n Lib.lua_getfield(@pointer, LUA_GLOBALSINDEX, name)\n end"
] |
[
"0.6926019",
"0.6926019",
"0.6647114",
"0.62372506",
"0.620995",
"0.61501765",
"0.6094475",
"0.60512537",
"0.6044292",
"0.5971754",
"0.5967766",
"0.59497285",
"0.5888526",
"0.5858662",
"0.58381605",
"0.57419056",
"0.5718646",
"0.5705616",
"0.5694432",
"0.56906307",
"0.56434",
"0.56344277",
"0.56233686",
"0.5593591",
"0.54607034",
"0.54551077",
"0.54490674",
"0.5399863",
"0.5396251",
"0.53840214",
"0.5330409",
"0.5324586",
"0.5306201",
"0.53020555",
"0.52869165",
"0.5285487",
"0.5285447",
"0.5281657",
"0.5267397",
"0.5261298",
"0.5258299",
"0.5253331",
"0.5241741",
"0.52257776",
"0.5221588",
"0.5210029",
"0.51975375",
"0.51924413",
"0.5174551",
"0.5159794",
"0.51507014",
"0.51424533",
"0.5136485",
"0.5134864",
"0.5134864",
"0.5134864",
"0.5124049",
"0.51230097",
"0.511515",
"0.5113448",
"0.51063347",
"0.5101782",
"0.5101694",
"0.51005197",
"0.50969446",
"0.50870204",
"0.5083231",
"0.5079202",
"0.5075425",
"0.50653857",
"0.5062536",
"0.5043354",
"0.5037757",
"0.5037757",
"0.5032159",
"0.5023661",
"0.50194883",
"0.5017673",
"0.5013457",
"0.50134397",
"0.5007097",
"0.5007097",
"0.5007097",
"0.5001299",
"0.49877256",
"0.49849516",
"0.49828017",
"0.49800068",
"0.4979671",
"0.4960875",
"0.4960875",
"0.49572596",
"0.4952766",
"0.49513638",
"0.49513638",
"0.49513638",
"0.49470714",
"0.49353087",
"0.49343023",
"0.49219432",
"0.49193057"
] |
0.0
|
-1
|
GET /clubs GET /clubs.json
|
def index
authorize Club
@clubs = Club.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def index\n\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clubs }\n end\n end",
"def show\n \n @club = Club.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n\n \n end",
"def show\n\t\trender json: @club\n\tend",
"def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n end\n end",
"def index\n @clubs = Club.all\n end",
"def index\n @clubs = Club.all\n end",
"def index\n @clubs = Club.all\n end",
"def show\n\n #params[:id] = @current_user.club_id\n @club = Club.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n end",
"def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def clubs\n \t@title = \"My Clubs\"\n \t@clubs = Student.find(params[:id]).clubs\n \trender 'show_clubs'\n end",
"def all_clubs\n Club.all\nend",
"def index\n @club = Club.find_by_slug(params[:club_id])\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end",
"def show\n @club_path = ClubPath.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club_path }\n end\n end",
"def index\n @clubs = Club.page(params[:page]).per(6)\n end",
"def index\n @clubs = Club.all \n respond_to do |format|\n format.html { \n authorize! :index, @clubs\n }\n format.json { \n \n }\n end\n end",
"def index\n @club2s = Club2.all\n end",
"def show\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def index\n @tennis_clubs = TennisClub.all\n end",
"def show\n @nightclub = Nightclub.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def clubs_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.clubs_get ...\"\n end\n # resource path\n local_var_path = \"/clubs\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#clubs_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n begin\n conditions = [\"club_id = ?\",@club.id]\n @courses = Course.find(:all, :order => 'id', :conditions => conditions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def index\n @clubs = Club.all\n # @small_genres = []\n end",
"def index\n @clubs = Club.all\n respond_with @clubs, :include => :id\n end",
"def index\n @clubusers = Clubusers.all\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club }\n end\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @club }\n end\n end",
"def index\n @admin_clubs = Admin::Club.all\n end",
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @club, status: :created\n\t\telse\n\t\t \trender json: @club.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def index\n @clubs = Club.order(name: :asc)\n end",
"def index\n @club_types = ClubType.all\n end",
"def club\n @user.club\n end",
"def index\n @stripclubs = Stripclub.all\n end",
"def index\n @clubs = Club.joins(:place).all\n\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def show\n @club = Club.find(params[:id])\n respond_with @club, :include => :id\n end",
"def show\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def index\n @club_students = ClubStudent.all\n end",
"def show\n respond_to do |format|\n format.html { \n authorize! :index, @club\n }\n format.json { \n \n }\n end\n end",
"def club\n viewing.club\n end",
"def new\n @club_path = ClubPath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club_path }\n end\n end",
"def index\n @tea_clubs = TeaClub.all\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def display_resource(club)\n club.name\n end",
"def set_club\n\n @club = Club.find(params[:id])\n\n end",
"def show_players_on_specific_club\n the_club = choose_club #user chooses club they want to see players for\n the_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n the_club.players.each do |player| #loops through instance of club and prints all players \n puts player.name\n end\nend",
"def set_club\n @club = Club.find(params[:id])\n @place = Place.find(@club.place_id)\n #devolve-nos a relacao que contem todos os UserClubs correspondentes ao clube com id = @club.id\n @users_clubs = UserClub.where(\"club_id = #{params[:id]}\")\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @teams = Team.joins('LEFT OUTER JOIN clubs on teams.club_id = clubs.id').select('teams.*, clubs.name as club_name')\n\n render json: @teams\n end",
"def clubs_get(opts = {})\n data, _status_code, _headers = clubs_get_with_http_info(opts)\n return data\n end",
"def team\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html #team.html.erb\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def new\n @beer_club = BeerClub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def new\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def show\n @club = Club.find(params[:id])\n authorize @club\n end",
"def index\n my_authorize_action_within_clubs!(:list, Club, @current_partner.clubs.collect(&:id))\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: ClubsDatatable.new(view_context,@current_partner,nil,nil,@current_agent) }\n end\n end",
"def create\n @club = Club.new(club_params)\n @club.save\n respond_with @club\n end",
"def index\n @clan_matches = ClanMatch.all\n\n render json: @clan_matches\n end",
"def new\n @beer_club = BeerClub.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def set_club_info\n @club_info = ClubInfo.find(params[:id])\n end",
"def index\n @championships = Championship.all\n\n render json: @championships\n end",
"def set_club\n\t\t\t@club = Club.find(params[:id])\n\t\tend",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def index\n @public_offers = @club.public_offers\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @club_updates = ClubUpdate.all\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def index\n @games_leaderboards = Games::Leaderboard.all\n\n render json: @games_leaderboards\n end",
"def index\n if params[:user_id].present?\n @teams = Team.where(\"user_id = #{params[:user_id]}\")\n elsif params[:club_id].present?\n @teams = Team.where(\"club_id = #{params[:club_id]}\")\n else\n @teams = Team.all\n end\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def show\n render json: @championship\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end",
"def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end",
"def sport(sport_id, **options) = get(\"/sports/#{sport_id}\", **options)",
"def get\n perform_request(api_url(\"champion\"))[\"champions\"].map {|c| Champion.new(c)}\n end",
"def new\n @nightclub = Nightclub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_with @club\n end",
"def create\n authorize Club\n @club = Club.new(club_params)\n @club.owner = current_user\n @club.users << current_user\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @conferences = @league.conferences\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conferences }\n end\n end",
"def create\n @admin_club = Admin::Club.new(admin_club_params)\n\n respond_to do |format|\n if @admin_club.save\n format.html { redirect_to @admin_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_club }\n else\n format.html { render :new }\n format.json { render json: @admin_club.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.82473654",
"0.8111927",
"0.80283284",
"0.8004295",
"0.7850272",
"0.77443665",
"0.7703937",
"0.75692767",
"0.75692767",
"0.75692767",
"0.75216234",
"0.7386078",
"0.7347323",
"0.7230501",
"0.71990705",
"0.7097331",
"0.70414716",
"0.7035367",
"0.6946004",
"0.691601",
"0.68934935",
"0.6878925",
"0.6869081",
"0.68662405",
"0.6844784",
"0.68441397",
"0.6818486",
"0.68081427",
"0.6756145",
"0.67531294",
"0.66749525",
"0.6599418",
"0.6595181",
"0.6570246",
"0.65540105",
"0.6536586",
"0.6536121",
"0.65078354",
"0.6487242",
"0.64753413",
"0.64492106",
"0.64278543",
"0.64034116",
"0.6360571",
"0.63458127",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345649",
"0.6345126",
"0.6342251",
"0.6342251",
"0.6328233",
"0.6309846",
"0.63073117",
"0.6300686",
"0.6300158",
"0.62956303",
"0.62954974",
"0.6250478",
"0.6191336",
"0.6191336",
"0.6189128",
"0.618247",
"0.6182378",
"0.61730343",
"0.6168787",
"0.6166467",
"0.6164159",
"0.61581796",
"0.612764",
"0.609958",
"0.60892355",
"0.60892355",
"0.6088128",
"0.60608053",
"0.6054273",
"0.6023187",
"0.6023187",
"0.60102385",
"0.6004912",
"0.6002463",
"0.59992445",
"0.5990025",
"0.59871787",
"0.59871787",
"0.59808886",
"0.5978515",
"0.5968971",
"0.5968904",
"0.5957636",
"0.59488636",
"0.5939106"
] |
0.7183093
|
15
|
GET /clubs/1 GET /clubs/1.json
|
def show
@club = Club.find(params[:id])
authorize @club
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def show\n \n @club = Club.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n\n \n end",
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n end\n end",
"def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clubs }\n end\n end",
"def show\n\n #params[:id] = @current_user.club_id\n @club = Club.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n end",
"def show\n\t\trender json: @club\n\tend",
"def index\n\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def show\n @club_path = ClubPath.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club_path }\n end\n end",
"def index\n @clubs = Club.all\n end",
"def index\n @clubs = Club.all\n end",
"def index\n @clubs = Club.all\n end",
"def clubs\n \t@title = \"My Clubs\"\n \t@clubs = Student.find(params[:id]).clubs\n \trender 'show_clubs'\n end",
"def show\n @nightclub = Nightclub.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club }\n end\n end",
"def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def show\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @club }\n end\n end",
"def index\n @club = Club.find_by_slug(params[:club_id])\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end",
"def index\n @club2s = Club2.all\n end",
"def index\n authorize Club\n @clubs = Club.all\n end",
"def all_clubs\n Club.all\nend",
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def index\n @clubs = Club.page(params[:page]).per(6)\n end",
"def index\n @clubs = Club.all\n respond_with @clubs, :include => :id\n end",
"def index\n @clubs = Club.all \n respond_to do |format|\n format.html { \n authorize! :index, @clubs\n }\n format.json { \n \n }\n end\n end",
"def show\n @club = Club.find(params[:id])\n respond_with @club, :include => :id\n end",
"def index\n begin\n conditions = [\"club_id = ?\",@club.id]\n @courses = Course.find(:all, :order => 'id', :conditions => conditions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n\n @club = Club.find(params[:id])\n\n end",
"def new\n @club_path = ClubPath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club_path }\n end\n end",
"def club\n @user.club\n end",
"def create\n\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @club, status: :created\n\t\telse\n\t\t \trender json: @club.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def clubs_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.clubs_get ...\"\n end\n # resource path\n local_var_path = \"/clubs\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#clubs_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def index\n @tennis_clubs = TennisClub.all\n end",
"def index\n @clubs = Club.all\n # @small_genres = []\n end",
"def display_resource(club)\n club.name\n end",
"def index\n @clubusers = Clubusers.all\n end",
"def club\n viewing.club\n end",
"def set_club_info\n @club_info = ClubInfo.find(params[:id])\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def team\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html #team.html.erb\n end\n end",
"def set_club\n\t\t\t@club = Club.find(params[:id])\n\t\tend",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n respond_to do |format|\n format.html { \n authorize! :index, @club\n }\n format.json { \n \n }\n end\n end",
"def index\n @admin_clubs = Admin::Club.all\n end",
"def index\n @clubs = Club.order(name: :asc)\n end",
"def new\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @beer_club = BeerClub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def index\n @club_types = ClubType.all\n end",
"def new\n @beer_club = BeerClub.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def show_players_on_specific_club\n the_club = choose_club #user chooses club they want to see players for\n the_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n the_club.players.each do |player| #loops through instance of club and prints all players \n puts player.name\n end\nend",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def set_club\n @club = Club.find(params[:id])\n @place = Place.find(@club.place_id)\n #devolve-nos a relacao que contem todos os UserClubs correspondentes ao clube com id = @club.id\n @users_clubs = UserClub.where(\"club_id = #{params[: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 index\n @clubs = Club.joins(:place).all\n\n end",
"def new\n @nightclub = Nightclub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def create\n @club = Club.new(club_params)\n @club.save\n respond_with @club\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def index\n @stripclubs = Stripclub.all\n end",
"def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end",
"def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end",
"def show\n @committeemember = Committeemember.find(params[:id])\n @club = Club.find(params[:club_id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @committeemember }\n end\n end",
"def index\n @club_students = ClubStudent.all\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Circolo creato con successo.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club = Club.find(params[:id])\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 :ok }\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 set_club2\n @club2 = Club2.find(params[:id])\n end",
"def show\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climb }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def show\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clonet }\n end\n end",
"def new\n @club = Club.new(:city_id => params[:id])\n\n puts \"Klub: \" + @club.city_id.to_s();\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @club }\n end\n end",
"def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: \"Club was successfully updated.\" }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @golf_cource }\n end\n end",
"def update\n @club = Club.find(params[:id])\n @club.update_attributes(club_params)\n respond_with @club\n end",
"def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @tea_clubs = TeaClub.all\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def update\n @club = Club.find(params[:id])\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"
] |
[
"0.83942306",
"0.82158464",
"0.81019014",
"0.8078959",
"0.7889925",
"0.7877483",
"0.786315",
"0.78516775",
"0.75047773",
"0.74475837",
"0.74475837",
"0.74475837",
"0.7375221",
"0.72653127",
"0.7220348",
"0.72018844",
"0.71983624",
"0.7168892",
"0.7067452",
"0.70564526",
"0.7014342",
"0.69192976",
"0.6912992",
"0.689318",
"0.68823195",
"0.6857011",
"0.68404716",
"0.6832341",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68291575",
"0.68019783",
"0.67821735",
"0.67746574",
"0.67648447",
"0.67645353",
"0.67550117",
"0.6713428",
"0.67030036",
"0.66829425",
"0.66782135",
"0.66682416",
"0.6663717",
"0.6637863",
"0.6637863",
"0.6627219",
"0.6606342",
"0.6596717",
"0.65825856",
"0.6560133",
"0.65482324",
"0.6541834",
"0.65336514",
"0.65094614",
"0.648826",
"0.648826",
"0.6477625",
"0.6476227",
"0.6448512",
"0.64327157",
"0.6428373",
"0.6428373",
"0.64266133",
"0.6381129",
"0.6376875",
"0.6362256",
"0.63607275",
"0.63477427",
"0.63178295",
"0.630229",
"0.630229",
"0.62930137",
"0.62843066",
"0.6248078",
"0.62445724",
"0.6240604",
"0.62403417",
"0.6239332",
"0.6232273",
"0.622759",
"0.620625",
"0.6202636",
"0.6201992",
"0.6201568",
"0.6201568",
"0.6201568",
"0.6201568",
"0.6201568",
"0.619432",
"0.61883503",
"0.61883503",
"0.61800754"
] |
0.64701915
|
66
|
POST /clubs POST /clubs.json
|
def create
authorize Club
@club = Club.new(club_params)
@club.owner = current_user
@club.users << current_user
respond_to do |format|
if @club.save
format.html { redirect_to @club, notice: 'Club was successfully created.' }
format.json { render :show, status: :created, location: @club }
else
format.html { render :new }
format.json { render json: @club.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @club, status: :created\n\t\telse\n\t\t \trender json: @club.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n @club.save\n respond_with @club\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Circolo creato con successo.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_club = Admin::Club.new(admin_club_params)\n\n respond_to do |format|\n if @admin_club.save\n format.html { redirect_to @admin_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_club }\n else\n format.html { render :new }\n format.json { render json: @admin_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tennis_club = TennisClub.new(tennis_club_params)\n\n respond_to do |format|\n if @tennis_club.save\n format.html { redirect_to @tennis_club, notice: 'Tennis club was successfully created.' }\n format.json { render :show, status: :created, location: @tennis_club }\n else\n format.html { render :new }\n format.json { render json: @tennis_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n @user_club = UserClub.create(user_id: current_user.id, club_id: @club.id, join_date: Date.current)\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def create\n @nightclub = Nightclub.new(params[:nightclub])\n\n respond_to do |format|\n if @nightclub.save\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully created.' }\n format.json { render json: @nightclub, status: :created, location: @nightclub }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clubuser = Clubusers.new(clubuser_params)\n\n respond_to do |format|\n if @clubuser.save\n format.html { redirect_to @clubuser, notice: 'Clubuser was successfully created.' }\n format.json { render :show, status: :created, location: @clubuser }\n else\n format.html { render :new }\n format.json { render json: @clubuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n if params[:token].present?\n @token = Token.where(\"Value = ?\", params[:token]).first\n @user = @token.user\n else\n @user = session[:currentUser]\n end\n \n create_club_ok = is_admin_or_event_manager(@user)\n\n if create_club_ok\n @club = Club.new(params[:club])\n end\n\n respond_to do |format|\n if create_club_ok\n if @club.save\n format.html { redirect_to @club, :notice => 'Club was successfully created.' }\n format.json { render :json => @club, :status => :created, :location => @club }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @club.errors, :status => :unprocessable_entity } \n end\n else\n format.html { redirect_to :back }\n format.json { render :json => @club.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club }\n end\n end",
"def create\n @beer_club = BeerClub.new(params[:beer_club])\n\n respond_to do |format|\n if @beer_club.save\n format.html { redirect_to join_path(@beer_club), notice: 'Beer club was successfully created.' }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to(@club, :notice => 'Team was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @club2 = Club2.new(club2_params)\n\n respond_to do |format|\n if @club2.save\n format.html { redirect_to @club2, notice: 'Club2 was successfully created.' }\n format.json { render :show, status: :created, location: @club2 }\n else\n format.html { render :new }\n format.json { render json: @club2.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club_type = ClubType.new(club_type_params)\n\n respond_to do |format|\n if @club_type.save\n format.html { redirect_to @club_type, notice: 'Club type was successfully created.' }\n format.json { render :show, status: :created, location: @club_type }\n else\n format.html { render :new }\n format.json { render json: @club_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @club }\n end\n end",
"def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clubs }\n end\n end",
"def create\n @nightclub = Nightclub.new(nightclub_params)\n\n respond_to do |format|\n if @nightclub.save\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nightclub }\n else\n format.html { render action: 'new' }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club_update = ClubUpdate.new(club_update_params)\n\n respond_to do |format|\n if @club_update.save\n format.html { redirect_to @club_update, notice: 'Club update was successfully created.' }\n format.json { render :show, status: :created, location: @club_update }\n else\n format.html { render :new }\n format.json { render json: @club_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_update_club = Admin::Update::Club.new(admin_update_club_params)\n\n respond_to do |format|\n if @admin_update_club.save\n format.html { redirect_to @admin_update_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_update_club }\n else\n format.html { render :new }\n format.json { render json: @admin_update_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wine_club = WineClub.new(wine_club_params)\n\n respond_to do |format|\n if @wine_club.save\n format.html { redirect_to @wine_club, notice: 'Wine club was successfully created.' }\n format.json { render :show, status: :created, location: @wine_club }\n else\n format.html { render :new }\n format.json { render json: @wine_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stripclub = Stripclub.new(stripclub_params)\n\n respond_to do |format|\n if @stripclub.save\n format.html { redirect_to @stripclub, notice: 'Stripclub was successfully created.' }\n format.json { render :show, status: :created, location: @stripclub }\n else\n format.html { render :new }\n format.json { render json: @stripclub.errors, status: :unprocessable_entity }\n end\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 index\n\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def club_params\n params.require(:club).permit(:club_type, :name, :members, :description, :sport, :place_id)\n end",
"def create\n @club_student = ClubStudent.new(club_student_params)\n\n respond_to do |format|\n if @club_student.save\n format.html { redirect_to @club_student, notice: 'Club student was successfully created.' }\n format.json { render :show, status: :created, location: @club_student }\n else\n format.html { render :new }\n format.json { render json: @club_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_params\n params.require(:club).permit(:name, :contact_officer, :date_created)\n end",
"def create\n #debugger\n @club = Club.create(params[:club])\n @current_user.club_id = @club.id\n\n @current_user.save\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 @user = User.new\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.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render json: @club, status: :created, location: @club }\n else\n format.html { render action: \"new\" }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @yong_hu = YongHu.find_by(user_id: current_user.user_id)\n @club = Club.new(club_params)\n @club.yong_hu_id = @yong_hu.id\n @club.status = '0'\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: '提交申请成功,等待社联大大审批中……' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.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\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 club_params\n params.require(:club).permit(:name, :short_name, :address, :postal4, :postal3, :city, :phone, :email, :president, :url, :municipality_id)\n end",
"def show\n \n @club = Club.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n\n \n end",
"def create\n if MemberRequest.req!(@club, current_user)\n flash[:success] = \"Request Sent!\" \n redirect_to view_club_path(path: @club.path)\n else\n flash[:danger] = 'ERROR: There was an error processing your request'\n redirect_to root_url\n end\n end",
"def create\n @club_path = ClubPath.new(params[:club_path])\n\n respond_to do |format|\n if @club_path.save\n format.html { redirect_to @club_path, notice: 'Club path was successfully created.' }\n format.json { render json: @club_path, status: :created, location: @club_path }\n else\n format.html { render action: \"new\" }\n format.json { render json: @club_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_params\n params.require(:club).permit(:name, :room_name)\n end",
"def index\n @clubs = Club.all\n end",
"def index\n @clubs = Club.all\n end",
"def index\n @clubs = Club.all\n end",
"def show\n\t\trender json: @club\n\tend",
"def new\n @club_path = ClubPath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club_path }\n end\n end",
"def club_params\n\t\t\tparams.require(:club).permit(:name, :contact_officer, :date_created)\n\t\tend",
"def club_params\n # @user_id = current_user.id\n params.require(:club).permit(:club_name, :club_email, :club_brief, :found_time)\n end",
"def club_params\n params.require(:club).permit(:name, :phone, :address, :wait, :avatar)\n end",
"def new\n @beer_club = BeerClub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def create\n @club = Club.new(params[:club])\n\n respond_to do |format|\n if @club.save\n @event = Event.new(:date => Time.now, :club_id => @club.id, :voices_number => 0, :voices_index => 0)\n\n if @event.save\n format.html { redirect_to(\"/cities/#{@club.city_id}\", :notice => 'Club was successfully created.') }\n format.xml { render :xml => @club, :status => :created, :location => @club }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @club.errors, :status => :unprocessable_entity }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @club.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @beer_club = BeerClub.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def new\n @nightclub = Nightclub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def club_params\n params.require(:club).permit(\n :name, :short_name, :description,\n :cover_image, :remove_cover_image, :logo, :remove_logo, :recording_area\n )\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 show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n end\n end",
"def tennis_club_params\n params.require(:tennis_club).permit(:city_id, :name, :phone_number, :address)\n end",
"def create\n @team = @club.teams.build(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to club_path(@club), notice: 'Mannschaft wurde erstellt. (though in html)' }\n format.json { render json: @team, status: :created, location: @team }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n \n respond_to do |format|\n if @club.save\n @club.users.push(User.find_by(email: @club.captain_email))\n @club.rolls.find_by(user_id: User.find_by(email: @club.captain_email).id).update(relation: \"captain\")\n \n \n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_params\n params.require(:club).permit(:name, :webLink, :registrationNumber, :description, :banner, :image, :image2, :image3)\n end",
"def recipe_club_params\n params.require(:recipe_club).permit(:name)\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 new\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"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 club_params\n params.require(:club).permit(:title, :desc, :time, :location, :pay, :image, :captain_email)\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def set_club\n\n @club = Club.find(params[:id])\n\n end",
"def create\n @club_award = ClubAward.new(club_award_params)\n\n respond_to do |format|\n if @club_award.save\n format.html { redirect_to @club_award, notice: 'Record was successfully created.' }\n format.json { render :show, status: :created, location: @club_award }\n else\n format.html { render :new }\n format.json { render json: @club_award.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def club_params\n params.require(:club).permit(:Name, :admin, :numberOfMembers, :category)\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def create\n\n @club = Club.new(club_params)\n if (@club.active == true and current_user.has_role? :admin)\n @club.active = true\n else\n @club.active = false\n end\n if (current_user.has_role? :admin)\n #@club.user = club_params.user <- so wars vorher thorsten\n @club.user = User.find( club_params[:user_id])\n else\n @club.user = current_user\n end\n\n\n respond_to { |format|\n if @club.save\n\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n }\n end",
"def update\n @club = Club.find(params[:id])\n @club.update_attributes(club_params)\n respond_with @club\n end",
"def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def clubs\n \t@title = \"My Clubs\"\n \t@clubs = Student.find(params[:id]).clubs\n \trender 'show_clubs'\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n\n end",
"def create\n @club = Club.new(club_params)\n # valores default\n @club.active = true\n @club.association_id = Association.find_by( :user_id => current_user.id ).id\n\n if @club.email.present? and @club.email.length > 5\n @user = User.new(name: @club.name,\n email: @club.email,\n password: @club.email,\n password_confirmation: @club.email,\n tipo: 3 )\n end\n\n respond_to do |format|\n if @club.email.present? and @club.email.length > 5\n if @user.save\n @club.user_id = @user.id\n # os admins nao podem criar clubes, apenas as proprias associações\n # NOTA CSH: numa versao onde os admins possam criar clubes para poder transitar de uma associação para outra p.ex. tem de ser alterado\n\n if @club.save\n format.html { redirect_to @club, notice: 'O clube foi criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n @user.destroy\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n else\n # logger.debug @user.errors.to_yaml\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n if @club.save\n format.html { redirect_to @club, notice: 'O clube foi criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def club_membership_params\n params.require(:club_membership).permit(:user_id, :club_id, :status)\n end",
"def create\n @list = List.new(params[:list])\n\n respond_to do |format|\n if @list.save\n format.html { redirect_to club_path(@list.club_id), notice: 'List was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"new\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: \"Club was successfully updated.\" }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tea_club_params\n params.require(:tea_club).permit(:name, :founded, :city)\n end",
"def join\n @club = Club.find(params[:id])\n authorize @club\n @club.club_memberships.create! user_id: current_user.id\n redirect_to action: :show\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def create\n begin\n @course = Course.new(params[:course])\n @course.club = @club\n \n respond_to do |format|\n if @course.save\n format.html { redirect_to club_course_path(@club, @course)}\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end"
] |
[
"0.8054144",
"0.7773733",
"0.7694407",
"0.7685378",
"0.7629768",
"0.7629768",
"0.7382724",
"0.737534",
"0.7166113",
"0.7161418",
"0.71364695",
"0.70934063",
"0.7001579",
"0.69559604",
"0.6933581",
"0.6887192",
"0.6851174",
"0.68438107",
"0.6837938",
"0.6834599",
"0.6810462",
"0.6758532",
"0.674702",
"0.673156",
"0.67224824",
"0.6716797",
"0.6680378",
"0.6651942",
"0.6644654",
"0.6577672",
"0.6576188",
"0.65210634",
"0.65055954",
"0.64986265",
"0.64972186",
"0.6494158",
"0.64882684",
"0.6462662",
"0.64592516",
"0.6420689",
"0.64056224",
"0.63801754",
"0.63430744",
"0.63430744",
"0.63430744",
"0.6331837",
"0.63275373",
"0.6322354",
"0.62981164",
"0.628866",
"0.62739164",
"0.62737817",
"0.6270163",
"0.6257593",
"0.6251718",
"0.6233795",
"0.62203616",
"0.6218815",
"0.62175703",
"0.6204614",
"0.6201325",
"0.6191554",
"0.6171913",
"0.61634266",
"0.6156629",
"0.61552805",
"0.615224",
"0.615224",
"0.6138838",
"0.61325735",
"0.6128586",
"0.6128586",
"0.61233395",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.61186594",
"0.60990536",
"0.60942835",
"0.60939175",
"0.6086718",
"0.60849077",
"0.6067777",
"0.6035139",
"0.6035139",
"0.6035139",
"0.603451",
"0.6033605",
"0.6024791",
"0.60161334",
"0.60097927",
"0.6004125",
"0.60012174"
] |
0.7116273
|
11
|
PATCH/PUT /clubs/1 PATCH/PUT /clubs/1.json
|
def update
@club = Club.find(params[:id])
authorize @club
respond_to do |format|
if @club.update(club_params)
format.html { redirect_to @club, notice: 'Club was successfully updated.' }
format.json { render :show, status: :ok, location: @club }
else
format.html { render :edit }
format.json { render json: @club.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"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 @club = Club.find(params[:id])\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 :ok }\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 @club = Club.find(params[:id])\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 @club = Club.find(params[:id])\n @club.update_attributes(club_params)\n respond_with @club\n end",
"def update\n\t\tif @club.update(club_params)\n\t \t\thead :no_content\n\t \telse\n\t \trender json: @club.errors, status: :unprocessable_entity\n\t \tend\n\tend",
"def update\n respond_to do |format|\n if @club.update(club_params)\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 @club.update(club_params)\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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :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 @club.update(club_params)\n format.html { redirect_to @club, notice: \"Club was successfully updated.\" }\n format.json { render :show, status: :ok, location: @club }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n #authorize!(:update, @club)\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to clubs_path, notice: 'Club was successfully updated.' }\n format.json { render :index, status: :ok, location: @club }\n else\n format.html { render :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 @club_update.update(club_update_params)\n format.html { redirect_to @club_update, notice: 'Club update was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_update }\n else\n format.html { render :edit }\n format.json { render json: @club_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club = Club.find(params[:id])\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.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @club.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_update_club.update(admin_update_club_params)\n format.html { redirect_to @admin_update_club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_update_club }\n else\n format.html { render :edit }\n format.json { render json: @admin_update_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Circolo aggiornato con successo.' }\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 @club2.update(club2_params)\n format.html { redirect_to @club2, notice: 'Club2 was successfully updated.' }\n format.json { render :show, status: :ok, location: @club2 }\n else\n format.html { render :edit }\n format.json { render json: @club2.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n redirect_to root_path, notice: t('club.update')\n else\n render :edit\n end\n end",
"def update\n @beer_club = BeerClub.find(params[:id])\n respond_to do |format|\n if @beer_club.update_attributes(params[:beer_club])\n format.html { redirect_to @beer_club, notice: 'Beer club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @beer_club = BeerClub.find(params[:id])\n\n respond_to do |format|\n if @beer_club.update_attributes(params[:beer_club])\n format.html { redirect_to @beer_club, notice: 'Beer club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tennis_club.update(tennis_club_params)\n format.html { redirect_to @tennis_club, notice: 'Tennis club was successfully updated.' }\n format.json { render :show, status: :ok, location: @tennis_club }\n else\n format.html { render :edit }\n format.json { render json: @tennis_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tea_club.update(tea_club_params)\n format.html { redirect_to @tea_club, notice: 'Tea club was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tea_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club_path = ClubPath.find(params[:id])\n\n respond_to do |format|\n if @club_path.update_attributes(params[:club_path])\n format.html { redirect_to @club_path, notice: 'Club path was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @club_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @club_type.update(club_type_params)\n format.html { redirect_to @club_type, notice: 'Club type was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_type }\n else\n format.html { render :edit }\n format.json { render json: @club_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clubuser.update(clubuser_params)\n format.html { redirect_to @clubuser, notice: 'Clubuser was successfully updated.' }\n format.json { render :show, status: :ok, location: @clubuser }\n else\n format.html { render :edit }\n format.json { render json: @clubuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to([@club, @team], :notice => 'Team was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\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 set_club_update\n @club_update = ClubUpdate.find(params[:id])\n end",
"def update\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to club_path(@club), notice: 'Mannschaft wurde aktualisiert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @nightclub = Nightclub.find(params[:id])\n\n respond_to do |format|\n if @nightclub.update_attributes(params[:nightclub])\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nightclub.update(nightclub_params)\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wine_club.update(wine_club_params)\n format.html { redirect_to @wine_club, notice: 'Wine club was successfully updated.' }\n format.json { render :show, status: :ok, location: @wine_club }\n else\n format.html { render :edit }\n format.json { render json: @wine_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_club\n\n @club = Club.find(params[:id])\n\n end",
"def update\n respond_to do |format|\n if @club_student.update(club_student_params)\n format.html { redirect_to @club_student, notice: 'Club student was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_student }\n else\n format.html { render :edit }\n format.json { render json: @club_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def set_club\n @club = Club.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @stripclub.update(stripclub_params)\n format.html { redirect_to @stripclub, notice: 'Stripclub was successfully updated.' }\n format.json { render :show, status: :ok, location: @stripclub }\n else\n format.html { render :edit }\n format.json { render json: @stripclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @absence = Absence.find(params[:id])\n #@member = Member.find(params[:member_id])\n #@club = Club.find(params[:club_id] ) \n\n \n \n\n respond_to do |format|\n if @absence.update_attributes(params[:absence])\n format.html { redirect_to club_member_absence_path(@club,@member,@absence), notice: 'Absence was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @absence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n club = ::Posts::Club.with_user(@user)\n authorize! :update, club\n if club.update_attributes(data_params)\n render_update_success club\n else\n render_failure club\n end\n end",
"def update\n \n if params[:destroy_logo] == \"1\"\n @admin_club.logo = nil\n end\n\n if params[:destroy_banner] == \"1\"\n @admin_club.banner = nil\n end\n\n\n respond_to do |format|\n if @admin_club.update(admin_club_params)\n format.html { redirect_to @admin_club, notice: 'Club was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_club }\n else\n format.html { render :edit }\n format.json { render json: @admin_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_update_params\n params.require(:club_update).permit(:content, :title)\n end",
"def set_club\n\t\t\t@club = Club.find(params[:id])\n\t\tend",
"def set_club_info\n @club_info = ClubInfo.find(params[:id])\n end",
"def create\n @club_update = ClubUpdate.new(club_update_params)\n\n respond_to do |format|\n if @club_update.save\n format.html { redirect_to @club_update, notice: 'Club update was successfully created.' }\n format.json { render :show, status: :created, location: @club_update }\n else\n format.html { render :new }\n format.json { render json: @club_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jugador = Jugador.find(params[:id])\n @clubes = Club.all\n @equipos = Equipo.all\n respond_to do |format|\n if @jugador.update_attributes(params[:jugador])\n format.html { redirect_to @jugador, notice: 'Jugador fue actualizado adecuadamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jugador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_update_club = Admin::Update::Club.new(admin_update_club_params)\n\n respond_to do |format|\n if @admin_update_club.save\n format.html { redirect_to @admin_update_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_update_club }\n else\n format.html { render :new }\n format.json { render json: @admin_update_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n \n @club = Club.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n\n \n end",
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def update\n respond_to do |format|\n if @club_award.update(club_award_params)\n format.html { redirect_to @club_award, notice: 'Record was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_award }\n else\n format.html { render :edit }\n format.json { render json: @club_award.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n if @clue.update_attributes(params[:clue])\n format.html { redirect_to @clue, notice: 'Clue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n if @clue.update_attributes(params[:clue])\n format.html { redirect_to @clue, notice: 'Clue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @athlete.altered_by = current_user.id\n namesplit = @athlete.name.split(' ')\n @athlete.short_name = \"#{namesplit.first} #{namesplit.last}\" if namesplit.length > 1\n @athlete.short_name = \"#{namesplit.first}\" if namesplit.length == 1\n\n respond_to do |format|\n\n if @athlete.update(athlete_params)\n if params[ :shortform ] or params[ :clubdetail ]\n @club = Club.find( @athlete.club_id )\n format.html { redirect_to club_path(@athlete.club_id), notice: 'Atleta criado com sucesso.' }\n else\n format.html { redirect_to @athlete, notice: 'Atleta actualizado com sucesso.' }\n end\n format.json { head :no_content }\n else\n if params[ :shortform ] or params[ :clubdetail ]\n @club = Club.find( @athlete.club_id )\n flash[:error] = @athlete.errors.full_messages.join(\".<br>\").html_safe\n format.html { redirect_to club_path(@athlete.club_id) }\n else\n format.html { render action: 'edit' }\n end\n format.json { render json: @athlete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def set_recipe_club\n @recipe_club = RecipeClub.find(params[:id])\n end",
"def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n end\n end",
"def set_club\n @club = Club.find(params[:id])\n @place = Place.find(@club.place_id)\n #devolve-nos a relacao que contem todos os UserClubs correspondentes ao clube com id = @club.id\n @users_clubs = UserClub.where(\"club_id = #{params[:id]}\")\n end",
"def update\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n if @slab.update_attributes(params[:slab])\n format.html { redirect_to @slab, :notice => 'Slab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @slab.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_club2\n @club2 = Club2.find(params[:id])\n end",
"def update\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n if @golf_cource.update_attributes(params[:golf_cource])\n format.html { redirect_to scaffold_golf_cource_url(@golf_cource), notice: 'Golf cource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @golf_cource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def admin_update_club_params\n params.require(:admin_update_club).permit(:shortname, :clubname, :clubdesc, :clubweblink, :videolink, :clubquote, :imagelink)\n end",
"def put!\n request! :put\n end",
"def show\n\n #params[:id] = @current_user.club_id\n @club = Club.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n end",
"def set_admin_update_club\n @admin_update_club = Admin::Update::Club.find(params[:id])\n end",
"def update\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n if @scribble.update_attributes(params[:scribble])\n format.html { redirect_to @scribble, :notice => 'Scribble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n if @scribble.update_attributes(params[:scribble])\n format.html { redirect_to @scribble, :notice => 'Scribble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @scribble = Scribble.find(params[:id])\n\n respond_to do |format|\n if @scribble.update_attributes(params[:scribble])\n format.html { redirect_to @scribble, :notice => 'Scribble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @scribble.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # só criar o user no caso de ainda não existir\n if @club.user_id.nil? and @club.email.present? and @club.email.length > 5\n @user = User.new(name: @club.name,\n email: @club.email,\n password: @club.email,\n password_confirmation: @club.email,\n tipo: 3 )\n end\n\n respond_to do |format|\n if @club.user_id.nil? and @club.email.present? and @club.email.length > 5\n if @user.save\n @club.user_id = @user.id\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Clube actualizado com sucesso.' }\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 else\n @user.destroy\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n if @club.update(club_params)\n format.html { redirect_to @club, notice: 'Clube actualizado com sucesso.' }\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\n end",
"def club_params\n params.require(:club).permit(:name, :contact_officer, :date_created)\n end",
"def update\n respond_to do |format|\n if @camp.update(camp_params)\n format.html { redirect_to @camp, notice: \"#{@camp.name} was revised in the system.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.jdson { render json: @camp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def update\n respond_to do |format|\n if @cubboard.update(cubboard_params)\n format.html { redirect_to @cubboard, notice: \"Cubboard was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cubboard }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cubboard.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_params\n # @user_id = current_user.id\n params.require(:club).permit(:club_name, :club_email, :club_brief, :found_time)\n end",
"def update\n respond_to do |format|\n if @conference.update_attributes(params[:conference])\n format.html { redirect_to [:admin, @sport], notice: 'Conference was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conference.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n if @team.update_attributes(params[:team])\n head :no_content\n else\n render json: @team.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def update\n @family_crest = FamilyCrest.find(params[:id])\n\n respond_to do |format|\n if @family_crest.update_attributes(params[:family_crest])\n format.html { redirect_to @family_crest, notice: 'Family crest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @family_crest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_params\n params.require(:club).permit(:club_type, :name, :members, :description, :sport, :place_id)\n end",
"def update\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n if @climb.update_attributes(params[:climb])\n format.html { redirect_to @climb, notice: 'Climb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @climb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end",
"def club_params\n\t\t\tparams.require(:club).permit(:name, :contact_officer, :date_created)\n\t\tend",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @boy = Boy.find(params[:id])\n\n respond_to do |format|\n if @boy.update_attributes(params[:boy])\n format.html { redirect_to @boy, notice: 'Boy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @boy = Boy.find(params[:id])\n\n respond_to do |format|\n if @boy.update_attributes(params[:boy])\n format.html { redirect_to @boy, notice: 'Boy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @membership_clerk.update(membership_clerk_params)\n format.html { redirect_to @membership_clerk, notice: 'Membership clerk was successfully updated.' }\n format.json { render :show, status: :ok, location: @membership_clerk }\n else\n format.html { render :edit }\n format.json { render json: @membership_clerk.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.78566873",
"0.7662503",
"0.7648432",
"0.7564167",
"0.7512484",
"0.74925065",
"0.74925065",
"0.7461075",
"0.7461075",
"0.7461075",
"0.7461075",
"0.7461075",
"0.74399173",
"0.72643304",
"0.72520417",
"0.7219107",
"0.7159269",
"0.7110806",
"0.7005018",
"0.70039654",
"0.69535154",
"0.6950677",
"0.69364595",
"0.6909931",
"0.69027513",
"0.6781219",
"0.6733932",
"0.6711913",
"0.6689747",
"0.6635662",
"0.66334355",
"0.6555807",
"0.65340936",
"0.65094066",
"0.64457417",
"0.64431715",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.63908625",
"0.6348015",
"0.6252792",
"0.6241076",
"0.62371933",
"0.62210476",
"0.61908907",
"0.61647004",
"0.61510634",
"0.61449957",
"0.61294264",
"0.61257833",
"0.612355",
"0.6115462",
"0.6065894",
"0.60650706",
"0.60650706",
"0.6061693",
"0.6033099",
"0.60004264",
"0.5996777",
"0.5956575",
"0.59153473",
"0.5903404",
"0.5860013",
"0.5858345",
"0.58454907",
"0.58451945",
"0.58433545",
"0.58427465",
"0.58391386",
"0.5838014",
"0.5826537",
"0.5826537",
"0.5826537",
"0.5820383",
"0.58006334",
"0.5792624",
"0.5789146",
"0.57859415",
"0.57829946",
"0.57688326",
"0.5768021",
"0.5759124",
"0.5759124",
"0.5757125",
"0.57536864",
"0.57535636",
"0.5747039",
"0.574129",
"0.57404417",
"0.57358325",
"0.57358325",
"0.572717"
] |
0.71363366
|
17
|
DELETE /clubs/1 DELETE /clubs/1.json
|
def destroy
@club = Club.find(params[:id])
authorize @club
@club.destroy
respond_to do |format|
format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n head :no_content\n end",
"def destroy\n @club_path = ClubPath.find(params[:id])\n @club_path.destroy\n\n respond_to do |format|\n format.html { redirect_to club_paths_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: \"Club was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to(clubs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n respond_with @club\n end",
"def destroy\n @club.destroy\n respond_to do |format|\n flash[:notice] = 'Clube foi apagado com sucesso.'\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tea_club.destroy\n respond_to do |format|\n format.html { redirect_to tea_clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nightclub = Nightclub.find(params[:id])\n @nightclub.destroy\n\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@club = Club.find(params[:id])\n\t\t@club.destroy\n\n\t\trespond_to do |format|\n\t\t format.html { redirect_to(clubs_url) }\n\t\t format.xml { head :ok }\n\t\tend\n\tend",
"def destroy\n @beer_club = BeerClub.find(params[:id])\n @beer_club.destroy\n\n respond_to do |format|\n format.html { redirect_to beer_clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beer_club = BeerClub.find(params[:id])\n @beer_club.destroy\n\n respond_to do |format|\n format.html { redirect_to beer_clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club2.destroy\n respond_to do |format|\n format.html { redirect_to club2s_url, notice: 'Club2 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nightclub.destroy\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_club.destroy\n respond_to do |format|\n format.html { redirect_to admin_clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club.address.destroy if @club.address.present?\n @club.events.destroy_all if @club.events.present?\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_update_club.destroy\n respond_to do |format|\n format.html { redirect_to admin_update_clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club_update.destroy\n respond_to do |format|\n format.html { redirect_to club_updates_url, notice: 'Club update was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@club.destroy\n\t\t\n\t\thead :no_content\n\tend",
"def destroy\n @club_type.destroy\n respond_to do |format|\n format.html { redirect_to club_types_url, notice: 'Club type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tennis_club.destroy\n respond_to do |format|\n format.html { redirect_to tennis_clubs_url, notice: 'Tennis club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = @club.teams.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to club_teams_url(@club.id) }\n format.json { head :no_content }\n end\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 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 @stripclub.destroy\n respond_to do |format|\n format.html { redirect_to stripclubs_url, notice: 'Stripclub was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club_award.destroy\n respond_to do |format|\n format.html { redirect_to club_awards_url, notice: 'Club award was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club_student.destroy\n respond_to do |format|\n format.html { redirect_to club_students_url, notice: 'Club student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if is_club_current_admin?(@club.id)\n @club.destroy\n respond_to do |format|\n format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\nelse\n flash[:error] = \"You cannot delete a club you did not create\"\n end",
"def destroy\n # @athlete.destroy\n @athlete.active = false;\n @athlete.save;\n respond_to do |format|\n if params[ :clubdetail ]\n format.html { redirect_to club_url( @athlete.club_id ) }\n else\n format.html { redirect_to athletes_url }\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_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 @clue = Clue.find(params[:id])\n @clue.destroy\n\n respond_to do |format|\n format.html { redirect_to clues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clue = Clue.find(params[:id])\n @clue.destroy\n\n respond_to do |format|\n format.html { redirect_to clues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb = Climb.find(params[:id])\n @climb.destroy\n\n respond_to do |format|\n format.html { redirect_to climbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cubboard.destroy\n respond_to do |format|\n format.html { redirect_to cubboards_url, notice: \"Cubboard was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to club_path(@event.club_id), notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @committeemember = Committeemember.find(params[:id])\n @committeemember.destroy\n\n respond_to do |format|\n format.html { redirect_to(club_committees_path(params[:club_id])) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @absence = Absence.find(params[:id])\n @absence.destroy\n\n respond_to do |format|\n format.html { redirect_to club_member_absences_path(params[:club_id],current_member) }\n format.json { head :ok }\n end\n end",
"def destroy\n @brewhouse = Brewhouse.find(params[:id])\n @brewhouse.destroy\n\n respond_to do |format|\n format.html { redirect_to brewhouses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb.destroy\n respond_to do |format|\n format.html { redirect_to climbs_url, notice: 'Climb was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n name = @bowler.full_name\n @bowler.record :destroy, current_user, selected_tournament\n @bowler.destroy\n respond_to do |format|\n format.html { redirect_to bowlers_url, notice: \"Bowler #{name} has been successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @championship = Championship.find(params[:id])\n @championship.destroy\n\n respond_to do |format|\n format.html { redirect_to championships_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @code_club_school.destroy\n respond_to do |format|\n format.html { redirect_to code_club_schools_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @albumsix.destroy\n respond_to do |format|\n format.html { redirect_to albumsixes_url, notice: 'Albumsix was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def soccer_delete\n base_delete(params, \"Soccer\")\n end",
"def destroy\n @golf_cource = GolfCource.find(params[:id])\n @golf_cource.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_golf_cources_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @boy = Boy.find(params[:id])\n @boy.destroy\n\n respond_to do |format|\n format.html { redirect_to boys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boy = Boy.find(params[:id])\n @boy.destroy\n\n respond_to do |format|\n format.html { redirect_to boys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocktail = Cocktail.find(params[:id])\n @cocktail.destroy\n\n respond_to do |format|\n format.html { redirect_to cocktails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocktail = Cocktail.find(params[:id])\n @cocktail.destroy\n\n respond_to do |format|\n format.html { redirect_to cocktails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scribble = Scribble.find(params[:id])\n @scribble.destroy\n\n respond_to do |format|\n format.html { redirect_to scribbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scribble = Scribble.find(params[:id])\n @scribble.destroy\n\n respond_to do |format|\n format.html { redirect_to scribbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scribble = Scribble.find(params[:id])\n @scribble.destroy\n\n respond_to do |format|\n format.html { redirect_to scribbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cabinet = Cabinet.find(params[:id])\n @cabinet.destroy\n\n respond_to do |format|\n format.html { redirect_to cabinets_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @jugador = Jugador.find(params[:id])\n @jugador.destroy\n @clubes = Club.all\n @equipos = Equipo.all\n respond_to do |format|\n format.html { redirect_to jugadores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bourbon.destroy\n respond_to do |format|\n format.html { redirect_to bourbons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tournament.destroy\n respond_to do |format|\n format.html { redirect_to tournaments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tournament.destroy\n respond_to do |format|\n format.html { redirect_to tournaments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clay.destroy\n respond_to do |format|\n format.html { redirect_to clays_url, notice: 'Clay was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @camp.destroy\n respond_to do |format|\n format.html { redirect_to camps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couche was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @slab = Slab.find(params[:id])\n @slab.destroy\n\n respond_to do |format|\n format.html { redirect_to slabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @camp = Camp.find(params[:id])\n @camp.destroy\n\n respond_to do |format|\n format.html { redirect_to camps_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @climb_datum = ClimbDatum.find(params[:id])\n @climb_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to climb_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hood.destroy\n respond_to do |format|\n format.html { redirect_to hoods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if current_user.admin\n @wine_club.destroy\n respond_to do |format|\n format.html { redirect_to wine_clubs_url, notice: 'Wine club was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n redirect_to wine_club_url, notice: 'You do not have sufficient rights.'\n end\n end",
"def destroy\n @camp = Camp.find(params[:id])\n @camp.destroy\n\n respond_to do |format|\n format.html { redirect_to camps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @livestock = Livestock.find(params[:id])\n @livestock.destroy\n\n respond_to do |format|\n format.html { redirect_to livestocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to bowls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tribal_membership.destroy\n respond_to do |format|\n format.html { redirect_to tribal_memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize(Coach)\n @sport.destroy\n respond_to do |format|\n format.html { redirect_to sports_url, notice: 'Sport was successfully destroyed.' }\n format.json { head :no_content }\n end\n \n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :ok }\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 destroy\n @conference.destroy\n\n respond_to do |format|\n format.html { redirect_to [:admin, @sport] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contractual_labour.destroy\n respond_to do |format|\n format.html { redirect_to contractual_labours_url, notice: 'Contractual labour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jam_circle.destroy\n respond_to do |format|\n format.html { redirect_to jam_circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @six.destroy\n respond_to do |format|\n format.html { redirect_to sixes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @sivic_banco.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_bancos_url }\r\n format.json { head :no_content }\r\n end\r\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 @court_hall.destroy\n respond_to do |format|\n format.html { redirect_to court_halls_url, notice: 'Court hall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end"
] |
[
"0.81467396",
"0.8125921",
"0.8125921",
"0.80589193",
"0.80589193",
"0.80283463",
"0.7990399",
"0.7949108",
"0.79312074",
"0.78865546",
"0.78865546",
"0.78865546",
"0.78705937",
"0.78516614",
"0.77526957",
"0.771957",
"0.7699575",
"0.7608901",
"0.7604228",
"0.7587584",
"0.7587584",
"0.7580031",
"0.7579375",
"0.75684977",
"0.75385565",
"0.7516351",
"0.7483231",
"0.7481083",
"0.7480546",
"0.7438556",
"0.73579013",
"0.73148775",
"0.71957695",
"0.71912444",
"0.70546234",
"0.7046241",
"0.69294477",
"0.6904359",
"0.69028914",
"0.67841846",
"0.6780219",
"0.6780219",
"0.6765001",
"0.67038876",
"0.66520154",
"0.6651997",
"0.66365486",
"0.6623009",
"0.6599313",
"0.65989256",
"0.6592137",
"0.6588493",
"0.65875113",
"0.6586263",
"0.65769774",
"0.65714043",
"0.6566615",
"0.6566615",
"0.6549712",
"0.6549712",
"0.6549381",
"0.6549381",
"0.6549381",
"0.65430504",
"0.6539699",
"0.653578",
"0.65334636",
"0.6532834",
"0.6527983",
"0.65248406",
"0.65248406",
"0.6521043",
"0.65117055",
"0.6508574",
"0.6488613",
"0.64871156",
"0.6486664",
"0.64860076",
"0.6484948",
"0.6474856",
"0.64665633",
"0.6466178",
"0.6454051",
"0.6448062",
"0.6448062",
"0.6448062",
"0.6448062",
"0.64473987",
"0.64461136",
"0.6445364",
"0.6441351",
"0.64345556",
"0.6434292",
"0.6431812",
"0.64309096",
"0.64306766",
"0.6428685",
"0.6427913",
"0.6425638",
"0.6422564"
] |
0.7623334
|
17
|
POST /clubs/1/join POST /clubs/1/join.json
|
def join
@club = Club.find(params[:id])
authorize @club
@club.club_memberships.create! user_id: current_user.id
redirect_to action: :show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def join\n @beer_club = BeerClub.find(params[:id])\n if Membership.where(:beer_club_id => @beer_club.id, :user_id => current_user.id).exists?\n respond_to do |format|\n format.html { redirect_to :back, notice: \"You are already a member of this club!\" }\n end\n else\n @membership = Membership.create\n @membership.beer_club_id = @beer_club.id\n @membership.user_id = current_user.id\n if @beer_club.memberships.count < 1\n @membership.confirmed = true\n else\n @membership.confirmed = false\n end\n respond_to do |format|\n if @membership.save\n format.html { redirect_to :back, notice: \"You joined #{@beer_club.name}\" }\n else\n format.html { redirect_to :back, notice: \"Something went awry! D:\" }\n end\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n @user_club = UserClub.create(user_id: current_user.id, club_id: @club.id, join_date: Date.current)\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join \n\n #Check if user exists\n user = User.find_by!(id: params[:user_id])\n\n if (ChannelJoined.exists?({ channel_id: params[:id], user_id: params[:user_id]}))\n json_response({\n \"joined\": true\n })\n else\n joined = ChannelJoined.create!(user_id: params[:user_id], channel_id: params[:id])\n json_response(joined.channel)\n end\n \n \n end",
"def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end",
"def join\n unless @user && @kroog && @kroog.open? && current_actor.can_follow?\n flash[:warning] = \"Error: The specified circle does not exist or cannot be joined\".t\n respond_to do |format|\n format.html do\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id])\n end\n format.js {render :update do |page|; page << 'document.location.reload(false);'; end}\n end\n return\n end\n\n # Add the relationship directly -- no invite intermediary\n Relationship.create_kroogi_relationship(:followed => @user.id, :follower => current_actor.id, :relationshiptype_id => @kroog.relationshiptype_id, :expires_at => Time.end, :skip_activity_message => true)\n\n flash[:success] = \"You have joined the %s circle of %s\" / [@user.circle_name(params[:circle].to_i), @user.login]\n PublicQuestionHelper::set_question_artist_id(@user, self, :force_show => true)\n respond_to do |wants|\n wants.html do\n redirect_to user_url_for(@user)\n end\n wants.js {}\n end\n end",
"def create\n @join = Join.find_by(user_id: current_user.id, hike_id: params[:id])\n if @join\n redirect_to :back\n else\n @join = Join.create(user_id:current_user.id, hike_id:params[:id])\n redirect_to :back\n end\n end",
"def join\n circle_id = params[:circle][:circle_id]\n circle_url = File.join(SITE_URL, \"circles/#{circle_id}\")\n\n joined = CircleUser.where(circle_id: circle_id, user_id: current_user.id).first_or_initialize\n\n respond_to do |format|\n if not joined.persisted?\n joined.save\n Circle.update_counters(params[:circle][:circle_id], people_count: 1)\n User.update_counters(current_user.id, circle_count: 1)\n mod = 1\n else\n joined.delete\n Circle.update_counters(params[:circle][:circle_id], people_count: -1)\n User.update_counters(current_user.id, circle_count: -1)\n mod = -1\n end\n format.json { render json: {'status' => mod, 'circle_url' => circle_url}, status: :created }\n end\n end",
"def create\n @beer_club = BeerClub.new(params[:beer_club])\n\n respond_to do |format|\n if @beer_club.save\n format.html { redirect_to join_path(@beer_club), notice: 'Beer club was successfully created.' }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n @person = Person.find(params[:person_id])\n @group = Group.find(params[:id])\n begin\n @person.join_group(@group.id, session[:cookie])\n flash[:notice] = [ :you_have_joined_to_group, @group.title(session[:cookie]) ]\n rescue RestClient::RequestFailed => e\n flash[:error] = message_from_error(e)\n end\n redirect_to group_path(params[:id])\n end",
"def join_group\n @disc_group = DiscussionGroup.find(params[:id])\n @join = DiscussionGroupUser.new(:discussion_group_id => @disc_group.id, :user_id => @login_user.id, :is_member => 1)\n if @join.save\n respond_to do |format|\n format.js\n end\n else\n render :text=>\"Fail\"\n end\n end",
"def join\n pids = get_player_list(@match).map{|p| p.try(:id)} # list of player ids\n status = false\n if can_join(pids) #if possible, join\n status = join_now(@match, current_user.id)\n done = [\"joined\", \"success\"]\n elsif pids.include?(current_user.id) #if already joined, then leave\n status = leave_now(@match, current_user.id, @host)\n done = [\"left\", \"warning\"]\n if !get_player_list(@match).any? #if there is no more players in match, then destroy\n destroy\n return\n end\n end\n\n respond_to do |format|\n if status and @match.save\n format.html { redirect_to @match, notice: ['You have succesfully ' + done[0] + ' the match.', \"alert alert-dismissible alert-\" + done[1]] }\n else\n format.html { redirect_to @match, notice: ['Sorry, your request could not be processed.', \"alert alert-dismissible alert-danger\"] }\n end\n end\n end",
"def joinGroup\n id = params[:id]\n line = \"https://gtcollab.herokuapp.com/api/groups/\" + id + \"/join/\"\n \n require \"net/http\"\n require \"uri\"\n\n parsed_url = URI.parse(line)\n\n http = Net::HTTP.new(parsed_url.host, parsed_url.port)\n http.use_ssl = true\n\n req = Net::HTTP::Post.new(parsed_url.request_uri)\n\n req.add_field(\"authorization\", $token)\n\n response = http.request(req)\n response.inspect\n\n redirect_to course_path(params[:course_id], :name => params[:name], :joined => params[:joined])\n end",
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def join\n @game = Game.find(params[:id])\n @game.assign_team(current_user)\n redirect_to \"/games/#{@game.id}\"\n end",
"def join\n\t\t@classroom = Classroom.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@membership = Membership.new\n\t\t@membership.classroom_id = @classroom.id\n\t\t@membership.user_id = params[:user_id]\n\t\tif @membership.save\n\t\t\tredirect_to params[:redirect_url] || @classroom, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to @classroom, alert: \"You are already a member of this class!\"\n\t\tend\n\tend",
"def create\n @join = Join.new(user_id: current_user.id, event_id: params[:event_id])\n if @join.save\n redirect_to \"/events\"\n else\n redirect_to \"/events\"\n end\n end",
"def create\n @joined = Joined.new(joined_params)\n\n respond_to do |format|\n if @joined.save\n format.html { redirect_to @joined, notice: 'Joined was successfully created.' }\n format.json { render :show, status: :created, location: @joined }\n else\n format.html { render :new }\n format.json { render json: @joined.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n course = Course.where(join_token: params[:course][:join_token]).first\n\n if course and not current_user.courses.include? course\n current_user.courses << course\n current_user.add_role :student, course\n course.assignments.each { |assignment| assignment.create_submissions_for_students }\n\n flash[:notice] = \"Successfully joined class\"\n redirect_to course_path(course.id)\n else\n flash[:notice] = \"Failed to join class\"\n redirect_to :back\n end\n end",
"def create\n @club = Club.new(club_params)\n \n respond_to do |format|\n if @club.save\n @club.users.push(User.find_by(email: @club.captain_email))\n @club.rolls.find_by(user_id: User.find_by(email: @club.captain_email).id).update(relation: \"captain\")\n \n \n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join_request\n \n end",
"def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!(:user => user)\n end",
"def join_group(id)\n\t\t\t#id: ID of the group to join\n\t\t\toptions = {\"id\" => id}\n\t\t\tdata = oauth_request(\"/group/join\", options, \"post\")\n\t\tend",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n @group = Group.find(params[:id])\n\n if !current_user.is_member_of?(@group)\n current_user.join!(@group)\n flash[:notice] = \"Successfully joined the group!\"\n else\n flash[:warning] = \"You are a member of this group!\"\n end\n\n redirect_to group_path(@group)\n end",
"def join\n @room = Room.find(params.require(:room_id))\n if @room&.add_user(current_user)\n success\n else\n not_found\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\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @club, status: :created\n\t\telse\n\t\t \trender json: @club.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def join\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, @household.id)\n\t redirect_to @household\n\tend",
"def create\n @supported_projects_join = SupportedProjectsJoin.new(supported_projects_join_params)\n\n respond_to do |format|\n if @supported_projects_join.save\n format.html { redirect_to @supported_projects_join, notice: 'Supported projects join was successfully created.' }\n format.json { render :show, status: :created, location: @supported_projects_join }\n else\n format.html { render :new }\n format.json { render json: @supported_projects_join.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize Club\n @club = Club.new(club_params)\n @club.owner = current_user\n @club.users << current_user\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n # Check status first to see if the user can join.\n # Check if the number of users exceed the the size of the room.\n @room = Room.find(params[:id])\n\n # Room is oversize\n if @room.is_full?\n message = \"#{current_user.name} cannot joined the room because the room is full.\"\n result = false\n elsif @room.status != ROOM_STATUS[:open]\n message = \"The room #{params[:id]} is not open!\"\n elsif @room.join?(current_user)\n message = \"#{current_user.name} is already joinned the room\"\n else\n\n result = @room.join(current_user)\n if result\n message = \"#{current_user.name} has joined the room\"\n else\n message = \"#{current_user.name} cannot join the room. Server side error\"\n end\n end\n\n if result\n channel = params[:id].to_s\n respond_message = {\n message: message,\n current_user: current_user,\n room_id: @room.id,\n status: USER_STATUS[:join]\n }\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n else\n channel = \"server_channel\"\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n end\n\n respond_to do |format|\n if result\n format.html { redirect_to @room, notice: message }\n format.json { render json: @room.to_hash_with_users(current_user).to_json, status: :created, location: @room }\n else\n format.html { render notice: \"Cannot join the room.\" }\n format.json { render json: {message: message}, status: :unprocessable_entity }\n end\n end\n end",
"def join\r\n if @trip.participants.include?(current_person)\r\n redirect_to(@trip, :notice => \"You are already a participant in the #{@trip.name}.\")\r\n return\r\n elsif @trip.organizers.include?(current_person) && request.post?\r\n @trip.participants << current_person\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n else\r\n @token = params[:token]\r\n invitation = Invitation.find_by_token(@token)\r\n if invitation.nil?\r\n redirect_to(person_root_url, :error => \"The invitation link you followed is invalid.\")\r\n return\r\n end\r\n \r\n if request.post?\r\n invitation.accept(current_person)\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n end\r\n end\r\n end",
"def join(force = false)\n post 'join'\n end",
"def join(id)\n precondition do\n raise unless id > 0\n end\n\n id = rpc \"join\", id \n @game.sync\n \n postcondition do\n raise unless id\n end\n end",
"def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def joinsquad\n if params[:id].to_i != @logged_in_registration.id.to_i\n flash[:error] = \"Error! Trying to sign someone else up into a squad?\"\n redirect_to root_url\n elsif @logged_in_registration.squad != nil\n flash[:error] = \"Error! You cannot change your squad.\"\n redirect_to root_url\n elsif !@current_game.has_begun?\n if params[:squadid].eql?(\"new\")\n @squad = Squad.new({\n :name => params[:new_squad_name],\n :leader_id => @logged_in_registration.id,\n :game_id => @current_game.id\n })\n if @squad.save()\n @logged_in_registration.update_attribute(:squad, @squad)\n redirect_to registration_url(@logged_in_registration)\n end\n else\n squad = Squad.find(params[:squadid])\n if squad.can_be_joined?\n @logged_in_registration.update_attribute(:squad, squad)\n redirect_to registration_url(@logged_in_registration)\n else\n flash[:error] = \"This squad cannot be joined.\"\n redirect_to squads_url()\n end\n end\n else\n flash[:error] = \"You cannot join a squad after the game has started\"\n redirect_to root_url\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Circolo creato con successo.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @form = Leagues::JoinLeagueForm.run(join_league_params.merge(current_user: current_user))\n respond_to do |format|\n if @form.valid?\n format.html { redirect_to @form.league, notice: 'League was successfully joined.' }\n format.json { render :show, status: :created, location: @league }\n else\n flash[:danger] = @form.errors[:base]&.first\n format.html { render :new }\n format.json { render json: @form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n @session = Session.where(unique_id: params[:id])\n @player = Player.new(\n name: params[:name],\n picture_url: params[:picture_url]\n )\n @session.players.push(@player)\n @session.save\n\n render status: :success\n end",
"def create\n if MemberRequest.req!(@club, current_user)\n flash[:success] = \"Request Sent!\" \n redirect_to view_club_path(path: @club.path)\n else\n flash[:danger] = 'ERROR: There was an error processing your request'\n redirect_to root_url\n end\n end",
"def join\n game = Game.find(params[:id])\n \n raise \"Game already started\" unless game.open?\n \n # Only add the player to the game if they aren't already in it\n game.join(current_user) unless game.has_player?(current_user)\n current_user.lives = 25\n current_user.save!\n redirect_to game_path\n rescue \n flash[:error] = \"That is not a game that can be joined\"\n redirect_to lobby_path\n end",
"def create\n @club = Club.new(club_params)\n @club.save\n respond_with @club\n end",
"def join\n if !current_user\n flash[:notice] = t(:join_dream)\n elsif @camp.users.include?(current_user)\n flash[:notice] = t(:join_already_sent)\n else\n flash[:notice] = t(:join_dream)\n @camp.users << @user\n end\n redirect_to @camp\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 @yong_hu = YongHu.find_by(user_id: current_user.user_id)\n @club = Club.new(club_params)\n @club.yong_hu_id = @yong_hu.id\n @club.status = '0'\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: '提交申请成功,等待社联大大审批中……' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n if request.post?\n if !@group.users.include?(current_user)\n @group.users << current_user\n flash[:success] = \"Thanks! Your membership must now be approved by an admin of #{@group.name}.\"\n\n #SEND OUT NOTIFICATION EMAILS\n @group.admins.each do |admin|\n Notifier.pending_user(admin, @group, current_user).deliver\n end\n\n redirect_to @group\n else\n flash[:error] = \"Error requesting to join #{@group.name}. Please try again.\"\n redirect_to @group\n end\n else #it fell back to GET (no js)\n flash[:error] = \"Please enable javascript to join.\"\n redirect_to @group\n end\n end",
"def join\n payload = { \"id\" => id }.to_json\n data = client.post \"#{api_prefix}/user/#{client.user.id}/rooms\", payload\n\n self\n end",
"def join\n if logged_in?\n @group_wanted = Group.find(params[:id]) # later change to params[:name]\n @country_wanted = Country.find(@group_wanted.country_id, :limit => 1)\n #match = current_user.countries.find(@country_wanted.id)\n #unless current_user.has_country?(@country_wanted.id) #countries.find(@country_wanted.id)\n #@matches = current_user.countries\n @match = Country.find_by_sql([\"SELECT * FROM countries_users WHERE user_id = ? AND country_id = ?\", current_user.id, @country_wanted.id])\n if @match.empty? #current_user.countries.find(@country_wanted.id).nil? #current_user.has_country?(@country_wanted.id) \n flash[:notice] = \"Joined!\"\n current_user.groups << @group_wanted # add group\n current_user.countries << @country_wanted # add country\n redirect_to '/perfil'\n else\n flash[:error] = \"You're either already subscribed to a group in the same country or in the same group.\"\n redirect_to :action => 'index'\n end \n end \n end",
"def join\n @plan = current_user.plans.create(:itinerary_id => params[:itinerary_id], :child_id => current_user.id, :parent_id => params[:parent_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to(itineraries_path, :notice => 'Plan was successfully created.') }\n else\n format.html { redirect_to(itineraries_path, :notice => 'There was an error in joining this itinerary') }\n end\n end\nend",
"def join\n network_invite = current_organization.network_invitations.find_by_network_id(params[:id], :include => :network)\n if network_invite.nil? then\n flash[:notice] = \"You must get an invite before joining that network.\"\n redirect_to networks_path\n else\n network_invite.accept!\n flash[:notice] = \"You have joined the network!\"\n redirect_to network_path(network_invite.network)\n end\n end",
"def join_team\n data = {\n display_name: params[:display_name],\n solver_id: params[:solver_id],\n red: params[:red],\n green: params[:green],\n blue: params[:blue]\n }\n Pusher.trigger(params[:channel], 'join_puzzle', data)\n render nothing: true\n end",
"def create\n\n if params[:token].present?\n @token = Token.where(\"Value = ?\", params[:token]).first\n @user = @token.user\n else\n @user = session[:currentUser]\n end\n \n create_club_ok = is_admin_or_event_manager(@user)\n\n if create_club_ok\n @club = Club.new(params[:club])\n end\n\n respond_to do |format|\n if create_club_ok\n if @club.save\n format.html { redirect_to @club, :notice => 'Club was successfully created.' }\n format.json { render :json => @club, :status => :created, :location => @club }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @club.errors, :status => :unprocessable_entity } \n end\n else\n format.html { redirect_to :back }\n format.json { render :json => @club.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def join\n redirect_to '/auth/linkedin'\n end",
"def join(person)\n members.push(person);\n end",
"def join\n @reservation = Reservation.find(params[:reservation_id])\n Dining.create(reservation: @reservation, member: current_member)\n Reservationrequest.where(reservation_id: @reservation.id, member_id: @reservation.members.last.id).destroy_all\n flash[:notice] = \"You joined #{@reservation.members.first.first_name} #{@reservation.members.first.last_name}'s reservation.\"\n redirect_to member_reservations_path\n end",
"def create\n @admin_club = Admin::Club.new(admin_club_params)\n\n respond_to do |format|\n if @admin_club.save\n format.html { redirect_to @admin_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_club }\n else\n format.html { render :new }\n format.json { render json: @admin_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club2 = Club2.new(club2_params)\n\n respond_to do |format|\n if @club2.save\n format.html { redirect_to @club2, notice: 'Club2 was successfully created.' }\n format.json { render :show, status: :created, location: @club2 }\n else\n format.html { render :new }\n format.json { render json: @club2.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @joining_form = JoiningForm.new(joining_form_params)\n\n respond_to do |format|\n if @joining_form.save\n format.html { redirect_to @joining_form, notice: 'Joining form was successfully created.' }\n format.json { render :show, status: :created, location: @joining_form }\n else\n format.html { render :new }\n format.json { render json: @joining_form.errors, status: :unprocessable_entity }\n end\n end\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\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 join\n @group = Group.find_by_id(params[:id])\n if @group\n @user.join_group(@group)\n flash[:success] = \"Join It Successed\"\n redirect_to :action => \"reports\", :id => @group\n else\n flash[:warning] = \"Not Exist Group to Join\"\n end\n end",
"def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end",
"def join\n if request_valid?\n request_user.online!\n \n msg = message(\"joined\")\n msg = javascript_chat_message(msg)\n \n # Inform all joined channels that the user has joined\n Juggernaut.send_to_channels(msg, params[:channels])\n \n render :nothing => true\n else\n # Prevent the user from joining the channel if the request is not\n # from a valid session/user combination\n render :text => \"403\", :status => 403\n end\n end",
"def join_group\n @assignment = Assignment.find(params[:id])\n @grouping = Grouping.find(params[:grouping_id])\n @user = Student.find(session[:uid])\n @user.join(@grouping.id)\n m_logger = MarkusLogger.instance\n m_logger.log(\"Student '#{@user.user_name}' joined group '#{@grouping.group.group_name}'\" +\n '(accepted invitation).')\n redirect_to action: 'student_interface', id: params[:id]\n end",
"def approve_join_request\n join_request = JoinRequest.find(params[:id])\n team = join_request.team\n # Only authorize the captain to do this\n if current_user.id == team.captain_id\n membership = Membership.create(\n team_id: join_request.team_id,\n user_id: join_request.user_id,\n admin: false\n )\n if membership.valid?\n join_request.destroy\n render json: {\n team: TeamSerializer.new(team),\n user: UserSerializer.new(current_user)\n }, status: :accepted\n else\n # invalid request\n render json: {\n message: \"Invalid request\",\n errors: membership.errors.full_messages\n }, status: :not_acceptable\n end\n else\n render json: { message: \"Only the captain is allowed to accept join requests\"}, status: :not_acceptable\n end\n end",
"def join_plan \n\t\trequire 'fcm'\n\t\tactivities = [\"grab food\", \"hang out\", \"group study\", \"party\"]\n\t\tplan_member = PlanMember.new(\n \tplan_id: params[:plan_id],\n \tuser_id: current_user.id\n )\n\t\tplan = Plan.find_by(id: params[:plan_id])\n\n\t\tif plan_member.save\n\t\t\tPlanMessage.create(\n \tplan_id: params[:plan_id],\n \tuser_id: current_user.id, \n \tcontent: \"#{current_user.fullname} is in!\",\n \tsystem_message: true\n )\t\n\n member_count = PlanMember.where(plan_id: params[:plan_id]).count\n\t\t\tis_happening = false\n\t if member_count > 2 && plan.is_happening == false\n\t \tis_happening = true\n\t \tplan.is_happening = true\n\t \tplan.save \n\n\t \tPlanMessage.create(\n\t \tplan_id: params[:plan_id],\n\t \tuser_id: current_user.id, \n\t \tcontent: \"Woohoo this plan to #{activities[plan.activity]} is happening! 3 or more people are in.\",\n\t \tsystem_message: true\n\t )\t\n\t end\n\t render json: { is_success: true, is_happening: is_happening, name_of_joiner: current_user.fullname}, status: :ok\n\t\t\n\t\telse\n\t\t\trender json: { is_success: false }, status: :ok\n\t\tend\n\tend",
"def create\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to(@club, :notice => 'Team was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @clubuser = Clubusers.new(clubuser_params)\n\n respond_to do |format|\n if @clubuser.save\n format.html { redirect_to @clubuser, notice: 'Clubuser was successfully created.' }\n format.json { render :show, status: :created, location: @clubuser }\n else\n format.html { render :new }\n format.json { render json: @clubuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join_competition(competition, auth)\n if existing_student = Student.find_by(linkedin_uid: auth.uid)\n\n login_as(existing_student)\n\n if competition != existing_student.competition\n flash[:notice] = \"You've already joined a different competition. Here is your dashboard for <strong>#{existing_student.competition.name}</strong>.\"\n end\n\n redirect_to team_path\n\n else\n student = Student.create!( competition: competition,\n name: auth.name,\n email: auth.email,\n avatar_url: auth.image,\n linkedin_uid: auth.uid,\n linkedin_token: auth.token )\n login_as(student)\n redirect_to new_team_membership_path\n end\n end",
"def join_room(id)\n @rooms.join id\n end",
"def create\n if current_user.join(@game)\n flash[:notice] = \"Thanks for joining up! If you follow us on Twitter, we'll send you a direct message when the game starts.\"\n session[:follow_prompt] = true\n else\n flash[:error] = \"Sorry you are unable to join this game.\"\n end\n redirect_to(game_path(@game))\n end",
"def create\n @team = Team.new(params[:team])\n if @team.save\n # the current user should join the team\n current_user.join!(@team)\n flash[:success] = \"New team created\"\n redirect_to @team\n else\n @title = \"Create a Team\"\n render :action => :new\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 user = User.find_user(params[:member][:user_id])\n @board = Board.find_board(params[:member][:board_id])\n @action = 'join'\n if ( !user.nil? && !@board.nil? )\n logger.debug \"----------------Member.new-------------------------------------\"\n @member = Member.new(params[:member])\n @member.user_id = user.id\n if params[:commit] == Member::Commit::FOLLOW\n logger.debug \"----------------Adding a follower #{user.full_name}-------------------------------------\"\n @member.user_id = current_user.id # follower could be only the current user\n @member.member_type = Member::MemberType::FOLLOWER\n # follower? is true if a user is a follower, member or owner\n if !current_user.follower?(@board)\n logger.debug \"----------------Saving follower #{user.full_name}-------------------------------------\"\n @action = 'follow'\n @member.save\n flash.now[:success] = \"Board \\\"#{@board.title}\\\" was linked to your profile.\"\n else\n flash.now[:warning] = \"Your profile already linked to \\\"#{@board.title}\\\".\"\n end\n else\n logger.debug \"----------------Adding a member #{user.full_name}-------------------------------------\"\n if !user.member?(@board)\n logger.debug \"----------------User #{user.full_name} is not a member-------------------------------------\"\n follower = user.follower?(@board)\n if follower\n logger.debug \"----------------Updating follower #{user.full_name} to become a member-------------------------------------\"\n follower.update_attribute(:member_type, Member::MemberType::MEMBER)\n else\n logger.debug \"----------------Saving #{user.full_name} as a member-------------------------------------\"\n @member.member_type = Member::MemberType::MEMBER\n @member.save\n end\n else\n logger.debug \"----------------Saving a follower #{user.full_name}-------------------------------------\"\n @member.member_type = Member::MemberType::MEMBER\n @member.save\n end\n flash.now[:success] = \"#{user.full_name} was added to your Board \\\"#{@board.title}\\\".\"\n end\n end\n\n if params[:commit] == Message::Commit::CONFIRM\n msg_id = params[:member][:message]\n unless ( msg_id.nil? )\n message = Message.find(msg_id)\n unless ( message.nil? )\n message.update_attribute(:msg_state, Message::State::CONFIRMED)\n end\n end\n end\n \n params[:act] = 'board_search'\n params[:search] = params[:member][:search] if !params[:member][:search].nil?\n\n respond_to do |format|\n #if @member.save\n format.html { redirect_to home_path }\n format.js\n format.json { render json: home_path, status: :created, location: home_path }\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 join\n end",
"def join\n user = User.find_by_id(params[:user_id])\n code = params[:code].to_s\n\n # if code matches a trip code in db, create UserTrip item, otherwise, return error code\n if trip = Trip.find_by_rand_code(code)\n ut = UserTrip.new()\n ut.user_id = user.id\n ut.trip_id = trip.id\n ut.save!\n render json: trip, status: 201\n else\n render json: {errors: user.errors}, status: 404\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 id = params[:format]\n line = \"https://gtcollab.herokuapp.com/api/groups/\" + id + \"/join/\"\n \n #puts line\n #puts $token\n\n require \"net/http\"\n require \"uri\"\n\n parsed_url = URI.parse(line)\n\n http = Net::HTTP.new(parsed_url.host, parsed_url.port)\n http.use_ssl = true\n\n req = Net::HTTP::Post.new(parsed_url.request_uri)\n\n req.add_field(\"authorization\", $token)\n\n response = http.request(req)\n response.inspect\n\n #puts response.body\n redirect_to courses_path\n end",
"def join\n # TODO: Use Action Cable to Keep channel open to player\n # TODO: Use Action Cable to Message player_1 that it's their turn to start\n\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: @game.game_state_message }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @absence = Absence.new(params[:absence])\n @absence.member_id = params[:member_id]\n @member = Member.find(params[:member_id])\n @club = Club.find(params[:club_id] ) \n\n respond_to do |format|\n if @absence.save\n format.html { redirect_to club_member_absence_path(@club,@member,@absence), notice: 'Absence was successfully created.' }\n format.json { render json: @absence, status: :created, location: @absence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @absence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n redirect_to event_url(@event) unless @current_role.blank? || @current_role.new_record?\n end",
"def create\n @wine_club = WineClub.new(wine_club_params)\n\n respond_to do |format|\n if @wine_club.save\n format.html { redirect_to @wine_club, notice: 'Wine club was successfully created.' }\n format.json { render :show, status: :created, location: @wine_club }\n else\n format.html { render :new }\n format.json { render json: @wine_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @list = List.new(params[:list])\n\n respond_to do |format|\n if @list.save\n format.html { redirect_to club_path(@list.club_id), notice: 'List was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"new\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n @join_errors = ActiveModel::Errors.new(self)\n begin\n load_update\n target_artist = Artist.find(params[:dest_artist_id])\n @artist.join_to_other(Setting.get_settings, target_artist)\n rescue\n @join_errors.add(:base , $!.message)\n Log.log_last_exception\n end\n\n check_errors_redirect( @join_errors , 'edit')\n end",
"def test_should_join_a_group_as_user_via_API_JSON\r\n get \"/logout\"\r\n post \"/memberships.json\", :api_key => 'testapikey',\r\n :group_id => 1,\r\n :user_id => 3\r\n assert_response :created\r\n membership = JSON.parse(response.body)\r\n assert membership['user_id'] == 3, 'Incorrect user id'\r\n assert membership['group_id'] == 1, 'Incorrect group id'\r\n assert membership['role_id'].to_i == Role.find_by_rolename('user').id, 'Incorrect role id' \r\n end",
"def create\n @nightclub = Nightclub.new(params[:nightclub])\n\n respond_to do |format|\n if @nightclub.save\n format.html { redirect_to @nightclub, notice: 'Nightclub was successfully created.' }\n format.json { render json: @nightclub, status: :created, location: @nightclub }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nightclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def club_membership_params\n params.require(:club_membership).permit(:user_id, :club_id, :status)\n end",
"def create\n @tennis_club = TennisClub.new(tennis_club_params)\n\n respond_to do |format|\n if @tennis_club.save\n format.html { redirect_to @tennis_club, notice: 'Tennis club was successfully created.' }\n format.json { render :show, status: :created, location: @tennis_club }\n else\n format.html { render :new }\n format.json { render json: @tennis_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment_word_join = CommentWordJoin.new(comment_word_join_params)\n\n respond_to do |format|\n if @comment_word_join.save\n format.html { redirect_to @comment_word_join, notice: 'Comment word join was successfully created.' }\n format.json { render :show, status: :created, location: @comment_word_join }\n else\n format.html { render :new }\n format.json { render json: @comment_word_join.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join_new\n @remaining_heroes = [ @board.max_heroes_count - @board.current_heroes_count, @board.max_heroes_count ].min\n load_heroes\n @sauron_state = ( @current_user.id == @board.sauron&.user_id )\n @sauron_disabled = @board.sauron\n end",
"def create\n @stripclub = Stripclub.new(stripclub_params)\n\n respond_to do |format|\n if @stripclub.save\n format.html { redirect_to @stripclub, notice: 'Stripclub was successfully created.' }\n format.json { render :show, status: :created, location: @stripclub }\n else\n format.html { render :new }\n format.json { render json: @stripclub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join\n @invite_code = params[:invite_code]\n end",
"def create\n @club = Club.new(club_params)\n # valores default\n @club.active = true\n @club.association_id = Association.find_by( :user_id => current_user.id ).id\n\n if @club.email.present? and @club.email.length > 5\n @user = User.new(name: @club.name,\n email: @club.email,\n password: @club.email,\n password_confirmation: @club.email,\n tipo: 3 )\n end\n\n respond_to do |format|\n if @club.email.present? and @club.email.length > 5\n if @user.save\n @club.user_id = @user.id\n # os admins nao podem criar clubes, apenas as proprias associações\n # NOTA CSH: numa versao onde os admins possam criar clubes para poder transitar de uma associação para outra p.ex. tem de ser alterado\n\n if @club.save\n format.html { redirect_to @club, notice: 'O clube foi criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n @user.destroy\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n else\n # logger.debug @user.errors.to_yaml\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n else\n if @club.save\n format.html { redirect_to @club, notice: 'O clube foi criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n\n end\n end",
"def create\n @admin_update_club = Admin::Update::Club.new(admin_update_club_params)\n\n respond_to do |format|\n if @admin_update_club.save\n format.html { redirect_to @admin_update_club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @admin_update_club }\n else\n format.html { render :new }\n format.json { render json: @admin_update_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @club = Club.new(club_params)\n if (@club.active == true and current_user.has_role? :admin)\n @club.active = true\n else\n @club.active = false\n end\n if (current_user.has_role? :admin)\n #@club.user = club_params.user <- so wars vorher thorsten\n @club.user = User.find( club_params[:user_id])\n else\n @club.user = current_user\n end\n\n\n respond_to { |format|\n if @club.save\n\n format.html { redirect_to @club, notice: \"Club was successfully created.\" }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n }\n end",
"def group_join!(group)\n affiliations.create!( :group_id => group.id )\n end"
] |
[
"0.7300599",
"0.65574485",
"0.64909005",
"0.64552486",
"0.64253485",
"0.63883805",
"0.6370366",
"0.63585943",
"0.63530385",
"0.6340715",
"0.63233674",
"0.6319779",
"0.6173563",
"0.61190057",
"0.60923785",
"0.60726094",
"0.6056324",
"0.6054606",
"0.6047761",
"0.6042337",
"0.6039123",
"0.6026407",
"0.6013097",
"0.60086083",
"0.5986546",
"0.5986546",
"0.5983925",
"0.5980634",
"0.5941516",
"0.59053725",
"0.58991164",
"0.5882295",
"0.58772755",
"0.5854936",
"0.58506596",
"0.5845439",
"0.584229",
"0.5839574",
"0.5839574",
"0.58189803",
"0.581448",
"0.5806106",
"0.57996076",
"0.57905394",
"0.5786222",
"0.5764319",
"0.5754639",
"0.5726174",
"0.57194954",
"0.57060605",
"0.5698439",
"0.5690589",
"0.568082",
"0.56806874",
"0.5667661",
"0.56644535",
"0.56517977",
"0.56514233",
"0.564829",
"0.564735",
"0.5642811",
"0.5642106",
"0.5631655",
"0.56227106",
"0.5601162",
"0.5569284",
"0.55513704",
"0.5543177",
"0.5542543",
"0.5536621",
"0.55277586",
"0.5503669",
"0.55010927",
"0.5493524",
"0.54929346",
"0.5490846",
"0.54838294",
"0.5476931",
"0.5472777",
"0.5453716",
"0.54515916",
"0.5449145",
"0.5446927",
"0.542679",
"0.54181594",
"0.5411617",
"0.5400389",
"0.53808373",
"0.53803587",
"0.53638214",
"0.533635",
"0.53246987",
"0.53194773",
"0.53083813",
"0.52968895",
"0.5293929",
"0.5273564",
"0.52682525",
"0.5258612",
"0.5254898"
] |
0.78311723
|
0
|
POST /clubs/1/leave POST /clubs/1/leave.json
|
def leave
@club = Club.find(params[:id])
authorize @club
@club.club_memberships.where(user_id: current_user).destroy_all
redirect_to action: :show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @leave = Leave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leave }\n end\n end",
"def create\n @leafe = Leave.new(leafe_params)\n\n respond_to do |format|\n if @leafe.save\n format.html { redirect_to @leafe, notice: 'Leave was successfully created.' }\n format.json { render :show, status: :created, location: @leafe }\n else\n format.html { render :new }\n format.json { render json: @leafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_leave = UserLeave.new(user_leave_params)\n\n respond_to do |format|\n if @user_leave.save\n format.html { redirect_to @user_leave, notice: 'User leave was successfully created.' }\n format.json { render :show, status: :created, location: @user_leave }\n else\n format.html { render :new }\n format.json { render json: @user_leave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def leave\n # Check status first to see if the user can join.\n # Check if the number of users exceed the the size of the room.\n @room = Room.find(params[:id])\n result = @room.leave(current_user)\n if result\n channel = params[:id].to_s\n respond_message = {\n message: \"has left the room\",\n current_user: current_user,\n room_id: @room.id,\n status: USER_STATUS[:leave]\n }\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n end\n\n respond_to do |format|\n if result\n format.html { redirect_to list_rooms_path, notice: 'Successfully left the room.' }\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n else\n format.html { redirect_to list_rooms_path }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @leave_response = LeaveResponse.new(leave_response_params)\n\n respond_to do |format|\n if @leave_response.save\n format.html { redirect_to @leave_response, notice: 'Leave response was successfully created.' }\n format.json { render :show, status: :created, location: @leave_response }\n else\n format.html { render :new }\n format.json { render json: @leave_response.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @leave_event = LeaveEvent.new(leave_event_params.permit!)\n respond_to do |format|\n if @leave_event.save\n format.html { redirect_to leave_events_path, notice: 'Leave event was successfully created.' }\n format.json { render :show, status: :created, location: @leave_event }\n else\n format.html { render :new }\n format.json { render json: @leave_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @leave = Leave.new(params[:leave])\n @leave.from_date = DateTime.strptime(\"#{params[:leave][:from_date]}\", \"%m/%d/%Y\")\n @leave.to_date = DateTime.strptime(\"#{params[:leave][:to_date]}\", \"%m/%d/%Y\")\n\n respond_to do |format|\n if @leave.save\n format.html { redirect_to leaves_path, notice: 'Leave was successfully created.' }\n format.json { render json: @leave, status: :created, location: @leave }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @leave.destroy\n respond_to do |format|\n format.html { redirect_to leaves_url, notice: 'Leave was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @leave_management = LeaveManagement.new(leave_management_params)\n\n respond_to do |format|\n if @leave_management.save\n format.html { redirect_to @leave_management, notice: 'Leave management was successfully created.' }\n format.json { render :show, status: :created, location: @leave_management }\n else\n format.html { render :new }\n format.json { render json: @leave_management.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @leave_record = LeaveRecord.new(leave_record_params)\n\n respond_to do |format|\n if @leave_record.save\n format.html { redirect_to @leave_record, notice: 'Leave record was successfully created.' }\n format.json { render :show, status: :created, location: @leave_record }\n else\n format.html { render :new }\n format.json { render json: @leave_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_leave\n @leave = Leave.find(params[:id])\n end",
"def set_leave\n @leave = Leave.find(params[:id])\n end",
"def set_leave\n @leave = Leave.find(params[:id])\n end",
"def destroy\n @leave = Leave.find(params[:id])\n @leave.destroy\n\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 @leave = Leave.find(params[:id])\n @leave.destroy\n\n respond_to do |format|\n format.html { redirect_to leaves_url, notice: 'Leave was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def create\n @leave = Leave.new(params[:leave])\n respond_to do |format|\n if @leave.save\n @leaves = Leave.find(:all)\n format.html {render :action => \"index\"}\n else\n @validates = Array.new\n @leave.errors.messages.each do |m|\n \t @validates << m \n end\n format.html { render :action => \"new\" }\n format.json { render :json => @leave.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_leave_response\n @leave_response = LeaveResponse.find(params[:id])\n end",
"def destroy\n @leafe.destroy\n respond_to do |format|\n format.html { redirect_to apply_leave_path, notice: 'Leave was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @leave.update(leave_params)\n format.html { redirect_to @leave, notice: 'Leafe was successfully updated.' }\n format.json { render :show, status: :ok, location: @leave }\n else\n format.html { render :edit }\n format.json { render json: @leave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def leave_params\n params.require(:leave).permit(:start_date, :end_date, :reason)\n end",
"def groups_leave(params = {})\n fail ArgumentError, \"Required arguments 'channel' missing\" if params['channel'].nil?\n response = @session.do_post \"#{SCOPE}.leave\", params\n Slack.parse_response(response)\n end",
"def create\n @personal_leafe = PersonalLeave.new(personal_leafe_params)\n\n respond_to do |format|\n if @personal_leafe.save\n format.html { redirect_to @personal_leafe, notice: 'Personal leave was successfully created.' }\n format.json { render :show, status: :created, location: @personal_leafe }\n else\n format.html { render :new }\n format.json { render json: @personal_leafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n begin\n @leave = Leavetype.find(params[:id])\n if @leave.destroy\n @@request_result = {success:true, notice: 'Operation ended successfully.'}\n else\n @@request_result[:errormsg] = @leave.errors.full_messages[0]\n end\n rescue Exception => e \n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def create\n @leave_apply = LeaveApply.new(leave_apply_params)\n\n respond_to do |format|\n if @leave_apply.save\n format.html { redirect_to @leave_apply, notice: 'Leave apply was successfully created.' }\n format.json { render :show, status: :created, location: @leave_apply }\n else\n format.html { render :new }\n format.json { render json: @leave_apply.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @leave_event.destroy\n respond_to do |format|\n format.html { redirect_to leave_events_url, notice: 'Leave event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n @leave = Leave.find(params[:id])\n\n respond_to do |format|\n if @leave.update_attributes(params[:leave])\n format.html { redirect_to leaves_path, notice: 'Leave was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def leave\n riak_admin 'leave'\n end",
"def add_leave(new_leave, emp)\n emp.each do |e|\n EmployeeLeave.create(employee_id: e.id, employee_leave_type_id: new_leave.id, leave_count: new_leave.max_leave_count)\n end\n end",
"def create\n @leave_head = LeaveHead.new(leave_head_params)\n\n respond_to do |format|\n if @leave_head.save\n format.html { redirect_to leave_heads_path, notice: 'Leave head was successfully created.' }\n format.json { render :show, status: :created, location: @leave_head }\n else\n format.html { render :new }\n format.json { render json: @leave_head.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @user_leave.destroy\n respond_to do |format|\n format.html { redirect_to user_leaves_url, notice: 'User leave was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def process_leave\n @leave_application = LeaveApplication.find(params[:id])\n if params[:leave_action].present?\n @leave_action = params[:leave_action]\n if params[:leave_action] == 'approve'\n @status = APPROVED\n call_function = :process_accept_application\n else\n @status = REJECTED\n call_function = :process_reject_application\n end\n @message = LeaveApplication.process_leave(params[:id], @status, call_function, params[:reject_reason], current_user.id)\n else\n @leave_application.update_attributes({reject_reason: params[:reject_reason]})\n @message = {:type=>:success, :text=>\"Comment Inserted successfully\"}\n end\n\n @pending_leaves = LeaveApplication.order_by(:start_at.desc).pending\n\n\n respond_to do|format|\n format.js{}\n format.html{ redirect_to view_leaves_path}\n end\n end",
"def leave\n @group_user = GroupUser.find(params[:id])\n @group_user.leave!\n respond_to do |format|\n flash[:notice] = 'Membership was cancelled.'\n format.html { redirect_to @group_user.group }\n format.xml { head :ok }\n end\n end",
"def create\n @leave_request = LeaveRequest.new(leave_request_params)\n @leave_request.user = current_user\n @leave_request.approved = 'false'\n respond_to do |format|\n if @leave_request.save\n UserAudit.create({:user => current_user, :action => \"created leave request\", :end_user => @leave_request.user.email})\n UserMailer.leave_request(current_user, @leave_request).deliver\n format.html { redirect_to leave_requests_path, notice: 'Leave request was successfully created.' }\n format.json { render action: 'show', status: :created, location: @leave_request }\n else\n format.html { render action: 'new' }\n format.json { render json: @leave_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @leave_management.destroy\n respond_to do |format|\n format.html { redirect_to leave_managements_url, notice: 'Leave management was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @beer_club = BeerClub.new(params[:beer_club])\n\n respond_to do |format|\n if @beer_club.save\n format.html { redirect_to join_path(@beer_club), notice: 'Beer club was successfully created.' }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @beer_club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_leave_event\n @leave_event = LeaveEvent.find(params[:id])\n end",
"def new\n @leave = Leave.new\n @staffs = Staff.order(:lastname,:firstname).find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @leave}\n end\n end",
"def amend\n @leave_request = current_account.leave_requests.find_by_identifier(params[:id])\n \n leave_request_params = {\n :tenant => current_account.subdomain,\n :request => @leave_request\n }\n \n # check whether this leave request is captured, and route onto the staff requests view\n if @leave_request.captured?\n redirect_to new_staff_leave_request_url(leave_request_params)\n else\n redirect_to new_employee_leave_request_url(leave_request_params)\n end\n \n end",
"def update\n respond_to do |format|\n if @user_leave.update(user_leave_params)\n format.html { redirect_to @user_leave, notice: 'User leave was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_leave }\n else\n format.html { render :edit }\n format.json { render json: @user_leave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_leave_request\n @leave_request = LeaveRequest.find(params[:id])\n end",
"def leave\n\t\t@user = User.find_by(id: params[:user_id])\n\t\tif !@user\n\t\t\tflash[:error] = \"User non esistente\"\n\t\t\tredirect_to root_path\n\t\t\treturn\t\t\n\t\tend\n\t\tif @user != current_user\n\t\t\tflash[:error] = \"User non esistente\"\n\t\t\tredirect_to user_teams_path(current_user.id)\n\t\t\treturn\n\t\tend\n\t\t@team = Team.find_by(id: params[:id])\n\t\tif !@team\n\t\t\tflash[:error] = \"Team non esistente\"\n\t\t\tredirect_to user_teams_path(current_user.id)\n\t\t\treturn\n\t\tend\n\t\tauthorize! :leave, @team, :message => \"Non sei autorizzato ad abbandonare questa partita\"\n\t\t@team.membro.where(user_id: @user.id)[0].destroy\n\t\tflash[:success] = \"Ti sei eliminato con successo dalla squadra\"\n\t\tredirect_to user_teams_path(@user)\n\tend",
"def destroy\n @leave_day.destroy\n respond_to do |format|\n format.html { redirect_to user_leave_days_url, notice: I18n.t('controllers.leave_days.successfully_destroyed') }\n format.json { head :no_content }\n end\n end",
"def create\n @allot_leafe = AllotLeave.new(allot_leafe_params)\n\n respond_to do |format|\n if @allot_leafe.save\n format.html { redirect_to new_allot_leafe_employee_leafe_path(@allot_leafe), notice: 'Allot leave was successfully created.' }\n format.json { render :show, status: :created, location: @allot_leafe }\n else\n format.html { render :new }\n format.json { render json: @allot_leafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n begin\n \n @new_type = params[:leave_type]\n @new_type[:mypclient_id] = @@client_id\n @new_type[:createdby] = @@username\n\n @leave_type = Leavetype.new(@new_type)\n if @leave_type.save\n @@request_result = {success: true, notice: 'Leave Type was successfully created.'}\n else\n @@request_result[:errormsg] = @leave_type.errors.full_messages[0]\n end\n rescue Exception => e \n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def local_leave(body)\n room = body.dup\n room = @var[:room] unless room.length >= 1\n room_hash = MD5::digest(room)[0,8]\n room_hash = EMPTY_ROOM if room == 'chat'\n unless room == 'chat'\n @connection.room_names.delete(room_hash)\n @connection.room_ids.delete(room)\n end\n _server_control('leave', room_hash)\n local_switch('chat')\nend",
"def update\n @leave = Leave.find(params[:id])\n\n respond_to do |format|\n if @leave.update_attributes(params[:leave])\n @leaves = Leave.find(:all)\n format.html {render :action => \"index\"}\n else\n @validates = Array.new\n @leave.errors.messages.each do |m|\n \t @validates << m \n end \t\n format.html { render :action => \"edit\" }\n format.json { render :json => @leave.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @leave = Leave.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leave }\n end\n end",
"def leave(user_id)\n \n end",
"def update\n respond_to do |format|\n if @leafe.update(leafe_params)\n format.html { redirect_to apply_leave_path, notice: 'Leave was successfully updated.' }\n format.json { render :show, status: :ok, location: @leafe }\n else\n format.html { render :edit }\n format.json { render json: @leafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @employee = Employee.find(params[:employee_id])\n\n # For URL like /employees/1/leave_records\n # Populate an leave_records associate with employee 1 with form data\n # employee will be associated with the leave_records\n @leave_record = @employee.leave_records.build(params.require(:leave_record).permit(:description, :date))\n if @leave_record.save\n # Save the leave_record successfully\n redirect_to employee_leave_record_url(@employee, @leave_record)\n else\n render :action => \"new\"\n end\n end",
"def leave_team\n data = {solver_id: params[:solver_id]}\n Pusher.trigger(params[:channel], 'leave_puzzle', data)\n render nothing: true\n end",
"def destroy\n @leave_response.destroy\n respond_to do |format|\n format.html { redirect_to leave_responses_url, notice: 'Leave response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def user_leave_params\n params.require(:user_leave).permit(:user_id, :leave_type, :leave_left, :leave_taken)\n end",
"def index\n @leave_responses = LeaveResponse.all\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 leave_params\n params.require(:leave).permit(:notes, :start_date, :end_date)\n end",
"def set_leave_record\n @leave_record = LeaveRecord.find(params[:id])\n end",
"def destroy\n @leave_apply.destroy\n respond_to do |format|\n format.html { redirect_to leave_applies_url, notice: 'Leave apply was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def leave_moderator_status!\n post(\"/api/leavemoderator\", id: fullname)\n end",
"def leave_contributor_status!\n post(\"/api/leavecontributor\", id: fullname)\n end",
"def leave\n @chat.members.delete(current_user)\n render json: { status: 'done' }, status: :ok\n ChatChannel.send_notification_to_chat(@chat.id, user_left_the_chat_msg)\n end",
"def leave\n client.api.leave_room(id)\n client.instance_variable_get(:@rooms).delete id\n true\n end",
"def create\n\n if params[:token].present?\n @token = Token.where(\"Value = ?\", params[:token]).first\n @user = @token.user\n else\n @user = session[:currentUser]\n end\n \n create_club_ok = is_admin_or_event_manager(@user)\n\n if create_club_ok\n @club = Club.new(params[:club])\n end\n\n respond_to do |format|\n if create_club_ok\n if @club.save\n format.html { redirect_to @club, :notice => 'Club was successfully created.' }\n format.json { render :json => @club, :status => :created, :location => @club }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @club.errors, :status => :unprocessable_entity } \n end\n else\n format.html { redirect_to :back }\n format.json { render :json => @club.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n @user_club = UserClub.create(user_id: current_user.id, club_id: @club.id, join_date: Date.current)\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_leave_day\n @leave_day = LeaveDay.find(params[:id])\n end",
"def new\n @beer_club = BeerClub.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def new\n @beer_club = BeerClub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer_club }\n end\n end",
"def leave_management_params\n params.require(:leave_management).permit(:holiday_name, :date, :user_id)\n end",
"def leave\n\n @team =Team.find(params[:team_id])\n @gamer = current_gamer\n if(@team.boss==@gamer)\n destroy\n else\n @team.gamers.delete(@gamer) unless @gamer.nil?\n redirect_to @team\n end\n \n \n end",
"def create\n @leaveforstaff = Leaveforstaff.new(params[:leaveforstaff])\n\n respond_to do |format|\n if @leaveforstaff.save\n flash[:notice] = t('staffleave.title')+\" \"+t('created')\n format.html { redirect_to(@leaveforstaff) }\n format.xml { render :xml => @leaveforstaff, :status => :created, :location => @leaveforstaff }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @leaveforstaff.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @event_leaderboard = EventLeaderboard.new(params[:event_leaderboard])\n\n if @event_leaderboard.save\n render json: @event_leaderboard, status: :created, location: @event_leaderboard\n else\n render json: @event_leaderboard.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n @leave_request = LeaveRequest.new(params[:leave_request])\n @leave_request.status = \"Pending\";\n @leave_request.managerid = params[:manager_id];\n\n respond_to do |format|\n if @leave_request.save\n\n @employees = Employee.find(session[:user_id])\n @manager = Employee.find(params[:manager_id])\n UserMailer.welcome_email(@manager,@leave_request,@employees,'Request For Leave',@manager.email).deliver\n\n format.html { redirect_to request_success_url, notice: 'Leave request has been sent successfully to your reporting manager' }\n format.json { render json: @leave_request, status: :created, location: @leave_request }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @leave_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_leave\n session=enter_the_room(\"zark\")[\"session\"]\n leave(session)\n end",
"def create\n @lobby = Lobby.new(lobby_params)\n\n respond_to do |format|\n if @lobby.save\n format.html { redirect_to @lobby, notice: 'Lobby was successfully created.' }\n format.json { render :show, status: :created, location: @lobby }\n else\n format.html { render :new }\n format.json { render json: @lobby.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @leavetype = LeaveType.new(:admin_adjust => true, :admin_assign => true, :employee_apply => true)\n @form_id = 'add-form'\n \n respond_to do |fmt|\n fmt.html { render :partial => 'form' }\n fmt.json { render :json => @leavetype }\n end\n end",
"def leave!\n leave(as: 'member')\n leave(as: 'guest')\n leave(as: 'power')\n\n remove_membership_associations\n end",
"def destroy\n @lobby.destroy\n respond_to do |format|\n format.html { redirect_to lobbies_url, notice: 'Lobby was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allot_leafe.destroy\n respond_to do |format|\n format.html { redirect_to allot_leaves_url, notice: 'Allot leave was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def join\n @beer_club = BeerClub.find(params[:id])\n if Membership.where(:beer_club_id => @beer_club.id, :user_id => current_user.id).exists?\n respond_to do |format|\n format.html { redirect_to :back, notice: \"You are already a member of this club!\" }\n end\n else\n @membership = Membership.create\n @membership.beer_club_id = @beer_club.id\n @membership.user_id = current_user.id\n if @beer_club.memberships.count < 1\n @membership.confirmed = true\n else\n @membership.confirmed = false\n end\n respond_to do |format|\n if @membership.save\n format.html { redirect_to :back, notice: \"You joined #{@beer_club.name}\" }\n else\n format.html { redirect_to :back, notice: \"Something went awry! D:\" }\n end\n end\n end\n end",
"def leave\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, nil)\n\t redirect_to @household\n\tend",
"def update\n respond_to do |format|\n if @leave_response.update(leave_response_params)\n format.html { redirect_to @leave_response, notice: 'Leave response was successfully updated.' }\n format.json { render :show, status: :ok, location: @leave_response }\n else\n format.html { render :edit }\n format.json { render json: @leave_response.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @absence = Absence.new(params[:absence])\n @absence.member_id = params[:member_id]\n @member = Member.find(params[:member_id])\n @club = Club.find(params[:club_id] ) \n\n respond_to do |format|\n if @absence.save\n format.html { redirect_to club_member_absence_path(@club,@member,@absence), notice: 'Absence was successfully created.' }\n format.json { render json: @absence, status: :created, location: @absence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @absence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def leave_response_params\n params.fetch(:leave_response, {})\n end",
"def leave\n @room = Room.find(params.require(:room_id))\n if @room&.remove_user(current_user)\n success\n else\n not_found\n end\n end",
"def new_leagues\n if User.no_club.length >= League::NUM_CLUBS\n leagues = League.create_with_users_with_no_club\n respond_to do |format|\n flash[:notice] = \"#{leagues.length}\" + t('defaults.new_leagues_success')\n format.html {redirect_to leagues_path}\n end\n end\n end",
"def destroy\n @leave_request = LeaveRequest.find(params[:id])\n @comment = leave_request_params[:comment]\n UserAudit.create({:user => current_user, :action => \"destroyed leave request\", :end_user => @leave_request.user.email})\n @leave_request.destroy\n UserMailer.reject_leave(current_user, @leave_request, @comment).deliver\n respond_to do |format|\n format.html { redirect_to approvals_leave_requests_url, notice: \"Leave Request Rejected.\" }\n format.json { head :no_content }\n end\n end",
"def create\n if MemberRequest.req!(@club, current_user)\n flash[:success] = \"Request Sent!\" \n redirect_to view_club_path(path: @club.path)\n else\n flash[:danger] = 'ERROR: There was an error processing your request'\n redirect_to root_url\n end\n end",
"def leave\n @person = Person.find(params[:person_id])\n @group = Group.find(params[:id])\n @person.leave_group(@group.id, session[:cookie])\n group_title = @group.title(session[:cookie])\n if group_title == \"Not found!\"\n #This happens when the last user leaves a group and the group dies\n group_title = \"\"\n end\n flash[:notice] = [ :you_have_left_group, @group.title(session[:cookie]), group_path(@group) ]\n redirect_to groups_path\n end",
"def create\n \n @recrutement = Recrutement.create('content' => params[:content], 'deadline' => params[:deadline], club_id: params['club_id'])\n\n respond_to do |format|\n if @recrutement.save\n format.html { redirect_to @recrutement, notice: 'Recrutement was successfully created.' }\n format.json { render :show, status: :created, location: @recrutement }\n else\n format.html { render :new }\n format.json { render json: @recrutement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render :show, status: :created, location: @club }\n else\n format.html { render :new }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def leave_event_params\n params.fetch(:leave_event, {})\n end",
"def leave_alliance(profile, msg)\n self.log_msg(msg)\n self.leave_alliance_without_notification(profile)\n AllianceMembers.delay.create_notification_leave(self.id)\n end",
"def leave_request_params\n params.require(:leave_request).permit(:start_date, :end_date, :leave_type, :comment)\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @club }\n end\n end",
"def leave(place)\n a = Town.find_by(name: place)\n narrate(\"You arrive at the #{a.name}\")\n @player.location = place\n @player.save\n a.drop(@player)\n end",
"def destroy\n @personal_leafe.destroy\n respond_to do |format|\n format.html { redirect_to personal_leaves_url, notice: 'Personal leave was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @club = Club.new(club_params)\n\n respond_to do |format|\n if @club.save\n format.html { redirect_to @club, notice: 'Club was successfully created.' }\n format.json { render action: 'show', status: :created, location: @club }\n else\n format.html { render action: 'new' }\n format.json { render json: @club.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @club = Club.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @club }\n end\n end"
] |
[
"0.6537879",
"0.6456636",
"0.64482385",
"0.63692695",
"0.636711",
"0.63562167",
"0.62911886",
"0.62337303",
"0.61901367",
"0.6177278",
"0.61333936",
"0.61333936",
"0.61333936",
"0.6106388",
"0.60843277",
"0.606639",
"0.59515834",
"0.59335065",
"0.5870352",
"0.586905",
"0.58247507",
"0.5812704",
"0.58028686",
"0.57856506",
"0.575321",
"0.57392305",
"0.5729254",
"0.571994",
"0.56951284",
"0.5693901",
"0.5691041",
"0.56835437",
"0.56793654",
"0.56293494",
"0.56285405",
"0.5626595",
"0.5624859",
"0.5608624",
"0.5606328",
"0.5594021",
"0.5587032",
"0.5568144",
"0.5539566",
"0.55391514",
"0.55364823",
"0.5533002",
"0.55302185",
"0.55249786",
"0.5511882",
"0.5504655",
"0.5501089",
"0.5475473",
"0.54754144",
"0.5459266",
"0.54413736",
"0.5421126",
"0.5416931",
"0.5410989",
"0.54042065",
"0.5394738",
"0.53696746",
"0.53690016",
"0.53641933",
"0.53559774",
"0.5349721",
"0.5340984",
"0.5324004",
"0.5309786",
"0.5306191",
"0.530054",
"0.5294041",
"0.5286389",
"0.528468",
"0.5270748",
"0.52489614",
"0.5243656",
"0.52373844",
"0.52288085",
"0.5218042",
"0.52144116",
"0.520519",
"0.5201259",
"0.5201056",
"0.5199745",
"0.51913697",
"0.51911306",
"0.5190686",
"0.51868194",
"0.5169927",
"0.51654303",
"0.51608753",
"0.51604253",
"0.51588756",
"0.51557964",
"0.5153494",
"0.51531893",
"0.5150231",
"0.5148527",
"0.5148527",
"0.51422864"
] |
0.6148277
|
10
|
Never trust parameters from the scary internet, only allow the white list through.
|
def club_params
params.require(:club).permit(
:name, :short_name, :description,
:cover_image, :remove_cover_image, :logo, :remove_logo, :recording_area
)
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 model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def 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 active_code_params\n params[:active_code].permit\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def 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 url_whitelist; 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 filter_params\n params.require(:filters).permit(:letters)\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 url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\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 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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.6293856",
"0.6290323",
"0.62816143",
"0.6241851",
"0.6241208",
"0.622036",
"0.62128764",
"0.62110275",
"0.61966056",
"0.61776453",
"0.617547",
"0.6174961",
"0.61654735",
"0.6153256",
"0.61516005",
"0.6149498",
"0.6123234",
"0.6118653",
"0.61077267",
"0.61061186",
"0.6093616",
"0.608318",
"0.6074428",
"0.60650206",
"0.60244286",
"0.6020295",
"0.60155797",
"0.6012826",
"0.6010141",
"0.6010141",
"0.60037106",
"0.600298",
"0.59979576",
"0.5994806",
"0.5994283",
"0.5993927",
"0.5980616",
"0.59667075",
"0.59614897",
"0.59610957",
"0.596071",
"0.5959614",
"0.59554",
"0.59542966",
"0.5946781",
"0.5940262",
"0.5940262",
"0.59401053",
"0.5937168",
"0.5932135",
"0.59293395",
"0.592659",
"0.59202623",
"0.59112674",
"0.59088206",
"0.590716",
"0.59056735",
"0.589997",
"0.5899655",
"0.5898926",
"0.5896042",
"0.589589",
"0.5895867",
"0.58894163",
"0.5884936",
"0.5879227",
"0.58740723",
"0.5871364",
"0.5870148",
"0.5869228",
"0.5868196",
"0.5867967",
"0.5865532",
"0.58653617",
"0.58644646",
"0.58631665",
"0.5862611",
"0.5857609",
"0.58558804",
"0.5853729",
"0.5853025"
] |
0.0
|
-1
|
For example, if the array , , so return . Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer. simpleArraySum has the following parameter(s): ar: an array of integers The first line contains an integer, , denoting the size of the array. The second line contains spaceseparated integers representing the array's elements. Output Format Print the sum of the array's elements as a single integer. Sample Input 6 1 2 3 4 10 11 Sample Output 31
|
def simpleArraySum(ar)
count = 0
ar.each {|x| count += x}
count
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def simpleArraySum(ar)\n return ar.map(&:to_i).sum\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def sum_array(array)\n return array.sum\n\n # sum_total_of_array = 0\n # for number in array\n # sum_total_of_array += number\n # end\n # return sum_total_of_array\nend",
"def simple_array_sum arr\n arr.reduce(:+)\n end",
"def sum_array(array)\n the_sum_of_array = array.sum\n the_sum_of_array\nend",
"def simpleArraySum(ar)\n #\n # Write your code here.\n #\n ar.reduce(&:+)\nend",
"def array_sum(arr)\n\tsum = 0\n\n\t# an for each loop\n\tfor i in arr\n\t\tsum += i\n\tend\n\t\n\treturn sum\n\t\nend",
"def sum_array(array)\n sum = 0\n\n array.each do |number|\n sum += number\n end\n\n return sum\nend",
"def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend",
"def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend",
"def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend",
"def sumArray(array)\n sum = 0\n array.each do\n |n|\n sum += n.to_i\n end\n puts \"Somme : #{sum}\"\nend",
"def sum_array(array)\n sum = 0\n array.each{ |num| sum += num }\n sum\nend",
"def sum(array)\n\tanswer = 0\n\tif array.length > 0 then\n\t\tarray.each {|x| answer += x}\n\telse\n\t\treturn 0\n\tend\n\treturn answer\nend",
"def array_sum(arr)\n arr.reduce(0) {|sum, el| sum + el}\nend",
"def sum_array(array)\n array.sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |x|\n sum += x\n end\n return sum\nend",
"def sum_array(int_array)\n int_array.reduce(:+)\nend",
"def sum_array(array)\n array.sum\nend",
"def array_sum(arr)\n\n sum = 0\n arr.each {|n| sum += n}\n\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n sum\nend",
"def sum arr\n #Just iterate through the array and add each element to the sum\n sum = 0\n for val in arr\n \tsum = sum + val\n end\n sum\nend",
"def it_arr_sum(array)\r\n sum = 0\r\n array.each {|ele| sum += ele}\r\n return sum\r\nend",
"def sum_array(array)\n sum = 0\n array.each do |element|\n sum += element\n end\n sum\nend",
"def simpleArraySum(ar)\n #\n # Write your code here.\n #\n sum = 0\n ar.collect do |number|\n sum += number\n end\n return sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum = sum + num\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum+=num\n end\n sum\nend",
"def sum(array)\n s = 0\n\tarray.each {|x| s+= x}\n\ts\nend",
"def array_sum(arr)\n if arr.length == 0\n return 0\n end\n arr.reduce(:+)\nend",
"def sum(in_array)\n # YOUR CODE HERE\n sumr=0\n if in_array.length == 0\n sumr=0\n elsif \n #Enumerable\n sumr= in_array.reduce(:+)\n end\n\n return sumr\nend",
"def sum_array(array)\n sum = 0\n array.each do |i|\n sum+=i\n end\n sum\nend",
"def sum arr\n result = 0\n #Iterate through the length of the array to find the sum of the array elements\n if arr.length > 0 then\n arr.each do |index|\n\tresult += index\n end\n end\n return result\nend",
"def sum_array(array)\n sum = 0\n array.each do |value|\n sum += value\n end\n sum\nend",
"def sum_array (arr)\n result = 0\n arr.each do |value|\n result +=value\n end\n result\nend",
"def sum(array)\n\n raise 'array includes non integers' unless \n (array.empty? || array.all? { |x| x.integer?})\n \n array.reduce(0,:+)\n \nend",
"def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\nend",
"def array_sum(arr)\n arr.reduce(:+)\nend",
"def array_sum(arr)\n arr.reduce(:+)\nend",
"def sum(theArray)\n\ttotal = 0\n\ttheArray.each do |i|\n\t\ttotal = total + i\n\tend\n\treturn total\nend",
"def array_sum(arr)\n return arr.reduce(0, :+)\nend",
"def sum_array(some_array) \n sum = 0\n\tsome_array.each do |x|\n\t if x.is_a?Integer\n\t sum = sum + x\n\t end\n\t \n\t end\n\t \n\tsum\n end",
"def sum(array)\n sum = 0\n array.each do |a|\n sum += a\n end\n return sum\nend",
"def array_sum(arr)\n arr.reduce(:+)\n\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def sum_array(array_num)\n\nend",
"def sum_of_sums(array)\r\nend",
"def array_sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend",
"def array_sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend",
"def sum_array(array)\n total = 0\n array.each do |num|\n total += num\n end\n total\nend",
"def sum_array(array)\nsum = 0\n for i in 0..array.length-1\n sum = sum+ array[i]\n end\n return sum\nend",
"def sum_array(array)\n\tarray.inject { |sum, n| sum + n }\nend",
"def sum(array)\n\treturn array.reduce(:+)\nend",
"def sum(array)\n return 0 if array.empty?\n return array.first if array.length == 1\n\n array.inject(:+)\nend",
"def sum arr\n sum = arr.sum\n return sum\nend",
"def sum(array)\n array.inject(0){|sum, n| sum + n}\n end",
"def sum(array)\n array.map(&:to_i).reduce(0, :+)\nend",
"def sum(array)\n sum = 0\n array.each { |n| sum += n } \n sum\nend",
"def sum arr\n # YOUR CODE HERE\n total = arr.sum\n \n return total\nend",
"def sum_array(array)\n\tarray.inject do |sum, n| sum + n\n\tend\nend",
"def sum(array)\n array.sum\nend",
"def sum(array)\n\tarray.reduce(:+)\nend",
"def sum(array_of_integers)\n # TODO\nend",
"def array_sum(arr)\n return 0 if arr.empty?\n\n arr.reduce(&:+)\nend",
"def sum(in_array)\n return 0 if in_array.length == 0\n return in_array.reduce(:+)\nend",
"def sum(array)\n array.reduce(0) {|sum, num| sum += num}\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 sum_array(array)\n array.reduce(:+)\nend",
"def sum(array)\n i = 0\n output = 0\n while i < array.length\n output += array[i].to_int\n i += 1\n end\n return output\nend",
"def sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def array_sum(arr)\n if arr.empty?\n 0\n else\n arr.reduce(:+)\nend\nend",
"def sum(arr)\n output = 0\n arr.each do |num|\n output += num\n end\n return output\nend",
"def sum arr\n if arr.length==0\n return 0\n end\n s = arr.reduce(:+)\n return s\nend",
"def sum_array(integers)\n integers.sum\nend",
"def sum(array)\n\t\tsum = 0 #initialise 0 \n\t\tif array.empty? # si tableau vide = rien \n\t\treturn 0 # renvoie 0\n\t\telse # sinon\n\t\tarray.each{|x| sum = sum + x} # tous les elements du tableaux / incremente le code sum\n \t\treturn sum\n\t\tend\n\tend",
"def sum_array(numbers)\n return numbers.sum()\nend",
"def sum_of_arr(arr)\n sum = 0\n arr.each do |i|\n sum = sum + i\n end\n sum\nend",
"def sum(arr_in)\n\treturn 0 if arr_in.empty?\n\tsum = 0\n\tarr_in.each { |elem| sum += elem }\n\treturn sum\nend",
"def sum(arr)\r\n #if array includes the value of non-integer,change it to 1\r\n iIntegerFlag=0\r\n #initialize the value of the sum of array's elements\r\n iSum=0\r\n #identify array\r\n if arr.instance_of?(Array) then\r\n #get the length of arr\r\n iArrLength=arr.size\r\n #justify whether the each element of array is a integer\r\n for value in arr do\r\n if !value.is_a?(Integer) then\r\n iIntegerFlag=1\r\n break\r\n end\r\n end\r\n if iIntegerFlag==1 then\r\n puts \"The array must be consisted of integers!\"\r\n return false\r\n else\r\n if iArrLength!=0 then\r\n for n in 1..iArrLength\r\n iSum=iSum+arr[n-1]\r\n end\r\n end\r\n return iSum\r\n end\r\n else\r\n puts \"Please input an array!\"\r\n return false\r\n end\r\nend",
"def summing_method(single_digit_array)\n summed_array = single_digit_array.sum\nend",
"def sum(array)\n array.reduce(0, :+)\n=begin\n res =0\n array.each { |a| res += a }\n res.to_i\n=end\nend",
"def my_sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def sum_of_sums(array)\n\n sums_array = []\n\n sum = 0\n array.each do |value|\n sum += value\n sums_array << sum\n end\n \n sums_array.sum\nend",
"def sum_array(array)\n #array.inject(0){|sum,x| sum + x }\n array.inject(0){|sum,x| sum + x }\nend",
"def sum arr\n rtn = 0\n arr.each { |n| rtn += n }\n return rtn\nend",
"def sum arr\n if !arr.empty?\n soma = 0\n arr.each do |elt| ; soma += elt ; end\n return soma\n end\n return 0 \nend",
"def sum_of_sums(array)\n sum = 0\n sum_array = array.map { |x| sum += x }\n sum_array.inject(:+)\nend",
"def sum (anArray)\n\n\ttotal = 0.0\n\t# use array each method to add up the numbers\n\tanArray.each {|x| total = x + total}\n\n\treturn total\nend",
"def total (array)\n\tsum=0\n\tarray.each do |n| sum += n\n\tend\n\treturn sum\nend",
"def sum (arr)\n s=0\n arr.each{|a| s+=a}\n return s\nend",
"def sum_of_sums(int_arr)\n sum = 0\n current_numbers = []\n int_arr.each { |int|\n current_numbers << int\n sum += current_numbers.sum\n }\n sum\nend",
"def sum arr\n arraySum = 0\n arr.each{|i|arraySum+=i}\n return arraySum\nend",
"def total(array)\nsum = 0 \n\tarray.each do |num|\n\tsum += num \n\tend \n\treturn sum\nend",
"def sum(array)\n array.reduce(0) {|base, ele|\n base+=ele\n }\n end",
"def sum(array)\n return 0 if array.empty?\n sum(array.drop(1)) + array.first\nend",
"def sum(array)\n return 0 if array.empty?\n sum(array.drop(1)) + array.first\nend",
"def sum (array)\n y=array.inject(:+).to_i\nend"
] |
[
"0.84559375",
"0.8279123",
"0.8244422",
"0.815086",
"0.810255",
"0.8083986",
"0.80654943",
"0.806012",
"0.7958405",
"0.794336",
"0.79200554",
"0.7916011",
"0.7913863",
"0.7900274",
"0.78907776",
"0.78897697",
"0.78890973",
"0.78884196",
"0.78776824",
"0.78756464",
"0.787426",
"0.7869032",
"0.78664994",
"0.7861958",
"0.7859281",
"0.78568023",
"0.7843021",
"0.78367823",
"0.7833954",
"0.7826344",
"0.78258115",
"0.78176254",
"0.7816584",
"0.78097904",
"0.78018874",
"0.7800708",
"0.7798589",
"0.77952135",
"0.7777162",
"0.7777162",
"0.777432",
"0.77676517",
"0.7758263",
"0.7752359",
"0.7745414",
"0.77442455",
"0.77442455",
"0.77442455",
"0.7741039",
"0.77388513",
"0.7736525",
"0.7736525",
"0.7702153",
"0.7701491",
"0.76953274",
"0.7687345",
"0.7680098",
"0.76695603",
"0.7666279",
"0.76620555",
"0.76580495",
"0.7657294",
"0.7648882",
"0.7646824",
"0.7645671",
"0.7643665",
"0.7640579",
"0.76393604",
"0.7629125",
"0.7627558",
"0.76238936",
"0.76158077",
"0.76117796",
"0.76021886",
"0.7600995",
"0.75969154",
"0.7588477",
"0.7576994",
"0.75767666",
"0.757195",
"0.75686514",
"0.7567092",
"0.7565319",
"0.7561819",
"0.75580686",
"0.7547118",
"0.7541852",
"0.75384134",
"0.75353914",
"0.75331277",
"0.7523469",
"0.75227493",
"0.7508153",
"0.75005794",
"0.74963564",
"0.74896896",
"0.748332",
"0.7480434",
"0.7480434",
"0.7472056"
] |
0.7952488
|
9
|
=begin saasclass.org HW 1: Ruby calisthenics by Nathan Dotz
|
def palindrome? ( something )
raise unless something.is_a?(String)
test_string = something.downcase.gsub(/\W/, '')
return test_string == test_string.reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def alg; end",
"def schumann; end",
"def numerator() end",
"def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n\nend",
"def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n\nend",
"def calculated; end",
"def sum; end",
"def advanced_calc\n print \"(p)ower, (s)qrt: \"\n\nend",
"def marcsCakewalk(calorie)\n arr = calorie.sort.reverse!\n\n sum = 0\n arr.each_with_index do |cal, index|\n sum += cal * (2**index)\n end\n sum\nend",
"def p6\n\trange = (1..100).to_a\n\tsquare_of_sum = range.reduce(:+) ** 2\n\tsum_of_square = (range.map{|x| x ** 2}).reduce(:+)\n\tsquare_of_sum - sum_of_square\nend",
"def cal()\n @v = 0.0;\n @n.times {|i|\n @v += @wn[i] * @xn[i];\n }\n nil;\n end",
"def s2(n)\n n*(n+1)*(2*n+1)/6\nend",
"def secret_formula( started ) # Here first parameter 'started' will be referenced to the start_point which equals 10000\n jelly_beans = started * 500 # the variable 'jelly_beans' is equal to 10000 x 500 = 5,000,000\n jars = jelly_beans / 1000 # the variable 'jars' is equal to the value of jelly_beans (5,000,000) / 1,000 = 5,000\n crates = jars / 100 # the variable 'crates' is equal to the value of jars (5,000) / 100 = 50\n return jelly_beans, jars, crates # returns all the expressed values for the three variables to be used outside the method\nend",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n# return jelly_beans, jars, crates\n puts \"Testing: \"\n puts \"Jelly Beans: #{jelly_beans}, Jars: #{jars}, and Crates: #{crates}\"\nend",
"def compute_ruby\n check_frequencies\n #\n # INITIALIZATION\n #\n @r = 0\n sdzero = 0\n @sdr = 0\n @itype = 0\n @ifault = 0\n delta = 0\n \n\n # GOTO (4, 1, 2 , 92), kdelta\n #\n # delta IS 0.0, 0.5 OR -0.5 ACCORDING TO WHICH CELL IS 0.0\n #\n\n if(@kdelta==2)\n # 1\n delta=0.5\n @r=-1 if (@a==0 and @d==0)\n elsif(@kdelta==3)\n # 2\n delta=-0.5\n @r=1 if (@b==0 and @c==0)\n end\n # 4\n if @r!=0\n @itype=3\n end\n\n #\n # STORE FREQUENCIES IN AA, BB, CC AND DD\n #\n @aa = @a + delta\n @bb = @b - delta\n @cc = @c - delta\n @dd = @d + delta\n @tot = @aa+@bb+@cc+@dd\n #\n # CHECK IF CORRELATION IS NEGATIVE, 0.0, POSITIVE\n # IF (AA * DD - BB * CC) 7, 5, 6\n\n corr_dir=@aa * @dd - @bb * @cc\n if(corr_dir < 0)\n # 7\n @probaa = @bb.quo(@tot)\n @probac = (@bb + @dd).quo(@tot)\n @ksign = 2\n # -> 8\n else\n if (corr_dir==0)\n # 5\n @itype=4\n end\n # 6\n #\n # COMPUTE PROBABILITIES OF QUADRANT AND OF MARGINALS\n # PROBAA AND PROBAC CHOSEN SO THAT CORRELATION IS POSITIVE.\n # KSIGN INDICATES WHETHER QUADRANTS HAVE BEEN SWITCHED\n #\n\n @probaa = @aa.quo(@tot)\n @probac = (@aa+@cc).quo(@tot)\n @ksign=1\n end\n # 8\n\n @probab = (@aa+@bb).quo(@tot)\n\n #\n # COMPUTE NORMAL DEVIATES FOR THE MARGINAL FREQUENCIES\n # SINCE NO MARGINAL CAN BE 0.0, IE IS NOT CHECKED\n #\n @zac = Distribution::Normal.p_value(@probac.to_f)\n @zab = Distribution::Normal.p_value(@probab.to_f)\n @ss = Math::exp(-0.5 * (@zac ** 2 + @zab ** 2)).quo(TWOPI)\n #\n # WHEN R IS 0.0, 1.0 OR -1.0, TRANSFER TO COMPUTE SDZERO\n #\n if (@r != 0 or @itype > 0)\n compute_sdzero\n return true\n end\n #\n # WHEN MARGINALS ARE EQUAL, COSINE EVALUATION IS USED\n #\n if (@a == @b and @b == @c)\n calculate_cosine\n return true\n end\n #\n # INITIAL ESTIMATE OF CORRELATION IS YULES Y\n #\n @rr = ((Math::sqrt(@aa * @dd) - Math::sqrt(@bb * @cc)) ** 2) / (@aa * @dd - @bb * @cc).abs\n @iter = 0\n begin\n #\n # IF RR EXCEEDS RCUT, GAUSSIAN QUADRATURE IS USED\n #\n #10\n if @rr>RCUT\n gaussian_quadrature\n return true\n end\n #\n # TETRACHORIC SERIES IS COMPUTED\n #\n # INITIALIZATION\n #\n va=1.0\n vb=@zac.to_f\n wa=1.0\n wb=@zab.to_f\n term = 1.0\n iterm = 0.0\n @sum = @probab * @probac\n deriv = 0.0\n sr = @ss\n #15\n begin\n if(sr.abs<=CONST)\n #\n # RESCALE TERMS TO AVOID OVERFLOWS AND UNDERFLOWS\n #\n sr = sr / CONST\n va = va * CHALF\n vb = vb * CHALF\n wa = wa * CHALF\n wb = wb * CHALF\n end\n #\n # FORM SUM AND DERIVATIVE OF SERIES\n #\n # 20\n dr = sr * va * wa\n sr = sr * @rr / term\n cof = sr * va * wa\n #\n # ITERM COUNTS NO. OF CONSECUTIVE TERMS < CONV\n #\n iterm+= 1\n iterm=0 if (cof.abs > CONV)\n @sum = @sum + cof\n deriv += dr\n vaa = va\n waa = wa\n va = vb\n wa = wb\n vb = @zac * va - term * vaa\n wb = @zab * wa - term * waa\n term += 1\n end while (iterm < 2 or term < 6)\n #\n # CHECK IF ITERATION CONVERGED\n #\n if((@sum-@probaa).abs <= CITER)\n @itype=term\n calculate_sdr\n return true\n end\n #\n # CALCULATE NEXT ESTIMATE OF CORRELATION\n #\n #25\n @iter += 1\n #\n # IF TOO MANY ITERATlONS, RUN IS TERMINATED\n #\n delta = (@sum - @probaa) / deriv\n @rrprev = @rr\n @rr = @rr - delta\n @rr += 0.5 * delta if(@iter == 1)\n @rr= RLIMIT if (@rr > RLIMIT)\n @rr =0 if (@rr < 0.0)\n end while @iter < NITER\n raise \"Too many iteration\"\n # GOTO 10\n end",
"def basic_calc\n print Rainbow(\"\\n(a)\").white+Rainbow(\"dd \").green+Rainbow(\"(s)\").white+Rainbow(\"ubtract \").green+Rainbow(\"(m)\").white+Rainbow(\"ultiply \").green+Rainbow(\"(d)\").white+Rainbow(\"ivide \").green\n choice = gets.chomp.to_s\n print Rainbow(\"\\nfirst number: \").blue\n first = gets.chomp.to_f\n print Rainbow(\"second number: \").blue\n second = gets.chomp.to_f\n case choice[0].downcase\n when \"a\"\n print Rainbow(\"\\n#{first} + #{second} = \").blue + Rainbow(\"#{first + second}\\n\\n\").white\n when \"s\"\n print Rainbow(\"\\n#{first} - #{second} = \").blue + Rainbow(\"#{first - second}\\n\\n\").white\n when \"m\"\n print Rainbow(\"\\n#{first} 8 #{second} = \").blue + Rainbow(\"#{first * second}\\n\\n\").white\n when \"d\"\n print Rainbow(\"\\n#{first} / #{second} = \").blue + Rainbow(\"#{(first / second).rounf(5)}\\n\\n\").white\n when \"q\"\n menu\n else \n print Rainbow(\"\\nYou are doing it \").green + Rainbow(\"WRONG\\n\").red\n basic_calc\n end\nend",
"def arithmetic1(n)\r\r\n n * 5 - 20\r\r\nend",
"def secret_formula(started)\r\n\tjelly_beans = started * 500\r\n\tjars = jelly_beans / 1000\r\n\tcrates = jars / 100\r\n\treturn jelly_beans, jars, crates\r\nend",
"def math(b1,b2,goal)\r\n\r\n\t# link to math:\r\n\t# http://www.math.tamu.edu/~dallen/hollywood/diehard/diehard.htm\r\n\t# mp = nq = k\r\n\t# (x)(b1) + (y)(b2) = goal\r\n\r\n\tx = 0\r\n\ty = 0\r\n\tcurrent_total = 0\r\n\r\n\t#determine x and y mathematically\r\n\twhile (current_total != goal) do\r\n\r\n\t\tif current_total < goal\r\n\t\t\tx += 1\r\n\t\telsif current_total > goal\r\n\t\t\ty -= 1\r\n\t\tend\r\n\r\n\t\tcurrent_total = x*b1.size + y*b2.size\r\n\t\tputs \"X: #{x}, Y: #{y}, CT: #{current_total}\"\r\n\r\n\tend\r\n\r\nend",
"def secret_formula(started)\n\tjelly_beans = started * 500 #assign the producto of the parameter and 500 to the variable jely_beans\n\tjars = jelly_beans / 1000 #assign the division of the variable jelly_beans and 1000 to the variable jars\n\tcrates = jars / 100 #crates is equal to the division of jars and 100\n\t#return jelly_beans, jars, crates #return the value of jelly_beans, jars and crates\nend",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def secret_formula(started)\n# Assigns variables, each building on the other.\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n# Returns a value that is associated with each variable\n return jelly_beans, jars, crates\nend",
"def square_of_sum\n end",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n return jelly_beans, jars , crates\nend",
"def strauss; end",
"def s1(n)\n (n*(n+1)/2)**2\nend",
"def eu1\n # .00028s | 1000 silent iterations\n total = 0\n (1..1000).each { |i| total += i if i % 3 == 0 or i % 5 == 0 }\n return total\nend",
"def sumOfGroup(k)\n return k**3\n \n#Given the fact that Sn=(A1+An)*n/2\n#Given the fact that An= A1+(n-1)d\n#Given the problme that A1 = n(n-1) +1 \n#Then Sn = n*n*n\n\nend",
"def primordial; end",
"def arithmetic( n )\n am = n.inject(0, :+)\n print \"AM = #{am/n.size.to_f} \"\nend",
"def main\n max = 10 ** 9 + 7\n all = 1\n zero = 1\n nine = 1\n zn = 1\n N.times.each do\n all = all * 10 % max\n zero = zero * 9 % max\n nine = nine * 9 % max\n zn = zn * 8 % max\n end\n return (all - zero - nine + zn) % max\nend",
"def sisoku(a, b)\r\n puts a+b\r\n puts a-b\r\n puts a*b\r\n puts a/b\r\n end",
"def p15\n\t\nend",
"def compute_sum_of_threes_and_fives\r\n sum = 0\r\n (1...1000).each do |n|\r\n sum += n if n % 3 == 0 || n % 5 == 0\r\n end\r\n sum\r\nend",
"def day_2_part_2\n noun = 0\n verb = 0\n\n while noun < 100\n while verb < 100\n if compute(noun, verb) == 19690720\n return (100 * noun) + verb\n end\n verb += 1\n end\n noun += 1\n verb = 0\n end\nend",
"def calculation\n end",
"def main\n sum, ssq = 0, 0\n 100.downto(1) { |x| sum+=x; ssq += (x*x) }\n res = sum**2 - ssq\n puts \"#{res}\"\nend",
"def euler020\n def fact(x)\n ans = x.downto(1).reduce(:*)\n end\n fact(100).to_s.split('').map { |x| x.to_i}.reduce(:+)\nend",
"def magicalWell(a, b, n)\n (1..n).sum {\n money = a*b \n a += 1\n b += 1\n money\n }\nend",
"def compute\n perimeter = 1000\n (1..(perimeter+ 1)).each do |a|\n ((a + 1)..(perimeter + 1)).each do |b|\n c = perimeter - a - b\n return (a * b * c).to_s if (a * a + b * b == c * c)\n end\n end\nend",
"def sum_of(a,b)\n\treturn a + b\nend",
"def arithmetic1 (n)\nn*5-20\nend",
"def basic_calc\n\n\n print Rainbow(\"(a)\").green + \"dd, \" + Rainbow(\"(s)\").yellow + \"ubtract, \" + Rainbow(\"(m)\").red + \"ultiply, \" + Rainbow(\"(d)\").cyan + \"ivide: \"\n basic_function = gets.chomp.downcase\n print \"Enter first number: \"\n first_number = gets.chomp.to_f\n print \"Enter second number: \"\n second_number = gets.chomp.to_f\n case basic_function\n when \"a\"\n answer = first_number + second_number\n puts \"Your answer is #{answer}\"\n when \"s\"\n answer = first_number - second_number\n puts \"Your answer is #{answer}\"\n when \"m\"\n answer = first_number * second_number\n puts \"Your answer is #{answer}\"\n when \"d\"\n answer = first_number / second_number\n puts \"Your answer is #{answer}\"\n \n else\n puts \"incorrect\"\n end \ngets\nend",
"def six\n square_of_sum(100) - sum_of_squares(100)\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def squared_sum(a, b)\n # Q1 CODE HERE\n return (a + b) ** 2\nend",
"def summation(num)\n num * (num + 1) / 2\nend",
"def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend",
"def sum_of_squares\n end",
"def numerology(num1)\n\t# Calculate answer \n\t(((((num1 + 5) * 2) - 4) / 2) - num1)\nend",
"def s(x); 1; end",
"def evens_and_odds(numbers)\nend",
"def oddball_sum(numbers)\n\nend",
"def solution4(input)\n end",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n return jelly_beans, jars, crates\nend",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n return jelly_beans, jars, crates\nend",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n return jelly_beans, jars, crates\nend",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n return jelly_beans, jars, crates\nend",
"def compound_interest\n\tp \"What is the principal amount?\"#\n\tprincipal = gets.chomp.to_i\n\tp \"What is the rate?\"\n\trate = gets.chomp.to_f\n\tp \"What is the number of years?\"\n\tterm = gets.chomp.to_i\n\tp \"What is the number of time the interest in compounded per year?\"\n\tcompounded = gets.chomp.to_i\n\t\n\tnew_rate = ((rate / compounded)/100) + 1\n\ttotal = principal\n\t(term * compounded).times do\n\t\ttotal = total * new_rate\n\tend\n\t\n\tp \"$#{principal} invested at #{rate}% for #{term} years compounded #{compounded} times per year is #{total.round(2)}\"\n\t\nend",
"def gecos(*) end",
"def euler006\n square_of_sum = (1..100).reduce(:+) ** 2\n sum_of_squares = (1..100).inject { |sum, n| sum + n*n }\n\n return square_of_sum - sum_of_squares\nend",
"def score; end",
"def secret_formula(started)\n\tjelly_beans = started * 500\n\tjars = jelly_beans / 1000\n\tcrates = jars / 100\n\treturn jelly_beans, jars, crates\nend",
"def secret_formula(started)\n\tjelly_beans = started * 500\n\tjars = jelly_beans / 1000\n\tcrates = jars / 100\n\treturn jelly_beans, jars, crates\nend",
"def secret_formula(started)\n\tjelly_beans = started * 500\n\tjars = jelly_beans / 1000\n\tcrates = jars / 100\n\treturn jelly_beans, jars, crates\nend",
"def secret_formula(started)\n jelly_beans = started * 500\n jars = jelly_beans / 1000\n crates = jars / 100\n# Return array of 3 values\n return jelly_beans, jars, crates\nend",
"def stderrs; end",
"def abc_three\n\t2.upto(1000) do |a|\n\t (a+1).upto(1000) do |b|\n\t \tc = Math.sqrt(a**2 + b**2)\n\t \tif (a+b+c==1000)\n\t \t\treturn a*b*c \n\t \tend\n\t end\n\tend\nend",
"def total(a,b)\r\n return (a+b)\r\nend",
"def kcal\n x = collect{|a| a.kcal}\n y = x.inject(0, :+)\n y\n end",
"def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n gets.chomp.downcase\nend",
"def herald; end",
"def solution(a, b, k)\n # write your code in Ruby 2.2\n e = b / k\n s = (a-1) / k\n\n e - s\nend",
"def square(num) #I calculate a simple method for calculating squares (after I will need it)\n return num * num\n end",
"def sum_of_cubes(a, b)\n=begin \n sum = 0\n (a..b).each do |n|\n sum += n*n*n\n end\n sum\n=end \n (a..b).reduce(0) { |a, b| a + b ** 3 }\nend",
"def calculoDiametro(raio)\n return raio * 2\nend",
"def basic_calc\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n basic = gets.chomp.downcase\n\n get_two_numbers\n\n case basic\n when \"a\"\n \tputs addition($num1, $num2)\n when \"s\"\n \tputs subtraction($num1, $num2)\n when \"m\"\n \tputs multiplication($num1, $num2)\n when \"d\"\n \tputs division($num1, $num2)\n end\n\nend",
"def most_specific_subdivision; end",
"def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend",
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"def factorial(number)\n \t if (number >= 2)\n \t\tresult.each do |number| number * (number -1)\n \t\tnumber -=\n \tend\n\n \treturn result\n \telse\n \t\tnumber == 0 || number == 1\n \t\treturn 1\n \tend\n\t\t\n\nend\n#This is as close as i got to getting factorial to work without using refactoring, per instructions.\n#Couldnt really get this to work. ",
"def rh_factor; end",
"def mortgage_calc principle, annual_interest, years\n n = years * 12\n r = (annual_interest / 100)/ 12 #since this is usually expressed as a percentage\n return (principle * r * (1 + r)**n / ((1 + r)**n - 1)).round(2)\nend",
"def sum_times_difference(a, b)\n\nend",
"def pre_divide; end",
"def p002rubynumbers \n\t\n\t puts 1+2\n\t puts 2*3\n\t #Integer division\n\t #When you do arithematic with integers, you'll get integer answers\n\t puts 3/2\n\t puts 10-11\n\t puts 1.5 /2.6\n\nend",
"def eaurang(a, b)\n a - b;\nend",
"def square(a) #a is the variable\n\t# is the input \n\t# the output is the LAST thing that it does - like the return in javascript\n\ta * a #so this is the last line and it becomes the output to whatever called it\nend",
"def total_retirement_saving(your_age)\n child_age = your_age / 2\n saving_per_year = child_age * child_age\n years_to_retire = 65 - child_age\n saving_per_year * years_to_retire\nend",
"def bs(a, b)\n if (b - a) == 1\n if a == 0\n pab = 1\n qab = 1\n else\n pab = ((6 * a)-5) * ((2 * a)-1) * ((6 * a)-1)\n qab = (a * a) * (a * $c3)\n end\n\n tab = pab * (13591409 + (545140134 * a))\n\n if a & 1 == 1\n tab = -tab\n end\n else\n m = 0\n m = ((a + b) / 2).round(0)\n\n pam, qam, tam = bs(a, m)\n pmb, qmb, tmb = bs(m, b)\n\n pab = pam * pmb\n qab = qam * qmb\n tab = qmb * tam + pam * tmb\n end\n return pab, qab, tab\nend",
"def arithmetic2(a, b)\nend",
"def sumn2(n)\n result = 0\n 1.upto(n) { |e| result += e if (e % 3 == 0) ^ (e % 5 == 0) }\n puts result\nend",
"def basic_calc\n print Rainbow(\"\\n(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \\n\").yellow\n basic_choice = gets.chomp.downcase\n\n print \"\\nEnter your first number: \" \n first_number = gets.to_f\n print \"\\nEnter your second number: \"\n second_number = gets.to_f\n\n\n case basic_choice[0]\n when \"a\"\n print \"\\n\\t#{first_number} + #{second_number} = \", first_number + second_number, \"\\n\"\n when \"s\"\n print \"\\n\\t#{first_number} - #{second_number} = \", first_number - second_number, \"\\n\"\n when \"m\"\n print \"\\n\\t#{first_number} * #{second_number} = \", first_number * second_number, \"\\n\"\n when \"d\"\n print \"\\n\\t#{first_number} / #{second_number} = \", first_number / second_number, \"\\n\"\n else Rainbow(\"\\nYou're doing it wrong!\".upcase).red\n end\n gets\nend",
"def SimpleAdding(num\n total = 1.upto(num).reduce(&:+)\n total \nend",
"def positive; end",
"def positive; end",
"def MyTables(tables,b,h,result) \n if tables == 1\n result=(b*h) #Cross sectional area\n elsif tables == 2\n result =((b*h**3)/12) #moment of inertia\n else\n result =((b*h**2)/6) #section modulus\n end #end of calculating result\nend"
] |
[
"0.6557689",
"0.6525326",
"0.63818663",
"0.6365048",
"0.6365048",
"0.63239104",
"0.62769127",
"0.622515",
"0.6221255",
"0.6205346",
"0.61757493",
"0.60707855",
"0.5999533",
"0.59901226",
"0.59878576",
"0.598367",
"0.5953868",
"0.5946026",
"0.5941206",
"0.5937179",
"0.5932781",
"0.5932781",
"0.5932781",
"0.5932781",
"0.5932781",
"0.5928702",
"0.5899527",
"0.5881855",
"0.58788294",
"0.5878136",
"0.5875376",
"0.5870709",
"0.58664215",
"0.5860955",
"0.58565676",
"0.5847621",
"0.584259",
"0.584141",
"0.58303094",
"0.58301616",
"0.5822453",
"0.5819419",
"0.5816586",
"0.58108836",
"0.58056754",
"0.58030736",
"0.57933015",
"0.57815164",
"0.5780651",
"0.5775877",
"0.576574",
"0.57573205",
"0.57390296",
"0.5737748",
"0.5736604",
"0.5736519",
"0.5734567",
"0.5726938",
"0.5722412",
"0.5722412",
"0.5722412",
"0.5722412",
"0.57191",
"0.5714637",
"0.5710138",
"0.56977254",
"0.5692675",
"0.5692675",
"0.5692675",
"0.5691249",
"0.5689724",
"0.5687746",
"0.5684353",
"0.56838816",
"0.5663349",
"0.5660911",
"0.56603277",
"0.5651339",
"0.5644951",
"0.5640759",
"0.56392306",
"0.56322855",
"0.5629563",
"0.562527",
"0.56219536",
"0.56219125",
"0.5619752",
"0.56162906",
"0.56109065",
"0.56071967",
"0.56033397",
"0.56014997",
"0.56011355",
"0.55934626",
"0.5591511",
"0.55896294",
"0.5587562",
"0.55816555",
"0.5581236",
"0.5581236",
"0.55804956"
] |
0.0
|
-1
|
information and their logs shall be automatically made for them. author vict0rem Gets numeric input, loops until user inputs only an integer value
|
def getIntegerInput()
val = gets.chomp
while !/((\d)+)/.match(val) || /((\d)+\.(\d)+)/.match(val)
puts 'This input should be an integer. Please input again.'
val = gets.chomp
end
return val
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ask_for_digits\r\n puts (\"Calculator\").colorize(:white).on_green\r\n variables = []\r\n input = @@prompt.ask(\"Enter a number between 1000 and 9999 e.g. 1234:\") do |q|\r\n q.convert -> (input) { input.split(/[\\s]/) }\r\n q.convert(:integer, \"Invalid input. Try again.\")\r\n end\r\n \r\n # Error handling: If they put in a negative number \r\n begin \r\n # Take the input, split by digits, and because that puts them in reverse order it must be reversed again\r\n variables = input.digits.reverse\r\n rescue\r\n system(\"clear\")\r\n puts \"Positive numbers only!\"\r\n ask_for_digits\r\n end \r\n \r\n\r\n if variables.length == 4\r\n numbers = []\r\n numbers += object_to_float(variables)\r\n op = Operations.new\r\n op.calculate(numbers[0], 0, numbers, [])\r\n ask_user_start\r\n \r\n else\r\n system(\"clear\")\r\n puts \"Invalid input\"\r\n ask_for_digits\r\n end\r\n \r\n end",
"def ask_user\n puts 'enter a number:'\n input = gets.chomp.to_i\n check_num(input)\n end",
"def ask_info(info)\n value = ''\n loop do\n value = gets.chomp\n break if (valid_number? value) && (value.to_f > 0)\n prompt \"The #{info} is not valid. Enter a valid #{info}:\"\n end\n value\nend",
"def input\n\tputs 'What sorta math do ya wanna do?'\n\tputs '1 for addition'\n\tputs '2 for subtraction'\n\tputs '3 for multiplication'\n\tputs '4 for division'\n\tputs '5 for exponent'\n\tputs '6 for squaring'\n\tputs '7 for cubing'\n\tputs '8 for square rooting'\n\tgets.chomp.to_i\nend",
"def user_input\n\tuser_selection = gets.strip.to_i\n\tinput_logic(user_selection)\nend",
"def get_user_integer\n valid_input = false\n input = 0\n until valid_input do\n user_input = gets.chomp.to_i\n if user_input > 0 && user_input.kind_of?(Integer)\n valid_input = true\n input += user_input\n clear\n break\n else\n puts \"Incorrect input, please enter an integer greater than 0\"\n end\n end\n return input\nend",
"def get_num\n puts \"==> Enter an Integer\"\n num = gets.chomp.gsub(/\\,/, '.')\n while !valid_num?(num)\n puts\"==> Try again, Integer input please\"\n num = gets.chomp.gsub(/\\,/, '.')\n end\n\n if valid_int?(num)\n num.to_i\n else\n num.to_f\n end\nend",
"def get_number(value_name)\r\n puts \"please input a value for #{value_name} (numbers)\"\r\n while true\r\n answer=gets.chomp\r\n break if is_number?(answer)\r\n puts \"please input only numbers for this value\"\r\n end\r\n answer.to_i\r\n end",
"def check_input_number(input_str)\n while input_str.to_i <= 0 do\n input_str = ask(\"Введи положительное число!\")\n end\n input_str.to_i\n end",
"def num_check(num)\n until num.to_i.to_s == num\n puts \"Invalid entry. Please entere an integer.\"\n num = gets.chomp.to_i\n end\n return num.to_i\nend",
"def query_integer(message_string)\n print message_string\n\n is_legal_input = false\n until is_legal_input do\n # Get an integer from the user, or return nil if a value is given\n # that is not clearly convertible to an integer.\n int_input = Integer(gets.chomp) rescue nil\n\n if int_input == nil\n print 'Sorry, an integer is required. Try again: '\n else\n is_legal_input = true end\n end #of until loop\n return int_input\nend",
"def get_user_input\n\t\tinput_right = false\n\t\tno_of_primes = 0\n\t\tloop do\n\t\t\tprint \"Enter the number of primes you want: \"\n\t\t\tno_of_primes = gets.chomp.to_i\n\t\t\tinput_right = (no_of_primes.to_i > 0) ? true : false\n\t\t\tif no_of_primes <= 0\n\t\t\t\tprint \"\\n Please enter a number( > 0 ) \\n\"\n\t\t\t\tself.no_of_primes = 0\n\t\t\tend\n\t\t\tbreak if input_right\n\t\tend\n self.no_of_primes = no_of_primes\n\tend",
"def get_input\n puts \"Please enter the 10 digit number :\"\n form_words gets.chomp\n end",
"def get_int_input(message)\n print message\n x = gets.strip\n if x.number?\n x.to_i\n else\n return get_int_input(message)\n end\n end",
"def insert_user(index)\n puts \"Введите длину стороны #{index.to_i + 1}\"\n Float(gets.chomp)\nrescue StandardError\n puts 'Введите число или число с плавающей точкой!'\n retry\nend",
"def get_number\nprint \"What number do you want to check? \"\n@number = gets.to_i\nend",
"def execute_44\n STDERR << \"\\nInput Number: \\n\"\n set_value( (STDIN.gets||'').chomp.to_i )\n advance_token()\n end",
"def get_user_input_for_test\n\t\tno_of_primes = 0\n\t\tprint \"\\n \\t Enter value for the number of primes you want: \"\n\t\tno_of_primes = gets.chomp.to_i\n\t\tif no_of_primes <= 0\n\t\t\tprint \"Please enter a number( > 0 ): \"\n\t\t\tself.no_of_primes = 0\n\t\t\treturn\n\t\tend\n\t\tself.no_of_primes = no_of_primes\n\tend",
"def int_input(prompt, err_msg = \"Please enter a number.\", repeat = true)\n str = \"\"\n until str[/^-?\\d+$/]\n str = input prompt\n puts err_msg unless str[/^-?\\d+$/] || err_msg.nil?\n return unless repeat\n end\n str.to_i\n end",
"def q1_get_num\n puts \"Enter a number please: \"\n gets.to_i\nend",
"def initial_input\n # grabs the user's input and store it before passing it to the method\n input = gets.chomp\n index = input_to_index(input)\n\n if !index.between?(0,1)\n puts \"\\nPlease, select a number between 1 and 2\".colorize(:light_red)\n self.initial_input\n elsif index == 1\n goodbye\n exit\n end\n index\n end",
"def input_number(num)\n loop do\n num = Kernel.gets().chomp()\n break if valid_number?(num)\n\n prompt(\"invalid_input\")\n end\n num\nend",
"def int_input(s = \"\\nPlease select an option:\".yellow.bold, limits = [1, 100])\n puts s\n user_input = gets.chomp\n #if user types 'exit', exit the application\n if user_input.downcase == \"exit\"\n exit()\n end\n\n #if user input is within allowed range, return it, otherwise, ask for it again\n if user_input.to_i >= limits[0] and user_input.to_i <= limits[1]\n return user_input.to_i\n else\n puts(\"Invalid input, please enter an integer value coresponding to an option, or type 'exit' to exit application:\".red.bold)\n sleep(1)\n return int_input(s, limits)\n end\n end",
"def enter_value()\n value = gets\n if int?(value.to_i)\n return value\n end #end of if\n end",
"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 ask_for_number\n gets.chomp.to_i\n end",
"def get_dimension( message )\r\n print \"Please enter the #{message}: \"\r\n dimension = gets.chomp.to_i\r\n while dimension <= 0 do\r\n\t print \"Please enter a number greater than zero as the #{message}: \"\r\n\t dimension = gets.chomp.to_i\r\n end\r\n return dimension\r\nend",
"def insert_user(index)\n if index.to_i == 1\n puts 'Введите длину основания'\n else\n puts 'Введите высоту'\n end\n Float(gets.chomp)\nrescue StandardError\n puts 'Введите число или число с плавающей точкой!'\n retry\nend",
"def readInteger\n shouldReadInt = true\n while shouldReadInt do\n input = gets.chomp\n if input =~ /^[\\d]+(\\.[\\d]+){0,1}$/\n shouldReadInt = false\n else\n puts \"please enter a valid number\" \n end\n end\n return Integer(input)\nend",
"def cig_amount\n puts \"How many cigarettes have you smoked today?\"\n cigarette_amount = gets.chomp\n #raise an error in case of incorrect input\n if cigarette_amount =~ /\\D+/ or cigarette_amount.start_with?(\"0\")\n raise ArgumentError.new(\"Error - incorrect input\")\n end\n @log[Date.today.iso8601] = cigarette_amount.to_i\n average\n puts \"Never give up giving up!\"\n #rescue from the error: recurse the function\n rescue\n system \"clear\"\n puts \"Seems like did not reply with a number, please try again\"\n sleep(0.5)\n cig_amount\n end",
"def choose_vehicle_price\n puts \"Enter new price\"\n @new_price = gets.chomp.to_i\n if !@new_price.is_a? Numeric\n puts Rainbow(\"This value is invalid. Please try again.\").red.bold\n choose_vehicle_price\n end\nend",
"def get_input_i\n\tgets.chomp.to_i\nend",
"def age_validator\n puts \"whats your characters age\" \n age = gets.strip.to_i \n until age > 16 #checks to see if age is a number \n begin \n if age >! 16\n end\n rescue #rescues if there is an error because its not an integer \n puts \"Input must be a valid number above 16, Try Again\"\n age = gets.strip.to_i\n end\n end\n return age\nend",
"def val_integer_list()\n var=-1\n loop {\n var=gets.chop.to_i\n if var<=0 || var>@lista.items.length\n print \"Please enter a correct number, try again: \"\n else\n break\n end\n }\n var\n end",
"def is_valid_numeric_input(order)\n\n print \"#{order} number >> \"\n num = gets.chomp\n\n until is_numeric(num)\n puts \"Not valid number. Please try again.\"\n print \"#{order} number >> \"\n num = gets.chomp\n end\n\n return num\nend",
"def user_number\n puts 'enter your number'\n numb1 = gets.chomp!.to_i\n if numb1 <= 50\n puts 'your number is equal to or less than 50'\n elsif numb1 == 51\n puts 'you number must be 51'\n elsif numb1 <= 100\n puts 'you number is equal to or less than 100'\n else\n 'puts you got a high number'\n end\n end",
"def fetch_number(prompt)\n\tprint prompt\n\tgets.to_f #allow decimal input\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 valid_integer(input)\n while true\n if input =~ /^(\\d)+$/ && input.to_i > 0\n return input.to_i\n else\n puts \"Try again! Only use numbers\"\n input = gets.chomp\n end\n end\nend",
"def ask(prompt)\n input = nil\n loop do\n puts prompt\n print '> '\n input = gets.chomp\n break if input =~ /\\A-?\\d+\\Z/\n\n system('clear')\n puts 'You must enter a whole numeric value when needed. Please try again!'.colorize(:red)\n end\n input\n end",
"def user_input()\n return gets.chomp.to_i\n end",
"def num_convert\n\tputs 'give me a number(1...3000)'\n\tnum_input = gets.chomp\n\tif !num_input.empty?\n\t\tif num_input.to_i <= 0\n\t\t\tputs 'Must use positive integer' \n\t\t\treturn\n\t\telse\n\t\t\tputs roman_numeral num_input.to_i\n\t\t\tnum_convert\n\t\tend\n\tend\nend",
"def get_valid_input(input_type, options = {})\n input = nil\n loop do\n input = gets.chomp\n # binding.pry\n if options.has_key?(:result) && input == \"\"\n input = options[:result]\n break\n else\n if input_type == \"num\"\n numeric?(input) || input.upcase == 'Q' ? break : say(\"Numbers only\")\n else\n %w(1 2 3 4 Q).include?(input.upcase) ? break : say(\"1, 2, 3, or 4 only\")\n end\n end\n end\n input\nend",
"def number_choice_one\n puts \"Now I need two numbers to use with that operator.\"\n puts \"Type your first number: \"\n gets.chomp.to_i\nend",
"def choose_number\n\t\tputs \"Choose a number between 1-10\"\n\t\t$input = gets.chomp.to_i\n\t\tif $input > 10 || $input < 1\n\t\t\tputs \"Invalid number. Please use a number between 1-10\"\n\t\t\tchoose_number\n\t\tend\n\tend",
"def prompt_i(lower, upper)\n loop do\n print \"[Enter an integer in the range #{lower}-#{upper}]\"\n print \"> \"\n input_str = @input.gets\n if input_str.nil?\n raise \"No input left (must be automated input)\"\n end\n input_str = input_str.chomp\n input_int = input_str.to_i\n if input_int.between?(lower, upper)\n return input_int\n else\n print \"[Invalid integer range]\"\n end\n end\n end",
"def receive_int(question, min, max)\n answer = receive_answer(question)\n while answer != answer.to_i.to_s or\n (answer == answer.to_i.to_s and (answer.to_i < min or answer.to_i > max))\n puts \"Please enter an integer between #{min} and #{max}.\"\n answer = receive_answer(question)\n end\n return answer.to_i\nend",
"def fetch_number\n print \"Please choose a number: \"\n gets.to_i\nend",
"def get_valid_number(cont)\n loop do\n puts \"Enter number or q:\"\n val = gets.chomp()\n if (val == \"q\") \n cont << val\n break\n end\n if is_num?(val)\n return val.to_f\n else\n puts \"Input was not numerical.\"\n end\n end\nend",
"def input_num()\n\twhile true\n \tputs \"Input a number.\"\n\t\tnum = gets.strip\n\t\tif /-\\d+/.match(num)\n\t\t\tnum = /\\d+/.match(num)[0]\n\t\t\treturn -num.to_i\n\t\telsif /[^0-9]/.match(num)\n\t\t\tputs \"Please only enter a number.\"\n\t\telsif /\\d+/.match(num)\n\t\t\tnum = /\\d+/.match(num)[0]\n\t\t\treturn num.to_i\n\t\telse\n\t\t\tputs \"Error\"\n\t\tend\n\tend\nend",
"def fetch_number\n print \"What is your number? \" # Will print this text and allow you to type in next to it\n gets.to_i # Will ask for a user input and then turn it into an integer (will also return)\nend",
"def inputParameters paramsnum \n\n\n #input parameters \n\t\n\n \t\n #input must not have limit info\n puts \"has (must not have type) limit? please input 0 or 1(0 means no limit,1 means has limit)\"\n haslimit = gets\n if haslimit.to_i == 1\n @haslimit = true\n puts \"please input the group num of limitValue\"\n gnum = gets\n inputMustNotHaveLimitValues gnum.to_i\n else\n @haslimit = false\n end\n\n\n #input must have limit info\n=begin puts \"has (must have type) limit? please input 0 or 1(0 means no limit,1 means has limit)\"\n musthavelimit = gets\n if musthavelimit.to_i == 1\n @musthavelimit = true\n puts \"please input the group num of limitValue\"\n gnum = gets\n inputMustHaveLimitValues gnum.to_i\n else\n @musthavelimit = false\n end\n=end\n \n\n end",
"def prompt\n print 'Type an integer number (or q to exit) and press Enter: '\n number = gets\n say_bye_and_exit if number =~ /^q/i\n number = prompt unless number =~ /^\\d+$/\n if number.to_i > 2 ** 64\n puts 'The number you entered is too big. Calculation can run a lot of time! Continue? (y/n)n'\n confirm = gets\n number = prompt unless confirm =~ /^y/i\n end\n number.to_i # to ensure Numeric value returs\nend",
"def get_requested_amount(type)\n request = prompt_user(\"How much would you like to #{type}?\").to_i\n while request <= 0\n request = prompt_user(\"Please enter an amount greater than $0.\").to_i\n end\n request.to_i\nend",
"def get_input\n input = gets.chomp\n until valid_input?(input)\n puts \"Invalid input. Please type in an EMPTY cell number from \"\\\n \"1-9, 'quit', or 'restart'.\"\n print \">> \"\n input = gets.chomp\n end\n input\n end",
"def validate_input\n\t\tif @options[:num].is_a?(Integer) and @options[:num] >= 0 \n\t\t\t@num = @options[:num].to_i.abs \n\n\t\telse\n\t\t\t@num = \"NAN\"\n\n\t\tend\n\tend",
"def read_number\n loop do\n puts '>> Please enter a positive or negative integer:'\n number = gets.chomp\n return number.to_i if valid_number?(number)\n puts '>> Invalid input. Only non-zero integers are allowed.'\n end\n end",
"def ask_for_initial_number(phrase)\n print \"Please enter the #{phrase}: \"\n input = gets.chomp\n if numerical_input?(input)\n return input.to_f\n else\n print \"#{tell_invalid(\"entry.\")} \"\n ask_for_initial_number(phrase)\n end\nend",
"def enter_age(age)\n # Do a loop until user inputs correct value\n while true do\n puts \"Please enter age\"\n age = gets.chomp.to_i\n age < 18 || age > 99 ? \"Not valid\" : break\n end\n age\n end",
"def getUserNumber\n begin\n return Float(gets.chomp)\n rescue\n puts \"Please enter the number as an integer.\"\n retry\n end\nend",
"def get_target_number\n print \"\\n\\nEnter a positive integer or -ve number to exit: \"\n input_value=gets\n is_num?(input_value)? input_value.to_i : nil\nend",
"def user_input\n puts \"Do you often play video-games? (yes/no)\"\n print '> '\n frequency = gets.chomp.downcase\n if frequency == \"yes\"\n begin \n puts \"How many hours a week on average do you think you have played video-games in the past month?\"\n @weekly_playtime = Integer(gets.chomp)\n #integer part of kernel module - can be called anywhere on a file, can be called on a particular thing. will try to convert to_int then to_i if that fails. \n if weekly_playtime == 0\n puts \"Please be realistic, you did play video games.\"\n exit \n end \n rescue ArgumentError \n puts \"Error! please type a whole number!\"\n retry \n end \n elsif frequency == \"no\"\n puts \"Are you using a stick to press the keys while you're up on your high horse!?\"\n exit\n else \n puts \"Error! Try again with yes or no!\"\n user_input \n end \n end",
"def get_input\n gets.chomp.to_i\nend",
"def check_num\n loop do\n puts \">please enter a positive or neg num\"\n num = gets.chomp\n return num.to_i if valid_number?(num)\n puts \"> oops. only non-zero intergers are allowed\"\n end\nend",
"def verify_number(data_to_verify)\n until (Float(data_to_verify) rescue nil) != nil && data_to_verify.to_f > 0\n puts \"Input not accepted, please enter a number:\"\n data_to_verify = gets.chomp\n end\n data_to_verify.to_f\nend",
"def geti\n gets.to_i\nend",
"def players\n \n puts \"How many players will be playing today?\"\n\n players = gets.chomp.to_i \n \n valid_inputs = [0,1,2,100]\n \n \n until valid_inputs.include?(players)\n puts \"Please enter a valid Input: \"\n players = gets.chomp.to_i\n end\n\n players\n \n end",
"def get_integer(prompt, min, max)\n expression = /[0-9]+/\n # Repeat until number within range\n number = 0 \n input = \"\" \n while number < min || number > max || input == \"\"\n # Repeat until valid number\n input = \"\"\n while input.match(expression).to_s != input || input == \"\" \n print prompt\n input = gets.chomp\n puts \"This is not a valid number!\" if input.match(expression).to_s != input || input == \"\"\n end\n number = input.to_i\n puts \"Number is too large. Maximum is #{max}.\" if number > max\n puts \"Number is too small. Minimum is #{min}.\" if number < min\n end\n return number\nend",
"def valid_num(num)\n until num.match(/[0-9]/)\n puts \"\\nERROR, please enter a valid number\"\n print \"=> \"\n num = gets.chomp\n end\n return num.to_i\nend",
"def check_number\n input = gets.chomp\n until input =~ /\\d/ \n puts \"Enter a valid number\"\n input = gets.chomp\n end\n return input.to_f\nend",
"def verify(input)\n until number_check(input)\n puts \"Please enter a number!\"\n input = gets.chomp\n end\n return input.to_f\nend",
"def get_number\n # gets user input and validates its numericality, user is prompted for input \n # => until a valid number is entered\n num = gets.chop.to_i\n if num == 0\n puts \"Not a number! Please try again\"\n get_number\n else\n return num\n end\n end",
"def advanced_calculator_type\n print \"What would you like to do? Type 1 to find exponents or 2 to find the square root of a number: \"\n selection = gets.to_i\n # puts \"You chose #{selection}\"\n if selection == 1\n \"exponents\"\n elsif selection == 2\n \"square root\"\n else\n \"error\"\n end\nend",
"def take_number #this method runs both methods within a method \"nesting methods\"\n\tprint \"Please give me a number.\"\n\tnum = gets.chomp\n\n\tif float_check(num)\n\t\tputs \"That's a float, we want an integer, please.\"\n\t\ttake_number\n\telse \n\t\tnum = num.to_i\n\t\tif zero_check(num)\n\t\t\tputs \"Give an integer that's not Zero\"\n\t\t\ttake_number\n\t\telse\n\t\t\treturn num\n\t\tend\n\tend\nend",
"def prompt_id_request()\n print \"Please enter a champion ID: \"\n id_request = gets.to_i\n while id_request <= 0\n puts \"Invalid ID. Please enter a champion ID: \"\n id_request = gets.to_i\n end\n return id_request\nend",
"def get_goal(avg)\n puts \"Your daily intake should be around #{avg}\"\n puts \"What is your goal?\"\n goal = (gets.chomp).to_i\n# Warn user if goal is over +- 200 \n if goal > (avg + 200)\n puts \"Your goal is above the daily average\"\n elsif goal < (avg - 200)\n puts \"Your goal is below the daily average\"\n else\n puts \"Good goal! You can do it!\"\n end\n goal\nend",
"def request_difficult\n until [1, 2].include?(difficult)\n show_difficults\n @difficult = $stdin.gets.to_i\n end\n end",
"def confirm_a_number (any_number)\n while any_number.to_i.to_s != any_number\n print \"Please enter an integer: \"\n any_number = gets.chomp\n end\n return any_number.to_i\nend",
"def old_roman\n #old_roman = ''\n while true \n puts \"enter a number between 1 and 3000\"\n request = gets.chomp.to_i\n (puts 'only enter between 1 and 3000';next) if request < 1 || request > 3000\n ms = request / 1000\n test = request - ms*1000\n d = test / 500\n test = test - d*500\n c = test / 100\n test = test - c*100\n l = test / 50\n test = test - l*50\n x = test / 10\n test = test - x*10\n v = test / 5\n test = test - v*5\n i = test\n puts\n puts request\n puts 'M'*ms + 'D'*d + 'C'*c+ 'L'*l + 'X'*x + 'V'*v+ 'I'*i\n end\nend",
"def take_number\n\tputs \"Give me a number?\"\n\tnum = gets.chomp\n\tif float_check(num)\n\t\tputs \"That's a float, we want an integer.\"\n\t\ttake_number\n\telse\n\t\tnum = num.to_i\n\t\tif zero_check(num)\n\t\t\tputs \"Give me an interger that's not zero\"\n\t\t\ttake_number\n\t\telse\n\t\t\treturn num\n\t\tend\n\tend\nend",
"def details(input)\n job = Job.find_by_id(input.to_i)\n if job\n puts \"\\n\\n\" + job.description\n puts menu\n else\n puts \"Out of range. Please input a number between 1 and #{Job.count}\"\n end\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 type_loop \n\tputs \"Type 1 to convert from Celsius to Fahrenheit, OR 2 to convert from Fahrenheit to Celsius.\"\n\n\n\ttype = gets.chomp.to_i\n\n\tcase type\n\twhen 1\n\t\tputs \"Please enter a number to convert to Celsius. \"\n\t\tc_to_f = gets.chomp.to_f \n\t\tconvert_to_f = ((c_to_f * 9)/5)+32\n\t\tputs \"Your temperature in Celcius is: #{convert_to_f}.\"\n\twhen 2 \n\t\tputs \"Please enter a number to convert to Fahrenheit.\"\n\t\tf_to_c = gets.chomp.to_f\n\t\tc_convert = ((f_to_c - 32)*5) / 9\n\t\tputs \"Your temperature in Fahrenheit is: #{c_convert}.\"\n\telse\n\t\tputs \"Improper Entry.\"\n\t\ttype_loop\n\tend\nend",
"def get_user_input(question, range = nil)\n print \"\\n#{question} : \"\n user_response = gets.chomp\n\n if range === nil then\n # check whether the user input is empty\n while user_response.empty? do\n print \"\\nError! You entered a wrong input!\" +\n \"\\n#{question} : \"\n user_response = gets.chomp\n end\n else\n # check whether the user input is an integer and also it is within the given range\n unless user_response.to_i.is_a?(Integer) && user_response.to_i.between?(0, range - 1)\n print \"\\nError! You entered a wrong input!\" +\n \"\\n#{question} : \"\n user_response = gets.chomp\n end\n end\n\n user_response\n end",
"def select_frame()\n\n clear_screen()\n puts \"Enter a number between 0 - 10:\"\n input = gets.chomp\n count = input.to_i\n\n if count < 0 || count > 10\n\n puts \"\\nInvalid number, press any key to try again...\"\n\n else\n\n show_frame(count.to_i) # have to change gets output from str to int\n puts \"Press any key to continue...\"\n\n end\n\n gets.chomp\n select_frame()\n\nend",
"def get_integer\n puts \"Type another integer.\"\n gets.chomp\nend",
"def y\n puts \"type a number\"\n u = gets.to_i\n puts \"type a max value\"\n m = gets.to_i\n\n a = []\n i = 0\n while i < m\n i += 1\n a << i\n end\n\n a.each do |x|\n if x % u == 0\n puts x\n else\n end\n end\n\nend",
"def get_user_age\n # chomp removes the end of line character\n user_input = gets.chomp\n user_input.to_i\nend",
"def prompt_user\n puts \"Please choose a number between 1 and 6\"\nend",
"def select_number\n number = 0\n loop do\n number = gets.to_i\n cond = true\n if number > 9 || number < 1\n puts 'Write a correct number'\n cond = false\n end\n break if cond\n end\n number\nend",
"def print_choices\n # A user should be able to enter numbers to perform the operation on\n puts \"========================\"\n puts \"Input number 1 please:\"\n @number_one = gets.chomp.to_i\n puts \"Input number 2 please:\"\n @number_two = gets.chomp.to_i\n puts \"\"\n puts \"What do you want to do with the numbers?\"\n # Calculator should be able to do basic arithmetic (+,-, *, /)\n puts \"1 - addition\"\n puts \"2 - subtraction\"\n puts \"3 - division\"\n puts \"4 - multiplication\"\n puts \"5 - quit\"\n gets.chomp.to_i\nend",
"def lanzamiento1(jug1)\r\n\tprint \"Turno #{jug1.capitalize}, seleccione casilla (0-6)\"\r\n\t@lanz1 = gets.to_i\r\n\r\nend",
"def get_number(identifier)\n print \"==> Enter the #{identifier} number: \"\n gets.chomp.to_i\nend",
"def num1\n\tputs \"What is the first Number?\"\n\t@number1 = gets.strip\n\t\tif @number1 == 'clear'\n\t\t\texit\n\t\telsif @number1 == \"0\"\n\t\t\t@number1.to_f\n\t\telse @number1 = @number1.to_f\n\t\t\tif @number1 == 0.0\n\t\t\t\tputs \"That is not a valid input, please try again.\"\n\t\t\t\twelcome\n\t\t\telse\n\t\t\tend\n\t\tend\n\toperator\nend",
"def statistic_run\n\n puts 'You want statistics about CS Air'\n\n # print out what to type in for each command\n @num_to_detail.each { |num, string| puts \"Type #{num} for #{string}\" }\n \n command = gets.chomp.to_i\n\n # wait till you receive correct input\n while not @num_to_detail.has_key?(command)\n puts 'Please try again'\n command = gets.chomp.to_i\n end\n \n case\n when command == 1\n puts \"#{@ui_lib.longest_single_flight}\"\n when command == 2\n puts \"#{@ui_lib.shortest_single_flight}\"\n when command == 3\n puts \"#{@ui_lib.average_flight_length}\"\n when command == 4\n puts \"#{@ui_lib.biggest_population_city}\"\n when command == 5\n puts \"#{@ui_lib.smallest_population_city}\"\n when command == 6\n puts \"#{@ui_lib.average_population}\"\n when command == 7\n @ui_lib.list_of_continents.each {|continent, list| puts \"#{continent},#{list}\"}\n when command == 8\n puts \"#{@ui_lib.list_of_hubs}\"\n end\n\n end",
"def number_validation (input)\n eval_num = nil \n until eval_num == \"Pass\" do\n # transforms a copy of the user input to check against the original value\n input_v = input.to_f*100\n input_v = input_v.to_i.to_s\n input_w = input.delete(\".\")\n if input == input.to_f.to_s\n eval_num = \"Pass\"\n elsif input == input.to_i.to_s\n eval_num = \"Pass\"\n elsif input_v == input_w \n eval_num = \"Pass\"\n else\n print \"Oh nos! You entered some non-number character. Enter a new one: \"\n input = gets.chomp\n end\n end \n return input\nend",
"def more_info\n puts \"\"\n puts \"\"\n puts \" Please enter a number for more information about an anime!\"\n input = gets.strip.to_i\n \n if input > 0 && input <= Anime.all.length \n array = Anime.all.uniq.sort{|a,b| a.name <=> b.name}\n anime = array[input-1]\n puts \"\"\n puts \" Anime: #{anime.name}\"\n puts \"\"\n puts \" Description: #{anime.description}\"\n puts \"\"\n puts \" Release date: #{anime.release}\"\n puts \"\"\n self.exit\n\n else input < 0 && input > Anime.all.length\n puts \"\"\n puts \"Invalid number, please try again :) \"\n puts \"\"\n sleep(2.5)\n self.list_all_titles\n end\n end",
"def valid_data(data)\r\n while true\r\n if data.to_i.to_s == data \r\n return data.to_i\r\n elsif data.to_f.to_s == data\r\n return data.to_f\r\n else\r\n puts \"You didn't enter a number. Please enter again.\"\r\n end\r\n puts \"Enter your the amount of the money:\"\r\n data = gets.chomp\r\n end\r\n end",
"def check_input(user_input)\n while (user_input.to_i == 0 && user_input.to_s != \"0\")\n puts \"Invalid input. Please re-enter a non-negative integer. Enter a negative integer to exit. \"\n user_input = gets.chomp\n end\n if user_input.to_i < 0\n puts \"Goodbye.\"\n exit\n end\n return user_input.to_i\nend",
"def edge_handle(input)\n if !!(input =~ /[^0-9]/)\n puts \"\\nPlease input an integer!\"\n return \"\"\n elsif input.to_i > 10\n puts \"\\nThere are only 10 pins to knock over, please check the score and try again.\"\n return \"\"\n elsif @game.current_frame_object.pins_knocked + input.to_i > 10 && @game.current_frame_number < 10\n puts \"\\nOnly ten pins can be knocked over in a frame, please check the score and try again.\"\n return \"\"\n else\n return input.to_i\n end\n end"
] |
[
"0.66092736",
"0.6603989",
"0.65450525",
"0.6543666",
"0.6501524",
"0.64608026",
"0.64101535",
"0.64075357",
"0.6405119",
"0.635944",
"0.63532937",
"0.6329079",
"0.63286066",
"0.63224363",
"0.62884784",
"0.62768",
"0.6269413",
"0.6258408",
"0.62535346",
"0.624236",
"0.6240378",
"0.6239666",
"0.62233377",
"0.6206676",
"0.6193324",
"0.6187119",
"0.61864847",
"0.6164122",
"0.6141407",
"0.6134908",
"0.61247456",
"0.61173815",
"0.6109677",
"0.60998356",
"0.60970783",
"0.60929763",
"0.60875875",
"0.60809875",
"0.6075851",
"0.6075494",
"0.60739756",
"0.6068111",
"0.6063737",
"0.6060777",
"0.6060513",
"0.60583746",
"0.6053581",
"0.6027922",
"0.60235405",
"0.601527",
"0.6003307",
"0.60018283",
"0.6000638",
"0.5994411",
"0.59934014",
"0.5983144",
"0.59825575",
"0.5982316",
"0.5979429",
"0.59574527",
"0.59572744",
"0.5957083",
"0.5955177",
"0.5954709",
"0.59308016",
"0.59198236",
"0.59182596",
"0.5916254",
"0.5911631",
"0.5905681",
"0.5893629",
"0.5890168",
"0.58897024",
"0.5887064",
"0.58853555",
"0.58836395",
"0.58731014",
"0.5869304",
"0.5869074",
"0.5862423",
"0.5860529",
"0.58600515",
"0.58527774",
"0.58509535",
"0.58497983",
"0.5849605",
"0.58441836",
"0.5844153",
"0.5840839",
"0.5840091",
"0.58374906",
"0.58325666",
"0.5826856",
"0.5820281",
"0.5813267",
"0.5810744",
"0.5808998",
"0.5808876",
"0.580494",
"0.5801134"
] |
0.6152773
|
28
|
Gets numeric input, loops until user inputs a float or integer value
|
def getFloatInput()
val = gets.chomp
while not /((\d)+)/.match(val) || /((\d)+\.(\d)+)/.match(val)
puts 'This input should be a decimal (I.E. 1.1 or 1.2) or integer
(I.E. 1 or 2). Please input again.'
val = gets.chomp
end
return val
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def number_check(number)\n until (number.to_f.to_s == number || number.to_i.to_s == number) && number.to_f != nil\n print \"ERROR: Please enter a valid number (float or integer):\"\n number = gets.chomp\n end\n return number\nend",
"def verify_number(data_to_verify)\n until (Float(data_to_verify) rescue nil) != nil && data_to_verify.to_f > 0\n puts \"Input not accepted, please enter a number:\"\n data_to_verify = gets.chomp\n end\n data_to_verify.to_f\nend",
"def check_number\n input = gets.chomp\n until input =~ /\\d/ \n puts \"Enter a valid number\"\n input = gets.chomp\n end\n return input.to_f\nend",
"def prompt(*args)\n input_arg=false\n until input_arg do # quits when input_arg=true\n print(*args) # prints the input which prompts the user visually\n value=Float(gets) # converts inputted arg as Float\n input_arg = value rescue false # checks if input is Float, otherwise continues to prompt\n end\n return value # finally returns value\nend",
"def get_num\n puts \"==> Enter an Integer\"\n num = gets.chomp.gsub(/\\,/, '.')\n while !valid_num?(num)\n puts\"==> Try again, Integer input please\"\n num = gets.chomp.gsub(/\\,/, '.')\n end\n\n if valid_int?(num)\n num.to_i\n else\n num.to_f\n end\nend",
"def valid_float(input)\n while true\n if input =~ /^(\\d)*(.)?(\\d)+$/ && input.to_f > 0\n return input.to_f\n else\n puts \"Try again! Only use numbers\"\n input = gets.chomp\n end\n end\nend",
"def get_user_num\n user_num = gets.chomp\n until user_num =~ /\\A[-+]?[0-9]*\\.?[0-9]+\\Z/\n print \"Not a valid number. Try again: \"\n user_num = gets.chomp\n end\n return user_num.to_f\nend",
"def get_num\n user_num = gets.chomp\n\n while user_num.to_f == 0 && (user_num != \"0\" && user_num != \"0.0\")\n print \"Sorry. Please enter a valid number: \"\n user_num = gets.chomp\n end\n\n if user_num.include?(\".\")\n return user_num.to_f\n else\n return user_num.to_i\n end\nend",
"def verify(input)\n until number_check(input)\n puts \"Please enter a number!\"\n input = gets.chomp\n end\n return input.to_f\nend",
"def get_valid_number(cont)\n loop do\n puts \"Enter number or q:\"\n val = gets.chomp()\n if (val == \"q\") \n cont << val\n break\n end\n if is_num?(val)\n return val.to_f\n else\n puts \"Input was not numerical.\"\n end\n end\nend",
"def getIntegerInput()\r\n val = gets.chomp\r\n while !/((\\d)+)/.match(val) || /((\\d)+\\.(\\d)+)/.match(val)\r\n puts 'This input should be an integer. Please input again.'\r\n val = gets.chomp\r\n end\r\n return val\r\nend",
"def number_check(num)\n begin\n num = gets.chomp\n if num.include?(\".\")\n return num = Float(num)\n else\n return num = Integer(num)\n end\n rescue\n puts \"Please enter a number\"\n retry\n end\nend",
"def is_valid_numeric_input(order)\n\n print \"#{order} number >> \"\n num = gets.chomp\n\n until is_numeric(num)\n puts \"Not valid number. Please try again.\"\n print \"#{order} number >> \"\n num = gets.chomp\n end\n\n return num\nend",
"def check_number(input)\n\t\tif input.is_a?(Float) or input =~ /[\\d\\.]+/\n\t\t\treturn input.to_f\n\t\telse\n\t\t\tputs \"You must enter a number. Please try again..\"\n\t\t\tinput = $stdin.gets.chomp\n\t\t\tcheck_number(input)\n\t\tend\n\t\treturn input\n\tend",
"def getFloat \n\tprint \"Enter number: \"\n\tnum = gets.chomp.to_f\n\treturn num\nend",
"def getUserNumber\n begin\n return Float(gets.chomp)\n rescue\n puts \"Please enter the number as an integer.\"\n retry\n end\nend",
"def input_check(number)\n until number.match(/\\A[-]?\\d+(\\.\\d+)?\\z/)\n puts \"Please enter a valid number \"\n number = gets.chomp\n end\n return number\nend",
"def take_number\n\n puts \"Give me a number\"\n num = gets.chomp\n\n if float_check(num)\n puts \"That's a float, we need an integer\"\n take_number\n else\n #gotta convert to Integer before zero-checking!\n num = num.to_i\n if zero_check(num)\n puts \"Please provide a non-zero number.\"\n take_number\n else\n return num\n end\n end\nend",
"def choose_vehicle_price\n puts \"Enter new price\"\n @new_price = gets.chomp.to_i\n if !@new_price.is_a? Numeric\n puts Rainbow(\"This value is invalid. Please try again.\").red.bold\n choose_vehicle_price\n end\nend",
"def take_number\n\tputs \"Give me a number?\"\n\tnum = gets.chomp\n\tif float_check(num)\n\t\tputs \"That's a float, we want an integer.\"\n\t\ttake_number\n\telse\n\t\tnum = num.to_i\n\t\tif zero_check(num)\n\t\t\tputs \"Give me an interger that's not zero\"\n\t\t\ttake_number\n\t\telse\n\t\t\treturn num\n\t\tend\n\tend\nend",
"def get_number(value_name)\r\n puts \"please input a value for #{value_name} (numbers)\"\r\n while true\r\n answer=gets.chomp\r\n break if is_number?(answer)\r\n puts \"please input only numbers for this value\"\r\n end\r\n answer.to_i\r\n end",
"def verify_number(num)\n # if if does not have a digit a period or white space, try again\n while num =~ /[^.\\d]/ || num == \"\"\n puts \"you did not entered a number, please try again:\"\n num = gets.chomp\n end\n # convert to integer or float\n if num =~ /\\./\n return num.to_f\n else\n return num.to_i\n end\nend",
"def get_float \r\n while true \r\n zahl=gets.chomp \r\n return zahl.to_f if (zahl==zahl.to_f.to_s or zahl==zahl.to_i.to_s) \r\n puts '- wie bitte? : ' \r\n end \r\nend",
"def fetch_number(prompt)\n\tprint prompt\n\tgets.to_f #allow decimal input\nend",
"def input_number(num)\n loop do\n num = Kernel.gets().chomp()\n break if valid_number?(num)\n\n prompt(\"invalid_input\")\n end\n num\nend",
"def get_float\n gets.chomp.to_f\nend",
"def num_check(num)\n until num.to_i.to_s == num\n puts \"Invalid entry. Please entere an integer.\"\n num = gets.chomp.to_i\n end\n return num.to_i\nend",
"def readInteger\n shouldReadInt = true\n while shouldReadInt do\n input = gets.chomp\n if input =~ /^[\\d]+(\\.[\\d]+){0,1}$/\n shouldReadInt = false\n else\n puts \"please enter a valid number\" \n end\n end\n return Integer(input)\nend",
"def valid_data(data)\r\n while true\r\n if data.to_i.to_s == data \r\n return data.to_i\r\n elsif data.to_f.to_s == data\r\n return data.to_f\r\n else\r\n puts \"You didn't enter a number. Please enter again.\"\r\n end\r\n puts \"Enter your the amount of the money:\"\r\n data = gets.chomp\r\n end\r\n end",
"def ask(prompt)\n input = nil\n loop do\n puts prompt\n print '> '\n input = gets.chomp\n break if input =~ /\\A-?\\d+\\Z/\n\n system('clear')\n puts 'You must enter a whole numeric value when needed. Please try again!'.colorize(:red)\n end\n input\n end",
"def valid_num?(input)\n integer?(input) || float?(input)\nend",
"def number_validation (input)\n eval_num = nil \n until eval_num == \"Pass\" do\n # transforms a copy of the user input to check against the original value\n input_v = input.to_f*100\n input_v = input_v.to_i.to_s\n input_w = input.delete(\".\")\n if input == input.to_f.to_s\n eval_num = \"Pass\"\n elsif input == input.to_i.to_s\n eval_num = \"Pass\"\n elsif input_v == input_w \n eval_num = \"Pass\"\n else\n print \"Oh nos! You entered some non-number character. Enter a new one: \"\n input = gets.chomp\n end\n end \n return input\nend",
"def get_user_integer\n valid_input = false\n input = 0\n until valid_input do\n user_input = gets.chomp.to_i\n if user_input > 0 && user_input.kind_of?(Integer)\n valid_input = true\n input += user_input\n clear\n break\n else\n puts \"Incorrect input, please enter an integer greater than 0\"\n end\n end\n return input\nend",
"def ask_for_initial_number(phrase)\n print \"Please enter the #{phrase}: \"\n input = gets.chomp\n if numerical_input?(input)\n return input.to_f\n else\n print \"#{tell_invalid(\"entry.\")} \"\n ask_for_initial_number(phrase)\n end\nend",
"def ask_user\n puts 'enter a number:'\n input = gets.chomp.to_i\n check_num(input)\n end",
"def check_valid (num)\n # repeat validation until proper numeric entry from user\n # \\A[-+]? match upto 1 - or + sign at start of string\n # [\\d]* match any number of digits\n # \\.? match up to 1 .\n # [\\d]+ match 1 or more digits\n until num =~ /\\A[-+]?[\\d]*\\.?[\\d]+$/ && num =~ /\\.?/ && num !~ /[a-zA-Z]/\n print \"Invalid entry, please enter a numeric: \"\n num = gets.chomp\n end\n return num\nend",
"def check_num\n loop do\n puts \">please enter a positive or neg num\"\n num = gets.chomp\n return num.to_i if valid_number?(num)\n puts \"> oops. only non-zero intergers are allowed\"\n end\nend",
"def user_input(p)\n loop do\n prompt p\n var = gets.chomp\n if number?(var)\n return var\n else\n prompt 'Invalid choice. Please try again.'\n end\n end\nend",
"def get_number\n # gets user input and validates its numericality, user is prompted for input \n # => until a valid number is entered\n num = gets.chop.to_i\n if num == 0\n puts \"Not a number! Please try again\"\n get_number\n else\n return num\n end\n end",
"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_one_number\n\tputs \"What number would you like to use?\"\n # all methods requiring one arg return floats except factorial_calc\n $num1 = gets.chomp.to_f\nend",
"def number_check(user_input)\n if user_input.numeric?\n return user_input\n else\n return false\n end\nend",
"def ask_info(info)\n value = ''\n loop do\n value = gets.chomp\n break if (valid_number? value) && (value.to_f > 0)\n prompt \"The #{info} is not valid. Enter a valid #{info}:\"\n end\n value\nend",
"def valid_num(num)\n until num.match(/[0-9]/)\n puts \"\\nERROR, please enter a valid number\"\n print \"=> \"\n num = gets.chomp\n end\n return num.to_i\nend",
"def get_amount_given\n puts \"What is the amount tendered?\"\n gets.chomp.to_f\nend",
"def enter_value()\n value = gets\n if int?(value.to_i)\n return value\n end #end of if\n end",
"def get_valid_input(input_type, options = {})\n input = nil\n loop do\n input = gets.chomp\n # binding.pry\n if options.has_key?(:result) && input == \"\"\n input = options[:result]\n break\n else\n if input_type == \"num\"\n numeric?(input) || input.upcase == 'Q' ? break : say(\"Numbers only\")\n else\n %w(1 2 3 4 Q).include?(input.upcase) ? break : say(\"1, 2, 3, or 4 only\")\n end\n end\n end\n input\nend",
"def get_height(name)\n\n puts \"Enter height in cm for #{name}: -> hit return to skip\"\n\n while true do\n\n # get the user to enter a height\n height = STDIN.gets.chomp\n\n if height.empty? then return \"N/A\" end\n\n # check it is valid and return\n if height.is_number? then return height\n\n # if not valid, try agiain\n else\n puts \"#{height} is not a valid height in cm, should be numeric\\ntry again...\"\n end\n end\n\nend",
"def get_input(message_str)\n # print prompt with text and get initial value\n prompt_string = PROMPT + \" \" + message_str + \" or [q] to quit\"\n puts prompt_string\n input_string = gets.chomp\n input_type = nil\n input_val = nil\n\n # boolean flag to determine if we need to continue\n # in the loop or drop out. false continues\n done = false\n \n # loop until we get either a 'q' or a valid numerical value\n # in the input string. 'q' exits the entire program\n begin\n input_type, input_val = get_input_type(input_string)\n if input_type == 's' && input_val == 'q'\n puts PROMPT + \" Bye.\"\n exit\n elsif input_type == 'i' || input_type == 'f'\n return input_val\n else\n puts \"Invalid entry. Please try again or [q] to quit\"\n puts prompt_string\n input_string = gets.chomp\n end\n end while done == false\nend",
"def ask_for_annual_rate\n puts prompt(:annual_rate)\n loop do\n annual_rate = gets.chomp\n if valid?(annual_rate)\n return annual_rate.to_f\n else\n space_prompts\n puts prompt(:rate_error)\n end\n end\nend",
"def type_loop \n\tputs \"Type 1 to convert from Celsius to Fahrenheit, OR 2 to convert from Fahrenheit to Celsius.\"\n\n\n\ttype = gets.chomp.to_i\n\n\tcase type\n\twhen 1\n\t\tputs \"Please enter a number to convert to Celsius. \"\n\t\tc_to_f = gets.chomp.to_f \n\t\tconvert_to_f = ((c_to_f * 9)/5)+32\n\t\tputs \"Your temperature in Celcius is: #{convert_to_f}.\"\n\twhen 2 \n\t\tputs \"Please enter a number to convert to Fahrenheit.\"\n\t\tf_to_c = gets.chomp.to_f\n\t\tc_convert = ((f_to_c - 32)*5) / 9\n\t\tputs \"Your temperature in Fahrenheit is: #{c_convert}.\"\n\telse\n\t\tputs \"Improper Entry.\"\n\t\ttype_loop\n\tend\nend",
"def read_number\n loop do\n puts '>> Please enter a positive or negative integer:'\n number = gets.chomp\n return number.to_i if valid_number?(number)\n puts '>> Invalid input. Only non-zero integers are allowed.'\n end\n end",
"def get_requested_amount(type)\n request = prompt_user(\"How much would you like to #{type}?\").to_i\n while request <= 0\n request = prompt_user(\"Please enter an amount greater than $0.\").to_i\n end\n request.to_i\nend",
"def input_num()\n\twhile true\n \tputs \"Input a number.\"\n\t\tnum = gets.strip\n\t\tif /-\\d+/.match(num)\n\t\t\tnum = /\\d+/.match(num)[0]\n\t\t\treturn -num.to_i\n\t\telsif /[^0-9]/.match(num)\n\t\t\tputs \"Please only enter a number.\"\n\t\telsif /\\d+/.match(num)\n\t\t\tnum = /\\d+/.match(num)[0]\n\t\t\treturn num.to_i\n\t\telse\n\t\t\tputs \"Error\"\n\t\tend\n\tend\nend",
"def is_digit?(input)\n !!Float(input) rescue false\nend",
"def numeric?(input)\n !Float(input).nil?\n rescue\n false\n end",
"def read_number\n loop do\n puts '>> Please enter a positive or negative integer:'\n number = gets.chomp\n\n if valid_number?(number)\n return number.to_i\n else\n puts '>> Invalid input. Only non-zero integers are allowed.'\n end\n end\nend",
"def confirm_a_number (any_number)\n while any_number.to_i.to_s != any_number\n print \"Please enter an integer: \"\n any_number = gets.chomp\n end\n return any_number.to_i\nend",
"def valid_integer(input)\n while true\n if input =~ /^(\\d)+$/ && input.to_i > 0\n return input.to_i\n else\n puts \"Try again! Only use numbers\"\n input = gets.chomp\n end\n end\nend",
"def query_integer(message_string)\n print message_string\n\n is_legal_input = false\n until is_legal_input do\n # Get an integer from the user, or return nil if a value is given\n # that is not clearly convertible to an integer.\n int_input = Integer(gets.chomp) rescue nil\n\n if int_input == nil\n print 'Sorry, an integer is required. Try again: '\n else\n is_legal_input = true end\n end #of until loop\n return int_input\nend",
"def float?(num)\n num.to_f.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def float?(num)\n num.to_f.to_s == num # converts num to interger and back to string and then compares this with num.\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def ask_for_digits\r\n puts (\"Calculator\").colorize(:white).on_green\r\n variables = []\r\n input = @@prompt.ask(\"Enter a number between 1000 and 9999 e.g. 1234:\") do |q|\r\n q.convert -> (input) { input.split(/[\\s]/) }\r\n q.convert(:integer, \"Invalid input. Try again.\")\r\n end\r\n \r\n # Error handling: If they put in a negative number \r\n begin \r\n # Take the input, split by digits, and because that puts them in reverse order it must be reversed again\r\n variables = input.digits.reverse\r\n rescue\r\n system(\"clear\")\r\n puts \"Positive numbers only!\"\r\n ask_for_digits\r\n end \r\n \r\n\r\n if variables.length == 4\r\n numbers = []\r\n numbers += object_to_float(variables)\r\n op = Operations.new\r\n op.calculate(numbers[0], 0, numbers, [])\r\n ask_user_start\r\n \r\n else\r\n system(\"clear\")\r\n puts \"Invalid input\"\r\n ask_for_digits\r\n end\r\n \r\n end",
"def numbers()\n puts 'What is the first number: '\n @first_number = gets.to_f\n puts \"What is the second number: \"\n @second_number = gets.to_f\nend",
"def age_validator\n puts \"whats your characters age\" \n age = gets.strip.to_i \n until age > 16 #checks to see if age is a number \n begin \n if age >! 16\n end\n rescue #rescues if there is an error because its not an integer \n puts \"Input must be a valid number above 16, Try Again\"\n age = gets.strip.to_i\n end\n end\n return age\nend",
"def numeric(input)\n return Float(input) != nil rescue false\n end",
"def get_target_number\n print \"\\n\\nEnter a positive integer or -ve number to exit: \"\n input_value=gets\n is_num?(input_value)? input_value.to_i : nil\nend",
"def menu_gets( prompt_str, input_type )\n # go in to an infinite loop\n while true\n print( prompt_str )\n input_str = gets.chomp\n \n # allow caller to set defaults\n return nil if input_str == \"\"\n \n case input_type\n when \"String\"\n return input_str\n when \"Integer\"\n output = input_str.to_i\n if output != 0\n return output\n else\n puts \"\\nSorry, you must enter a non-zero integer...\\n\"\n end\n when \"Float\"\n output = input_str.to_f\n if output != 0\n return output\n else\n puts \"\\nSorry, you must enter a non-zero float...\\n\"\n end\n when \"Money\"\n output = input_str.to_f\n if output != 0\n return output.round(2)\n else\n puts \"\\nSorry, you must enter a non-zero float...\\n\"\n end\n end\n end\nend",
"def second_number_function \n puts \"What is the second number?\"\n print \"> \" \n second_number = gets.strip \n if second_number =~ /-?\\d+\\.?\\d*/\n puts \"accepted\" \n @second_number = second_number.to_f\n calculations \n else puts \"Must enter a number\" \n second_number_function \n calculations \n end \nend",
"def num1\n\tputs \"What is the first Number?\"\n\t@number1 = gets.strip\n\t\tif @number1 == 'clear'\n\t\t\texit\n\t\telsif @number1 == \"0\"\n\t\t\t@number1.to_f\n\t\telse @number1 = @number1.to_f\n\t\t\tif @number1 == 0.0\n\t\t\t\tputs \"That is not a valid input, please try again.\"\n\t\t\t\twelcome\n\t\t\telse\n\t\t\tend\n\t\tend\n\toperator\nend",
"def last_number\n puts \"enter your last number:\"\n @num2 = gets.to_f\n puts \"Your last number is #{@num2}\"\nend",
"def first_number_function \n puts \"What is the first number?\"\n print \"> \"\n first_number = gets.strip \n if first_number =~ /-?\\d+\\.?\\d*/\n puts \"Accepted\"\n @first_number = first_number.to_f \n operator_function \n else puts \"Must enter a number.\"\n first_number_function \n end \nend",
"def take_number #this method runs both methods within a method \"nesting methods\"\n\tprint \"Please give me a number.\"\n\tnum = gets.chomp\n\n\tif float_check(num)\n\t\tputs \"That's a float, we want an integer, please.\"\n\t\ttake_number\n\telse \n\t\tnum = num.to_i\n\t\tif zero_check(num)\n\t\t\tputs \"Give an integer that's not Zero\"\n\t\t\ttake_number\n\t\telse\n\t\t\treturn num\n\t\tend\n\tend\nend",
"def is_valid_number(input)\n raise \"Not a valid number. Please enter a number greater than 0.0, making sure to not include any letters or symbols.\" unless input.to_f.is_a? Numeric\n end",
"def is_number?(input)\n true if Float(input) rescue false\n end",
"def fetch_number\n print \"Please choose a number: \"\n gets.to_i\nend",
"def q1_get_num\n puts \"Enter a number please: \"\n gets.to_i\nend",
"def prompt_numbers\n puts \"give me a number\"\n a = gets.chomp.to_f\n puts \"give me another number\"\n b = gets.chomp.to_f\n return a, b\nend",
"def get_weight(unit)\n puts \"Enter your weight in #{unit}\"\n weight = gets.to_f\n return weight\nend",
"def get_earned_credits\n begin\n puts \"\\nPlease enter total credits earned: \"\n @earned_credits = gets.chomp\n end until is_float? @earned_credits\n @earned_credits = @earned_credits.to_f\n end",
"def int_input(prompt, err_msg = \"Please enter a number.\", repeat = true)\n str = \"\"\n until str[/^-?\\d+$/]\n str = input prompt\n puts err_msg unless str[/^-?\\d+$/] || err_msg.nil?\n return unless repeat\n end\n str.to_i\n end",
"def prompt_numbers\n puts \"Give me a number\"\n a = gets.chomp.to_f\n puts \"Give me another number\"\n b = gets.chomp.to_f\n return a, b\nend",
"def prompt_numbers\n puts \"Give me a number\"\n a = gets.chomp.to_f\n puts \"Give me another number\"\n b = gets.chomp.to_f\n return a, b\nend",
"def prompt_numbers\n puts \"Give me a number\"\n a = gets.chomp.to_f\n puts \"Give me another number\"\n b = gets.chomp.to_f\n return a, b\nend",
"def valid_number?(num)\n integer?(num) || float?(num)\nend",
"def divide(num_one, num_two)\n if num_two == 0\n until num_two != 0\n puts \"You can't divide by zero. Enter the second number again: \"\n num_two = gets.chomp.to_i\n end\n end\n return num_one / num_two\nend",
"def user_num\n loop do\n prompt(MESSAGES['number_request'])\n num1 = Kernel.gets().chomp()\n num2 = Kernel.gets().chomp()\n if number?(num1) && number?(num2)\n return num1, num2\n else\n prompt(MESSAGES['invalid_numbers'])\n end\n end\nend",
"def ask_for_loan_amt\n puts prompt(:loan_amt)\n loop do\n loan_amt = gets.chomp\n if valid_dollar_amt?(loan_amt)\n return loan_amt.to_f.round(2)\n else\n space_prompts\n puts prompt(:loan_amt_error)\n end\n end\nend",
"def get_user_input\n\t\tinput_right = false\n\t\tno_of_primes = 0\n\t\tloop do\n\t\t\tprint \"Enter the number of primes you want: \"\n\t\t\tno_of_primes = gets.chomp.to_i\n\t\t\tinput_right = (no_of_primes.to_i > 0) ? true : false\n\t\t\tif no_of_primes <= 0\n\t\t\t\tprint \"\\n Please enter a number( > 0 ) \\n\"\n\t\t\t\tself.no_of_primes = 0\n\t\t\tend\n\t\t\tbreak if input_right\n\t\tend\n self.no_of_primes = no_of_primes\n\tend",
"def verify(x)\n\ty = 1\n\twhile y == 1\n\t\tif x.is_a?(Integer) && x > 0 && x < 10 #need to fix this. Still able to take non integers like 1.5\n\t\t\treturn x\n\t\t\ty-=1\n\t\telse\n\t\t\tputs \"Try again - number must be 1 through 10 and an integer\"\n\t\t\tx = gets.chomp.to_i\n\t\tend\n\tend\nend",
"def ask_for_guess(min, max)\n puts \"Guess a number #{min} to #{max}?\"\n\n guess = gets.to_i\n while guess < min or guess > max\n puts \"Your number must be greater than #{min} and less than #{max}. Guess again.\"\n guess = gets.to_i\n end\n \n guess\nend",
"def prompt\n print 'Type an integer number (or q to exit) and press Enter: '\n number = gets\n say_bye_and_exit if number =~ /^q/i\n number = prompt unless number =~ /^\\d+$/\n if number.to_i > 2 ** 64\n puts 'The number you entered is too big. Calculation can run a lot of time! Continue? (y/n)n'\n confirm = gets\n number = prompt unless confirm =~ /^y/i\n end\n number.to_i # to ensure Numeric value returs\nend",
"def enter_age(age)\n # Do a loop until user inputs correct value\n while true do\n puts \"Please enter age\"\n age = gets.chomp.to_i\n age < 18 || age > 99 ? \"Not valid\" : break\n end\n age\n end",
"def number?(num)\n loop do\n if !REGEX.match(num)\n message(TEXT['real'])\n num = Kernel.gets().chomp()\n else\n break\n end\n end\n num\nend",
"def check_input_number(input_str)\n while input_str.to_i <= 0 do\n input_str = ask(\"Введи положительное число!\")\n end\n input_str.to_i\n end",
"def fetch_number\n print \"What is your number? \" # Will print this text and allow you to type in next to it\n gets.to_i # Will ask for a user input and then turn it into an integer (will also return)\nend",
"def request_amt\n amt = ''\n loop do\n prompt('What is the loan amount in whole dollars')\n amt = gets.chomp\n if valid_number?(amt)\n return amt\n else\n prompt('Not a valid loan amount, please enter only numbers')\n end\n end\nend",
"def user_input\n\tuser_selection = gets.strip.to_i\n\tinput_logic(user_selection)\nend"
] |
[
"0.77336425",
"0.77113897",
"0.76842934",
"0.76531905",
"0.7525484",
"0.75112915",
"0.74006647",
"0.73721296",
"0.7364309",
"0.72914773",
"0.7273671",
"0.7222926",
"0.71937853",
"0.70949006",
"0.7084996",
"0.7074564",
"0.698324",
"0.6965458",
"0.69071674",
"0.68944436",
"0.6875672",
"0.6828659",
"0.6826287",
"0.68099207",
"0.6782007",
"0.67645484",
"0.6735525",
"0.6728626",
"0.6666176",
"0.666352",
"0.6663212",
"0.6637897",
"0.6634463",
"0.6621854",
"0.659467",
"0.6585799",
"0.65850693",
"0.6579725",
"0.6567164",
"0.65399617",
"0.65385836",
"0.649149",
"0.6460093",
"0.64534384",
"0.6434404",
"0.64103127",
"0.63988817",
"0.6398731",
"0.63931185",
"0.63829184",
"0.63409454",
"0.6336885",
"0.6331304",
"0.631936",
"0.6317971",
"0.6312947",
"0.6301826",
"0.627823",
"0.6255709",
"0.6250941",
"0.62493604",
"0.62493604",
"0.62456644",
"0.62456644",
"0.6229722",
"0.6209976",
"0.6207047",
"0.62039405",
"0.61993796",
"0.6195404",
"0.6182007",
"0.6180811",
"0.61697674",
"0.61664313",
"0.6162964",
"0.61576337",
"0.6142762",
"0.6114402",
"0.61131173",
"0.6112062",
"0.6107321",
"0.61028594",
"0.60900533",
"0.6063382",
"0.6063382",
"0.60632706",
"0.60562366",
"0.60554665",
"0.6053702",
"0.6053001",
"0.60391927",
"0.6038309",
"0.60375226",
"0.6022815",
"0.6010498",
"0.59841335",
"0.5981703",
"0.5974822",
"0.5949444",
"0.5949019"
] |
0.7706417
|
2
|
These defs are made to determine the amount of CP a character needs to level up and if they did level up how much CP they will need for their next level.
|
def CP(level)
cpNeeded = 0
if level > 0 && level <= 5
cpNeeded + 4
elsif level > 5 && level <= 20
cpNeeded + 8
else
cpNeeded + 0
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_cr_or_level(num_of_pcs, cr_or_level)\n if num_of_pcs <= 4\n @cr = cr_or_level\n elsif num_of_pcs == 5\n @cr = cr_or_level + (cr_or_level * 0.25)\n elsif num_of_pcs == 6\n @cr = cr_or_level + (cr_or_level * 0.5)\n elsif num_of_pcs == 7\n @cr = cr_or_level + (cr_or_level * 0.75)\n elsif num_of_pcs == 8\n @cr = cr_or_level + cr_or_level\n end\n end",
"def calculate_cbm\n @cbm = @bab + @str_modifier + @unarmed_prof\n @cbm_def = 10 + @bab + @str_modifier + @dex_modifier + @unarmed_prof\n end",
"def bc_count\n \t@generic.size + @initial.size + @final.size + @cyclic.size\n end",
"def calculate_level\n # Increase level for every 10 lines cleared\n @level = @start_level + (@lines_cleared / 10).floor\n end",
"def coat_length; end",
"def prop_c\n bases_c / length.to_f\n end",
"def xp_required\n 750 * ((@level + 1) ** 2)\n end",
"def cnps\n if (cnpswage() > SystemVariable.value(:cnps_ceiling))\n ( SystemVariable.value(:cnps_ceiling) *\n SystemVariable.value(:emp_cnps) ).round\n else\n ( cnpswage() * SystemVariable.value(:emp_cnps) ).round\n end\n end",
"def calc_critical_count(user, target, initial_critical_count)\n return 0 if NO_CRITICAL_ABILITIES.include?(target.ability_db_symbol)\n critical_count = initial_critical_count\n critical_count += 2 if user.focus_energy?\n critical_count += 1 if user.ability_db_symbol == :super_luck\n critical_count += 1 if calc_critical_count_item(user)\n return critical_count\n end",
"def levels\n # divide total points available in to X tiers\n # set up a hash\n # Beginner - 1\n # Good start - 2\n # Moving Up - 3\n # good - 4\n # Solid - 5\n # Nice - 6\n # Great - 7\n # Amazing - 8\n # Genius - 9\n # Queen Bee - 10\n end",
"def cac2\n 0\n end",
"def total_node_number_cps(tree)\n callcc{|cc|\n helper_2(tree.root, cc, 0)\n }\nend",
"def base_cost class_name = nil, race = nil, primary_school=nil, build=nil\n\t\tif @character != nil\n\t\t\tclass_name = @character.character_class.to_s if class_name == nil\n\t\t\trace = @character.race.to_s if race == nil\n\t\t\tprimary_school = @character.primary if primary_school == nil\n\t\t\tsecondary_school=@character.secondary if secondary_school==nil\n\t\t\tbuild = @character.build if build == nil\n\t\tend\n\n\t\tif !self.legal?\n\t\t\treturn false\n\t\tend\n\n\t\tcost = @skill.cost(class_name, race)\n\n\t\t# Prohibited or racial\n\t\tif cost == nil or @character.race.prohibited? @skill\n\t\t\treturn false\n\t\tend\n\n\t\tmodifiers = $character.race.skill_cost_modifiers(@skill.to_s)\n\n\t\tif cost.is_a? Integer\n\t\t\tcost *= 2 if modifiers.include? :doubled\n\t\t\tcost = (cost/2) + (cost%2) if modifiers.include? :halved\n\t\t\tcost = cost - 1 if modifiers.include? :reduced\n\n\t\t\treturn @count * cost\n\t\tend\n\t\t# Formal\n\t\tunless @skill.to_s.match('Formal').nil?\n\t\t\t$log.info \"Character_Skill.cost() Calculating cost of Formal Magic\"\n\t\t\tif @skill.to_s.match(primary_school)\n\t\t\t\tcost = cost['Primary']\n\n\t\t\t\tcost *= 2 if modifiers.include? :doubled\n\t\t\t\tcost = (cost/2) + (cost%2) if modifiers.include? :halved\n\t\t\t\tcost = cost - 1 if modifiers.include? :reduced\n\n\t\t\t\treturn @count * cost\n\t\t\telsif @skill.to_s.match(secondary_school)\n\t\t\t\tcost = cost['Secondary']\n\n\t\t\t\tcost *= 2 if modifiers.include? :doubled\n\t\t\t\tcost = (cost/2) + (cost%2) if modifiers.include? :halved\n\t\t\t\tcost = cost - 1 if modifiers.include? :reduced\n\n\t\t\t\treturn @count * cost\n\t\t\telse\n\t\t\t\t$log.error \"School of formal magic did not match primary OR secondary\"\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\t# Must be a templar purchasing profs or crit attacks\n\t\t# (or a rogue getting master profs / master crit attacks)\n\t\t# TODO: check build to see if there are profs if this is a crit att\n\t\tunless @skill.to_s.match('Attack').nil?\n\t\t\tset = 0\n\t\t\tif build != nil\n\t\t\t\tunless @skill.to_s.match('Master').nil?\n\t\t\t\t\tset = build.count('Master Proficiency', {}) + build.count('Proficiency',{})\n\t\t\t\t\tset = 2 if set > 2\n\t\t\t\t\t# You cannot buy Master Critical Attacks if you already have normal Proficiencies\n\t\t\t\t\t# I'm allowing it unless it's the same hand\n\t\t\t\t\tif build.count('Proficiency', {'Hand'=>@options['Hand']}) != 0\n\t\t\t\t\t\treturn false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tset = build.count('Proficiency', {}) + build.count('Master Proficiency', {})\n\t\t\t\t\tset = 2 if set > 2\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn @count * cost[set]\n\t\tend\n\t\t# Must be a prof.\n\t\t# Profs are accounted for in the following order:\n\t\t# Right, Master; Left, Master; Right, Normal; Left, Normal\n\t\t# Technically there's a bug here: a templar purchasing different normal profs in the same hand will pay weird prices\n\t\t# He's saving 2 build over buying a single Master Prof...\n\t\tadditional_count = 0\n\t\tunless @skill.to_s.match('Master') and @options['Hand'] == 'Right'\n\t\t\tadditional_count += build.count('Master Proficiency',{'Hand'=>'Right'})\n\t\t\tunless @skill.to_s.match('Master') and @options['Hand'] == 'Left'\n\t\t\t\tadditional_count += build.count('Master Proficiency',{'Hand'=>'Left'})\n\t\t\t\tunless (not @skill.to_s.match('Master')) and @options['Hand'] == 'Right'\n\t\t\t\t\tadditional_count += build.count('Proficiency',{'Hand'=>'Right'})\n\t\t\t\t\tunless (not @skill.to_s.match('Master')) and @options['Hand'] == 'Left'\n\t\t\t\t\t\tadditional_count += build.count('Proficiency',{'Hand'=>' Left'})\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# Prevent addition of a normal Prof if you have a Master Crit Attack in that hand\n\t\tunless skill.to_s.match('Master')\n\t\t\tif build.count('Master Critical Attack', {'Hand'=>@options['Hand']}) > 0\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\t# Use additional count to determine the first cost to apply\n\t\t# Use count to determine the final cost to apply\n\t\tif additional_count >= 2\n\t\t\treturn cost[2]*@count\n\t\tend\n\t\tif additional_count == 1\n\t\t\treturn cost[1] + cost[2]*(@count-1)\n\t\tend\n\t\tif @count >= 3\n\t\t\treturn cost[0] + cost[1] + (cost[2]*(@count-2))\n\t\tend\n\t\tif @count == 2\n\t\t\treturn cost[0] + cost[1]\n\t\tend\n\t\treturn cost[0]\n\n\t\t# The following occurs when calculating the cost of a solitary temporary prof\n\t\tif build != nil and @temp\n\t\t\tif @skill.to_s.match('Master')\n\t\t\t\tset = build.count('Master Proficiency', {})\n\t\t\t\tset = 2 if set > 2\n\t\t\telse\n\t\t\t\tset = build.count('Proficiency', {})\n\t\t\t\tset = 2 if set > 2\n\t\t\tend\n\t\t\treturn cost[set]\n\t\tend\n\t\treturn cost[0]\n\tend",
"def additional_z\n return 0 if [:idle, :hurt, :covered].include?(battle_phase) \n return 1 if covering\n return 2\n # Active battler displayed above another (increment by 2)\n end",
"def compute_fullcnpswage\n ( full_caissebase + full_process_bonuses ).ceil\n end",
"def free_helpers\n if division == 'Small Churches'\n 2\n elsif division == 'Medium Churches'\n 4\n elsif participants.coming.accepted.playing_sport.size <= 80\n 6\n else\n 8\n end\n end",
"def capacity_costs\n fetch(:capacity_costs) do\n if fixed_costs_per_mw_input_capacity\n fixed_costs_per_mw_input_capacity * input_capacity\n else\n 0.0\n end\n end\n end",
"def effective_level\n level + level_bonus\n end",
"def character_percent_complete(character)\n level_total=self.levels.select{|level| character.levels.include?(level) }\n (level_total.length/7.0*100).round\n end",
"def gc\n s = codons.map { |c| c.nuc_codon[2] }.join\n ((s.count('G')+s.count('C')).to_f/codons.count).round(4)\n end",
"def level_cost(skill, level)\n return Integer((level*10) + (level*16))\n end",
"def number_of_cases\n fee_quantity_for('BANOC') + 1\n end",
"def covered_strength; end",
"def number_of_units\n return 0.0 if demand.zero?\n return super unless full_load_hours&.positive?\n\n if input_capacity&.positive?\n demand / (input_capacity * full_load_hours)\n elsif output_capacity&.positive?\n (demand - output_of_loss) / (output_capacity * full_load_hours)\n else\n super\n end\n end",
"def weight\n (kyc_level == 'any' ? 0 : 10) + (group == 'any' ? 0 : 1)\n end",
"def variable_operation_and_maintenance_costs_for_ccs\n fetch(:variable_operation_and_maintenance_costs_for_ccs) do\n return 0.0 if input_capacity.zero?\n\n typical_input *\n variable_operation_and_maintenance_costs_for_ccs_per_full_load_hour /\n (input_capacity * 3600.0)\n end\n end",
"def cpl\n end",
"def create_test_character\n @level = 3\n @str = 10 # affects sword/unarmed attack, cbm, cbm_def\n @dex = 18 # affects ac, cbm_def\n @con = 14 # affects hp\n @mag = 15 # affects mag_resist, mag_dc\n @cha = 16 # affects crowd and magic\n\n @one_hand_prof = 2\n @dual_wield_prof = 2\n @two_hand_prof = 3\n @magic_prof = 2\n @unarmed_prof = 0\n\n calculate_initial_stats\n\n add_spell_to_known_spells(\"cure light wounds\", @full_spell_list[\"cure light wounds\"])\n add_spell_to_known_spells(\"magic missle\", @full_spell_list[\"magic missle\"])\n add_spell_to_known_spells(\"beguiler's grace\", @full_spell_list[\"beguiler's grace\"])\n add_spell_to_known_spells(\"shock weapon\", @full_spell_list[\"shock weapon\"])\n add_spell_to_known_spells(\"ray of sickening\", @full_spell_list[\"ray of sickening\"])\n add_spell_to_known_spells(\"ear-piercing scream\", @full_spell_list[\"ear-piercing scream\"])\n\n add_item(\"bronze sword\", @items.item_list[\"bronze sword\"])\n add_item(\"bronze dual swords\", @items.item_list[\"bronze dual swords\"])\n add_item(\"health potion\", @items.item_list[\"health potion\"])\n add_item(\"bronze shield\", @items.item_list[\"bronze shield\"])\n end",
"def count_chars(n)\n return THOUSAND if n == 1_000\n total = 0\n if n >= 100\n total += ONES[n/100] + HUNDRED\n total += AND unless n%100 == 0\n n %= 100\n end\n (total += TEENS[n]; return total) if n > 10 && n < 20\n (total += TENS[n/10]; n %= 10) if n >= 10\n total += ONES[n] if n > 0\n total\nend",
"def inc_c\n end",
"def post_level(count)\n case count\n when (0..30)\n return 'Apprentice'\n when (31..75)\n return 'Junior Cook'\n when (76..125)\n return 'Chef'\n when (126..250)\n return 'Sous Chef'\n when count > 251\n return 'Executive Chef'\n end\n end",
"def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end",
"def num_bases\n self.map { |chr,n| n }.sum\n end",
"def char_length\n @char_length ||= (@n**2 / 10) + 1\n end",
"def desired_xp\n return (200 * level * (level + 1)).to_i\n end",
"def check_caffeine_level()\n\t\tif @caffeine_level <= 0\n\t\t\tputs \"#{@name}'s caffeine level is at 0! Drink coffee now!\"\n\t\telsif @caffeine_level < 10\n\t\t\tputs \"#{@name}'s caffeine level is at #{@caffeine_level}! Drink coffee soon!\"\n\t\tend\n\tend",
"def invention_chance\n\tbase_chance = 0.0\n\tgid = self.item.groupID\n\ttid = self.item.typeID\n\tif gid == 27 || gid == 419 || tid == 22544\n\t\tbase_chance = 0.2\n\telsif gid == 26 || gid == 28 || tid == 22548\n\t\tbase_chance = 0.25\n\telsif gid == 25 || gid == 420 || gid == 513 || tid == 22546\n\t\tbase_chance = 0.3\n\telse\n\t\tbase_chance = 0.4\n\tend\n\n# TODO determine which datacores are needed and the skill level associated with that datacore\n# character = Character.find(char_id)\n# encryption_skill_level = character.skill_level(...)\n# datacore_1_skill_level = character.skill_level(...)\n# datacore_2_skill_level = character.skill_level(...)\n\tencryption_skill_level = 3\n\tdatacore_1_skill_level = 3\n\tdatacore_2_skill_level = 3\n\tmeta_level = 0\n\tdecryptor_modifier = 1.0\n\tbase_chance * (1.0 + (0.01 * encryption_skill_level)) * (1.0 + ((datacore_1_skill_level + datacore_2_skill_level) * (0.1 / (5.0 - meta_level)))) * decryptor_modifier\nend",
"def cp_c\n end",
"def cops; end",
"def cops; end",
"def cops; end",
"def mode_pin\n self.rules = nil\n if cracker == 'hashcat'\n self.attack = '3'\n self.mask = '?d'*8\n self.incremental = true\n self.increment_length = [4,8]\n self.max_runtime = 300 #5min on an i7 got through 4-7 digits. 8digit was 32min more\n end\n end",
"def efficiency_based_capacity\n cop_cutoff = @config.cop_cutoff || 1.0\n\n input_cap =\n total_value do\n @config.capacity[@config.efficiency_based_on]\n end\n\n input_efficiency.map do |eff|\n eff < cop_cutoff ? 0.0 : input_cap * eff\n end\n end",
"def cp_l\n end",
"def exp_for_level(l)\n def self.point_cost(pt, l)\n if l < 20\n pt*l*3\n elsif l < 100\n 60*pt + ((pt*(l-20))*4.0**(1.0 + l/100.0)).round\n else\n 1340*pt + (pt*(l-100)*5.0**(1.0 + l/100.0)).round\n end\n end\n cost = 0\n Stat.symbols.each{|a|\n cost += point_cost(Stat.mod_cost(self[a]), l)\n }\n cost += point_cost(Stat.mod_cost(self.owner[:freepts].to_i), l)\n cost\n end",
"def number_of_councils\n payer_breakdown && payer_breakdown.select{ |p| p[:organisation_type] == 'Council' }.size\n end",
"def proficiency_bonus\n\t\t(level()+3)/4 + 1\n\tend",
"def complexity_level_number\n ComplexityLevelHelper::COMPLEXITIES.fetch(complexity_level)\n end",
"def base_width; 24 + SKC_Settings::WIDTH; end",
"def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end",
"def get_xp\n return 3 * level\n end",
"def calc_secondary_attributes\n self.san = self.pow * 5\n self.idea = self.int * 5\n self.health = ((self.siz+self.con)/2.0).ceil\n self.luck = self.pow * 5\n self.know = self.edu * 5 \n self.magic = self.pow\n end",
"def mp_cost(level = @skl_level)\n return Integer(cost( level ).gsub( /(\\d+)[ ]*(MP|SP)/i ) { $1.to_i })\n end",
"def threshold_calc level:, length: \n\t\toptimal_num_nodes = 3**level\n\t\tif length < (optimal_num_nodes*@min_threshold).floor\n\t\t\treturn length\n\t\tend\n\t\treturn (optimal_num_nodes*@threshold).floor\n\tend",
"def getc() end",
"def getc() end",
"def getc() end",
"def character_count(char)\n char.each_codepoint.sum { |codepoint| BASIC_PLANE.include?(codepoint) ? 1 : 2 }\n end",
"def tiles_remaining\n # still not sure why or how this is working. TODO: may take out later\n total_num_tiles = @default_set.inject(0) { |letter, letter_quantity| letter += letter_quantity[1] }\n p \"++++TEST++++\"\n p total_num_tiles\n return total_num_tiles\n end",
"def tile_size level\n\t\t\t2 ** level\n\t\tend",
"def compute_skill_cost(skill_name)\n\n max_skill_level =\n case level\n when 1..2 then 1\n when 3..5 then 2\n when 6..8 then 3\n else 4; end\n\n current_level = @skills[skill_name] || -1\n new_level = current_level + 1\n\n return 9999 if new_level > max_skill_level # making it too costly\n\n new_level + 1\n end",
"def compute_need_bits; end",
"def max_number_of_a_level(level)\n 4 * level * level + 4 * level + 1\n end",
"def cost_of_cable(length)\n\t\tmeter = length * 0.01\n\t\tdollar = [meter * 0.4079 + 0.5771, meter * 0.0919 + 7.2745].min * BANDWIDTH\n\t\t(dollar * 100).round.to_f / 100\n\tend",
"def mode_coverage(percent, zero_insignificant)\n\n coverage_hash = Hash.new(0)\n length = @windows.length\n @windows.each do |k,v| \n if zero_insignificant & (v == '0')\n length -= 1\n end\n coverage_hash[v] += 1\n end\n max = 0\n max_class = nil\n coverage_hash.each do |k,v|\n if (v > max) \n max = v \n max_class = k\n end \n end\n \n if max_class == '0'\n # @@log.info self\n return max_class\n elsif max.to_f/length.to_f >= percent\n # @@log.info self\n return max_class\n end\n #@@log.debug \"#{max}/#{length}(orig: #{@windows.length}) < #{percent} (#{max.to_f/length.to_f})\"\n @@log.warn \"CANNOT RESOLVE BIN FOR: #{self}\"\n return '666'\n end",
"def cooling_based_input_capacity\n fetch(:cooling_based_input_capacity) do\n if cooling_output_conversion && cooling_output_conversion > 0\n heat_output_capacity / cooling_output_conversion\n end\n end\n end",
"def base_composition\n if @base_composition\n return @base_composition\n end\n # else run the C method\n composition(@seq.seq)\n alphabet = ['a', 'c', 'g', 't', 'n']\n @base_composition = {}\n @dibase_composition = {}\n bases = []\n dibases = []\n alphabet.each do |c|\n bases << \"#{c}\".to_sym\n end\n alphabet.each do |c|\n alphabet.each do |d|\n dibases << \"#{c}#{d}\".to_sym\n end\n end\n bases.each_with_index do |a,i|\n @base_composition[a] = base_count(i)\n end\n dibases.each_with_index do |a,i|\n @dibase_composition[a] = dibase_count(i)\n end\n return @base_composition\n end",
"def cc_count\n stats = self.association_stats\n stats['cc_conditions'] + stats['cc_loops'] + stats['cc_questions'] +\n stats['cc_sequences'] + stats['cc_statements']\n end",
"def level_up\n @level += 1\n @maxhp = 100 + @level * 12\n @hp = @maxhp\n @connections[@level/5] = nil if @level % 5 == 0\n end",
"def levelUp\n @level += 1\n # every level requires a higher score threshhold score to advance\n @threshold += level * 150\n\n # after 9 planes, stop adding planes to make it possible to have\n # somewhere to go to dodge the planes if there is not laser\n game.add_plane if level < 9\n end",
"def manage_commission_level\n\t\tif self.commission_level.present? && !self.commission_level.empty?\n \t\tsum = 0\n\t\t\tlevel = 0\n _commission_level = {}\n \tself.commission_level.each do |k, v| \n \t\tlevel = level + 1\n _commission_level[level] = v\n \t\tsum = sum + v.to_d\n \tend\n self.commission_level = _commission_level\n \tself.levels = level\n \tself.commission = sum\n end\n\tend",
"def value\n return 3*level\n end",
"def calc_length\n Base.calculate_and_set_length self\n self.ihl = 5 + self[:options].sz / 4\n end",
"def sufficient_caffeine_level(min)\n\t\t@caffeine_level >= min\n\tend",
"def fixed_costs\n fixed_costs_per_unit * number_of_units\n end",
"def cost(cover)\n return cover.each_cube.reduce(0) do |sum, cube|\n # sum + cube.each_bit.count { |b| b != \"-\" }\n sum + cube.each_byte.count { |b| b != 45 }\n end\n end",
"def compute_places(wc)\n if wc.capacity == nil or wc.capacity > 7\n wc.places = 2\n else\n wc.places = 1\n end\n\n wc.places_for_females = [ wc.places, wc.capacity_females ].compact.min\n wc.places_for_males = [ wc.places, wc.capacity_males ].compact.min\n end",
"def price_unit_factor\n return 1 if unit_id == price_unit_id\n return pack_size || 1 if price_unit_id == pack_unit_id\n return (pack_size || 1) * (subpack_size || 1) if price_unit_id == subpack_unit_id\n return 1\n end",
"def complexity_level_number\n COMPLEXITIES.fetch(complexity_level)\n end",
"def ccf\n end",
"def celebrity; end",
"def celebrity; end",
"def masterwork_prob_bonus; 0; end",
"def strain_threshold\n strain_th = self.willpower\n if self.race && self.race.strain_threshold\n strain_th += self.race.strain_threshold\n end\n # Then increase based on selected talents.\n self.talent_alterations.each do |talent_id, stat|\n stat.each do |type, value|\n if type == :strain\n strain_th += value['count']\n end\n end\n end\n strain_th\n end",
"def num_of_correct(crct)\n if self.total.nil?\n self.total = 1\n else\n self.total += 1\n end\n \n if crct == 1\n if self.correct.nil?\n self.correct = 1\n else\n self.correct += 1\n end \n else\n self.correct = 0\n end\n end",
"def kcalglucidos\n\t\t\t@carbohidratos * 4\n\t\tend",
"def canAfford?(cost, character)\n return cost <= character.gp\n end",
"def level_for(binary_code)\n binary_code_length = binary_code.to_s(2).length\n binary_code_length += 1 unless binary_code_length.even?\n binary_code_length / 2\n end",
"def costable_energy_factor\n fetch(:costable_energy_factor) do\n costable, loss, total = costable_conversions\n\n if costable.nil?\n 1.0\n elsif (total - loss).positive?\n costable + loss * costable / (total - loss)\n else\n 0.0\n end\n end\n end",
"def level_up\r\r\n return unless can_level\r\r\n return if @level == @max_level\r\r\n @level += 1\r\r\n if @special == nil then\r\r\n @special = 0\r\r\n end\r\r\n level_update\r\r\n end",
"def calculate_taxes\n\n character_name = player_character.base_card.name\n\n case character_name\n when 'merchant'\n colour = 'green'\n\n when 'king'\n colour = 'yellow'\n when 'warlord'\n colour = 'red'\n else\n colour = 'blue'\n end\n purple_district = districts_on_game.where(\"colour = 'purple'\")\n colour_recount = cards.districts.where(\"state = 'ONGAME' AND colour = ?\", colour).count + (purple_district.exists?([\"name = 'school_magic'\"])? 1:0)\n end",
"def base_width; 26 + @width; end",
"def full_contract_length\n full_length = self.contract_length\n if self.is_extended\n full_length += 1\n end\n\n if self.is_franchised\n full_length += 1\n end \n full_length\n end",
"def calculate_number_of_commissions\n (@cancellation_factor * @hash[\"number of commissions\"][0].from_german_to_f).to_german_s\n end",
"def iclevel\n \"\"\n end",
"def get_difficulty\n if self.power < 3\n difficulty = 1\n elsif self.power >= 3 && self.power < 6\n difficulty = 2\n else\n difficulty = 3\n end\n end",
"def amount_of_chocolate_chips(perfect_10_recipe)\n return perfect_10_recipe[:mini_dark_chocolate_chips]\nend",
"def calculate_base_cost!\n result_obj = self.cost_matrix.reduction\n\n @base_cost = result_obj[:total_reduction]\n if(self.parent)\n @base_cost += self.parent.base_cost + self.parent.reduced_cost_matrix[self.parent.city_id, self.city_id]\n end\n\n @reduced_cost_matrix = result_obj[:matrix]\n end",
"def climb_count\n self.climbs.inject(0) do |sum, climb|\n sum += climb.block_1 if climb.block_1\n sum += climb.block_2 if climb.block_2\n sum += climb.block_3 if climb.block_3\n sum += climb.block_4 if climb.block_4\n sum\n end\n end",
"def decide_level(levels_input_data)\n course_ds = levels_input_data.course_ds\n course_failures = levels_input_data.course_failures\n recent_absence_rate = levels_input_data.recent_absence_rate\n recent_discipline_actions = levels_input_data.recent_discipline_actions\n\n # Level 4: At least 4 F's\n # OR less than 80% attendance over last 45 school days\n # OR 7 or more discipline actions over the last 45 school days\n level_four_triggers = [\n (:academic if course_failures >= 4),\n (:absence if recent_absence_rate < 0.80),\n (:discipline if recent_discipline_actions >= 7)\n ].compact\n return Level.new(4, level_four_triggers, levels_input_data) if level_four_triggers.size > 0\n\n # Level 3: 3 F's\n # OR less than 85% attendance over last 45\n # OR 5-6 discipline actions over the last 45 school days\n level_three_triggers = [\n (:academic if course_failures >= 3),\n (:absence if recent_absence_rate < 0.85),\n (:discipline if recent_discipline_actions >= 5)\n ].compact\n return Level.new(3, level_three_triggers, levels_input_data) if level_three_triggers.size > 0\n\n # Level 2: 2 F's\n # OR less than 90% attendance over last 45\n # (no discipline involved in calculation)\n level_two_triggers = [\n (:academic if course_failures >= 2),\n (:absence if recent_absence_rate < 0.90)\n ].compact\n return Level.new(2, level_two_triggers, levels_input_data) if level_two_triggers.size > 0\n\n # Level 1: 1 F and 2 Ds\n # OR less than 95% attendance over last 45 days\n # (no discipline involved)\n level_one_triggers = [\n (:academic if course_failures == 1 && course_ds >= 2),\n (:absence if recent_absence_rate < 0.95)\n ].compact\n return Level.new(1, level_one_triggers, levels_input_data) if level_one_triggers.size > 0\n\n # Level 0: Not any of the other levels\n return Level.new(0, [], levels_input_data)\n end"
] |
[
"0.65192807",
"0.5765847",
"0.5704485",
"0.5703791",
"0.5649336",
"0.56417644",
"0.5570401",
"0.55661213",
"0.5530373",
"0.54888004",
"0.5477106",
"0.5445855",
"0.5432166",
"0.5427537",
"0.5421823",
"0.53717446",
"0.53274924",
"0.5319638",
"0.5318701",
"0.526846",
"0.5257585",
"0.52404386",
"0.52219087",
"0.5216306",
"0.51990455",
"0.5171573",
"0.51436496",
"0.5142931",
"0.5137442",
"0.5120996",
"0.5114052",
"0.51137793",
"0.511367",
"0.5111408",
"0.51106775",
"0.510677",
"0.50856763",
"0.5084547",
"0.50785464",
"0.50785464",
"0.50785464",
"0.5077888",
"0.50678587",
"0.50647736",
"0.5063285",
"0.5062574",
"0.5062495",
"0.5050838",
"0.50446767",
"0.5035308",
"0.5022365",
"0.5018505",
"0.50171393",
"0.5016256",
"0.5001471",
"0.5001471",
"0.5001471",
"0.50013137",
"0.500106",
"0.49917844",
"0.4991145",
"0.49854437",
"0.49834058",
"0.4982031",
"0.49743766",
"0.49706838",
"0.49620277",
"0.49575207",
"0.49489897",
"0.4945499",
"0.49340573",
"0.49293554",
"0.49241573",
"0.49213418",
"0.4917026",
"0.49167445",
"0.49124894",
"0.49064067",
"0.4904792",
"0.49043775",
"0.49015087",
"0.49015087",
"0.48891348",
"0.48858273",
"0.4882975",
"0.488233",
"0.48726445",
"0.48615158",
"0.48553747",
"0.4847593",
"0.48449135",
"0.4843135",
"0.48368847",
"0.4835976",
"0.48321378",
"0.4831129",
"0.4828001",
"0.4827653",
"0.4827611",
"0.48259908"
] |
0.75770634
|
0
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set Complete? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def set_complete?(eqps = [])
itms = items
!itms.empty? && ((itms & eqps).size == itms.size)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_as_complete\n mark_as_complete_and_save\n end",
"def complete?; end",
"def mark_complete\n self.complete = true\n self.save\n end",
"def mark_as_complete_and_save\n self.complete = true\n save\n end",
"def complete!\n @completed = true\n @completed_at = Time.now\n end",
"def completed_it\n self.complete = true\n end",
"def complete\n end",
"def complete?\n true\n end",
"def complete?\n end",
"def complete?\n true\n end",
"def incomplete!\r\n @is_complete = false\r\n end",
"def completed\n @status = 'complete'\n end",
"def complete!\n self.completed = true\n self.completed_at = Time.now.utc\n save! # TODO: With a bang?\n end",
"def update_done\n self.done = true if COMPLETE_STATUSES.include? self.detailed_status\n end",
"def complete?\n true\n end",
"def complete?\n true\n end",
"def complete\n nil\n end",
"def complete\n nil\n end",
"def complete!\n self.is_completed = true\n self.save\n end",
"def complete?\n @complete\n end",
"def complete?\n @complete\n end",
"def complete?\n self.status == STATUS[:complete] \n #self.status == 1\n end",
"def complete!\n # this should change the boolean to true\n self.complete = true\n self.save!\n end",
"def complete!\n self.update_attribute(:is_completed, true)\n # TODO: send an email to teacher about taks completion\n end",
"def mark_complete\n if self.completed\n self.progress = \"COMP\"\n self.progress_percentage = \"100\"\n elsif self.progress and !self.progress.eql?('COMP') and self.progress_percentage\n self.progress = self.progress\n self.progress_percentage = self.progress_percentage\n else\n self.progress = \"INPR\"\n self.progress_percentage = \"0\"\n end\n end",
"def mark_task_complete\n system \"clear\"\n # If task was set\n\n loop do\n task = get_task_choice(\"mark complete\")\n if task && task != :back\n task.status = :completed\n\n system \"clear\"\n display_tasks(:completed)\n display_tasks(:failed)\n\n # Cancel notifications\n task.cancel_reminder_notification\n task.cancel_failed_notification\n\n puts \"Congratulations on completing this task!\".light_white\n break unless CLI.agree(\"\\nMark another task complete? (y/n)\".light_white)\n else\n break\n end\n end\n end",
"def complete!\n @completed_at = Time.now\n end",
"def complete!\n @completed_at = Time.now\n end",
"def setCompleted(completed)\r\n\t\t\t\t\t@completed = completed\r\n\t\t\t\tend",
"def setCompleted(completed)\r\n\t\t\t\t\t@completed = completed\r\n\t\t\t\tend",
"def mark_state_complete!\n get[state.to_s] = :complete\n end",
"def complete?\n complete == true\n end",
"def completed()\n @completed=true\n @tCompleted=Time.now\n end",
"def check_completion_status\n\t\trace = Race.find_by_id(self.race_id)\n\t\treturn if (race.nil?)\n\t\t\n\t\tself.is_complete = race.is_complete \n\t\tself.save\n\tend",
"def markDone\n if @complete == \"Item incomplete\"\n @complete = \"Item complete\"\n else\n @complete = \"Item complete\"\n end\n end",
"def complete?\r\n @is_complete\r\n end",
"def complete?\n false\n end",
"def complete!\n self.status = 'completed'\n self.save\n end",
"def complete\n self.dup.complete!\n end",
"def complete?\n self.complete\n end",
"def mark_as_completed!\n mark_state_complete!\n end",
"def complete\n self.update_attribute('state', 'complete')\n end",
"def set_complete\n @complete = Complete.find(params[:id])\n end",
"def check_completed\n\t\tend",
"def mark_as_complete(options)\n self.is_complete = options[:is_complete]\n self.is_applicable = true # if item.is_complete\n self.save_with_validation(false)\n end",
"def complete!\n return if completed?\n self.status = \"complete\"\n self.stop = Time.now.to_s\n end",
"def complete\n @status = :ok\n do_stop\n log_complete\n end",
"def check_if_complete(card)\t\n\t\tif @cards.has_value?(4)\n\t\t\tcompleted_card = card\n\t\t\t@complete_sets.push(completed_card)\n\t\t\tremove_set_from_hand(completed_card)\n\t\tend\n\n\tend",
"def complete?\n return state == \"complete\"\n end",
"def all_complete\n self.tasks.count == self.tasks.done.count\n end",
"def test_complete?\n assert(@LiarHand.complete? == true, 'Hand for <LiarHand> expected to be full but wasnt.')\n assert(@IdiotHand.complete? == true, 'Hand for <IdiotHand> expected to be full but wasnt.')\n\n assert(@LightHand.complete? == true, 'Hand for <LightHand> expected to be full but wasnt')\n assert(@SpiderHand.complete? == true, 'Hand for <SpiderHand> expected to be full but wasnt')\n end",
"def completed\n @completed ||= count('completed')\n end",
"def set_done\n @done = true\n end",
"def complete?\n !incomplete?\n end",
"def complete?\n !incomplete?\n end",
"def complete?\n\tstatus == \"Completed\"\n end",
"def complete?\n status == \"Completed\"\n end",
"def set_complete_incomplete\n @tasks_incomplete = @tasks.where(\"completed = 'f'\").order('tasks.created_at DESC')\n @tasks_complete = @tasks.where(\"completed = 't'\").order('tasks.created_at DESC')\n end",
"def complete!\n status \"Success\"\n self\n end",
"def complete!\n load_attributes_from_response(post(:complete))\n end",
"def mask_as_done!\n @completed = true\n end",
"def mark_complete(db, complete, name)\n\tcomplete = \"complete\"\n\tdb.execute(\"UPDATE upper_body SET complete=? WHERE name=?\", [complete, name])\n\tdb.execute(\"UPDATE lower_body SET complete=? WHERE name=?\", [complete, name])\n\tputs \"set #{name} to complete\"\nend",
"def setup_complete\n puts green(\"Setup complete\")\n end",
"def complete?\n self.state == 'complete'\n end",
"def marked_as_complete?\n get[state.to_s] and get[state.to_s].to_sym == :complete\n end",
"def converge_complete\n end",
"def completed\n end",
"def complete\n raise NotImplementedError\n end",
"def set_complete(name)\n\t\tif index = find_index(name)\n\t\t\ttodo_items[index].set_complete!\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def update_complete\n # checks to see if the Item's :complete attribute is true\n if self.complete\n # if complete is arleady true, then update it to false\n self.update_attribute(:complete, false)\n else\n # if complete is already false(which is usually the case since the attribute has\n # a default value of false making it incomplete) update the complete attribute to\n # true. This will allow the user to toggle between complete and incomplete items in\n # their respective lists. \n self.update_attribute(:complete, true)\n end\n end",
"def complete\n synchronize do\n return if complete?\n\n @is_final_state = true\n @final_time = Time.now\n end\n end",
"def possibly_set_as_completed\n # this is a guard against setting something completed that isn't and that will make this method fail\n return false unless available_in_merritt? # this also sets @mrt_results member variable so we don't have to redo the query again\n\n merritt_id = \"#{APP_CONFIG[:repository][:domain]}/d/#{@mrt_results['ark']}\"\n StashEngine.repository.harvested(identifier: resource.identifier, record_identifier: merritt_id)\n\n if StashEngine::RepoQueueState.where(resource_id: resource_id, state: 'completed').count < 1\n StashEngine.repository.class.update_repo_queue_state(resource_id: resource_id, state: 'completed')\n end\n\n update_size!\n ::StashEngine.repository.cleanup_files(resource)\n true\n end",
"def completion_aspect\n true_value = \"Completed\"\n false_value = \"Incomplete\"\n self.complete ? true_value : false_value\n end",
"def complete? c\n c.complete?\n end",
"def mark_done\n @done = true\n end",
"def setDone\n @done = Time.now\n end",
"def setPercentComplete(percentComplete)\r\n\t\t\t\t\t@percentComplete = percentComplete\r\n\t\t\t\tend",
"def completed()\n end",
"def complete!\n raise NotImplementedError\n end",
"def incomplete?\r\n !complete?\r\n end",
"def update_completed? ; false ; end",
"def flag_completion\n @completion_flagged = !@completion_flagged\n end",
"def complete?\n keys.all?(&:complete?)\n end",
"def incomplete?\n !@complete\n end",
"def completed=(value)\n return @completed = value\n end",
"def mark_as_done!\n @done = true\n end",
"def completed?\n attributes['percentDone'] >= 1\n end",
"def set_transaction_complete_flag()\n @is_transaction_complete = true\n end",
"def completed\n proptime 'COMPLETED'\n end",
"def complete\n authorize Test\n @tests = Test.by_lab(@lab).joins(:plate).where(plates: { state: Plate.states[:complete] })\n end",
"def validate_user_complete_update\n\t\tself.complete = User::user_complete_validation(self)\n\tend",
"def complete!\n update_attributes(completed_at: Time.now)\n pause! if running?\n end",
"def is_complete?\n self.audit_state == AUDIT_COMPLETE\n end",
"def is_complete?\n # puts @xml.root.attributes['complete']\n xml = Document.new(File.open(@xmlfile))\n return 'yes' == xml.root.attributes['complete']\n end",
"def completed=(values)\n self.value = values.first\n end",
"def mark_as_done\n @is_done = true\n end",
"def complete?\n status_code == 'OK'\n end",
"def mark_as_completed\n completed_at.nil? ? self.completed = true : errors.add(:completed, '- This task has already been completed!')\n end",
"def incomplete?\n !complete? && status != 'unknown'\n end",
"def mark_as_done!\n @status = :finished\n end"
] |
[
"0.7429153",
"0.6970775",
"0.6965546",
"0.6938573",
"0.6916579",
"0.6851977",
"0.6825764",
"0.67574567",
"0.66737837",
"0.6659592",
"0.6612763",
"0.65987337",
"0.65907615",
"0.6567258",
"0.65655744",
"0.65655744",
"0.65529007",
"0.65529007",
"0.65388346",
"0.6531535",
"0.65236616",
"0.6517029",
"0.6511516",
"0.64919704",
"0.6485814",
"0.64771706",
"0.64393085",
"0.64393085",
"0.64384013",
"0.64384013",
"0.64123565",
"0.641216",
"0.6405445",
"0.64051116",
"0.6403962",
"0.63820255",
"0.63677084",
"0.63653255",
"0.6351459",
"0.6351054",
"0.63380927",
"0.6324979",
"0.63190657",
"0.63036805",
"0.62984675",
"0.6254146",
"0.62169677",
"0.62163115",
"0.62144923",
"0.62107605",
"0.6209948",
"0.6184947",
"0.61689454",
"0.6168133",
"0.6168133",
"0.6164762",
"0.6156663",
"0.6156631",
"0.6149134",
"0.61319566",
"0.6121488",
"0.61188555",
"0.6113529",
"0.60821474",
"0.6076003",
"0.6075759",
"0.60514796",
"0.6050962",
"0.60370344",
"0.60331774",
"0.60309696",
"0.6022363",
"0.6019026",
"0.6010594",
"0.60099804",
"0.5993803",
"0.59919196",
"0.59815735",
"0.5970156",
"0.5956721",
"0.5949743",
"0.59403783",
"0.59133476",
"0.59054935",
"0.5867196",
"0.5861347",
"0.5859945",
"0.5854654",
"0.58536047",
"0.5851706",
"0.5812355",
"0.5802038",
"0.5792442",
"0.57899165",
"0.578785",
"0.5785138",
"0.57736456",
"0.57711583",
"0.576901",
"0.5762816"
] |
0.6527179
|
20
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equip Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def maesb_generate_equip_set
@maesb_belongs_to_sets = []
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def maesb_generate_equipment_sets\n # Generate Equipment Sets\n ($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }\n # Update items to refer to the set to which they belong\n set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }\n set_items.each { |set_item| \n set_item.maesb_sets.collect {|set| set.items }.flatten.uniq.each { |equip|\n equip.maesb_belongs_to_sets.push(set_item.id) \n }\n }\n end",
"def maesb_generate_equip_set\n super\n @maesb_sets = note.scan(/\\\\SET\\s*\\[(.+?)\\]/i).collect { |set_s| \n MAESB_EquipmentSet.new(set_s[0]) }\n end",
"def equip(entity)\n prev_item = entity.outfit[@type]\n\n entity.outfit[@type] = self\n alter_stats(entity, true)\n\n if prev_item\n prev_item.alter_stats(entity, false)\n entity.add_item(prev_item)\n end\n\n print \"#{entity.name} equips #{@name}!\\n\\n\"\n end",
"def unequip!\n self.slot = EquipSlot::Inventory\n self.save!\n end",
"def power_ups\n @power_ups.map {|pup| Equip_Abilities.new(pup[0], pup[1], pup[2])}\n end",
"def set_equip\n @equip = Equip.find(params[:id])\n end",
"def equipment_list\n [\n \"Backhoe\",\n \"Bobcat\",\n \"Compactor\",\n \"Compactor 815\",\n \"Compactor 815F\",\n \"Compactor 825G\",\n \"Compactor 825H\",\n \"Crane\",\n \"Dozer-D3\",\n \"Dozer-D6\",\n \"Dozer D6M Swamp\",\n \"Dozer D6R Swamp\",\n \"Dozer D6T XL\",\n \"Dozer-D6H\",\n \"Dozer-D65\",\n \"Dozer - D6C\",\n \"Dozer - D6R\",\n \"Dozer - D6R Xl\",\n \"Dozer - D7\",\n \"Dozer - D7H\",\n \"Dozer - D8\",\n \"Dozer - D9T\",\n \"Dozer R -D9\",\n \"Dump Truck 25T\",\n \"Dump Truck 30T\",\n \"Dump Truck 40T\",\n \"Dump Truck 50T\",\n \"Drott 9T\",\n \"Drott 8T\",\n \"Drott\",\n \"Excavator\",\n \"EXC 8T\",\n \"EXC 12-22T \",\n \"EXC 12T\",\n \"EXC 13T\",\n \"EXC13.5T\",\n \"EXC 14T\",\n \"EXC 15T\",\n \"EXC 17T WHEELED\",\n \"EXC 18T\",\n \"EXC 20-29T\",\n \"EXC 20T WHEELED\",\n \"EXC 20T\",\n \"EXC 20T \",\n \"EXC 20T 8T 12\",\n \"EXC 22T\",\n \"EXC 24T\",\n \"EXC 25T\",\n \"EXC 30T\",\n \"EXC 35T\",\n \"EXC 40T\",\n \"EXC 45T\",\n \"EXC 60T\",\n \"EXC 4.5T \",\n \"EXC 4T\",\n \"EXC 3.5T\",\n \"EXC 3T COMBO\",\n \"EXC 3T\",\n \"EXC 5T\",\n \"EXC 5T COMBO\",\n \"EXC 5T \",\n \"EXC 5.5T\",\n \"EXC 5-10T\",\n \"EXC 5-30T\",\n \"EXC 5T & 6T\",\n \"EXC 6T\",\n \"EXC 6T \",\n \"EXC 7.5T\",\n \"EXC 7.5T \",\n \"EXC 8T \",\n \"Float\",\n \"Grader 12G 140H\",\n \"Grader\",\n \"IT Loader\",\n \"Loader\",\n \"Moxy Dump\",\n \"Moxy Dump 20T\",\n \"Moxy Dump 25T\",\n \"Moxy Dump 30T\",\n \"Posi Track\",\n \"Pug Mill\",\n \"Roller Pad SF\",\n \"Roller Smooth\",\n \"Roller 12T\",\n \"Roller\",\n \"Roller 14T\",\n \"Roller Smooth 12T\",\n \"Roller Pad SF 12T\",\n \"Roller Pad\",\n \"Roller Pad SF 16T\",\n \"Scraper 633\",\n \"Scraper 623E\",\n \"Scraper\",\n \"Screening Plant\",\n \"Semi\",\n \"Semi/T & T\",\n \"Semi Tipper\",\n \"Sweeper\",\n \"Tilt Tray\",\n \"Truck\",\n \"Truck & 3 Axle Trailer\",\n \"Truck & 4 Axle Trailer\",\n \"Truck & Dog\",\n \"Watercart\"\n ]\n end",
"def prepare_equipment\n show do\n title 'Gather materials'\n check 'Fill 2 buckets with ice.'\n check \"Get the 24-well aluminum block out of the 4 #{DEGREES_C}\" \\\n 'refrigerator and place it in one of the ice buckets.'\n check \"Set the refigerated centrifuge to 4 #{DEGREES_C}.\"\n end\n end",
"def storage_equip_items\n storage_weapons + storage_armors\n end",
"def make_item_list\n @data = equips_for_enchant\n end",
"def unequip_item\n\t\tself.equiped = false\n\t\tself.save\n\tend",
"def init_equips(equips)\n @equips = Array.new(equip_slots.size) { Game_BaseItem.new }\n equips.each_with_index do |item_id, i|\n break if i > @equips.size - 1\n @equips[i].set_equip(item_id < 0, item_id.abs)\n end\n refresh\n end",
"def clear_equipments\n equip_slots.size.times do |i|\n change_equip(i, nil) if equip_change_ok?(i)\n end\n end",
"def set_equipo\n @equipo = Equipo.find(params[:id])\n end",
"def equipment; end",
"def set_equipo\n @equipo = Equipo.find(params[:id])\n end",
"def unequip(entity)\n entity.outfit.delete(@type)\n alter_stats(entity, false)\n\n print \"#{entity.name} unequips #{@name}!\\n\\n\"\n end",
"def createEnemyStarShip\n loot = createLoot\n damage1 = createDamageNumeric\n damage2 = createDamageSpecific\n \n enemy1 = EnemyStarShip.new(\"E1\",5,6,loot[0],damage1[0])\n enemy2 = EnemyStarShip.new(\"E2\",10,20,loot[1],damage2[1])\n enemy3 = EnemyStarShip.new(\"E3\",50,100,loot[2],damage2[4])\n \n enemies = [enemy1,enemy2,enemy3]\n return enemies\n end",
"def optimize_equipments\n clear_equipments\n equip_slots.size.times do |i|\n next if !equip_change_ok?(i)\n items = $game_party.equip_items.select do |item|\n etype_can_equip?(i, item) &&\n equippable?(item) && item.performance >= 0\n end\n change_equip(i, items.max_by {|item| item.performance })\n end\n end",
"def set_equipo\n @equipo = Equipo.find( params[:id] )\n end",
"def optimize_equipments\n clear_equipments\n equip_slots.size.times do |i|\n next if !equip_change_ok?(i)\n items = $game_party.equip_items.select do |item|\n item.etype_id == equip_slots[i] &&\n equippable?(item) && item.performance >= 0\n end\n change_equip(i, items.max_by {|item| item.performance })\n end\n end",
"def generate_event_set(events)\n usable_events = self.find_usable_events(events)\n self.new_event_set(usable_events)\n end",
"def population(starting_set)\n starting_set = starting_set.to_s if starting_set.is_a?(Symbol)\n p = Population.find_or_initialize_by_populatable_type_and_populatable_id_and_starting_set_and_conditions_counter(\n \"Offering\", self.id, starting_set, 0)\n if p.new_record?\n p.title = \"#{self.title}: #{starting_set.titleize}\"\n until p.valid? && !p.errors.on(:title)\n if p.title[/\\d+$/].nil?\n p.title += \" 2\"\n else\n new_num = p.title[/\\d+$/].to_i + 1\n p.title.gsub!(/\\d+$/, new_num.to_s)\n end\n end \n p.system = true\n p.description = \"Automatically generated by Offering ##{self.id} from starting set '#{starting_set}'\"\n p.access_level = \"everyone\"\n p.save\n end\n p\n end",
"def set_equip_type\n @equip_type = EquipType.find(params[:id])\n end",
"def sku_combination_creation\n end",
"def equips_for_enchant\n return [] if @enchant_item.nil?\n $game_party.items.select { |item|\n item.enchantable? && item.tier == @enchant_item.enchant_tier\n }\n end",
"def get_clean_inventory(data_set)\n\t\tclean_inventory = @helpers.make_hoa\n\n\t\tdata_set.each do |item_info|\n\t\t\tif item_info.has_key?(:type)\n\t\t\t\titem_type = item_info.delete(:type)\n\t\t\t\tclean_inventory[item_type].push(item_info)\n\t\t\telse\n\t\t\t\tputs \"Skipping, invalid item, missing type\"\n\t\t\tend\n\t\tend\n\n\t\treturn clean_inventory\n\tend",
"def load_notetag_init_equips\n @equips = []\n res = self.note.match(TH::EquipManager::Initial_Equip_Regex)\n if res\n res[1].split.each {|info|\n type, id = info[0], info[1..-1].to_i\n id *= -1 if type == \"w\"\n @equips.push id\n }\n else\n @equips = [0]\n end\n @init_equip_checked = true\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 build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend",
"def index\n @equip_types = EquipType.all\n end",
"def element_set\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.element_set : []\n end",
"def equipped?\n EquipSlot.equipable_slots.include? slot\n end",
"def enemy_fleet()\n enemy_fleet = Array.new\n for count in 1..6 do \n enemy_fleet.push(Ship.new(generateHull, generateFirepower, generateAccuracy))\n end\n return enemy_fleet\nend",
"def equip(equip_type, id)\n case equip_type\n when 0 # Weapon\n if id == 0 or $game_party.weapon_number(id) > 0\n $game_party.gain_weapon(@weapon_id, 1)\n @weapon_id = id\n $game_party.lose_weapon(id, 1)\n end\n when 1 # Shield\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor1_id], $data_armors[id])\n $game_party.gain_armor(@armor1_id, 1)\n @armor1_id = id\n $game_party.lose_armor(id, 1)\n end\n when 2 # Head\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor2_id], $data_armors[id])\n $game_party.gain_armor(@armor2_id, 1)\n @armor2_id = id\n $game_party.lose_armor(id, 1)\n end\n when 3 # Body\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor3_id], $data_armors[id])\n $game_party.gain_armor(@armor3_id, 1)\n @armor3_id = id\n $game_party.lose_armor(id, 1)\n end\n when 4 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor4_id], $data_armors[id])\n $game_party.gain_armor(@armor4_id, 1)\n @armor4_id = id\n $game_party.lose_armor(id, 1)\n end\n when 5 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce1_id], $data_armors[id])\n $game_party.gain_armor(@pierce1_id, 1)\n @pierce1_id = id\n $game_party.lose_armor(id, 1)\n end\n when 6 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce2_id], $data_armors[id])\n $game_party.gain_armor(@pierce2_id, 1)\n @pierce2_id = id\n $game_party.lose_armor(id, 1)\n end\n when 7 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce3_id], $data_armors[id])\n $game_party.gain_armor(@pierce3_id, 1)\n @pierce3_id = id\n $game_party.lose_armor(id, 1)\n end\n when 8 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce4_id], $data_armors[id])\n $game_party.gain_armor(@pierce4_id, 1)\n @pierce4_id = id\n $game_party.lose_armor(id, 1)\n end \n when 9 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce5_id], $data_armors[id])\n $game_party.gain_armor(@pierce5_id, 1)\n @pierce5_id = id\n $game_party.lose_armor(id, 1)\n end\n when 10 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce6_id], $data_armors[id])\n $game_party.gain_armor(@pierce6_id, 1)\n @pierce6_id = id\n $game_party.lose_armor(id, 1)\n end\n when 11 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce7_id], $data_armors[id])\n $game_party.gain_armor(@pierce7_id, 1)\n @pierce7_id = id\n $game_party.lose_armor(id, 1)\n end \n end\n $game_switches[100] = true\n end",
"def class_id=(class_id)\n if $data_classes[class_id] != nil\n @class_id = class_id\n # Remove items that are no longer equippable\n unless equippable?($data_weapons[@weapon_id])\n equip(0, 0)\n end\n unless equippable?($data_armors[@armor1_id])\n equip(1, 0)\n end\n unless equippable?($data_armors[@armor2_id])\n equip(2, 0)\n end\n unless equippable?($data_armors[@armor3_id])\n equip(3, 0)\n end\n unless equippable?($data_armors[@armor4_id])\n equip(4, 0)\n end\n #unless equippable?($data_armors[@pierce1_id])\n # equip(5, 0)\n #end\n #unless equippable?($data_armors[@pierce2_id])\n # equip(6, 0)\n #end\n #unless equippable?($data_armors[@pierce3_id])\n # equip(7, 0)\n #end\n #unless equippable?($data_armors[@pierce4_id])\n # equip(8, 0)\n #end\n #unless equippable?($data_armors[@pierce5_id])\n # equip(9, 0)\n #end\n #unless equippable?($data_armors[@pierce6_id])\n # equip(10, 0)\n #end\n #unless equippable?($data_armors[@pierce7_id])\n # equip(11, 0)\n #end\n end\n end",
"def use(entity)\n print \"Type 'equip #{@name}' to equip this item.\\n\\n\"\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def plus_state_set\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.plus_state_set : []\n end",
"def e1334_random_bag (values)\n end",
"def equipment_names\n equipment = self.quote.project.company.equipment\n list = equipment.collect! {|x| x.name}\n# list.join()\n end",
"def redo_option_values_tirerack\n start_time = Time.now\n mfg_list = get_manufacturer_list\n count_v = 0\n count_p = 0\n mfg_list.each do |mfg|\n data = YAML.load(open_file_read('tires', mfg))\n data.each_key do |model|\n p = Product.find_by_name(model)\n if p.master.nil?\n price = get_lowest_price_from_yaml(data[model][:variants])\n Variant.create({\n :product_id => p.id,\n :is_master => true,\n :price => price,\n :cost_price => price\n }) \n end\n \n count_p += 1\n if p\n # add the variants we need now\n variant_counter = 0\n data[model][:variants].each do |v|\n # check to see that the variant is even available before trying to add it\n # :availability and :level are the keys to make up the onhand values\n \n # unfortunately, some variants have a price of zero... so at least give them the price of the variant with one\n if v[:price] == 0.0\n price = get_lowest_price_from_yaml(data[model][:variants])\n else\n price = v[:price]\n end\n \n options = {\n :sku => \"#{model}_#{variant_counter += 1}\",\n :cost_price => price,\n :price => markup_tirerack(price),\n :width => '',\n :weight => v[:weight].to_i,\n :on_hand => v[:level].to_i\n }\n \n begin \n new_variant = p.variants.create(options)\n \n # puts \"Load Range #{OptionValue.find(:first, :conditions => {:name => v[:load_range].to_s, :option_type_id => OptionType.find_by_name('load-range').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:load_range].to_s, :option_type_id => OptionType.find_by_name('load-range').id})\n \n # puts \"UTQG: #{OptionValue.find(:first, :conditions => {:name => v[:utqg].to_s, :option_type_id => OptionType.find_by_name('utqg').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:utqg].to_s, :option_type_id => OptionType.find_by_name('utqg').id})\n \n # puts \"Load Index: #{OptionValue.find(:first, :conditions => {:name => v[:load_index].to_s, :option_type_id => OptionType.find_by_name('load-index').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:load_index].to_s, :option_type_id => OptionType.find_by_name('load-index').id})\n \n # puts \"Load Factor: #{OptionValue.find(:first, :conditions => {:name => v[:load_factor].to_s, :option_type_id => OptionType.find_by_name('load-factor').id})}\\n\" \n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:load_factor].to_s, :option_type_id => OptionType.find_by_name('load-factor').id})\n \n # puts \"Speed Rating: #{OptionValue.find(:first, :conditions => {:name => v[:speed_rating].to_s, :option_type_id => OptionType.find_by_name('speed-rating').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:speed_rating].to_s, :option_type_id => OptionType.find_by_name('speed-rating').id})\n \n # puts \"Size: #{OptionValue.find(:first, :conditions => {:name => v[:size].to_s, :option_type_id => OptionType.find_by_name('size').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:size].to_s, :option_type_id => OptionType.find_by_name('size').id})\n \n # puts \"SideWall: #{OptionValue.find(:first, :conditions => {:name => v[:sidewall].to_s, :option_type_id => OptionType.find_by_name('sidewall').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:sidewall].to_s, :option_type_id => OptionType.find_by_name('sidewall').id})\n new_variant.save!\n # puts \"Created Variant #{new_variant.sku}\\n\"\n count_v += 1\n rescue => error\n ap p\n ap options\n ap v\n puts \"Could not built the variant for the product due to error: #{error}\\n\"\n end\n end\n end\n end \n end\n puts \"redo_option_values_tirerack task took #{Time.now - start_time} seconds and worked on #{count_p} products, #{count_v} with variants\\n\" \n end",
"def base_eva\n armor1 = $data_armors[@armor1_id]\n armor2 = $data_armors[@armor2_id]\n armor3 = $data_armors[@armor3_id]\n armor4 = $data_armors[@armor4_id]\n eva1 = armor1 != nil ? armor1.eva : 0\n eva2 = armor2 != nil ? armor2.eva : 0\n eva3 = armor3 != nil ? armor3.eva : 0\n eva4 = armor4 != nil ? armor4.eva : 0\n return eva1 + eva2 + eva3 + eva4\n end",
"def create_empty\n EadGenerator.generate_empty\n end",
"def set_offer\n @offer = Offer.find(params[:id])\n flat = @offer.characteristics.includes(:property).pluck(\n \"properties.title,\n characteristics.title\").to_h.values_at(*@offer.compare.site.site_offer_order)\n @par= flat.join(\";\")\n\n var = @offer.variants.first\n if var\n flat = var.prices.pluck( \"title, value\").to_h\n flat = flat.values_at(*@offer.compare.site.site_variant_order)\n @chr= [@offer.scu,var.quantity,*flat].join(\";\") \n end\n end",
"def generate_individual_ships\n # for each ship type, create it and then assign it to its accessor\n %w|carrier battleship submarine warship destroyer|.each do |type|\n ship = Ship.new(type)\n case type\n when \"carrier\"\n then @carrier = ship\n when \"battleship\"\n then @battleship = ship\n when \"submarine\"\n then @submarine = ship\n when \"warship\"\n then @warship = ship\n when \"destroyer\"\n then @destroyer = ship\n end\n @fleet << ship # for fleet-building\n end\n end",
"def initialize_deck\n VALUES.product(SUITS).shuffle\nend",
"def equipment_class\n Equipment\n end",
"def make_cartesian\n #asks for name of the first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates the desired set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if not found, ends the method\n return 0\n end\n #asks for name of second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates desired set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if not ends the method\n return 0\n end\n\n #asks the user to name the new set\n puts \"Enter name for cartesian set:\"\n newsetname = gets\n #for loop iterates through current sets \n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == newsetname.chomp\n #if a set already has that name it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n\n #creates new set by instantiating the cartesian method from the first set, and passing the other set as a parameter\n cartset = set1.cartesian(set2, newsetname.chomp)\n #adds new set to the list of current sets\n $current_sets.push(cartset)\n puts \"Cartesian Product set created!\"\nend",
"def get_slot(slot)\n equipments[slot]\n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def generate_stack\n VALUES.product(SUITS).map!(&:join)\n\n # stack = []\n # VALUES.each do |value|\n # SUITS.each do |suit|\n # stack << value + suit\n # end\n # end\n # stack\n end",
"def equip_message\n @equip_slot_info.equip_message\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def prepare_all\n reservations = []\n @items.each do |id, quantity|\n quantity.times do\n reservations << Reservation.new(reserver: reserver,\n start_date: @start_date,\n due_date: @due_date,\n equipment_model_id: id)\n end\n end\n reservations\n end",
"def equipment_profile_options\n all.collect do |ep|\n [\n ep.name,\n (ep.temperature_sensors.order('id ASC') +\n ep.heating_elements.order('id ASC') +\n ep.pumps.order('id ASC') +\n ep.thermostats.order('id ASC') +\n ep.recirculating_infusion_mash_systems.order('id ASC')).collect do |s|\n [\"#{s.type.titlecase} #{s.rhizome_eid}\", \"#{s.type}_#{s.id}\"]\n end\n ]\n end\n end",
"def set_equipo\n @equipo = Equipo.find_by(nombre:params[:nombre])\n end",
"def initialize_deck\n SUITS.product(VALUES).shuffle\nend",
"def equip(entity)\n prev_weapon = nil\n if entity.outfit[@type]\n prev_weapon = entity.outfit[@type]\n end\n\n super(entity)\n\n if (prev_weapon && prev_weapon.attack)\n entity.remove_battle_command(prev_weapon.attack)\n end\n\n if @attack\n entity.add_battle_command(@attack)\n end\n\n end",
"def create_deck\n @deck = CARDS.product(SUITS).shuffle\n end",
"def planets()\n pseed = @seed.clone\n Enumerator.new do |yielder|\n loop do\n name, new_seed = planet_name(pseed)\n yielder.yield name\n break if new_seed==@seed\n pseed = new_seed\n end\n end\n end",
"def supplyInitialize\n\t\t#Treasure cards\n\t\ttext = \"Gain 1 coin.\"\n\t\tcard = Treasure.new(\"Copper\", 0, 60, 1)\n\t\tcard.initCon(\"C\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Gain 2 coins.\"\n\t\tcard = Treasure.new(\"Silver\", 3, 40, 2)\n\t\tcard.initCon(\"S\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Gain 3 coins.\"\n\t\tcard = Treasure.new(\"Gold\", 6, 30, 3)\n\t\tcard.initCon(\"G\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\t#Victory cards\n\t\ttext = \"Worth 1 victory point.\"\n\t\tcard = Victory.new(\"Estate\", 2, 1)\n\t\tcard.initCon(\"E\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Worth 3 victory points.\"\n\t\tcard = Victory.new(\"Duchy\", 5, 3)\n\t\tcard.initCon(\"D\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Worth 6 victory points.\"\n\t\tcard = Victory.new(\"Province\", 8, 6)\n\t\tcard.initCon(\"P\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\t#Curse cards\n\t\ttext = \"Worth -1 victory point.\"\n\t\tcard = Curse.new(\"Curse\", 0, 10, 1)\n\t\tcard.initCon(\"U\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\tend",
"def create_armors \n armor = Armor.create(name: 'Light Armor', armor_rating: 5, cost: 0, :merchant_id => self.id)\n\n armor1 = Armor.create(name: 'Medium Armor', armor_rating: 10, cost: 15, :merchant_id => self.id)\n\n armor2 = Armor.create(name: 'Dragonbone Armor', armor_rating: 15 , cost: 45, :merchant_id => self.id )\n\n end",
"def generate_inventory(products, below_threshold = false, new_form_warehouse = false)\n products.each do |product|\n count = if new_form_warehouse\n 0\n elsif below_threshold\n rand(1..THRESHOLD_LIMIT - 1)\n else\n rand(THRESHOLD_LIMIT + 1..50)\n end\n inventory.create!(product: product, item_count: count, low_item_threshold: THRESHOLD_LIMIT)\n end\n end",
"def new\n logger.debug \"==> EC.n 0: #{params.inspect}\"\n @endorsement = Endorsement.new\n @marker = Endorsement.new\n @products = Array.new\n if params[:product] == \"Beverage\"\n @marker = Beverage.find(:first)\n @products = Beverage.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n #@beverages.each { |x| x.insert(1, \"Beverage\") }\n elsif params[:product] == \"Fashion\"\n @marker = Fashion.find(:first)\n @products = Fashion.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n elsif params[:product] == \"Snack\"\n @marker = Snack.find(:first)\n @products = Snack.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n else\n logger.debug \"==> EC.n 0.1\"\n @bev = Beverage.new\n @products.concat(@bev.get_all_for_select)\n @fas = Fashion.new\n @products.concat(@fas.get_all_for_select)\n @sna = Snack.new\n @products.concat(@sna.get_all_for_select)\n logger.debug \"==> EC.n 0.4\"\n\n #this returns items that only exist in endorsements\n #not a meta table of all items. need outer join.\n #@zoo = Endorsement.find(:all, \n # :include => [:beverage, :snack, :fashion],\n # :joins => [:beverage, :snack, :fashion]).map do |x|\n # x.endorseable.name\n #end\n #@fun = Endorsement.find(:all).map { |x| x.endorseable.name }\n\n #@products.concat(@fashions)\n #@products.concat(@snacks)\n #@e = Endorsement.new\n #@products = @e.get_products_select\n=begin\n @products = Endorsement.find(:all, \n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n #remove this from the above find statement\n # :include => [:beverage, :fashion, :snack],\n end\n #@beverages.each { |x| @products << x }\n #@fashions.each { |x| @products << x }\n #@snacks.each { |x| @products << x }\n logger.debug \"==> EC.n 0.3: #{@products.inspect}\"\n logger.debug \"==> EC.n 0.4: #{@marker.inspect}\"\n logger.debug \"==> EC.n 0.5: #{@marker.class}\"\n=begin\n below is the way to get stuff for dropdown from endorsement\n via interface endorseable\n @beverages = Endorsement.find(:all,\n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n @players = Player.find(:all, :order => \"lastname ASC\",\n :select => \"id, firstname, lastname\").map {|p|\n [\"#{p.lastname}, #{p.firstname}\", p.id]}\n @x = Player.find(:first)\n @b = Beverage.find(:all)\n #logger.debug \"==> EC.n 1: #{@beverages.class}\"\n #logger.debug \"==> EC.n 1.1: #{@beverages.empty?}\"\n #logger.debug \"==> EC.n 1.2: #{@beverages.inspect}\"\n logger.debug \"==> EC.n 2: #{@players.class}\"\n logger.debug \"==> EC.n 2.1: #{@players.empty?}\"\n logger.debug \"==> EC.n 2.2: #{@players.inspect}\"\n logger.debug \"==> EC.n 3: #{@x.endorsements.inspect}\"\n logger.debug \"==> EC.n 4: #{@b.class}\"\n logger.debug \"==> EC.n 4.1: #{@b.empty?}\"\n logger.debug \"==> EC.n 4.2: #{@b.inspect}\"\n\n=begin\n @endorsement = Endorsement.find(:all,\n :select => \"id, name, lastname\").map {|p|\n [p.firstname, p.lastname, p.id]}\n=end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @endorsement }\n end\n end",
"def destroy\n @equipo = set_equipo,\n @equipo.destroy\n end",
"def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end",
"def check_equip_effects(equip)\n end",
"def set_battle_equip\n @battle_equip = BattleEquip.find(params[:id])\n end",
"def all_weapons_codes\n weapon_codes = []\n all_weapons.each do |hex_code, values|\n weapon_codes << hex_code\n end\n weapon_codes\n end",
"def create_item(index)\n item = @data[index]\n rect = item_rect(index, true)\n\n case index\n when 0\n if @actor.two_swords_style\n kindDesc = Vocab::weapon1\n else\n kindDesc = Vocab::weapon\n end\n when 1\n if @actor.two_swords_style\n kindDesc = Vocab::weapon2\n else\n kindDesc = Vocab::armor1\n end\n when 2\n kindDesc = Vocab::armor2\n when 3\n kindDesc = Vocab::armor3\n when 4\n kindDesc = Vocab::armor4\n end\n \n rect.y += WLH*index \n equipItem = UCEquipItem.new(self, item, rect, kindDesc)\n \n f = Font.new()\n f.color = system_color\n equipItem.cEquipKind.font = f\n return equipItem\n end",
"def load_products\n @products_type[\"watermelon\"] = Creator.createProduct(:watermelon, \"watermelon\")\n @products_type[\"watermelon\"].add_pack(3, 6.99)\n @products_type[\"watermelon\"].add_pack(5, 8.99)\n\n @products_type[\"pineapple\"] = Creator.createProduct(:pineapple, \"pineapple\")\n @products_type[\"pineapple\"].add_pack(2, 9.95)\n @products_type[\"pineapple\"].add_pack(5, 16.95)\n @products_type[\"pineapple\"].add_pack(8, 24.95)\n\n @products_type[\"rockmelon\"] = Creator.createProduct(:rockmelon, \"rockmelon\")\n @products_type[\"rockmelon\"].add_pack(3, 5.95)\n @products_type[\"rockmelon\"].add_pack(5, 9.95)\n @products_type[\"rockmelon\"].add_pack(9, 16.99)\n end",
"def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend",
"def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend",
"def get_energia_proteins\n\t\t\t\t@proteins * 4\n\t\t\tend",
"def check_instance_equips(equips)\n new_equips = []\n equips.each_with_index do |item_id, i|\n etype_id = index_to_etype_id(i)\n slot_id = empty_slot(etype_id)\n if etype_id == 0\n equip = $data_weapons[item_id]\n else\n equip = $data_armors[item_id]\n end\n new_equips << InstanceManager.get_instance(equip)\n end\n return new_equips.collect {|obj| obj ? obj.id : 0}\n end",
"def new_input_set()\n return ElectricityUseInputSet.new()\n end",
"def reset_equipments\n floors.each{ |floor| floor.reset_equipments }\n end",
"def dumpAugmented\n item_fields = []\n Item.fields.keys.each do |field_name|\n if field_name[0]!='_' && !(field_name.include? \"image\")\n item_fields.push(field_name)\n end\n end\n item_fields.push(\"_SKU\")\n field_list = [\"student_id\",\"email\",\"start_date\",\"end_date\"]\n header = [\"Student ID\",\"Email\",\"Pick-up date\", \"Due date\",\"Returned on\"]\n all_items = Item.all\n CSV.generate(headers: true) do |csv|\n all_items.each do |item|\n # First Item detail\n csv << [\"Item Details\"]\n csv << item_fields\n csv_arr = []\n item_fields.each do |f_name|\n csv_arr.push(item[f_name])\n end\n csv << csv_arr\n # Now add transactions\n item_transactions = item.transactions\n if (item_transactions.count > 0)\n csv << [\"Item transactions\"]\n csv << header\n item_transactions.each do |transaction|\n csv_arr = []\n field_list.each do |f_name|\n csv_arr.push(transaction[f_name])\n end\n rt_date = (transaction.status) ? transaction.return_date : \"Not returned Yet!\"\n csv_arr.push(rt_date)\n csv << csv_arr\n end\n end\n\n # Now add reservations\n item_reservations = item.reservations\n if (item_reservations.count > 0 )\n csv << [\"Item reservations\"]\n csv << header[0,header.size-1]\n item_reservations.each do |reserve|\n csv_arr = []\n field_list.each do |f_name|\n csv_arr.push(reserve[f_name])\n end\n csv << csv_arr\n end\n end\n csv << []\n end\n end\n end",
"def voivodeship\n fetch_sample(VOIVODESHIP)\n end",
"def generate_data\n\t\tgenerate_stations\n\t\tgenerate_demands\n\tend",
"def create_full_product\n generate_product_name\n generate_product_code\n generate_product_manufacturer\n generate_product_description\n generate_product_price\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 get_dept\n \n DEPTS[Kernel.rand(DEPTS.length-1)].to_s\n\nend",
"def new_input_set()\n return PurchaseInputSet.new()\n end",
"def fetch_inventory\n @offer[:records] ||= Item.where(survivor_id: @offer[:survivor_id]).to_a\n @for[:records] ||= Item.where(survivor_id: @for[:survivor_id]).to_a\n end",
"def set_equip(is_weapon, item_id)\n @class = is_weapon ? RPG::Weapon : RPG::Armor\n @item_id = item_id\n end",
"def new_input_set()\n return EducationalOfferingsInputSet.new()\n end",
"def buyable_items(_entity)\n []\n end",
"def seed_data\n\n target_isolates = rand(20) + 5\n shipment = shipments.new({:target_isolates => target_isolates})\n\n base_objective = BaseObjective.parent_objectives.to_a.sample\n if base_objective.first == \"objective_b\"\n bacteria_type = {:bacteria_type => ObjectiveB::bacteria_type_values.sample.last}\n code_prefix = bacteria_type.values.last\n end\n\n objective = base_objective.last\n\n starting_code = starting_code_for(objective, code_prefix ||= nil)\n\n shipment.target_isolates.times do |x|\n parent_objective = objective.new(bacteria_type ||= {})\n \n code_number = parent_objective.code_prefix+\"#{(starting_code + x + 1)}\"\n\n isolate = shipment.isolates.new({code_number: code_number})\n isolate.parent = parent_objective\n isolate.save\n end\n\n shipment.update_attribute(:objective_name, \"#{objective.name} #{objective.new(bacteria_type ||= {}).name}\")\n\n end",
"def ranged_weapon; end",
"def create_potions\n potion = Potion.create(name: 'Basic Healing Potion', heal_amount: 10, cost: 10, :merchant_id => self.id)\n\n potion1 = Potion.create(name: 'Superior Healing Potion', heal_amount: 25, cost: 20, :merchant_id => self.id)\n\n potion2 = Potion.create(name: 'Full Heal Potion', heal_amount: 50, cost: 45, :merchant_id => self.id )\n\n end",
"def set_equip(is_weapon, item_id)\r\n @class = is_weapon ? RPG::Weapon : RPG::Armor\r\n @item_id = item_id\r\n end",
"def build_deck\n CARD_SUITS.product(CARD_VALUES).shuffle\nend",
"def load_equipment(object, game_objects)\n\n if not object.respond_to? :equipment\n #log \"#{object} has no equipment\"\n return\n end\n\n load_inv(object.equipment, game_objects)\n object.equipment.each do |o|\n o.info.equipment_of = object.goid\n end\n end",
"def of_generate_offer\n supplier = params[:supplier]\n request = params[:request]\n offer_no = params[:offer_no]\n offer_date = params[:offer_date] # YYYYMMDD\n offer = nil\n offer_item = nil\n code = ''\n\n if request != '0'\n offer_request = OfferRequest.find(request) rescue nil\n offer_request_items = offer_request.offer_request_items rescue nil\n if !offer_request.nil? && !offer_request_items.nil?\n # Format offer_date\n offer_date = (offer_date[0..3] + '-' + offer_date[4..5] + '-' + offer_date[6..7]).to_date\n # Try to save new offer\n offer = Offer.new\n offer.offer_no = offer_no\n offer.offer_date = offer_date\n offer.offer_request_id = offer_request.id\n offer.supplier_id = supplier\n offer.payment_method_id = offer_request.payment_method_id\n offer.created_by = current_user.id if !current_user.nil?\n offer.discount_pct = offer_request.discount_pct\n offer.discount = offer_request.discount\n offer.project_id = offer_request.project_id\n offer.store_id = offer_request.store_id\n offer.work_order_id = offer_request.work_order_id\n offer.charge_account_id = offer_request.charge_account_id\n offer.organization_id = offer_request.organization_id\n if offer.save\n # Try to save new offer items\n offer_request_items.each do |i|\n offer_item = OfferItem.new\n offer_item.offer_id = offer.id\n offer_item.product_id = i.product_id\n offer_item.description = i.description\n offer_item.quantity = i.quantity\n offer_item.price = i.price\n offer_item.tax_type_id = i.tax_type_id\n offer_item.created_by = current_user.id if !current_user.nil?\n offer_item.project_id = i.project_id\n offer_item.store_id = i.store_id\n offer_item.work_order_id = i.work_order_id\n offer_item.charge_account_id = i.charge_account_id\n if !offer_item.save\n # Can't save offer item (exit)\n code = '$write'\n break\n end # !offer_item.save?\n end # do |i|\n # Update totals\n offer.update_column(:totals, Offer.find(offer.id).total)\n else\n # Can't save offer\n code = '$write'\n end # offer.save?\n else\n # Offer request or items not found\n code = '$err'\n end # !offer_request.nil? && !offer_request_items.nil?\n else\n # Offer request 0\n code = '$err'\n end # request != '0'\n if code == ''\n code = I18n.t(\"ag2_purchase.offers.generate_offer_ok\", var: offer.id.to_s)\n end\n @json_data = { \"code\" => code }\n render json: @json_data\n end",
"def armor_set\n armor_ids = armors.compact.map{|a| a.real_id}\n SETS::Armors.select{|k,v| (v - armor_ids).empty? }.map{ |a| a[0] }.max\n end"
] |
[
"0.68351865",
"0.60732543",
"0.60037035",
"0.5973523",
"0.5968878",
"0.5706798",
"0.5605056",
"0.55641353",
"0.55604774",
"0.55501145",
"0.5425557",
"0.5397567",
"0.5395156",
"0.53529346",
"0.53304124",
"0.5302607",
"0.5301194",
"0.52929443",
"0.5286353",
"0.5280704",
"0.5276057",
"0.52314466",
"0.52202094",
"0.5213971",
"0.51986945",
"0.51898366",
"0.515096",
"0.513942",
"0.5130379",
"0.5112986",
"0.5083783",
"0.50572366",
"0.5006978",
"0.49961418",
"0.49765822",
"0.49754474",
"0.49591497",
"0.49553925",
"0.49553925",
"0.49553925",
"0.49553925",
"0.49272442",
"0.49135518",
"0.48930538",
"0.48928267",
"0.48906216",
"0.48780328",
"0.48748475",
"0.48704025",
"0.48620197",
"0.48609376",
"0.48541644",
"0.48408145",
"0.48368788",
"0.48355886",
"0.48319802",
"0.48233283",
"0.48223132",
"0.481955",
"0.48178154",
"0.48048264",
"0.47977242",
"0.47957617",
"0.47947145",
"0.47947034",
"0.47912323",
"0.47788736",
"0.4774379",
"0.47698882",
"0.47595456",
"0.47488734",
"0.4747206",
"0.47431135",
"0.4741525",
"0.47396338",
"0.473319",
"0.473319",
"0.47132847",
"0.471225",
"0.4712228",
"0.47090232",
"0.4705966",
"0.4697843",
"0.46946973",
"0.468613",
"0.46649152",
"0.4658662",
"0.46470922",
"0.46399117",
"0.4638999",
"0.46367306",
"0.4635377",
"0.46251845",
"0.46230868",
"0.46225366",
"0.4620378",
"0.46192986",
"0.46124613",
"0.46091488",
"0.46076298"
] |
0.6679016
|
1
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equip Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def maesb_generate_equip_set
super
@maesb_sets = note.scan(/\\SET\s*\[(.+?)\]/i).collect { |set_s|
MAESB_EquipmentSet.new(set_s[0]) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def maesb_generate_equipment_sets\n # Generate Equipment Sets\n ($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }\n # Update items to refer to the set to which they belong\n set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }\n set_items.each { |set_item| \n set_item.maesb_sets.collect {|set| set.items }.flatten.uniq.each { |equip|\n equip.maesb_belongs_to_sets.push(set_item.id) \n }\n }\n end",
"def maesb_generate_equip_set\n @maesb_belongs_to_sets = []\n end",
"def equip(entity)\n prev_item = entity.outfit[@type]\n\n entity.outfit[@type] = self\n alter_stats(entity, true)\n\n if prev_item\n prev_item.alter_stats(entity, false)\n entity.add_item(prev_item)\n end\n\n print \"#{entity.name} equips #{@name}!\\n\\n\"\n end",
"def unequip!\n self.slot = EquipSlot::Inventory\n self.save!\n end",
"def power_ups\n @power_ups.map {|pup| Equip_Abilities.new(pup[0], pup[1], pup[2])}\n end",
"def set_equip\n @equip = Equip.find(params[:id])\n end",
"def equipment_list\n [\n \"Backhoe\",\n \"Bobcat\",\n \"Compactor\",\n \"Compactor 815\",\n \"Compactor 815F\",\n \"Compactor 825G\",\n \"Compactor 825H\",\n \"Crane\",\n \"Dozer-D3\",\n \"Dozer-D6\",\n \"Dozer D6M Swamp\",\n \"Dozer D6R Swamp\",\n \"Dozer D6T XL\",\n \"Dozer-D6H\",\n \"Dozer-D65\",\n \"Dozer - D6C\",\n \"Dozer - D6R\",\n \"Dozer - D6R Xl\",\n \"Dozer - D7\",\n \"Dozer - D7H\",\n \"Dozer - D8\",\n \"Dozer - D9T\",\n \"Dozer R -D9\",\n \"Dump Truck 25T\",\n \"Dump Truck 30T\",\n \"Dump Truck 40T\",\n \"Dump Truck 50T\",\n \"Drott 9T\",\n \"Drott 8T\",\n \"Drott\",\n \"Excavator\",\n \"EXC 8T\",\n \"EXC 12-22T \",\n \"EXC 12T\",\n \"EXC 13T\",\n \"EXC13.5T\",\n \"EXC 14T\",\n \"EXC 15T\",\n \"EXC 17T WHEELED\",\n \"EXC 18T\",\n \"EXC 20-29T\",\n \"EXC 20T WHEELED\",\n \"EXC 20T\",\n \"EXC 20T \",\n \"EXC 20T 8T 12\",\n \"EXC 22T\",\n \"EXC 24T\",\n \"EXC 25T\",\n \"EXC 30T\",\n \"EXC 35T\",\n \"EXC 40T\",\n \"EXC 45T\",\n \"EXC 60T\",\n \"EXC 4.5T \",\n \"EXC 4T\",\n \"EXC 3.5T\",\n \"EXC 3T COMBO\",\n \"EXC 3T\",\n \"EXC 5T\",\n \"EXC 5T COMBO\",\n \"EXC 5T \",\n \"EXC 5.5T\",\n \"EXC 5-10T\",\n \"EXC 5-30T\",\n \"EXC 5T & 6T\",\n \"EXC 6T\",\n \"EXC 6T \",\n \"EXC 7.5T\",\n \"EXC 7.5T \",\n \"EXC 8T \",\n \"Float\",\n \"Grader 12G 140H\",\n \"Grader\",\n \"IT Loader\",\n \"Loader\",\n \"Moxy Dump\",\n \"Moxy Dump 20T\",\n \"Moxy Dump 25T\",\n \"Moxy Dump 30T\",\n \"Posi Track\",\n \"Pug Mill\",\n \"Roller Pad SF\",\n \"Roller Smooth\",\n \"Roller 12T\",\n \"Roller\",\n \"Roller 14T\",\n \"Roller Smooth 12T\",\n \"Roller Pad SF 12T\",\n \"Roller Pad\",\n \"Roller Pad SF 16T\",\n \"Scraper 633\",\n \"Scraper 623E\",\n \"Scraper\",\n \"Screening Plant\",\n \"Semi\",\n \"Semi/T & T\",\n \"Semi Tipper\",\n \"Sweeper\",\n \"Tilt Tray\",\n \"Truck\",\n \"Truck & 3 Axle Trailer\",\n \"Truck & 4 Axle Trailer\",\n \"Truck & Dog\",\n \"Watercart\"\n ]\n end",
"def prepare_equipment\n show do\n title 'Gather materials'\n check 'Fill 2 buckets with ice.'\n check \"Get the 24-well aluminum block out of the 4 #{DEGREES_C}\" \\\n 'refrigerator and place it in one of the ice buckets.'\n check \"Set the refigerated centrifuge to 4 #{DEGREES_C}.\"\n end\n end",
"def storage_equip_items\n storage_weapons + storage_armors\n end",
"def make_item_list\n @data = equips_for_enchant\n end",
"def unequip_item\n\t\tself.equiped = false\n\t\tself.save\n\tend",
"def init_equips(equips)\n @equips = Array.new(equip_slots.size) { Game_BaseItem.new }\n equips.each_with_index do |item_id, i|\n break if i > @equips.size - 1\n @equips[i].set_equip(item_id < 0, item_id.abs)\n end\n refresh\n end",
"def clear_equipments\n equip_slots.size.times do |i|\n change_equip(i, nil) if equip_change_ok?(i)\n end\n end",
"def set_equipo\n @equipo = Equipo.find(params[:id])\n end",
"def equipment; end",
"def set_equipo\n @equipo = Equipo.find(params[:id])\n end",
"def unequip(entity)\n entity.outfit.delete(@type)\n alter_stats(entity, false)\n\n print \"#{entity.name} unequips #{@name}!\\n\\n\"\n end",
"def createEnemyStarShip\n loot = createLoot\n damage1 = createDamageNumeric\n damage2 = createDamageSpecific\n \n enemy1 = EnemyStarShip.new(\"E1\",5,6,loot[0],damage1[0])\n enemy2 = EnemyStarShip.new(\"E2\",10,20,loot[1],damage2[1])\n enemy3 = EnemyStarShip.new(\"E3\",50,100,loot[2],damage2[4])\n \n enemies = [enemy1,enemy2,enemy3]\n return enemies\n end",
"def optimize_equipments\n clear_equipments\n equip_slots.size.times do |i|\n next if !equip_change_ok?(i)\n items = $game_party.equip_items.select do |item|\n etype_can_equip?(i, item) &&\n equippable?(item) && item.performance >= 0\n end\n change_equip(i, items.max_by {|item| item.performance })\n end\n end",
"def set_equipo\n @equipo = Equipo.find( params[:id] )\n end",
"def optimize_equipments\n clear_equipments\n equip_slots.size.times do |i|\n next if !equip_change_ok?(i)\n items = $game_party.equip_items.select do |item|\n item.etype_id == equip_slots[i] &&\n equippable?(item) && item.performance >= 0\n end\n change_equip(i, items.max_by {|item| item.performance })\n end\n end",
"def generate_event_set(events)\n usable_events = self.find_usable_events(events)\n self.new_event_set(usable_events)\n end",
"def population(starting_set)\n starting_set = starting_set.to_s if starting_set.is_a?(Symbol)\n p = Population.find_or_initialize_by_populatable_type_and_populatable_id_and_starting_set_and_conditions_counter(\n \"Offering\", self.id, starting_set, 0)\n if p.new_record?\n p.title = \"#{self.title}: #{starting_set.titleize}\"\n until p.valid? && !p.errors.on(:title)\n if p.title[/\\d+$/].nil?\n p.title += \" 2\"\n else\n new_num = p.title[/\\d+$/].to_i + 1\n p.title.gsub!(/\\d+$/, new_num.to_s)\n end\n end \n p.system = true\n p.description = \"Automatically generated by Offering ##{self.id} from starting set '#{starting_set}'\"\n p.access_level = \"everyone\"\n p.save\n end\n p\n end",
"def set_equip_type\n @equip_type = EquipType.find(params[:id])\n end",
"def sku_combination_creation\n end",
"def equips_for_enchant\n return [] if @enchant_item.nil?\n $game_party.items.select { |item|\n item.enchantable? && item.tier == @enchant_item.enchant_tier\n }\n end",
"def get_clean_inventory(data_set)\n\t\tclean_inventory = @helpers.make_hoa\n\n\t\tdata_set.each do |item_info|\n\t\t\tif item_info.has_key?(:type)\n\t\t\t\titem_type = item_info.delete(:type)\n\t\t\t\tclean_inventory[item_type].push(item_info)\n\t\t\telse\n\t\t\t\tputs \"Skipping, invalid item, missing type\"\n\t\t\tend\n\t\tend\n\n\t\treturn clean_inventory\n\tend",
"def load_notetag_init_equips\n @equips = []\n res = self.note.match(TH::EquipManager::Initial_Equip_Regex)\n if res\n res[1].split.each {|info|\n type, id = info[0], info[1..-1].to_i\n id *= -1 if type == \"w\"\n @equips.push id\n }\n else\n @equips = [0]\n end\n @init_equip_checked = true\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 build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend",
"def index\n @equip_types = EquipType.all\n end",
"def element_set\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.element_set : []\n end",
"def equipped?\n EquipSlot.equipable_slots.include? slot\n end",
"def enemy_fleet()\n enemy_fleet = Array.new\n for count in 1..6 do \n enemy_fleet.push(Ship.new(generateHull, generateFirepower, generateAccuracy))\n end\n return enemy_fleet\nend",
"def equip(equip_type, id)\n case equip_type\n when 0 # Weapon\n if id == 0 or $game_party.weapon_number(id) > 0\n $game_party.gain_weapon(@weapon_id, 1)\n @weapon_id = id\n $game_party.lose_weapon(id, 1)\n end\n when 1 # Shield\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor1_id], $data_armors[id])\n $game_party.gain_armor(@armor1_id, 1)\n @armor1_id = id\n $game_party.lose_armor(id, 1)\n end\n when 2 # Head\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor2_id], $data_armors[id])\n $game_party.gain_armor(@armor2_id, 1)\n @armor2_id = id\n $game_party.lose_armor(id, 1)\n end\n when 3 # Body\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor3_id], $data_armors[id])\n $game_party.gain_armor(@armor3_id, 1)\n @armor3_id = id\n $game_party.lose_armor(id, 1)\n end\n when 4 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor4_id], $data_armors[id])\n $game_party.gain_armor(@armor4_id, 1)\n @armor4_id = id\n $game_party.lose_armor(id, 1)\n end\n when 5 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce1_id], $data_armors[id])\n $game_party.gain_armor(@pierce1_id, 1)\n @pierce1_id = id\n $game_party.lose_armor(id, 1)\n end\n when 6 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce2_id], $data_armors[id])\n $game_party.gain_armor(@pierce2_id, 1)\n @pierce2_id = id\n $game_party.lose_armor(id, 1)\n end\n when 7 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce3_id], $data_armors[id])\n $game_party.gain_armor(@pierce3_id, 1)\n @pierce3_id = id\n $game_party.lose_armor(id, 1)\n end\n when 8 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce4_id], $data_armors[id])\n $game_party.gain_armor(@pierce4_id, 1)\n @pierce4_id = id\n $game_party.lose_armor(id, 1)\n end \n when 9 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce5_id], $data_armors[id])\n $game_party.gain_armor(@pierce5_id, 1)\n @pierce5_id = id\n $game_party.lose_armor(id, 1)\n end\n when 10 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce6_id], $data_armors[id])\n $game_party.gain_armor(@pierce6_id, 1)\n @pierce6_id = id\n $game_party.lose_armor(id, 1)\n end\n when 11 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce7_id], $data_armors[id])\n $game_party.gain_armor(@pierce7_id, 1)\n @pierce7_id = id\n $game_party.lose_armor(id, 1)\n end \n end\n $game_switches[100] = true\n end",
"def class_id=(class_id)\n if $data_classes[class_id] != nil\n @class_id = class_id\n # Remove items that are no longer equippable\n unless equippable?($data_weapons[@weapon_id])\n equip(0, 0)\n end\n unless equippable?($data_armors[@armor1_id])\n equip(1, 0)\n end\n unless equippable?($data_armors[@armor2_id])\n equip(2, 0)\n end\n unless equippable?($data_armors[@armor3_id])\n equip(3, 0)\n end\n unless equippable?($data_armors[@armor4_id])\n equip(4, 0)\n end\n #unless equippable?($data_armors[@pierce1_id])\n # equip(5, 0)\n #end\n #unless equippable?($data_armors[@pierce2_id])\n # equip(6, 0)\n #end\n #unless equippable?($data_armors[@pierce3_id])\n # equip(7, 0)\n #end\n #unless equippable?($data_armors[@pierce4_id])\n # equip(8, 0)\n #end\n #unless equippable?($data_armors[@pierce5_id])\n # equip(9, 0)\n #end\n #unless equippable?($data_armors[@pierce6_id])\n # equip(10, 0)\n #end\n #unless equippable?($data_armors[@pierce7_id])\n # equip(11, 0)\n #end\n end\n end",
"def use(entity)\n print \"Type 'equip #{@name}' to equip this item.\\n\\n\"\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def plus_state_set\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.plus_state_set : []\n end",
"def e1334_random_bag (values)\n end",
"def redo_option_values_tirerack\n start_time = Time.now\n mfg_list = get_manufacturer_list\n count_v = 0\n count_p = 0\n mfg_list.each do |mfg|\n data = YAML.load(open_file_read('tires', mfg))\n data.each_key do |model|\n p = Product.find_by_name(model)\n if p.master.nil?\n price = get_lowest_price_from_yaml(data[model][:variants])\n Variant.create({\n :product_id => p.id,\n :is_master => true,\n :price => price,\n :cost_price => price\n }) \n end\n \n count_p += 1\n if p\n # add the variants we need now\n variant_counter = 0\n data[model][:variants].each do |v|\n # check to see that the variant is even available before trying to add it\n # :availability and :level are the keys to make up the onhand values\n \n # unfortunately, some variants have a price of zero... so at least give them the price of the variant with one\n if v[:price] == 0.0\n price = get_lowest_price_from_yaml(data[model][:variants])\n else\n price = v[:price]\n end\n \n options = {\n :sku => \"#{model}_#{variant_counter += 1}\",\n :cost_price => price,\n :price => markup_tirerack(price),\n :width => '',\n :weight => v[:weight].to_i,\n :on_hand => v[:level].to_i\n }\n \n begin \n new_variant = p.variants.create(options)\n \n # puts \"Load Range #{OptionValue.find(:first, :conditions => {:name => v[:load_range].to_s, :option_type_id => OptionType.find_by_name('load-range').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:load_range].to_s, :option_type_id => OptionType.find_by_name('load-range').id})\n \n # puts \"UTQG: #{OptionValue.find(:first, :conditions => {:name => v[:utqg].to_s, :option_type_id => OptionType.find_by_name('utqg').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:utqg].to_s, :option_type_id => OptionType.find_by_name('utqg').id})\n \n # puts \"Load Index: #{OptionValue.find(:first, :conditions => {:name => v[:load_index].to_s, :option_type_id => OptionType.find_by_name('load-index').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:load_index].to_s, :option_type_id => OptionType.find_by_name('load-index').id})\n \n # puts \"Load Factor: #{OptionValue.find(:first, :conditions => {:name => v[:load_factor].to_s, :option_type_id => OptionType.find_by_name('load-factor').id})}\\n\" \n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:load_factor].to_s, :option_type_id => OptionType.find_by_name('load-factor').id})\n \n # puts \"Speed Rating: #{OptionValue.find(:first, :conditions => {:name => v[:speed_rating].to_s, :option_type_id => OptionType.find_by_name('speed-rating').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:speed_rating].to_s, :option_type_id => OptionType.find_by_name('speed-rating').id})\n \n # puts \"Size: #{OptionValue.find(:first, :conditions => {:name => v[:size].to_s, :option_type_id => OptionType.find_by_name('size').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:size].to_s, :option_type_id => OptionType.find_by_name('size').id})\n \n # puts \"SideWall: #{OptionValue.find(:first, :conditions => {:name => v[:sidewall].to_s, :option_type_id => OptionType.find_by_name('sidewall').id})}\\n\"\n new_variant.option_values << OptionValue.find(:first, :conditions => {:name => v[:sidewall].to_s, :option_type_id => OptionType.find_by_name('sidewall').id})\n new_variant.save!\n # puts \"Created Variant #{new_variant.sku}\\n\"\n count_v += 1\n rescue => error\n ap p\n ap options\n ap v\n puts \"Could not built the variant for the product due to error: #{error}\\n\"\n end\n end\n end\n end \n end\n puts \"redo_option_values_tirerack task took #{Time.now - start_time} seconds and worked on #{count_p} products, #{count_v} with variants\\n\" \n end",
"def equipment_names\n equipment = self.quote.project.company.equipment\n list = equipment.collect! {|x| x.name}\n# list.join()\n end",
"def base_eva\n armor1 = $data_armors[@armor1_id]\n armor2 = $data_armors[@armor2_id]\n armor3 = $data_armors[@armor3_id]\n armor4 = $data_armors[@armor4_id]\n eva1 = armor1 != nil ? armor1.eva : 0\n eva2 = armor2 != nil ? armor2.eva : 0\n eva3 = armor3 != nil ? armor3.eva : 0\n eva4 = armor4 != nil ? armor4.eva : 0\n return eva1 + eva2 + eva3 + eva4\n end",
"def create_empty\n EadGenerator.generate_empty\n end",
"def set_offer\n @offer = Offer.find(params[:id])\n flat = @offer.characteristics.includes(:property).pluck(\n \"properties.title,\n characteristics.title\").to_h.values_at(*@offer.compare.site.site_offer_order)\n @par= flat.join(\";\")\n\n var = @offer.variants.first\n if var\n flat = var.prices.pluck( \"title, value\").to_h\n flat = flat.values_at(*@offer.compare.site.site_variant_order)\n @chr= [@offer.scu,var.quantity,*flat].join(\";\") \n end\n end",
"def generate_individual_ships\n # for each ship type, create it and then assign it to its accessor\n %w|carrier battleship submarine warship destroyer|.each do |type|\n ship = Ship.new(type)\n case type\n when \"carrier\"\n then @carrier = ship\n when \"battleship\"\n then @battleship = ship\n when \"submarine\"\n then @submarine = ship\n when \"warship\"\n then @warship = ship\n when \"destroyer\"\n then @destroyer = ship\n end\n @fleet << ship # for fleet-building\n end\n end",
"def equipment_class\n Equipment\n end",
"def initialize_deck\n VALUES.product(SUITS).shuffle\nend",
"def make_cartesian\n #asks for name of the first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates the desired set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if not found, ends the method\n return 0\n end\n #asks for name of second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates desired set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if not ends the method\n return 0\n end\n\n #asks the user to name the new set\n puts \"Enter name for cartesian set:\"\n newsetname = gets\n #for loop iterates through current sets \n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == newsetname.chomp\n #if a set already has that name it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n\n #creates new set by instantiating the cartesian method from the first set, and passing the other set as a parameter\n cartset = set1.cartesian(set2, newsetname.chomp)\n #adds new set to the list of current sets\n $current_sets.push(cartset)\n puts \"Cartesian Product set created!\"\nend",
"def get_slot(slot)\n equipments[slot]\n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def generate_stack\n VALUES.product(SUITS).map!(&:join)\n\n # stack = []\n # VALUES.each do |value|\n # SUITS.each do |suit|\n # stack << value + suit\n # end\n # end\n # stack\n end",
"def equip_message\n @equip_slot_info.equip_message\n end",
"def set_equipamento\n @equipamento = Equipamento.find(params[:id])\n end",
"def prepare_all\n reservations = []\n @items.each do |id, quantity|\n quantity.times do\n reservations << Reservation.new(reserver: reserver,\n start_date: @start_date,\n due_date: @due_date,\n equipment_model_id: id)\n end\n end\n reservations\n end",
"def equipment_profile_options\n all.collect do |ep|\n [\n ep.name,\n (ep.temperature_sensors.order('id ASC') +\n ep.heating_elements.order('id ASC') +\n ep.pumps.order('id ASC') +\n ep.thermostats.order('id ASC') +\n ep.recirculating_infusion_mash_systems.order('id ASC')).collect do |s|\n [\"#{s.type.titlecase} #{s.rhizome_eid}\", \"#{s.type}_#{s.id}\"]\n end\n ]\n end\n end",
"def set_equipo\n @equipo = Equipo.find_by(nombre:params[:nombre])\n end",
"def initialize_deck\n SUITS.product(VALUES).shuffle\nend",
"def equip(entity)\n prev_weapon = nil\n if entity.outfit[@type]\n prev_weapon = entity.outfit[@type]\n end\n\n super(entity)\n\n if (prev_weapon && prev_weapon.attack)\n entity.remove_battle_command(prev_weapon.attack)\n end\n\n if @attack\n entity.add_battle_command(@attack)\n end\n\n end",
"def create_deck\n @deck = CARDS.product(SUITS).shuffle\n end",
"def planets()\n pseed = @seed.clone\n Enumerator.new do |yielder|\n loop do\n name, new_seed = planet_name(pseed)\n yielder.yield name\n break if new_seed==@seed\n pseed = new_seed\n end\n end\n end",
"def supplyInitialize\n\t\t#Treasure cards\n\t\ttext = \"Gain 1 coin.\"\n\t\tcard = Treasure.new(\"Copper\", 0, 60, 1)\n\t\tcard.initCon(\"C\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Gain 2 coins.\"\n\t\tcard = Treasure.new(\"Silver\", 3, 40, 2)\n\t\tcard.initCon(\"S\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Gain 3 coins.\"\n\t\tcard = Treasure.new(\"Gold\", 6, 30, 3)\n\t\tcard.initCon(\"G\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\t#Victory cards\n\t\ttext = \"Worth 1 victory point.\"\n\t\tcard = Victory.new(\"Estate\", 2, 1)\n\t\tcard.initCon(\"E\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Worth 3 victory points.\"\n\t\tcard = Victory.new(\"Duchy\", 5, 3)\n\t\tcard.initCon(\"D\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\ttext = \"Worth 6 victory points.\"\n\t\tcard = Victory.new(\"Province\", 8, 6)\n\t\tcard.initCon(\"P\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\n\t\t#Curse cards\n\t\ttext = \"Worth -1 victory point.\"\n\t\tcard = Curse.new(\"Curse\", 0, 10, 1)\n\t\tcard.initCon(\"U\", text) if card.respond_to? \"initCon\"\n\t\tcard.loadImage if card.respond_to? \"loadImage\"\n\t\t@supply<< card\n\tend",
"def create_armors \n armor = Armor.create(name: 'Light Armor', armor_rating: 5, cost: 0, :merchant_id => self.id)\n\n armor1 = Armor.create(name: 'Medium Armor', armor_rating: 10, cost: 15, :merchant_id => self.id)\n\n armor2 = Armor.create(name: 'Dragonbone Armor', armor_rating: 15 , cost: 45, :merchant_id => self.id )\n\n end",
"def generate_inventory(products, below_threshold = false, new_form_warehouse = false)\n products.each do |product|\n count = if new_form_warehouse\n 0\n elsif below_threshold\n rand(1..THRESHOLD_LIMIT - 1)\n else\n rand(THRESHOLD_LIMIT + 1..50)\n end\n inventory.create!(product: product, item_count: count, low_item_threshold: THRESHOLD_LIMIT)\n end\n end",
"def new\n logger.debug \"==> EC.n 0: #{params.inspect}\"\n @endorsement = Endorsement.new\n @marker = Endorsement.new\n @products = Array.new\n if params[:product] == \"Beverage\"\n @marker = Beverage.find(:first)\n @products = Beverage.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n #@beverages.each { |x| x.insert(1, \"Beverage\") }\n elsif params[:product] == \"Fashion\"\n @marker = Fashion.find(:first)\n @products = Fashion.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n elsif params[:product] == \"Snack\"\n @marker = Snack.find(:first)\n @products = Snack.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n else\n logger.debug \"==> EC.n 0.1\"\n @bev = Beverage.new\n @products.concat(@bev.get_all_for_select)\n @fas = Fashion.new\n @products.concat(@fas.get_all_for_select)\n @sna = Snack.new\n @products.concat(@sna.get_all_for_select)\n logger.debug \"==> EC.n 0.4\"\n\n #this returns items that only exist in endorsements\n #not a meta table of all items. need outer join.\n #@zoo = Endorsement.find(:all, \n # :include => [:beverage, :snack, :fashion],\n # :joins => [:beverage, :snack, :fashion]).map do |x|\n # x.endorseable.name\n #end\n #@fun = Endorsement.find(:all).map { |x| x.endorseable.name }\n\n #@products.concat(@fashions)\n #@products.concat(@snacks)\n #@e = Endorsement.new\n #@products = @e.get_products_select\n=begin\n @products = Endorsement.find(:all, \n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n #remove this from the above find statement\n # :include => [:beverage, :fashion, :snack],\n end\n #@beverages.each { |x| @products << x }\n #@fashions.each { |x| @products << x }\n #@snacks.each { |x| @products << x }\n logger.debug \"==> EC.n 0.3: #{@products.inspect}\"\n logger.debug \"==> EC.n 0.4: #{@marker.inspect}\"\n logger.debug \"==> EC.n 0.5: #{@marker.class}\"\n=begin\n below is the way to get stuff for dropdown from endorsement\n via interface endorseable\n @beverages = Endorsement.find(:all,\n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n @players = Player.find(:all, :order => \"lastname ASC\",\n :select => \"id, firstname, lastname\").map {|p|\n [\"#{p.lastname}, #{p.firstname}\", p.id]}\n @x = Player.find(:first)\n @b = Beverage.find(:all)\n #logger.debug \"==> EC.n 1: #{@beverages.class}\"\n #logger.debug \"==> EC.n 1.1: #{@beverages.empty?}\"\n #logger.debug \"==> EC.n 1.2: #{@beverages.inspect}\"\n logger.debug \"==> EC.n 2: #{@players.class}\"\n logger.debug \"==> EC.n 2.1: #{@players.empty?}\"\n logger.debug \"==> EC.n 2.2: #{@players.inspect}\"\n logger.debug \"==> EC.n 3: #{@x.endorsements.inspect}\"\n logger.debug \"==> EC.n 4: #{@b.class}\"\n logger.debug \"==> EC.n 4.1: #{@b.empty?}\"\n logger.debug \"==> EC.n 4.2: #{@b.inspect}\"\n\n=begin\n @endorsement = Endorsement.find(:all,\n :select => \"id, name, lastname\").map {|p|\n [p.firstname, p.lastname, p.id]}\n=end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @endorsement }\n end\n end",
"def destroy\n @equipo = set_equipo,\n @equipo.destroy\n end",
"def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end",
"def check_equip_effects(equip)\n end",
"def set_battle_equip\n @battle_equip = BattleEquip.find(params[:id])\n end",
"def create_item(index)\n item = @data[index]\n rect = item_rect(index, true)\n\n case index\n when 0\n if @actor.two_swords_style\n kindDesc = Vocab::weapon1\n else\n kindDesc = Vocab::weapon\n end\n when 1\n if @actor.two_swords_style\n kindDesc = Vocab::weapon2\n else\n kindDesc = Vocab::armor1\n end\n when 2\n kindDesc = Vocab::armor2\n when 3\n kindDesc = Vocab::armor3\n when 4\n kindDesc = Vocab::armor4\n end\n \n rect.y += WLH*index \n equipItem = UCEquipItem.new(self, item, rect, kindDesc)\n \n f = Font.new()\n f.color = system_color\n equipItem.cEquipKind.font = f\n return equipItem\n end",
"def all_weapons_codes\n weapon_codes = []\n all_weapons.each do |hex_code, values|\n weapon_codes << hex_code\n end\n weapon_codes\n end",
"def load_products\n @products_type[\"watermelon\"] = Creator.createProduct(:watermelon, \"watermelon\")\n @products_type[\"watermelon\"].add_pack(3, 6.99)\n @products_type[\"watermelon\"].add_pack(5, 8.99)\n\n @products_type[\"pineapple\"] = Creator.createProduct(:pineapple, \"pineapple\")\n @products_type[\"pineapple\"].add_pack(2, 9.95)\n @products_type[\"pineapple\"].add_pack(5, 16.95)\n @products_type[\"pineapple\"].add_pack(8, 24.95)\n\n @products_type[\"rockmelon\"] = Creator.createProduct(:rockmelon, \"rockmelon\")\n @products_type[\"rockmelon\"].add_pack(3, 5.95)\n @products_type[\"rockmelon\"].add_pack(5, 9.95)\n @products_type[\"rockmelon\"].add_pack(9, 16.99)\n end",
"def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend",
"def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend",
"def check_instance_equips(equips)\n new_equips = []\n equips.each_with_index do |item_id, i|\n etype_id = index_to_etype_id(i)\n slot_id = empty_slot(etype_id)\n if etype_id == 0\n equip = $data_weapons[item_id]\n else\n equip = $data_armors[item_id]\n end\n new_equips << InstanceManager.get_instance(equip)\n end\n return new_equips.collect {|obj| obj ? obj.id : 0}\n end",
"def get_energia_proteins\n\t\t\t\t@proteins * 4\n\t\t\tend",
"def new_input_set()\n return ElectricityUseInputSet.new()\n end",
"def reset_equipments\n floors.each{ |floor| floor.reset_equipments }\n end",
"def dumpAugmented\n item_fields = []\n Item.fields.keys.each do |field_name|\n if field_name[0]!='_' && !(field_name.include? \"image\")\n item_fields.push(field_name)\n end\n end\n item_fields.push(\"_SKU\")\n field_list = [\"student_id\",\"email\",\"start_date\",\"end_date\"]\n header = [\"Student ID\",\"Email\",\"Pick-up date\", \"Due date\",\"Returned on\"]\n all_items = Item.all\n CSV.generate(headers: true) do |csv|\n all_items.each do |item|\n # First Item detail\n csv << [\"Item Details\"]\n csv << item_fields\n csv_arr = []\n item_fields.each do |f_name|\n csv_arr.push(item[f_name])\n end\n csv << csv_arr\n # Now add transactions\n item_transactions = item.transactions\n if (item_transactions.count > 0)\n csv << [\"Item transactions\"]\n csv << header\n item_transactions.each do |transaction|\n csv_arr = []\n field_list.each do |f_name|\n csv_arr.push(transaction[f_name])\n end\n rt_date = (transaction.status) ? transaction.return_date : \"Not returned Yet!\"\n csv_arr.push(rt_date)\n csv << csv_arr\n end\n end\n\n # Now add reservations\n item_reservations = item.reservations\n if (item_reservations.count > 0 )\n csv << [\"Item reservations\"]\n csv << header[0,header.size-1]\n item_reservations.each do |reserve|\n csv_arr = []\n field_list.each do |f_name|\n csv_arr.push(reserve[f_name])\n end\n csv << csv_arr\n end\n end\n csv << []\n end\n end\n end",
"def voivodeship\n fetch_sample(VOIVODESHIP)\n end",
"def generate_data\n\t\tgenerate_stations\n\t\tgenerate_demands\n\tend",
"def create_full_product\n generate_product_name\n generate_product_code\n generate_product_manufacturer\n generate_product_description\n generate_product_price\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 get_dept\n \n DEPTS[Kernel.rand(DEPTS.length-1)].to_s\n\nend",
"def new_input_set()\n return PurchaseInputSet.new()\n end",
"def fetch_inventory\n @offer[:records] ||= Item.where(survivor_id: @offer[:survivor_id]).to_a\n @for[:records] ||= Item.where(survivor_id: @for[:survivor_id]).to_a\n end",
"def set_equip(is_weapon, item_id)\n @class = is_weapon ? RPG::Weapon : RPG::Armor\n @item_id = item_id\n end",
"def new_input_set()\n return EducationalOfferingsInputSet.new()\n end",
"def buyable_items(_entity)\n []\n end",
"def seed_data\n\n target_isolates = rand(20) + 5\n shipment = shipments.new({:target_isolates => target_isolates})\n\n base_objective = BaseObjective.parent_objectives.to_a.sample\n if base_objective.first == \"objective_b\"\n bacteria_type = {:bacteria_type => ObjectiveB::bacteria_type_values.sample.last}\n code_prefix = bacteria_type.values.last\n end\n\n objective = base_objective.last\n\n starting_code = starting_code_for(objective, code_prefix ||= nil)\n\n shipment.target_isolates.times do |x|\n parent_objective = objective.new(bacteria_type ||= {})\n \n code_number = parent_objective.code_prefix+\"#{(starting_code + x + 1)}\"\n\n isolate = shipment.isolates.new({code_number: code_number})\n isolate.parent = parent_objective\n isolate.save\n end\n\n shipment.update_attribute(:objective_name, \"#{objective.name} #{objective.new(bacteria_type ||= {}).name}\")\n\n end",
"def ranged_weapon; end",
"def create_potions\n potion = Potion.create(name: 'Basic Healing Potion', heal_amount: 10, cost: 10, :merchant_id => self.id)\n\n potion1 = Potion.create(name: 'Superior Healing Potion', heal_amount: 25, cost: 20, :merchant_id => self.id)\n\n potion2 = Potion.create(name: 'Full Heal Potion', heal_amount: 50, cost: 45, :merchant_id => self.id )\n\n end",
"def set_equip(is_weapon, item_id)\r\n @class = is_weapon ? RPG::Weapon : RPG::Armor\r\n @item_id = item_id\r\n end",
"def build_deck\n CARD_SUITS.product(CARD_VALUES).shuffle\nend",
"def load_equipment(object, game_objects)\n\n if not object.respond_to? :equipment\n #log \"#{object} has no equipment\"\n return\n end\n\n load_inv(object.equipment, game_objects)\n object.equipment.each do |o|\n o.info.equipment_of = object.goid\n end\n end",
"def of_generate_offer\n supplier = params[:supplier]\n request = params[:request]\n offer_no = params[:offer_no]\n offer_date = params[:offer_date] # YYYYMMDD\n offer = nil\n offer_item = nil\n code = ''\n\n if request != '0'\n offer_request = OfferRequest.find(request) rescue nil\n offer_request_items = offer_request.offer_request_items rescue nil\n if !offer_request.nil? && !offer_request_items.nil?\n # Format offer_date\n offer_date = (offer_date[0..3] + '-' + offer_date[4..5] + '-' + offer_date[6..7]).to_date\n # Try to save new offer\n offer = Offer.new\n offer.offer_no = offer_no\n offer.offer_date = offer_date\n offer.offer_request_id = offer_request.id\n offer.supplier_id = supplier\n offer.payment_method_id = offer_request.payment_method_id\n offer.created_by = current_user.id if !current_user.nil?\n offer.discount_pct = offer_request.discount_pct\n offer.discount = offer_request.discount\n offer.project_id = offer_request.project_id\n offer.store_id = offer_request.store_id\n offer.work_order_id = offer_request.work_order_id\n offer.charge_account_id = offer_request.charge_account_id\n offer.organization_id = offer_request.organization_id\n if offer.save\n # Try to save new offer items\n offer_request_items.each do |i|\n offer_item = OfferItem.new\n offer_item.offer_id = offer.id\n offer_item.product_id = i.product_id\n offer_item.description = i.description\n offer_item.quantity = i.quantity\n offer_item.price = i.price\n offer_item.tax_type_id = i.tax_type_id\n offer_item.created_by = current_user.id if !current_user.nil?\n offer_item.project_id = i.project_id\n offer_item.store_id = i.store_id\n offer_item.work_order_id = i.work_order_id\n offer_item.charge_account_id = i.charge_account_id\n if !offer_item.save\n # Can't save offer item (exit)\n code = '$write'\n break\n end # !offer_item.save?\n end # do |i|\n # Update totals\n offer.update_column(:totals, Offer.find(offer.id).total)\n else\n # Can't save offer\n code = '$write'\n end # offer.save?\n else\n # Offer request or items not found\n code = '$err'\n end # !offer_request.nil? && !offer_request_items.nil?\n else\n # Offer request 0\n code = '$err'\n end # request != '0'\n if code == ''\n code = I18n.t(\"ag2_purchase.offers.generate_offer_ok\", var: offer.id.to_s)\n end\n @json_data = { \"code\" => code }\n render json: @json_data\n end",
"def armor_set\n armor_ids = armors.compact.map{|a| a.real_id}\n SETS::Armors.select{|k,v| (v - armor_ids).empty? }.map{ |a| a[0] }.max\n end"
] |
[
"0.68341446",
"0.6678514",
"0.6005648",
"0.5975926",
"0.5968161",
"0.57080483",
"0.56052655",
"0.55645406",
"0.55605036",
"0.555093",
"0.5427449",
"0.5399112",
"0.53962564",
"0.5353751",
"0.5332548",
"0.53034526",
"0.53031844",
"0.52937335",
"0.52871126",
"0.52815944",
"0.5276818",
"0.52305436",
"0.5218801",
"0.52144474",
"0.5198543",
"0.5190667",
"0.5150122",
"0.51409346",
"0.51326233",
"0.5113326",
"0.50825185",
"0.5056217",
"0.5007535",
"0.49964797",
"0.4978384",
"0.49758667",
"0.49615076",
"0.495673",
"0.495673",
"0.495673",
"0.495673",
"0.49257997",
"0.49128404",
"0.4893549",
"0.48919815",
"0.48918253",
"0.48791468",
"0.48763204",
"0.48699018",
"0.48627913",
"0.4861623",
"0.48531085",
"0.48427266",
"0.4837256",
"0.4835682",
"0.48341504",
"0.48246586",
"0.48227507",
"0.48187447",
"0.48183724",
"0.48044354",
"0.47991046",
"0.47958955",
"0.47945923",
"0.47943285",
"0.47914153",
"0.47806898",
"0.47744972",
"0.47709754",
"0.4760952",
"0.4749355",
"0.47471568",
"0.47425205",
"0.47418845",
"0.47377604",
"0.47326523",
"0.47326523",
"0.47135925",
"0.47129965",
"0.47129822",
"0.47095",
"0.4706708",
"0.46980047",
"0.46952975",
"0.4686604",
"0.46662262",
"0.46593916",
"0.4648276",
"0.46423265",
"0.46393824",
"0.46374923",
"0.46362448",
"0.46253902",
"0.46235907",
"0.46220276",
"0.4620724",
"0.46198142",
"0.46121487",
"0.4612037",
"0.46064612"
] |
0.6074233
|
2
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set Complete? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def maesb_set_complete?(maesb_equips)
maesb_sets.each { |set| return true if set && set.set_complete?(maesb_equips) }
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_as_complete\n mark_as_complete_and_save\n end",
"def complete?; end",
"def mark_complete\n self.complete = true\n self.save\n end",
"def mark_as_complete_and_save\n self.complete = true\n save\n end",
"def complete!\n @completed = true\n @completed_at = Time.now\n end",
"def completed_it\n self.complete = true\n end",
"def complete\n end",
"def complete?\n true\n end",
"def complete?\n end",
"def complete?\n true\n end",
"def incomplete!\r\n @is_complete = false\r\n end",
"def completed\n @status = 'complete'\n end",
"def complete!\n self.completed = true\n self.completed_at = Time.now.utc\n save! # TODO: With a bang?\n end",
"def update_done\n self.done = true if COMPLETE_STATUSES.include? self.detailed_status\n end",
"def complete?\n true\n end",
"def complete?\n true\n end",
"def complete\n nil\n end",
"def complete\n nil\n end",
"def complete!\n self.is_completed = true\n self.save\n end",
"def complete?\n @complete\n end",
"def set_complete?(eqps = [])\n itms = items\n !itms.empty? && ((itms & eqps).size == itms.size)\n end",
"def complete?\n @complete\n end",
"def complete?\n self.status == STATUS[:complete] \n #self.status == 1\n end",
"def complete!\n # this should change the boolean to true\n self.complete = true\n self.save!\n end",
"def complete!\n self.update_attribute(:is_completed, true)\n # TODO: send an email to teacher about taks completion\n end",
"def mark_complete\n if self.completed\n self.progress = \"COMP\"\n self.progress_percentage = \"100\"\n elsif self.progress and !self.progress.eql?('COMP') and self.progress_percentage\n self.progress = self.progress\n self.progress_percentage = self.progress_percentage\n else\n self.progress = \"INPR\"\n self.progress_percentage = \"0\"\n end\n end",
"def mark_task_complete\n system \"clear\"\n # If task was set\n\n loop do\n task = get_task_choice(\"mark complete\")\n if task && task != :back\n task.status = :completed\n\n system \"clear\"\n display_tasks(:completed)\n display_tasks(:failed)\n\n # Cancel notifications\n task.cancel_reminder_notification\n task.cancel_failed_notification\n\n puts \"Congratulations on completing this task!\".light_white\n break unless CLI.agree(\"\\nMark another task complete? (y/n)\".light_white)\n else\n break\n end\n end\n end",
"def complete!\n @completed_at = Time.now\n end",
"def complete!\n @completed_at = Time.now\n end",
"def setCompleted(completed)\r\n\t\t\t\t\t@completed = completed\r\n\t\t\t\tend",
"def setCompleted(completed)\r\n\t\t\t\t\t@completed = completed\r\n\t\t\t\tend",
"def mark_state_complete!\n get[state.to_s] = :complete\n end",
"def complete?\n complete == true\n end",
"def completed()\n @completed=true\n @tCompleted=Time.now\n end",
"def check_completion_status\n\t\trace = Race.find_by_id(self.race_id)\n\t\treturn if (race.nil?)\n\t\t\n\t\tself.is_complete = race.is_complete \n\t\tself.save\n\tend",
"def markDone\n if @complete == \"Item incomplete\"\n @complete = \"Item complete\"\n else\n @complete = \"Item complete\"\n end\n end",
"def complete?\r\n @is_complete\r\n end",
"def complete?\n false\n end",
"def complete!\n self.status = 'completed'\n self.save\n end",
"def complete\n self.dup.complete!\n end",
"def complete?\n self.complete\n end",
"def mark_as_completed!\n mark_state_complete!\n end",
"def complete\n self.update_attribute('state', 'complete')\n end",
"def set_complete\n @complete = Complete.find(params[:id])\n end",
"def check_completed\n\t\tend",
"def mark_as_complete(options)\n self.is_complete = options[:is_complete]\n self.is_applicable = true # if item.is_complete\n self.save_with_validation(false)\n end",
"def complete!\n return if completed?\n self.status = \"complete\"\n self.stop = Time.now.to_s\n end",
"def complete\n @status = :ok\n do_stop\n log_complete\n end",
"def check_if_complete(card)\t\n\t\tif @cards.has_value?(4)\n\t\t\tcompleted_card = card\n\t\t\t@complete_sets.push(completed_card)\n\t\t\tremove_set_from_hand(completed_card)\n\t\tend\n\n\tend",
"def complete?\n return state == \"complete\"\n end",
"def all_complete\n self.tasks.count == self.tasks.done.count\n end",
"def test_complete?\n assert(@LiarHand.complete? == true, 'Hand for <LiarHand> expected to be full but wasnt.')\n assert(@IdiotHand.complete? == true, 'Hand for <IdiotHand> expected to be full but wasnt.')\n\n assert(@LightHand.complete? == true, 'Hand for <LightHand> expected to be full but wasnt')\n assert(@SpiderHand.complete? == true, 'Hand for <SpiderHand> expected to be full but wasnt')\n end",
"def completed\n @completed ||= count('completed')\n end",
"def set_done\n @done = true\n end",
"def complete?\n !incomplete?\n end",
"def complete?\n !incomplete?\n end",
"def complete?\n\tstatus == \"Completed\"\n end",
"def complete?\n status == \"Completed\"\n end",
"def set_complete_incomplete\n @tasks_incomplete = @tasks.where(\"completed = 'f'\").order('tasks.created_at DESC')\n @tasks_complete = @tasks.where(\"completed = 't'\").order('tasks.created_at DESC')\n end",
"def complete!\n status \"Success\"\n self\n end",
"def complete!\n load_attributes_from_response(post(:complete))\n end",
"def mask_as_done!\n @completed = true\n end",
"def mark_complete(db, complete, name)\n\tcomplete = \"complete\"\n\tdb.execute(\"UPDATE upper_body SET complete=? WHERE name=?\", [complete, name])\n\tdb.execute(\"UPDATE lower_body SET complete=? WHERE name=?\", [complete, name])\n\tputs \"set #{name} to complete\"\nend",
"def setup_complete\n puts green(\"Setup complete\")\n end",
"def complete?\n self.state == 'complete'\n end",
"def marked_as_complete?\n get[state.to_s] and get[state.to_s].to_sym == :complete\n end",
"def converge_complete\n end",
"def completed\n end",
"def complete\n raise NotImplementedError\n end",
"def set_complete(name)\n\t\tif index = find_index(name)\n\t\t\ttodo_items[index].set_complete!\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def update_complete\n # checks to see if the Item's :complete attribute is true\n if self.complete\n # if complete is arleady true, then update it to false\n self.update_attribute(:complete, false)\n else\n # if complete is already false(which is usually the case since the attribute has\n # a default value of false making it incomplete) update the complete attribute to\n # true. This will allow the user to toggle between complete and incomplete items in\n # their respective lists. \n self.update_attribute(:complete, true)\n end\n end",
"def complete\n synchronize do\n return if complete?\n\n @is_final_state = true\n @final_time = Time.now\n end\n end",
"def possibly_set_as_completed\n # this is a guard against setting something completed that isn't and that will make this method fail\n return false unless available_in_merritt? # this also sets @mrt_results member variable so we don't have to redo the query again\n\n merritt_id = \"#{APP_CONFIG[:repository][:domain]}/d/#{@mrt_results['ark']}\"\n StashEngine.repository.harvested(identifier: resource.identifier, record_identifier: merritt_id)\n\n if StashEngine::RepoQueueState.where(resource_id: resource_id, state: 'completed').count < 1\n StashEngine.repository.class.update_repo_queue_state(resource_id: resource_id, state: 'completed')\n end\n\n update_size!\n ::StashEngine.repository.cleanup_files(resource)\n true\n end",
"def completion_aspect\n true_value = \"Completed\"\n false_value = \"Incomplete\"\n self.complete ? true_value : false_value\n end",
"def complete? c\n c.complete?\n end",
"def mark_done\n @done = true\n end",
"def setDone\n @done = Time.now\n end",
"def setPercentComplete(percentComplete)\r\n\t\t\t\t\t@percentComplete = percentComplete\r\n\t\t\t\tend",
"def completed()\n end",
"def complete!\n raise NotImplementedError\n end",
"def incomplete?\r\n !complete?\r\n end",
"def update_completed? ; false ; end",
"def flag_completion\n @completion_flagged = !@completion_flagged\n end",
"def complete?\n keys.all?(&:complete?)\n end",
"def incomplete?\n !@complete\n end",
"def completed=(value)\n return @completed = value\n end",
"def mark_as_done!\n @done = true\n end",
"def completed?\n attributes['percentDone'] >= 1\n end",
"def set_transaction_complete_flag()\n @is_transaction_complete = true\n end",
"def completed\n proptime 'COMPLETED'\n end",
"def complete\n authorize Test\n @tests = Test.by_lab(@lab).joins(:plate).where(plates: { state: Plate.states[:complete] })\n end",
"def validate_user_complete_update\n\t\tself.complete = User::user_complete_validation(self)\n\tend",
"def complete!\n update_attributes(completed_at: Time.now)\n pause! if running?\n end",
"def is_complete?\n self.audit_state == AUDIT_COMPLETE\n end",
"def is_complete?\n # puts @xml.root.attributes['complete']\n xml = Document.new(File.open(@xmlfile))\n return 'yes' == xml.root.attributes['complete']\n end",
"def completed=(values)\n self.value = values.first\n end",
"def mark_as_done\n @is_done = true\n end",
"def complete?\n status_code == 'OK'\n end",
"def mark_as_completed\n completed_at.nil? ? self.completed = true : errors.add(:completed, '- This task has already been completed!')\n end",
"def incomplete?\n !complete? && status != 'unknown'\n end",
"def mark_as_done!\n @status = :finished\n end"
] |
[
"0.7429153",
"0.6970775",
"0.6965546",
"0.6938573",
"0.6916579",
"0.6851977",
"0.6825764",
"0.67574567",
"0.66737837",
"0.6659592",
"0.6612763",
"0.65987337",
"0.65907615",
"0.6567258",
"0.65655744",
"0.65655744",
"0.65529007",
"0.65529007",
"0.65388346",
"0.6531535",
"0.6527179",
"0.65236616",
"0.6517029",
"0.6511516",
"0.64919704",
"0.6485814",
"0.64771706",
"0.64393085",
"0.64393085",
"0.64384013",
"0.64384013",
"0.64123565",
"0.641216",
"0.6405445",
"0.64051116",
"0.6403962",
"0.63820255",
"0.63677084",
"0.63653255",
"0.6351459",
"0.6351054",
"0.63380927",
"0.6324979",
"0.63190657",
"0.63036805",
"0.62984675",
"0.6254146",
"0.62169677",
"0.62163115",
"0.62144923",
"0.62107605",
"0.6209948",
"0.6184947",
"0.61689454",
"0.6168133",
"0.6168133",
"0.6164762",
"0.6156663",
"0.6156631",
"0.6149134",
"0.61319566",
"0.6121488",
"0.61188555",
"0.6113529",
"0.60821474",
"0.6076003",
"0.6075759",
"0.60514796",
"0.6050962",
"0.60370344",
"0.60331774",
"0.60309696",
"0.6022363",
"0.6019026",
"0.6010594",
"0.60099804",
"0.5993803",
"0.59919196",
"0.59815735",
"0.5970156",
"0.5956721",
"0.5949743",
"0.59403783",
"0.59133476",
"0.59054935",
"0.5867196",
"0.5861347",
"0.5859945",
"0.5854654",
"0.58536047",
"0.5851706",
"0.5812355",
"0.5802038",
"0.5792442",
"0.57899165",
"0.578785",
"0.5785138",
"0.57736456",
"0.57711583",
"0.576901",
"0.5762816"
] |
0.0
|
-1
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equipment Sets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def maesb_generate_equipment_sets
# Generate Equipment Sets
($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }
# Update items to refer to the set to which they belong
set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }
set_items.each { |set_item|
set_item.maesb_sets.collect {|set| set.items }.flatten.uniq.each { |equip|
equip.maesb_belongs_to_sets.push(set_item.id)
}
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def maesb_generate_equip_set\n @maesb_belongs_to_sets = []\n end",
"def maesb_generate_equip_set\n super\n @maesb_sets = note.scan(/\\\\SET\\s*\\[(.+?)\\]/i).collect { |set_s| \n MAESB_EquipmentSet.new(set_s[0]) }\n end",
"def generate_demands\n\t\n\t\tcase @inputs.generation_method\n\t\twhen 'Centroïd'\n\t\t\n\t\t\tnbCreatedDemands = 1\n\t\t\t(1..@inputs.nb_demands).each do |idDemand|\n\t\t\t\t\n\t\t\t\t# Find a time\n\t\t\t\trt = generate_random_time\n\t\t\t\t\n\t\t\t\t# Find 2 stations for that time\n\t\t\t\tstation_O, station_D = pickTwoStations(rt)\n\t\t\t\t\n\t\t\t\t# Demand creation\n\t\t\t\ttravelTime = calculate_TravelTime_TS(station_O, station_D, rt)\n\t\t\t\tarrivalTime = (rt + travelTime) % @nbTSInOneDay \n\t\t\t\t\n\t\t\t\tdemandAlreadyExists = false\n\t\t\t\t@list_demands.each do |d| # if the demand already exists, just increase its internal demand by 1\n\t\t\t\t\tif(d.sOrigin == station_O && d.sDestination == station_D && d.departureTime_TS == rt)\n\t\t\t\t\t\td.increaseDemandBy(1)\n\t\t\t\t\t\tdemandAlreadyExists = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tunless(demandAlreadyExists) # create a new demand if it does not exist\n\t\t\t\t\t@list_demands.push(CS_demand.new(nbCreatedDemands, station_O, station_D, rt, arrivalTime))\n\t\t\t\t\tnbCreatedDemands += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\n\t\twhen 'Uniform'\n\t\telse \n\t\tend\n\tend",
"def generate_data\n\t\tgenerate_stations\n\t\tgenerate_demands\n\tend",
"def prepare_all\n reservations = []\n @items.each do |id, quantity|\n quantity.times do\n reservations << Reservation.new(reserver: reserver,\n start_date: @start_date,\n due_date: @due_date,\n equipment_model_id: id)\n end\n end\n reservations\n end",
"def equipment_list\n [\n \"Backhoe\",\n \"Bobcat\",\n \"Compactor\",\n \"Compactor 815\",\n \"Compactor 815F\",\n \"Compactor 825G\",\n \"Compactor 825H\",\n \"Crane\",\n \"Dozer-D3\",\n \"Dozer-D6\",\n \"Dozer D6M Swamp\",\n \"Dozer D6R Swamp\",\n \"Dozer D6T XL\",\n \"Dozer-D6H\",\n \"Dozer-D65\",\n \"Dozer - D6C\",\n \"Dozer - D6R\",\n \"Dozer - D6R Xl\",\n \"Dozer - D7\",\n \"Dozer - D7H\",\n \"Dozer - D8\",\n \"Dozer - D9T\",\n \"Dozer R -D9\",\n \"Dump Truck 25T\",\n \"Dump Truck 30T\",\n \"Dump Truck 40T\",\n \"Dump Truck 50T\",\n \"Drott 9T\",\n \"Drott 8T\",\n \"Drott\",\n \"Excavator\",\n \"EXC 8T\",\n \"EXC 12-22T \",\n \"EXC 12T\",\n \"EXC 13T\",\n \"EXC13.5T\",\n \"EXC 14T\",\n \"EXC 15T\",\n \"EXC 17T WHEELED\",\n \"EXC 18T\",\n \"EXC 20-29T\",\n \"EXC 20T WHEELED\",\n \"EXC 20T\",\n \"EXC 20T \",\n \"EXC 20T 8T 12\",\n \"EXC 22T\",\n \"EXC 24T\",\n \"EXC 25T\",\n \"EXC 30T\",\n \"EXC 35T\",\n \"EXC 40T\",\n \"EXC 45T\",\n \"EXC 60T\",\n \"EXC 4.5T \",\n \"EXC 4T\",\n \"EXC 3.5T\",\n \"EXC 3T COMBO\",\n \"EXC 3T\",\n \"EXC 5T\",\n \"EXC 5T COMBO\",\n \"EXC 5T \",\n \"EXC 5.5T\",\n \"EXC 5-10T\",\n \"EXC 5-30T\",\n \"EXC 5T & 6T\",\n \"EXC 6T\",\n \"EXC 6T \",\n \"EXC 7.5T\",\n \"EXC 7.5T \",\n \"EXC 8T \",\n \"Float\",\n \"Grader 12G 140H\",\n \"Grader\",\n \"IT Loader\",\n \"Loader\",\n \"Moxy Dump\",\n \"Moxy Dump 20T\",\n \"Moxy Dump 25T\",\n \"Moxy Dump 30T\",\n \"Posi Track\",\n \"Pug Mill\",\n \"Roller Pad SF\",\n \"Roller Smooth\",\n \"Roller 12T\",\n \"Roller\",\n \"Roller 14T\",\n \"Roller Smooth 12T\",\n \"Roller Pad SF 12T\",\n \"Roller Pad\",\n \"Roller Pad SF 16T\",\n \"Scraper 633\",\n \"Scraper 623E\",\n \"Scraper\",\n \"Screening Plant\",\n \"Semi\",\n \"Semi/T & T\",\n \"Semi Tipper\",\n \"Sweeper\",\n \"Tilt Tray\",\n \"Truck\",\n \"Truck & 3 Axle Trailer\",\n \"Truck & 4 Axle Trailer\",\n \"Truck & Dog\",\n \"Watercart\"\n ]\n end",
"def make_cartesian\n #asks for name of the first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates the desired set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if not found, ends the method\n return 0\n end\n #asks for name of second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates desired set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if not ends the method\n return 0\n end\n\n #asks the user to name the new set\n puts \"Enter name for cartesian set:\"\n newsetname = gets\n #for loop iterates through current sets \n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == newsetname.chomp\n #if a set already has that name it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n\n #creates new set by instantiating the cartesian method from the first set, and passing the other set as a parameter\n cartset = set1.cartesian(set2, newsetname.chomp)\n #adds new set to the list of current sets\n $current_sets.push(cartset)\n puts \"Cartesian Product set created!\"\nend",
"def sets\n end",
"def prepare_equipment\n show do\n title 'Gather materials'\n check 'Fill 2 buckets with ice.'\n check \"Get the 24-well aluminum block out of the 4 #{DEGREES_C}\" \\\n 'refrigerator and place it in one of the ice buckets.'\n check \"Set the refigerated centrifuge to 4 #{DEGREES_C}.\"\n end\n end",
"def create_item_sets\n threshold = @baskets.rows.length * Settings::CONFIG.support_threshold\n singletons = []\n\n @item_counts.each_with_index do |support, item_id|\n if support && support >= threshold\n singletons << ItemSet.new([item_id], support) \n end\n end\n\n singletons\n end",
"def get_sets\n result = []\n (0..(TAILLE_TAPIS + TAILLE_EXT*self.etendu - 3)).each do |a|\n ((a + 1)..(TAILLE_TAPIS + TAILLE_EXT*self.etendu - 2)).each do |b|\n ((b + 1)..(TAILLE_TAPIS + TAILLE_EXT*self.etendu - 1)).each do |c|\n if (is_a_set?([self.talon[self.tapis[a]], self.talon[self.tapis[b]], self.talon[self.tapis[c]]]))[0]\n result << [a, b, c]\n end\n end\n end\n end\n result\n end",
"def create_generations\n @generations.each do |g|\n create_generation(g) unless Generation.find_by(name: g['name'])\n end\n end",
"def create_machines\n i = 1\n self.machines = []\n status = MachineStatus.find_by_name(\"bookable\")\n\n while i <= @count.to_i\n name = sprintf \"%s%0.2d\", self.name.downcase, i\n self.machines << Machine.new({ :name => name,\n :description => @machine_description,\n :machine_status => status\n })\n i += 1\n end \n end",
"def sets\n return [EscholSet.new({name: \"everything\", spec: \"everything\"})]\n end",
"def make_and_model\n\tfor i in 0...@manufacturers.count\n\t\tputs \"#{i}. #{@manufacturers[i]}: #{@models[i]}\"\n\t\ti += 1\n\tend\nend",
"def sku_combination_creation\n end",
"def generate_event_set(events)\n usable_events = self.find_usable_events(events)\n self.new_event_set(usable_events)\n end",
"def assign_wares\n create_weapons \n create_armors\n create_potions\n end",
"def get_clean_inventory(data_set)\n\t\tclean_inventory = @helpers.make_hoa\n\n\t\tdata_set.each do |item_info|\n\t\t\tif item_info.has_key?(:type)\n\t\t\t\titem_type = item_info.delete(:type)\n\t\t\t\tclean_inventory[item_type].push(item_info)\n\t\t\telse\n\t\t\t\tputs \"Skipping, invalid item, missing type\"\n\t\t\tend\n\t\tend\n\n\t\treturn clean_inventory\n\tend",
"def create_Ants\n while @food > 0\n create_random_Ant\n create_Ant_Room\n end\n \n end",
"def generate_first_sets\n @grammar.each do |variable, _|\n generate_first_set variable\n end\n end",
"def generate_n_sets(array, number_of_sets)\n\nend",
"def generate_alltestc\n\n end",
"def generate_tables\n create_characters\n create_kiosks\n create_traps\n create_buttons\n end",
"def all_selectable_materials\n categories = Category.order(\"depth ASC \")\n \n # MATERIAL = {\n # :steel => {\n # :value => 1, \n # :name => \"Steel\" \n # } ,\n # :copper => {\n # :value => 2, \n # :name => \"Tembaga\"\n # }, \n # :alumunium => {\n # :value => 3, \n # :name => \"Aluminium\"\n # }\n # }\n # \n \n result = []\n MATERIAL.each do |material| \n result << [ \"#{category.name}\" , \n category.id ] \n end\n return result\n end",
"def storage_equip_items\n storage_weapons + storage_armors\n end",
"def create_tag_sets\n FactoryGirl.create(:tag, name: 'e0_out_of_business')\n FactoryGirl.create(:tag, name: 'e1_existence_doubtful')\n FactoryGirl.create(:tag, name: 'e2_existence_unknown')\n FactoryGirl.create(:tag, name: 'e3_existence_confirmed')\n\n FactoryGirl.create(:tag, name: 'n1_no_contact')\n FactoryGirl.create(:tag, name: 'n5_signed_only')\n FactoryGirl.create(:tag, name: 'n6_signedAndNDAd')\n\n FactoryGirl.create(:tag, name: 'b0_none_sent')\n\n FactoryGirl.create(:tag, name: 'datadump')\nend",
"def print_all_combinations(selected_set, left_over_set)\ndebug(\"first #{selected_set} - left over #{left_over_set}\")\n left_over_set.each do |left_over|\n save(selected_set + [left_over])\n end\nend",
"def bulk_generate\n\n end",
"def create_set\n x = 1\n while Dir.exists?(File.join(@path, \"Packages Set %d\" % x)) do\n x = x.next\n end\n\n package_set = File.join(@path, \"Packages Set %d\" % x)\n Dir.mkdir(package_set)\n end",
"def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend",
"def generate_primer_id_pool(l=8)\n nt = ['A','T','C','G']\n pid_pool = ['A','T','C','G']\n (l-1).times do\n pid_pool = pid_pool.product(nt)\n pid_pool.collect! do |v|\n v.join(\"\")\n end\n end\n return pid_pool\nend",
"def populate\n entity_count = gets.to_i\n entity_count.times do\n unit_id, team, unit_type, *unit_charac = gets.split(' ')\n\n create_unit(unit_id, team, unit_type, unit_charac)\n end\n end",
"def populate\n entity_count = gets.to_i\n entity_count.times do\n unit_id, team, unit_type, *unit_charac = gets.split(' ')\n\n create_unit(unit_id, team, unit_type, unit_charac)\n end\n end",
"def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end",
"def population(starting_set)\n starting_set = starting_set.to_s if starting_set.is_a?(Symbol)\n p = Population.find_or_initialize_by_populatable_type_and_populatable_id_and_starting_set_and_conditions_counter(\n \"Offering\", self.id, starting_set, 0)\n if p.new_record?\n p.title = \"#{self.title}: #{starting_set.titleize}\"\n until p.valid? && !p.errors.on(:title)\n if p.title[/\\d+$/].nil?\n p.title += \" 2\"\n else\n new_num = p.title[/\\d+$/].to_i + 1\n p.title.gsub!(/\\d+$/, new_num.to_s)\n end\n end \n p.system = true\n p.description = \"Automatically generated by Offering ##{self.id} from starting set '#{starting_set}'\"\n p.access_level = \"everyone\"\n p.save\n end\n p\n end",
"def new_set\r\n @sets[@current_set_name] = @current_set\r\n @current_set = []\r\n end",
"def make_item_list\n @data = equips_for_enchant\n end",
"def createSuppliesPackage\n supplies1 = SuppliesPackage.new(2,3,5)\n supplies2 = SuppliesPackage.new(4,5,6)\n supplies3 = SuppliesPackage.new(7,8,9)\n \n supplies = [supplies1,supplies2,supplies3]\n return supplies\n end",
"def prepare_materials(ops, composition)\n # ops.each do |op|\n # add_hidden_input(op, DYE_SAMPLE, dye)\n # add_hidden_input(op, POLYMERASE_SAMPLE, polymerase)\n # end\n\n templates = ops.map { |op| op.input(TEMPLATE).item }\n\n fwd_primers = get_primer_set(ops, FORWARD_PRIMER)\n rev_primers = get_primer_set(ops, REVERSE_PRIMER)\n\n items_to_take = [templates, fwd_primers, rev_primers]\n\n if composition.polymerase.item\n items_to_take << composition.polymerase.item\n end\n\n if composition.dye.item\n items_to_take << composition.dye.item\n end\n\n take(items_to_take.flatten, interactive: true, method: 'boxes')\n\n vortex_samples([fwd_primers, rev_primers, templates])\n end",
"def create_fuel_tech(input,output)\n\n #find_or_create commodities\n com = {}\n [input,output].each do |c|\n if Commodity.where(:name=>c).empty?\n com[c] = Commodity.create(:name=>c,:description=>\"\",:set_list=>\"ENC,C\")\n else\n com[c] = Commodity.find_by_name(c)\n end\n end\n\n #check if a fuel tech already exists?\n if (com[input].consumed_by & com[output].produced_by).size > 0\n return nil\n end\n\n t = Technology.new\n name = \"TECH-\" + output\n while Technology.find_by_name(name)\n name.succ!\n end\n t.name = name\n t.description = \"Fuel tech\"\n t.set_list = \"FUELTECH,P\"\n t.save\n fi = InFlow.create\n fi.commodities << com[input]\n t.flows << fi\n fo = OutFlow.create\n fo.commodities << com[output]\n t.flows << fo\n t.save\n p = Parameter.find_by_name(\"eff_flo\")\n ParameterValue.create(:parameter => p,\n :technology => t,\n :in_flow =>fi,\n :out_flow =>fo,\n :value => 1,\n :source => \"Fuel tech\")\n t.flow_act = fi\n t\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 generate_patients\n base_patients = [Generator.create_base_patient]\n generated_patients = []\n \n # Gather all available populations. Each kind of population (e.g. IPP, DENOM) can have many multiples (e.g. IPP_1, IPP_2)\n populations = []\n [\"IPP\", \"DENOM\", \"NUMER\", \"EXCL\", \"DENEXCEP\"].each do |population|\n i = 1\n populations << population\n while Generator.hqmf.population_criteria(\"#{population}_#{i}\").present? do\n populations << \"#{population}_#{i}\"\n i += 1\n end\n end\n\n populations = [\"EXCL_1\"]\n\n populations.each do |population|\n criteria = Generator.hqmf.population_criteria(population)\n \n # We don't need to do anything for populations with nothing specified\n next if criteria.nil? || !criteria.preconditions.present?\n criteria.generate(base_patients) \n \n # Mark the patient we just created with its expected population. Then extend the Record to be augmented by the next population.\n base_patients.collect! do |patient|\n patient.elimination_population = population\n generated_patients.push(Generator.finalize_patient(patient))\n Generator.extend_patient(patient)\n end\n end\n \n generated_patients\n end",
"def list_sets\n puts \"Available sets:\"\n #loops through $current_sets and displays the name of each set\n i=0\n for i in 0..$current_sets.length-1\n puts $current_sets[i].setname\n end\nend",
"def create_recommendable_sets\n [create_liked_by_set, create_disliked_by_set]\n end",
"def create_recommendable_sets\n [create_liked_by_set, create_disliked_by_set]\n end",
"def create_recommendable_sets\n [create_liked_by_set, create_disliked_by_set]\n end",
"def mk_products\n # create some test products\n @first_product = Product.create!(:name => \"Test product 1\")\n @second_products = Product.create!(:name => \"Test product 2\") \n @product_ids = Product.all.map(&:id)\n assert_equal(2,Product.all.size)\n [@first_product,@second_product]\n end",
"def generate_responsibilities\n set_positions\n set_team_members\n create_responsibilities\n\n\n\n assign_responsibilities\n\n # assign_team_members\n end",
"def generateproblems\n # First problem is unique\n # rand(0..1) picks a random problem from type 0 or 1\n # , 0) is the first problem\n types(rand(0..1), 0)\n (1..8).each do |i|\n types(rand(1..9), i)\n end\n types(10, 9)\n (10..18).each do |i|\n types(rand(1..9), i)\n end\n end",
"def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend",
"def make_new_set\n #prompts the user for the name of the file to create a set from\n puts \"Enter File name to create a new set. (Make sure the file is in the same directory as this program): \"\n #gets takes what the user types into the terminal\n filename = gets\n #checks if the file exists\n if File.exist?(filename.chomp)\n #if it does, read in every line of the file and store them in an array\n arr = IO.readlines(filename.chomp);\n else\n #if it does not, state this and exit the method\n puts \"File Does not exist!\"\n return 0;\n end\n\n #asks for a name for new set\n puts \"Name the set: \"\n #receives name entered by user and creates a new set based on the array of lines and the name entered\n setname = gets\n\n #for loop iterates through all existing sets in $current_sets\n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == setname.chomp\n # if any set has the same name as the specified set name, it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n\n newset=Set.new(arr, setname.chomp)\n #adds new set to $current_sets so it can be accessed later\n $current_sets.push(newset)\n puts \"Set created!\"\nend",
"def generate_resources\n [\n {\n :name => \"Weather Uppsala 1\",\n :description => \"Sensor which measures the weather in different places from Uppsala\",\n :manufacturer => \"Ericsson\",\n :model => \"ee80\",\n # :make => \"2\",\n # :serial_num => \"1234-ABCD-987\",\n # :polling_freq => \"60\",\n # :data_overview => \"data data data\",\n # :location => \"Uppsala, Sweden\",\n # :uri => \"http =>//sensors.ericsson.se\",\n :tags => \"temperature, weather, humidity, ericsson\",\n :resource_type => \"sensor\",\n :active => \"true\",\n :user_id => @cid\n },\n\n {\n :name => \"Weather Uppsala 2\",\n :description => \"Sensor which measures the weather in Uppsala\",\n :manufacturer => \"Ericsson\",\n :model => \"ef90\",\n # :make => \"2\",\n # :serial_num => \"5678-ABCD-987\",\n # :polling_freq => \"60\",\n # :resource_type => \"sensor\",\n # :data_overview => \"data data data\",\n # :location => \"Uppsala, Sweden\",\n # :uri => \"http =>//sensors.ericsson.se\",\n :tags => \"temperature, weather, humidity, ericsson\",\n :resource_type => \"sensor\",\n :active => \"true\",\n :user_id => @cid\n },\n\n {\n :name => \"Siemens si5\",\n :description => \"Sensor which measures the pollution\",\n :manufacturer => \"Siemens\",\n :model => \"s7\",\n # :make => \"1\",\n # :serial_num => \"1679-FGD-987\",\n # :polling_freq => \"60\",\n # :resource_type => \"sensor\",\n # :data_overview => \"data data data\",\n # :location => \"Stockholm, Sweden\",\n # :uri => \"http =>//sensors.siemens.se\",\n :tags => \"pollution, air, siemens\",\n :resource_type => \"sensor\",\n :active => \"true\",\n :user_id => @cid\n }\n ]\nend",
"def load_products\n @products_type[\"watermelon\"] = Creator.createProduct(:watermelon, \"watermelon\")\n @products_type[\"watermelon\"].add_pack(3, 6.99)\n @products_type[\"watermelon\"].add_pack(5, 8.99)\n\n @products_type[\"pineapple\"] = Creator.createProduct(:pineapple, \"pineapple\")\n @products_type[\"pineapple\"].add_pack(2, 9.95)\n @products_type[\"pineapple\"].add_pack(5, 16.95)\n @products_type[\"pineapple\"].add_pack(8, 24.95)\n\n @products_type[\"rockmelon\"] = Creator.createProduct(:rockmelon, \"rockmelon\")\n @products_type[\"rockmelon\"].add_pack(3, 5.95)\n @products_type[\"rockmelon\"].add_pack(5, 9.95)\n @products_type[\"rockmelon\"].add_pack(9, 16.99)\n end",
"def newDemandListForCycle()\n list = @innerFactory.newDemandListForCycle() ;\n list.each{|demand|\n selectParty().allocDemand(demand) ;\n }\n \n return list ;\n end",
"def element_set\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.element_set : []\n end",
"def generate_questions\n Question.destroy_all\n\n puts 'Generating photo questions'\n MULTIPLIER.times do\n Question.make_photo_question\n end\n\n puts 'Generating type questions'\n MULTIPLIER.times do\n Question.make_type_question\n end\nend",
"def newDemandListForCycle()\n list = [] ;\n @factoryList.each{|factory|\n sublist = factory.newDemandListForCycle() ;\n list.concat(sublist) ;\n }\n return list ;\n end",
"def generate_inventory(products, below_threshold = false, new_form_warehouse = false)\n products.each do |product|\n count = if new_form_warehouse\n 0\n elsif below_threshold\n rand(1..THRESHOLD_LIMIT - 1)\n else\n rand(THRESHOLD_LIMIT + 1..50)\n end\n inventory.create!(product: product, item_count: count, low_item_threshold: THRESHOLD_LIMIT)\n end\n end",
"def create_shifts\n\tself.shifts=[]\n\tif self.locations.size==0\n\t self.locations=self.area.locations\n\tend\n\tst=self.shifttimes \n \tst.each do |t|\n\t\tself.locations.each do |l|\n\t\t\n\t\t\tshift=Shift.new\n\t\t\tshift.location=l\n\t\t\tshift.start=t\n\t\t\tself.shifts << shift\n\t\tend\n \tend\n end",
"def reset_equipments\n floors.each{ |floor| floor.reset_equipments }\n end",
"def clear_equipments\n equip_slots.size.times do |i|\n change_equip(i, nil) if equip_change_ok?(i)\n end\n end",
"def create_armors \n armor = Armor.create(name: 'Light Armor', armor_rating: 5, cost: 0, :merchant_id => self.id)\n\n armor1 = Armor.create(name: 'Medium Armor', armor_rating: 10, cost: 15, :merchant_id => self.id)\n\n armor2 = Armor.create(name: 'Dragonbone Armor', armor_rating: 15 , cost: 45, :merchant_id => self.id )\n\n end",
"def create_dependencies\n create_course_bin()\n\n #create 8 default semesters\n Semester.create_semesters(start_sem, start_year.to_i, 8) {|semester| semesters.concat semester} \n end",
"def create_microtiter_plates(operations:)\n operations.each do |operation|\n method = operation.temporary[:options][:layout_method]\n group_size = operation.temporary[:options][:group_size]\n program_name = operation.temporary[:options][:program_name]\n\n output_collection = operation.output(PLATE).collection\n output_collection.associate(PRIMER_GROUP_SIZE_KEY, group_size)\n output_collection.associate(COMPOSITION_NAME_KEY, program_name)\n output_collection.associate(PRIMER_METHOD_KEY, method)\n\n microtiter_plate = MicrotiterPlateFactory.build(\n collection: output_collection,\n group_size: group_size,\n method: method\n )\n operation.temporary[:microtiter_plate] = microtiter_plate\n end\n end",
"def cmd_db_set_auto\n\t\t\t#TODO: Find a way to persist sets by serializing? them to .msf4 etc\n\t\t\t#TODO: Let the user add or subtract from this\n\t\t\tself.create_set(\"windows\", \"hosts where os_name~windows\")\n\t\t\tself.create_set(\"linux\", \"hosts where os_name~linux\")\n\t\t\tself.create_set(\"all_hosts\", \"hosts\")\n\t\t\tself.create_set(\"all_active_sessions\", \"sessions where closed_at=nil\")\n\t\t\tself.create_set(\"unknown\", \"hosts where os_name=nil\")\n\t\t\tcmd_db_set_list\n\t\tend",
"def power_ups\n @power_ups.map {|pup| Equip_Abilities.new(pup[0], pup[1], pup[2])}\n end",
"def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend",
"def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend",
"def create_deck\n @deck = CARDS.product(SUITS).shuffle\n end",
"def generate_all_data_bag_items\n DATA_BAGS_CONF.each_pair do |data_bag_name, config|\n config.each_pair do |item, value|\n next unless value\n create_data_bag_item(data_bag_name, item, value)\n end\n end\nend",
"def large_one_itemsets\n database.each_with_object(counter) do |(_, itemset), support|\n itemset.each { |item| support[item] += 1 }\n end.\n select { |item, support| support >= @min_support }.\n map { |item, support| Itemset.new([item], support: support) }\n end",
"def create_outlets\n if self.pack_group_template_outlets.length == 0\n counts = PackGroupsCountsConfig.find_all_by_commodity_code(self.commodity_code,:order => 'position')\n if counts.length == 0\n raise \"No sequence of counts('pack_groups_counts_configs' table) have been defined for commodity '#{self.commodity_code}'.\n <br> Use the program called 'pack_groups_counts_configs'(usually under 'tools') to define the list(and order of) size_counts\n <br>to use for allocating drops to counts per pack_group\"\n end\n \n \n counts.each do |count|\n pgo = PackGroupTemplateOutlet.new\n pgo.pack_group_template_id = self.id\n \n if count.size_code\n pgo.size_code = count.size_code\n else\n pgo.standard_size_count_value = count.standard_size_count_value\n end\n \n pgo.create\n end\n \n end\n \n end",
"def create_empty\n EadGenerator.generate_empty\n end",
"def add_construction_set(template, clim, building_type, spc_type, is_residential)\n\n construction_set = OpenStudio::Model::OptionalDefaultConstructionSet.new\n\n # Find the climate zone set that this climate zone falls into\n climate_zone_set = find_climate_zone_set(clim, template)\n if !climate_zone_set\n return construction_set\n end\n \n # Get the object data\n data = self.find_object(self.standards['construction_sets'], {'template'=>template, 'climate_zone_set'=> climate_zone_set, 'building_type'=>building_type, 'space_type'=>spc_type, 'is_residential'=>is_residential})\n if !data\n data = self.find_object(self.standards['construction_sets'], {'template'=>template, 'climate_zone_set'=> climate_zone_set, 'building_type'=>building_type, 'space_type'=>spc_type})\n if !data\n return construction_set\n end\n end \n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding construction set: #{template}-#{clim}-#{building_type}-#{spc_type}-is_residential#{is_residential}\") \n \n name = make_name(template, clim, building_type, spc_type)\n\n # Create a new construction set and name it\n construction_set = OpenStudio::Model::DefaultConstructionSet.new(self)\n construction_set.setName(name)\n\n # Exterior surfaces constructions\n exterior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(self)\n construction_set.setDefaultExteriorSurfaceConstructions(exterior_surfaces)\n if data['exterior_floor_standards_construction_type'] && data['exterior_floor_building_category']\n exterior_surfaces.setFloorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorFloor',\n data['exterior_floor_standards_construction_type'],\n data['exterior_floor_building_category']))\n end\n if data['exterior_wall_standards_construction_type'] && data['exterior_wall_building_category']\n exterior_surfaces.setWallConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorWall',\n data['exterior_wall_standards_construction_type'],\n data['exterior_wall_building_category']))\n end\n if data['exterior_roof_standards_construction_type'] && data['exterior_roof_building_category']\n exterior_surfaces.setRoofCeilingConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorRoof',\n data['exterior_roof_standards_construction_type'],\n data['exterior_roof_building_category']))\n end\n\n # Interior surfaces constructions\n interior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(self)\n construction_set.setDefaultInteriorSurfaceConstructions(interior_surfaces)\n construction_name = data['interior_floors']\n if construction_name != nil\n interior_surfaces.setFloorConstruction(add_construction(construction_name))\n end\n construction_name = data['interior_walls']\n if construction_name != nil\n interior_surfaces.setWallConstruction(add_construction(construction_name))\n end\n construction_name = data['interior_ceilings']\n if construction_name != nil\n interior_surfaces.setRoofCeilingConstruction(add_construction(construction_name))\n end\n\n # Ground contact surfaces constructions\n ground_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(self)\n construction_set.setDefaultGroundContactSurfaceConstructions(ground_surfaces)\n if data['ground_contact_floor_standards_construction_type'] && data['ground_contact_floor_building_category']\n ground_surfaces.setFloorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'GroundContactFloor',\n data['ground_contact_floor_standards_construction_type'],\n data['ground_contact_floor_building_category']))\n end\n if data['ground_contact_wall_standards_construction_type'] && data['ground_contact_wall_building_category']\n ground_surfaces.setWallConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'GroundContactWall',\n data['ground_contact_wall_standards_construction_type'],\n data['ground_contact_wall_building_category']))\n end\n if data['ground_contact_ceiling_standards_construction_type'] && data['ground_contact_ceiling_building_category']\n ground_surfaces.setRoofCeilingConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'GroundContactRoof',\n data['ground_contact_ceiling_standards_construction_type'],\n data['ground_contact_ceiling_building_category']))\n end\n\n # Exterior sub surfaces constructions\n exterior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(self)\n construction_set.setDefaultExteriorSubSurfaceConstructions(exterior_subsurfaces)\n if data['exterior_fixed_window_standards_construction_type'] && data['exterior_fixed_window_building_category']\n exterior_subsurfaces.setFixedWindowConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorWindow',\n data['exterior_fixed_window_standards_construction_type'],\n data['exterior_fixed_window_building_category']))\n end\n if data['exterior_operable_window_standards_construction_type'] && data['exterior_operable_window_building_category']\n exterior_subsurfaces.setOperableWindowConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorWindow',\n data['exterior_operable_window_standards_construction_type'],\n data['exterior_operable_window_building_category']))\n end\n if data['exterior_door_standards_construction_type'] && data['exterior_door_building_category']\n exterior_subsurfaces.setDoorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorDoor',\n data['exterior_door_standards_construction_type'],\n data['exterior_door_building_category']))\n end\n construction_name = data['exterior_glass_doors']\n if construction_name != nil\n exterior_subsurfaces.setGlassDoorConstruction(add_construction(construction_name))\n end\n if data['exterior_overhead_door_standards_construction_type'] && data['exterior_overhead_door_building_category']\n exterior_subsurfaces.setOverheadDoorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorDoor',\n data['exterior_overhead_door_standards_construction_type'],\n data['exterior_overhead_door_building_category']))\n end\n if data['exterior_skylight_standards_construction_type'] && data['exterior_skylight_building_category']\n exterior_subsurfaces.setSkylightConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'Skylight',\n data['exterior_skylight_standards_construction_type'],\n data['exterior_skylight_building_category']))\n end\n if construction_name = data['tubular_daylight_domes']\n exterior_subsurfaces.setTubularDaylightDomeConstruction(add_construction(construction_name))\n end\n if construction_name = data['tubular_daylight_diffusers']\n exterior_subsurfaces.setTubularDaylightDiffuserConstruction(add_construction(construction_name))\n end\n\n # Interior sub surfaces constructions\n interior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(self)\n construction_set.setDefaultInteriorSubSurfaceConstructions(interior_subsurfaces)\n if construction_name = data['interior_fixed_windows']\n interior_subsurfaces.setFixedWindowConstruction(add_construction(construction_name))\n end\n if construction_name = data['interior_operable_windows']\n interior_subsurfaces.setOperableWindowConstruction(add_construction(construction_name))\n end\n if construction_name = data['interior_doors']\n interior_subsurfaces.setDoorConstruction(add_construction(construction_name))\n end\n\n # Other constructions\n if construction_name = data['interior_partitions']\n construction_set.setInteriorPartitionConstruction(add_construction(construction_name))\n end\n if construction_name = data['space_shading']\n construction_set.setSpaceShadingConstruction(add_construction(construction_name))\n end\n if construction_name = data['building_shading']\n construction_set.setBuildingShadingConstruction(add_construction(construction_name))\n end\n if construction_name = data['site_shading']\n construction_set.setSiteShadingConstruction(add_construction(construction_name))\n end\n\n # componentize the construction set\n #construction_set_component = construction_set.createComponent\n\n # Return the construction set\n return OpenStudio::Model::OptionalDefaultConstructionSet.new(construction_set)\n \n end",
"def select_equipment\n @project = Project.find(params[:id]) \n @procedure = Procedurex.find(params[:proc_id])\n @ingreds =@procedure.ingredientss #this reduces code and potential spelling error\n \n #this was the best way I could find of identifying all the baskets already created for the ingredients of a procedure\n @rightbaskets=Array.new\n \n x=@ingreds.count #x is the number of ingredients - the total baskets necessary for this project\n @project.baskets.each do |b|\n if b.procedurex==@procedure then #if a extant basket belongs to the procedure\n x=x-1 #reduce number of new baskets to be created by 1\n @rightbaskets.push(b) #add basket to the array of current baskets\n end\n end\n \n x.times do |pl|\n basket=Basket.create(:procedurex_id =>:proc_id, :project_id =>:id) #create baskets where there are not extant ones for this procedure\n @rightbaskets.push(basket) #add the new basket to the array of current baskets\n end\n \n respond_to do |format|\n format.html # select_equipment.html.erb\n format.json { render json: @project }\n end\n end",
"def genQuestionaire\n #Table \"questions\" from the database through instance variable \"roster\"\n roster=@DB[:questions]\n #Limit for the iterator that will generate the list of questions\n lim=@number-1\n #Space available\n available=[]\n #This iterator stores the whole database in the \"available\" variable\n #in the form of several \"Question\" objects\n (1..40).each do |index|\n #Paramters for the \"Question\" class are set\n #Question text\n q=roster.first(id: index)[:question].to_s\n #Answer a\n a=roster.first(id: index)[:answerA].to_s\n #Answer b\n b=roster.first(id: index)[:answerB].to_s\n #Answer c\n c=roster.first(id: index)[:answerC].to_s\n #Correct answer\n corr=roster.first(id: index)[:correct].to_s\n #Questions are built\n available.push Question.new q, a, b, c, corr\n end\n \n #The \"available\" variable is randomized and stored in the \"scrambled\" variable\n scrambled=available.shuffle\n \n #This iterator takes the number of questions specified by the users and stores \n #them in the final questionaire\n (0..lim).each do |question|\n @questions.push scrambled[question]\n end\n puts \n end",
"def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.select do |card|\n shoe << card\n end\n end\n shoe\nend",
"def create_assessment\n @unique_questions = []\n\n questions = QuizQuestion.for_language_course(self, [\"multiple_choice\", \"short_answer\"])\n questions_grouped_by_lesson = questions.group_by(&:lesson_id).values.shuffle\n\n setup_multiple_choice_questions(questions_grouped_by_lesson)\n setup_short_answer_questions(questions_grouped_by_lesson)\n\n @unique_questions\n end",
"def new\n logger.debug \"==> EC.n 0: #{params.inspect}\"\n @endorsement = Endorsement.new\n @marker = Endorsement.new\n @products = Array.new\n if params[:product] == \"Beverage\"\n @marker = Beverage.find(:first)\n @products = Beverage.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n #@beverages.each { |x| x.insert(1, \"Beverage\") }\n elsif params[:product] == \"Fashion\"\n @marker = Fashion.find(:first)\n @products = Fashion.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n elsif params[:product] == \"Snack\"\n @marker = Snack.find(:first)\n @products = Snack.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n else\n logger.debug \"==> EC.n 0.1\"\n @bev = Beverage.new\n @products.concat(@bev.get_all_for_select)\n @fas = Fashion.new\n @products.concat(@fas.get_all_for_select)\n @sna = Snack.new\n @products.concat(@sna.get_all_for_select)\n logger.debug \"==> EC.n 0.4\"\n\n #this returns items that only exist in endorsements\n #not a meta table of all items. need outer join.\n #@zoo = Endorsement.find(:all, \n # :include => [:beverage, :snack, :fashion],\n # :joins => [:beverage, :snack, :fashion]).map do |x|\n # x.endorseable.name\n #end\n #@fun = Endorsement.find(:all).map { |x| x.endorseable.name }\n\n #@products.concat(@fashions)\n #@products.concat(@snacks)\n #@e = Endorsement.new\n #@products = @e.get_products_select\n=begin\n @products = Endorsement.find(:all, \n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n #remove this from the above find statement\n # :include => [:beverage, :fashion, :snack],\n end\n #@beverages.each { |x| @products << x }\n #@fashions.each { |x| @products << x }\n #@snacks.each { |x| @products << x }\n logger.debug \"==> EC.n 0.3: #{@products.inspect}\"\n logger.debug \"==> EC.n 0.4: #{@marker.inspect}\"\n logger.debug \"==> EC.n 0.5: #{@marker.class}\"\n=begin\n below is the way to get stuff for dropdown from endorsement\n via interface endorseable\n @beverages = Endorsement.find(:all,\n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n @players = Player.find(:all, :order => \"lastname ASC\",\n :select => \"id, firstname, lastname\").map {|p|\n [\"#{p.lastname}, #{p.firstname}\", p.id]}\n @x = Player.find(:first)\n @b = Beverage.find(:all)\n #logger.debug \"==> EC.n 1: #{@beverages.class}\"\n #logger.debug \"==> EC.n 1.1: #{@beverages.empty?}\"\n #logger.debug \"==> EC.n 1.2: #{@beverages.inspect}\"\n logger.debug \"==> EC.n 2: #{@players.class}\"\n logger.debug \"==> EC.n 2.1: #{@players.empty?}\"\n logger.debug \"==> EC.n 2.2: #{@players.inspect}\"\n logger.debug \"==> EC.n 3: #{@x.endorsements.inspect}\"\n logger.debug \"==> EC.n 4: #{@b.class}\"\n logger.debug \"==> EC.n 4.1: #{@b.empty?}\"\n logger.debug \"==> EC.n 4.2: #{@b.inspect}\"\n\n=begin\n @endorsement = Endorsement.find(:all,\n :select => \"id, name, lastname\").map {|p|\n [p.firstname, p.lastname, p.id]}\n=end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @endorsement }\n end\n end",
"def generateListCities(times_to_gen)\n\n\txml_result = \"\"\n\tsortBy = \"\"\n\ttimes_to_gen.times {\n\n\t\tprint(\"\\nEnter a sort method (name or coordinates): \")\n\t\tsortBy = $stdin.readline.chomp\n\t\twhile (sortBy != \"name\" && sortBy != \"coordinates\")\n\t\t\tprint(\"\\nEnter a valid sort method (name or coordinates): \")\n\t\t\tsortBy = $stdin.readline.chomp\n\t\tend\n\n\t\txml_result += \"\\n<listCities id=\\\"5\\\" sortBy=\\\"#{sortBy}\\\" />\"\n\n\t}\n\n\treturn xml_result\n\nend",
"def setup_test(operations, ot_type_name)\n operations.make\n operations.each do |op|\n output_collection = op.output('PCR Plate').collection\n rows = output_collection.dimensions[0]\n sample_names = ['RP', '2019-nCoVPC_N1', '2019-nCoVPC_N2']\n (rows/(sample_names.length)).times do\n sample_names.each do |name|\n collection = Collection.new_collection(ot_type_name)\n samples = Array.new(collection.dimensions[0], Sample.find_by_name(name))\n collection.add_samples(samples)\n end\n end\n end\n end",
"def create_objects_merchant_with_many_customers_and_items\n let!(:customer1) { create(:customer) } # Transaction_count = 1\n let!(:customer2) { create(:customer) } # Transaction_count = 3 #=> Top Customer 3\n let!(:customer3) { create(:customer) } # Transaction_count = 5 #=> Top Customer 1\n let!(:customer4) { create(:customer) } # Transaction_count = 4 #=> Top Customer 2\n let!(:customer5) { create(:customer) } # Transaction_count = 1\n let!(:customer6) { create(:customer) } # Transaction_count = 1\n let!(:customer7) { create(:customer) } # Transaction_count = 2 #=> Top Customer 4 (4a)\n let!(:customer8) { create(:customer) } # Transaction_count = 2 #=> Top Customer 5 (4b)\n let!(:customer9) { create(:customer) } # Transaction_count = 1\n let!(:customer10) { create(:customer) } # Transaction_count = 1\n\n let!(:merchant) { create(:enabled_merchant) }\n\n let!(:item1) { create(:item, merchant: merchant) }\n let!(:item2) { create(:item, merchant: merchant) }\n let!(:item3) { create(:item, merchant: merchant) }\n let!(:item4) { create(:item, merchant: merchant) }\n let!(:item5) { create(:item, merchant: merchant) }\n let!(:item6) { create(:item, merchant: merchant) }\n let!(:item7) { create(:item, merchant: merchant) }\n let!(:item8) { create(:item, merchant: merchant) }\n let!(:item9) { create(:item, merchant: merchant) }\n let!(:item10) { create(:item, merchant: merchant) }\n let!(:item11) { create(:item, merchant: merchant) }\n let!(:item12) { create(:item, merchant: merchant) }\n let!(:item13) { create(:item, merchant: merchant) }\n let!(:item14) { create(:item, merchant: merchant) }\n let!(:item15) { create(:item, merchant: merchant) }\n let!(:item16) { create(:item, merchant: merchant) }\n let!(:item17) { create(:item, merchant: merchant) }\n let!(:item18) { create(:item, merchant: merchant) }\n let!(:item19) { create(:item, merchant: merchant) }\n let!(:item20) { create(:item, merchant: merchant) }\n\n let!(:invoice1a) { create(:invoice, :completed, customer: customer1, created_at: '2021-07-24T17:30:05+0700') } # 15\n let!(:invoice1b) { create(:invoice, :completed, customer: customer1, created_at: '2021-07-27T17:30:05+0700') } # 18\n let!(:invoice2a) { create(:invoice, :completed, customer: customer2, created_at: '2021-07-26T17:30:05+0700') } # 17\n let!(:invoice2b) { create(:invoice, :completed, customer: customer2, created_at: '2021-07-17T17:30:05+0700') } # 10\n let!(:invoice2c) { create(:invoice, :completed, customer: customer2, created_at: '2021-07-18T17:30:05+0700') } # 11\n let!(:invoice3a) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-29T17:30:05+0700') } # 20\n let!(:invoice3b) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-22T17:30:05+0700') } # 13\n let!(:invoice3c) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-28T17:30:05+0700') } # 19\n let!(:invoice3d) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-02T17:30:05+0700') } # 2\n let!(:invoice3e) { create(:invoice, :completed, customer: customer3, created_at: '2021-07-15T17:30:05+0700') } # 8\n let!(:invoice4a) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-29T17:30:05+0705') } # 21\n let!(:invoice4b) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-16T17:30:05+0700') } # 9\n let!(:invoice4c) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-08T17:30:05+0700') } # 5\n let!(:invoice4d) { create(:invoice, :completed, customer: customer4, created_at: '2021-07-01T17:30:05+0700') } # 1\n let!(:invoice5a) { create(:invoice, :completed, customer: customer5, created_at: '2021-07-04T17:30:05+0700') } # 3\n let!(:invoice6a) { create(:invoice, :completed, customer: customer6, created_at: '2021-07-06T17:30:05+0700') } # 4\n let!(:invoice7a) { create(:invoice, :completed, customer: customer7, created_at: '2021-07-23T17:30:05+0700') } # 14\n let!(:invoice7b) { create(:invoice, :completed, customer: customer7, created_at: '2021-07-21T17:30:05+0700') } # 12\n let!(:invoice8a) { create(:invoice, :completed, customer: customer8, created_at: '2021-07-25T17:30:05+0700') } # 16\n let!(:invoice8b) { create(:invoice, :completed, customer: customer8, created_at: '2021-07-30T17:30:05+0700') } # 22\n let!(:invoice9a) { create(:invoice, :completed, customer: customer9, created_at: '2021-07-14T17:30:05+0700') } # 7\n let!(:invoice10a) { create(:invoice, :completed, customer: customer10, created_at: '2021-07-13T17:30:05+0700') } # 6\n\n let!(:transaction1a) { create(:transaction, :failed, invoice: invoice1a) }\n let!(:transaction1b) { create(:transaction, :success, invoice: invoice1b) }\n let!(:transaction2a) { create(:transaction, :success, invoice: invoice2a) }\n let!(:transaction2b) { create(:transaction, :success, invoice: invoice2b) }\n let!(:transaction2c) { create(:transaction, :success, invoice: invoice2c) }\n let!(:transaction3a) { create(:transaction, :success, invoice: invoice3a) }\n let!(:transaction3b) { create(:transaction, :success, invoice: invoice3b) }\n let!(:transaction3c) { create(:transaction, :success, invoice: invoice3c) }\n let!(:transaction3d) { create(:transaction, :success, invoice: invoice3d) }\n let!(:transaction3e) { create(:transaction, :success, invoice: invoice3e) }\n let!(:transaction4a) { create(:transaction, :success, invoice: invoice4a) }\n let!(:transaction4b) { create(:transaction, :success, invoice: invoice4b) }\n let!(:transaction4c) { create(:transaction, :success, invoice: invoice4c) }\n let!(:transaction4d) { create(:transaction, :success, invoice: invoice4d) }\n let!(:transaction5a) { create(:transaction, :success, invoice: invoice5a) }\n let!(:transaction6a) { create(:transaction, :success, invoice: invoice6a) }\n let!(:transaction7a) { create(:transaction, :success, invoice: invoice7a) }\n let!(:transaction7b) { create(:transaction, :success, invoice: invoice7b) }\n let!(:transaction8a) { create(:transaction, :success, invoice: invoice8a) }\n let!(:transaction8b) { create(:transaction, :success, invoice: invoice8b) }\n let!(:transaction9a) { create(:transaction, :success, invoice: invoice9a) }\n let!(:transaction10a) { create(:transaction, :success, invoice: invoice10a) }\n\n let!(:invoice_item1a_1) { create(:invoice_item, :pending, item: item1, invoice: invoice1a, quantity: 2, unit_price: 10) }\n let!(:invoice_item1a_2) { create(:invoice_item, :pending, item: item1, invoice: invoice1a, quantity: 5, unit_price: 20) }\n let!(:invoice_item1b_1) { create(:invoice_item, :shipped, item: item2, invoice: invoice1b, quantity: 4, unit_price: 10) }\n let!(:invoice_item1b_2) { create(:invoice_item, :shipped, item: item2, invoice: invoice1b, quantity: 5, unit_price: 20) }\n let!(:invoice_item2a_1) { create(:invoice_item, :shipped, item: item3, invoice: invoice2a, quantity: 1, unit_price: 10) }\n let!(:invoice_item2a_2) { create(:invoice_item, :shipped, item: item3, invoice: invoice2a, quantity: 5, unit_price: 20) }\n let!(:invoice_item2b_1) { create(:invoice_item, :shipped, item: item4, invoice: invoice2b, quantity: 3, unit_price: 10) }\n let!(:invoice_item2b_2) { create(:invoice_item, :shipped, item: item4, invoice: invoice2b, quantity: 5, unit_price: 20) }\n let!(:invoice_item2c_1) { create(:invoice_item, :shipped, item: item5, invoice: invoice2c, quantity: 5, unit_price: 10) }\n let!(:invoice_item2c_2) { create(:invoice_item, :shipped, item: item5, invoice: invoice2c, quantity: 10, unit_price: 20) }\n let!(:invoice_item3a_1) { create(:invoice_item, :shipped, item: item6, invoice: invoice3a, quantity: 6, unit_price: 10) }\n let!(:invoice_item3a_2) { create(:invoice_item, :shipped, item: item6, invoice: invoice3a, quantity: 5, unit_price: 20) }\n let!(:invoice_item3b_1) { create(:invoice_item, :packaged, item: item7, invoice: invoice3b, quantity: 7, unit_price: 17) }\n let!(:invoice_item3b_2) { create(:invoice_item, :packaged, item: item9, invoice: invoice3b, quantity: 1, unit_price: 20) }\n let!(:invoice_item3c_1) { create(:invoice_item, :shipped, item: item8, invoice: invoice3c, quantity: 15, unit_price: 14) }\n let!(:invoice_item3c_2) { create(:invoice_item, :shipped, item: item9, invoice: invoice3c, quantity: 1, unit_price: 20) }\n let!(:invoice_item3d_1) { create(:invoice_item, :packaged, item: item9, invoice: invoice3d, quantity: 1, unit_price: 10) }\n let!(:invoice_item3e_1) { create(:invoice_item, :packaged, item: item9, invoice: invoice3e, quantity: 3, unit_price: 20) }\n let!(:invoice_item4a_1) { create(:invoice_item, :shipped, item: item10, invoice: invoice4a, quantity: 3, unit_price: 10) }\n let!(:invoice_item4a_2) { create(:invoice_item, :shipped, item: item10, invoice: invoice4a, quantity: 5, unit_price: 20) }\n let!(:invoice_item4b_1) { create(:invoice_item, :shipped, item: item11, invoice: invoice4b, quantity: 5, unit_price: 10) }\n let!(:invoice_item4b_2) { create(:invoice_item, :packaged, item: item11, invoice: invoice4b, quantity: 5, unit_price: 20) }\n let!(:invoice_item4b_3) { create(:invoice_item, :shipped, item: item12, invoice: invoice4b, quantity: 5, unit_price: 10) }\n let!(:invoice_item4c_1) { create(:invoice_item, :packaged, item: item12, invoice: invoice4c, quantity: 5, unit_price: 10) }\n let!(:invoice_item4c_2) { create(:invoice_item, :shipped, item: item12, invoice: invoice4d, quantity: 4, unit_price: 25) }\n let!(:invoice_item5a_1) { create(:invoice_item, :shipped, item: item13, invoice: invoice5a, quantity: 6, unit_price: 10) }\n let!(:invoice_item5a_2) { create(:invoice_item, :shipped, item: item13, invoice: invoice5a, quantity: 5, unit_price: 20) }\n let!(:invoice_item6a_1) { create(:invoice_item, :shipped, item: item14, invoice: invoice6a, quantity: 6, unit_price: 10) }\n let!(:invoice_item6a_2) { create(:invoice_item, :packaged, item: item14, invoice: invoice6a, quantity: 5, unit_price: 20) }\n let!(:invoice_item7a_1) { create(:invoice_item, :shipped, item: item15, invoice: invoice7a, quantity: 8, unit_price: 10) }\n let!(:invoice_item7a_2) { create(:invoice_item, :packaged, item: item15, invoice: invoice7a, quantity: 3, unit_price: 20) }\n let!(:invoice_item7a_3) { create(:invoice_item, :shipped, item: item15, invoice: invoice7b, quantity: 2, unit_price: 20) }\n let!(:invoice_item7b_1) { create(:invoice_item, :shipped, item: item16, invoice: invoice7b, quantity: 6, unit_price: 10) }\n let!(:invoice_item7b_2) { create(:invoice_item, :pending, item: item16, invoice: invoice7b, quantity: 5, unit_price: 20) }\n let!(:invoice_item8a_1) { create(:invoice_item, :pending, item: item17, invoice: invoice8a, quantity: 6, unit_price: 10) }\n let!(:invoice_item8a_2) { create(:invoice_item, :pending, item: item17, invoice: invoice8a, quantity: 5, unit_price: 20) }\n let!(:invoice_item8b_1) { create(:invoice_item, :shipped, item: item18, invoice: invoice8b, quantity: 8, unit_price: 10) }\n let!(:invoice_item8b_2) { create(:invoice_item, :shipped, item: item18, invoice: invoice8b, quantity: 8, unit_price: 20) }\n let!(:invoice_item9a_1) { create(:invoice_item, :shipped, item: item19, invoice: invoice9a, quantity: 6, unit_price: 10) }\n let!(:invoice_item9a_2) { create(:invoice_item, :shipped, item: item19, invoice: invoice9a, quantity: 5, unit_price: 20) }\n let!(:invoice_item10a_1) { create(:invoice_item, :pending, item: item20, invoice: invoice10a, quantity: 6, unit_price: 10) }\n let!(:invoice_item10a_2) { create(:invoice_item, :shipped, item: item20, invoice: invoice10a, quantity: 5, unit_price: 20) }\nend",
"def new_input_set()\n return ElectricityUseInputSet.new()\n end",
"def manufacture\n if required_param_types_present?\n generate_new_item_object\n else\n raise RuntimeError.new(\"One or more required objects is missing.\")\n end\n end",
"def valid_sets; end",
"def template_object_sets\n\t\t\toutput = []\n\t\t\tset = xpath '//template_object_set'\n\t\t\tset.each do |node|\n\t\t\t\toutput << node\n\t\t\tend\n\t\t\n\t\t\treturn output\n\t\tend",
"def generate_stack\n VALUES.product(SUITS).map!(&:join)\n\n # stack = []\n # VALUES.each do |value|\n # SUITS.each do |suit|\n # stack << value + suit\n # end\n # end\n # stack\n end",
"def each_set\n \n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def select\n @equipment = Equipment.all\n end",
"def make_union\n #prompts for name of first set\n puts \"Enter name of first set:\"\n set1name = gets\n #locates first set\n set1 = find_set(set1name.chomp)\n if set1 == nil\n #if it is not found, it ends the method\n return 0\n end\n #prompts for the name of the second set\n puts \"Enter name of second set:\"\n set2name = gets\n #locates the second set\n set2 = find_set(set2name.chomp)\n if set2 == nil\n #if it is not found, it ends the method\n return 0\n end\n\n #asks the user to name the new set\n puts \"Enter name for union set:\"\n newsetname = gets\n #for loop iterates through all existing sets in $current_sets\n i=0\n for i in 0..($current_sets.length-1)\n if $current_sets[i].setname == newsetname.chomp\n # if any set has the same name as the specified set name, it ends the method\n puts \"There is already a set with that name!\"\n return 0\n \n end\n end\n #calls unionset from the first set entered, and passes the second set entered as a parameter\n unionset = set1.union(set2, newsetname.chomp)\n #adds the new set to the list of current sets\n $current_sets.push(unionset)\n puts \"Union set created!\"\nend",
"def hw_to_sets(hw,book) \n sets = []\n stream_starts_at_set = 1\n hw.each { |stream|\n stream_starts_at_set = stream_starts_at_set+stream[\"delay\"].to_i\n set_number = stream_starts_at_set\n stream[\"chunks\"].each { |chunk|\n if sets[set_number].nil? then sets[set_number]=[] end\n sets[set_number].push(chunk)\n set_number = set_number+1\n }\n }\n 1.upto(sets.length-1) { |set_number|\n if sets[set_number].nil? then sets[set_number]=[] end\n }\n\n read_problems_csv(book)\n\n 1.upto(sets.length-1) { |set_number|\n sets[set_number].each { |chunk|\n chunk.each { |fg|\n flags,probs = fg\n probs.each { |g|\n g.each { |p|\n k = [p[0],p[1]]\n if p[0]<0 then\n fatal_error(\"in hw_to_sets, chapter=#{p[0]} for a problem on hw #{set_number}\")\n end\n label = $num_to_label[k]\n if $problem_assigned_on_set[k].nil?\n $problem_assigned_on_set[k] = set_number\n else\n if p[2].nil? || p[2]=='' then\n fatal_error(\"problem #{p[0]}-#{p[1]}, #{label}, assigned on both hw #{$problem_assigned_on_set[k]} and hw #{set_number}, and no specific parts were given on the second hw\")\n end\n end\n }\n }\n }\n }\n }\n\n return sets\nend",
"def chosen\n the_set = []\n self.itemlist.each { |k,v| the_set << self.object(k).chosen }\n the_set\n end",
"def build_pack_materials_grid(data_set,can_create_run)\n\n\n\n column_configs = Array.new\n\n\tcolumn_configs[0] = {:field_type => 'text',:field_name => 'retail_item_pack_material_code'}\n\tcolumn_configs[1] = {:field_type => 'text',:field_name => 'retail_unit_pack_material_code'}\n\tcolumn_configs[2] = {:field_type => 'text',:field_name => 'trade_unit_pack_material_code'}\n\tcolumn_configs[3] = {:field_type => 'text',:field_name => 'pallet_pack_material_code'}\n\tcolumn_configs[4] = {:field_type => 'text',:field_name => 'fg_product_code'}\n\tcolumn_configs[5] = {:field_type => 'text',:field_name => 'carton_setup_code'}\n\tcolumn_configs[6] = {:field_type => 'text',:field_name => 'created_at'}\n\n\n\n return get_data_grid(data_set,column_configs)\nend",
"def allocateBySATforEachDemand(demand)\n selfDefnWeightsArray = Array.new();\n nofBus = @simulator.savList.size();\n acceptedSizeArray = Array.new();\n allPairsHashArray = Array.new();\n deadlineArray = Array.new();\n # Anonymous1 04/02 -> extension for the case of (one demand n-passengers) via 'pickDropArray'\n pickDropArray = Array.new();\n # Anonymous1 04/09 -> number of carried\n nofCarried = Array.new();\n newDemandSize = 1;\n capacityArray = Array.new();\n tmpArray = Array.new();\n tmpHash = Hash.new();\n # for dealing with the capacity's inconsistency of dummyPoint\n busIDArrayWhoseBusIncludeDummy = Array.new();\n @simulator.savList.each{|sav|\n #sav.clearDummyViaPointsInTail();\n if sav.viaPointList.size()-1 > sav.viaPointIndex && sav.viaPointList.size() >= 2\n for i in sav.viaPointIndex..sav.viaPointList.size()-2\n if sav.viaPointList[sav.viaPointIndex].mode != :dummy && sav.viaPointList[i].mode == :dummy\n puts \"caught you!\";\n sav.viaPointList.delete_at(i);\n end\n end\n end\n for i in sav.viaPointIndex..sav.viaPointList.size()-1\n if sav.viaPointList[i].mode == :dummy\n busIDArrayWhoseBusIncludeDummy.push(1);\n break;\n elsif i == sav.viaPointList.size()-1 && sav.viaPointList[i].mode != :dummy\n busIDArrayWhoseBusIncludeDummy.push(0);\n end\n end\n tmpArray.clear();\n tmpArray.push(sav.fetchPosition());\n acceptedSizeArray.push(sav.viaPointList.size()-sav.viaPointIndex);\n for i in sav.viaPointIndex..sav.viaPointList.size()-1\n tmpArray.push(sav.viaPointList[i]);\n end\n tmpHash.clear();\n for i in 1..tmpArray.size()-1\n if tmpArray[i].mode == :pickUp\n for j in i+1..tmpArray.size()-1\n if tmpArray[i].demand == tmpArray[j].demand && tmpArray[j].mode == :dropOff\n tmpHash.store(j-1, i-1);\n break;\n end\n end\n end\n end\n allPairsHashArray.push(tmpHash.clone());\n tmpArray.push(demand.tripViaPoint.pickUp);\n tmpArray.push(demand.tripViaPoint.dropOff);\n for i in 1..tmpArray.size()-1\n if tmpArray[i].mode == :dropOff\n deadlineArray.push((1*(tmpArray[i].demand.tripRequiredTime.dropOff)).to_i);\n pickDropArray.push((-1*(tmpArray[i].demand.numPassenger)).to_i);\n elsif tmpArray[i].mode == :pickUp\n deadlineArray.push(0);\n pickDropArray.push((1*(tmpArray[i].demand.numPassenger)).to_i);\n elsif tmpArray[i].mode == :dummy\n deadlineArray.push(0);\n pickDropArray.push(0);\n end\n end\n nofCarried.push(sav.countNumOnBoard());\n for i in 1..tmpArray.size()-1\n for j in 0..tmpArray.size()-1\n selfDefnWeightsArray.push((1+1*(estimateTime(tmpArray[j], tmpArray[i], sav, :averageManhattan))).to_i);\n end\n end\n capacityArray.push(sav.capacity);\n if sav.countNumOnBoard() > sav.capacity\n #puts \"error numOnBorad: #{sav.countNumOnBoard()}\";\n #exit;\n end\n }\n #puts \"selfDefnWeightsArray: #{selfDefnWeightsArray}\";\n #puts \"nofBus: #{nofBus}\";\n #puts \"acceptedSizeArray: #{acceptedSizeArray}\";\n #puts \"allPairsHashArray: #{allPairsHashArray}\";\n #puts \"deadlineArray: #{deadlineArray}\";\n #puts \"pickDropArray: #{pickDropArray}\";\n #puts \"newDemandSize: #{newDemandSize}\";\n #puts \"capacityArray: #{capacityArray}\";\n encodingDone = false;\n if (nofBus * newDemandSize != 0) \n #wcnfGen(selfDefnWeightsArray, nofBus, acceptedSizeArray, allPairsHashArray, deadlineArray, newDemandSize, capacityArray);\n #runMaxSATSolver = \"../../encodedProblem/qmaxsat_g3 -cpu-lim=10 -card=mrwto -pmodel=0 -incr=1 ../../encodedProblem/test.wcnf ../../encodedProblem/externality.txt ../../encodedProblem/answer.txt > ../../encodedProblem/log.txt\";\n # for NCC\n encodingDone = wcnfGenNcc(selfDefnWeightsArray, nofBus, acceptedSizeArray, allPairsHashArray, deadlineArray, newDemandSize, capacityArray, busIDArrayWhoseBusIncludeDummy,pickDropArray,nofCarried);\n runMaxSATSolver = \"../../encodedProblem/qmaxsatNcc_g3 -cpu-lim=10 -card=mrwto -pmodel=0 -incr=1 ../../encodedProblem/test.wcnf ../../encodedProblem/externality.txt ../../encodedProblem/answer.txt > ../../encodedProblem/log.txt\";\n clearPreviousAns = \"rm ../../encodedProblem/answer.txt\";\n if encodingDone \n system(runMaxSATSolver);\n else\n system(clearPreviousAns);\n end\n end\n \n if encodingDone\n maxSATans = IO.readlines(\"../../encodedProblem/answer.txt\");\n else\n maxSATans = Array.new();\n maxSATans.push(\"UNSAT\");\n maxSATans.push(\"noEncodedProblem\");\n end\n if encodingDone && maxSATans[0].include?(\"OPT\") && maxSATans[1] != nil\n allocatedViaPointList = Array.new();\n tmpAnsReadLine = Array.new();\n busID = maxSATans[1].to_i;\n updateFlag = false;\n sav = @simulator.savList[busID-1];\n tmpAnsReadLine = maxSATans[2].split(\" \").map{|str| str.to_i};\n if sav.viaPointIndex == sav.viaPointList.size()\n for i in 0..sav.viaPointList.size()-1\n allocatedViaPointList.push(sav.viaPointList[i]);\n end\n for i in 1..tmpAnsReadLine.size()-1\n updateFlag = true;\n if ( (tmpAnsReadLine[i]-(acceptedSizeArray[busID-1]))%2 == 0 ) # pickUp\n allocatedViaPointList.push( demand.tripViaPoint.pickUp );\n else # dropOff\n allocatedViaPointList.push( demand.tripViaPoint.dropOff );\n end\n end\n elsif acceptedSizeArray[busID-1]+1 < tmpAnsReadLine.size()\n for i in 0..sav.viaPointIndex\n allocatedViaPointList.push(sav.viaPointList[i]);\n end\n for i in 2..tmpAnsReadLine.size()-1\n updateFlag = true;\n if (tmpAnsReadLine[i] > acceptedSizeArray[busID-1]+1)\n if ( (tmpAnsReadLine[i]-(acceptedSizeArray[busID-1]+1))%2 == 1 ) # pickUp\n allocatedViaPointList.push( demand.tripViaPoint.pickUp );\n else # dropOff\n allocatedViaPointList.push( demand.tripViaPoint.dropOff );\n end\n else\n allocatedViaPointList.push(sav.viaPointList[ sav.viaPointIndex+tmpAnsReadLine[i]-2 ]);\n end\n end\n end\n if ( updateFlag )\n tmpViaPointIndex = sav.viaPointIndex;\n sav.viaPointList.clear();\n #for i in 0..allocatedViaPointList.size()-1\n # sav.viaPointList.push(allocatedViaPointList[i]);\n #end\n for i in 0..allocatedViaPointList.size()-1\n if i <= tmpViaPointIndex || allocatedViaPointList[i].mode != :dummy\n sav.viaPointList.push(allocatedViaPointList[i]);\n else\n puts \"planned route includes dummyViaPoint (NOT FIRST POINT)!\";\n end\n end\n \n viaPointIndex = sav.viaPointIndex ;\n prevPos = sav.fetchPosition() ;\n currentTime = @simulator.currentTime ;\n (viaPointIndex...sav.viaPointList.size).each{|idx|\n viaPoint = sav.viaPointList[idx] ;\n diffTime = estimateTime(prevPos, viaPoint, sav, :averageManhattan) ;\n currentTime += diffTime ;\n\n # store new plan\n if(true) then\n if(viaPoint.mode == :pickUp) then\n viaPoint.demand.updatePlannedPickUpTime(currentTime) ;\n elsif(viaPoint.mode == :dropOff) then\n viaPoint.demand.updatePlannedDropOffTime(currentTime) ;\n end\n end\n\n prevPos = viaPoint.pos ;\n }\n \n sav.assignedDemandList.push(demand) ;\n sav.clearDummyViaPointsInTail();\n demand.sav = sav ;\n \n #@simulator.savList[busID-1] = sav;\n\n pushAllocatedDemand( demand ) ;\n end\n\n else #if maxSATans[0].include?(\"UNSAT\") || !encodingDone\n if maxSATans[1] != nil\n if maxSATans[1].include?(\"exceeDeadline\")\n puts \"UNSAT (reason: exceeDeadline)\";\n demand.cancel(@simulator, :exceedDropOffTime);\n elsif maxSATans[1].include?(\"exceedCapacity\")\n puts \"UNSAT (reason: exceedCapacity)\";\n demand.cancel(@simulator, :exceedCapacity);\n elsif maxSATans[1].include?(\"noEncodedProblem\")\n puts \"UNSAT (reason: noEncodedProblem)\";\n demand.cancel(@simulator, :notAssigned);\n else\n puts \"UNSAT (reason: searchTimeout)\";\n demand.cancel(@simulator, :notAssigned);\n end\n else\n puts \"Unknown reason\";\n demand.cancel(@simulator, :notAssigned);\n #exit;\n end\n pushCancelledDemand( demand ) ;\n end\n \n sumOFinished = 0;\n @simulator.savList.each{|sav|\n for i in 0..sav.viaPointIndex-1\n if sav.viaPointList[i] != nil && sav.viaPointList[i].mode == :dropOff\n sumOFinished += 1;\n end\n end\n }\n puts \"sumOFinished : #{sumOFinished} | timeCost : #{@simulator.currentTime}\";\n if @simulator.currentTime >= 44000\n puts \"Finished time : #{@simulator.currentTime}\";\n exit;\n end\n \n end",
"def generate_alltest\n\n end",
"def seed_data\n # for my own testing purposes\n puts \"Providing some seed data here\"\n today = Date.today\n range1 = DateRange.new(start_date_obj: today, end_date_obj: today + 3)\n hotel.make_reservation(date_range: range1, customer: \"Butters\", new_nightly_rate: 50)\n hotel.make_reservation(date_range: range1, customer: \"Me\")\n hotel.make_block(date_range: range1, room_ids:[11,12,13,14,15], new_nightly_rate:100)\n hotel.make_reservation_from_block(room_id:11, customer:\"Oski\")\n hotel.make_reservation_from_block(room_id:12, customer: \"Jesse\")\n hotel.make_block(date_range: range1, room_ids:[19,20], new_nightly_rate:125)\nend",
"def new_input_set()\n return PurchaseInputSet.new()\n end",
"def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.map do |card|\n shoe << card\n end\n end\n shoe\nend"
] |
[
"0.7470944",
"0.6843264",
"0.59731007",
"0.59340966",
"0.5891488",
"0.58855706",
"0.5860812",
"0.58247143",
"0.5794167",
"0.57598925",
"0.57151693",
"0.5606726",
"0.5597033",
"0.55759776",
"0.555635",
"0.5553693",
"0.5518126",
"0.5489724",
"0.547689",
"0.54609674",
"0.54409105",
"0.5430314",
"0.54256386",
"0.54063404",
"0.53706867",
"0.5370138",
"0.53661895",
"0.53638697",
"0.53620166",
"0.53607595",
"0.5355207",
"0.53466845",
"0.5342034",
"0.5342034",
"0.5335411",
"0.5335284",
"0.53349316",
"0.53331006",
"0.5322692",
"0.5307291",
"0.5300652",
"0.52945185",
"0.5275855",
"0.5254746",
"0.52511674",
"0.52511674",
"0.52511674",
"0.52507174",
"0.52499884",
"0.5239529",
"0.5239088",
"0.52381766",
"0.5237034",
"0.5215475",
"0.52108276",
"0.5208446",
"0.52012545",
"0.5200415",
"0.519373",
"0.5188477",
"0.51820934",
"0.51806635",
"0.51699275",
"0.51659226",
"0.51613826",
"0.51521367",
"0.514175",
"0.51400363",
"0.51400363",
"0.513336",
"0.51297414",
"0.512737",
"0.5124027",
"0.5123282",
"0.51229215",
"0.5115265",
"0.5096548",
"0.5096512",
"0.50960135",
"0.5092813",
"0.50923175",
"0.5086852",
"0.50799745",
"0.50793195",
"0.5078923",
"0.50756705",
"0.5060922",
"0.5060885",
"0.5048865",
"0.5039774",
"0.5037374",
"0.5036657",
"0.50361675",
"0.5036102",
"0.50336504",
"0.50302374",
"0.5026415",
"0.50221837",
"0.502117",
"0.50151014"
] |
0.8237184
|
0
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get Array of All Objects Retaining Features ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def feature_objects(*args, &block)
maesb_sets.compact + (super(*args, &block))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_features\r\n feature_objects.inject([]) {|r, obj| r + obj.features }\r\n end",
"def objects\n @objects ||= []\n end",
"def objects\n @objects ||= []\n end",
"def objects\n @objects ||= []\n end",
"def all_objects; end",
"def array\n self.allObjects\n end",
"def objects\n @@objects ||= []\n end",
"def getObjects\n readObjects\n\n return @Objects\n end",
"def objects\n return @objects unless @objects.nil?\n objs = []\n dict = @instance.getDictionary\n (0 ... dict.getChildCount).each do |i|\n obj = dict.getChildAt(i)\n objs << {\n :name => obj.getName,\n :qual => obj.getQualification.toString.downcase.to_sym,\n :type => obj.getType.toString.downcase.to_sym,\n :object => obj,\n }\n end\n @objects = objs\n end",
"def feature_objects\r\n states\r\n end",
"def ignorable_objects\n\t\t[]\n\tend",
"def objects; end",
"def object_attributes\n []\n end",
"def objects\n @objects ||= population_group_members.collect(&:objects).flatten.uniq\n end",
"def features\n []\n end",
"def features\n []\n end",
"def all\n load_all! unless @objs_list\n @objs_list.values\n end",
"def all_objects\n processed_rows.collect { |_i, rp| rp.all_objects }.flatten\n end",
"def data_objects\n self.locations.map{|loc| loc.data_objects}.flatten.uniq.compact\n end",
"def in_memory\n []\n end",
"def to_a\r\n @objs.dup\r\n end",
"def fetch_all\n self.to_a\n end",
"def referenced_objects\n return @referenced_objects\n end",
"def in_memory\n []\n end",
"def in_memory\n []\n end",
"def objects\n @graphs.inject([]) {|memo, g| memo += g.objects}\n end",
"def instances #:nodoc:\n r = []\n ObjectSpace.each_object(self) { |mod| r << mod }\n r\n end",
"def all_objects\n objects = {\n \"Strawberries\" => get_strawberries,\n \"Mushrooms\" => get_mushrooms,\n \"Monsters\" => get_monsters,\n \"Persons\" => get_persons\n }\n end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def features\n @inventory.features(self).to_a\n end",
"def get_objects_of_class_by_class_name(class_name)\n var_array = []\n @objects.each do |_k, v|\n var_array.push(v) if v.class.to_s == class_name.to_s\n end\n var_array\n end",
"def available_known_objects\n known_objects=self.known_objects\n if not self.project.nil?\n return known_objects\n else\n upper_level_known_objects=self.concept.concept_category.function.function_structure_diagram.available_known_objects\n return (upper_level_known_objects + known_objects).uniq\n end\n end",
"def features\n @features ||= {}\n @features.keys\n end",
"def read_object_array(cls, io_offset, length)\n @io.seek io_offset\n array = []\n length.times do\n # All object arrays only contain java object refs\n id = @io.read_id\n array << @snapshot.resolve_object_ref(id)\n end\n array\n end",
"def getAssociatedObjects\n Item_objects = ObjectSpace.each_object(Item).to_a\n puts Item_objects\n item_ordered = Array.new\n Item_objects.each do |x| \n # if arr[x].order_id == @order_id\n # item_ordered = arr[x]\n # end\n # item_ordered\n puts Item_objects[x]\n end\n end",
"def variable_objects()\n @var_set.values\n end",
"def target_objects\n return @target_objects\n end",
"def target_objects\n return @target_objects\n end",
"def list_objects\n list_names.each_with_object([]) do |name, objects|\n begin\n objects << restore(name)\n rescue\n end\n end\n end",
"def items\n items = []\n iter = @obj.items\n\n while (i = iter.next)\n items << i\n end\n\n items\n end",
"def all_objects_in_order\n all_objects\n end",
"def all\n @@all ||= Array.new\n end",
"def object\n\t\t\treturn @obj_with_keys\n\t\tend",
"def getMembersAsArray() \n ret = []\n it = self.getIterator() \n while(it.hasMoreResources())\n ret << it.nextResource().getContentAsREXML()\n end\n \n return ret\n end",
"def object_instances\n return [] if object_definition.blank?\n \n latest_version = ::AP::VoiceExtension::Voice::Config.instance.latest_version\n klazz = \"::#{latest_version.upcase}::#{object_definition.name}\".constantize\n query_scope = object_definition.query_scope\n objects = klazz.respond_to?(query_scope.to_sym) ? klazz.send(query_scope.to_sym) : []\n if objects.blank?\n return []\n else\n return objects\n end\n end",
"def cache_objects_keys\n @object_data[].keys\n end",
"def get_objects(target_class, table_name, inclusive = false)\n answer = Array.new\n\n coord_system_ids_with_features = nil\n # Get all the coord_systems with this type of features on them\n if Collection.check\n coord_system_ids_with_features = Collection.find_all_coord_by_table_name(table_name,self.seq_region.coord_system.species_id).collect{|mc| mc.coord_system_id}\n else\n coord_system_ids_with_features = MetaCoord.find_all_by_table_name(table_name).collect{|mc| mc.coord_system_id}\n end \n # Get the features of the original slice\n if coord_system_ids_with_features.include?(self.seq_region.coord_system_id)\n sql = ''\n if inclusive\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{self.seq_region.id.to_s}\nAND (( seq_region_start BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\nOR ( seq_region_end BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\nOR ( seq_region_start <= #{self.start.to_s} AND seq_region_end >= #{self.stop.to_s} )\n )\nSQL\n else\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{self.seq_region.id.to_s}\nAND seq_region_start >= #{self.start.to_s}\nAND seq_region_end <= #{self.stop.to_s} \nSQL\n end\n answer.push(target_class.find_by_sql(sql))\n coord_system_ids_with_features.delete(self.seq_region.coord_system_id)\n end\n\n # Transform the original slice to other coord systems and get those\n # features as well. At the moment, only 'direct' projections can be made.\n # Later, I'm hoping to add functionality for following a path from one\n # coord_system to another if they're not directly linked in the assembly\n # table.\n coord_system_ids_with_features.each do |target_coord_system_id|\n target_slices = self.project(CoordSystem.find(target_coord_system_id).name)\n target_slices.each do |slice|\n if slice.class == Slice\n if inclusive\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\nAND (( seq_region_start BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\nOR ( seq_region_end BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\nOR ( seq_region_start <= #{slice.start.to_s} AND seq_region_end >= #{slice.stop.to_s} )\n )\nSQL\n else\n sql = <<SQL\nSELECT * FROM #{table_name}\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\nAND seq_region_start >= #{slice.start.to_s}\nAND seq_region_end <= #{slice.stop.to_s} \nSQL\n end \n answer.push(target_class.find_by_sql(sql))\n end\n end\n end\n\n answer.flatten!\n answer.uniq!\n\n return answer\n end",
"def all\n Maglev::PERSISTENT_ROOT[self].values\n end",
"def all\n @customer_objects\n end",
"def get_objects_of_class(obj)\n get_objects_of_class_by_class_name(obj)\n end",
"def objects\n objects = []\n params[:format] = 'xml' unless params[:format]\n if !params[:overlap].nil? and params[:overlap] == \"true\" #if we want to include objects that can fall onto the edge of the range\n objects = Feature.find_in_range(params[:reference_id], params[:start], params[:end], params[:id])\n else #if we want to include only objects entirely within the range\n objects = Feature.find_in_range_no_overlap(params[:reference_id], params[:start], params[:end], params[:id])\n end\n objects.delete_if { |obj| obj.feature != params[:type] } if !params[:type].nil?\n #respond(objects, params[:format])\n respond objects\n end",
"def objects_with_references\n end",
"def index\n @used_objects = UsedObject.all\n end",
"def to_a\n @size_dep.depend\n array = []\n Volt.run_in_mode(:no_model_promises) do\n attributes.size.times do |index|\n array << deep_unwrap(self[index])\n end\n end\n array\n end",
"def features\n\t\tcollection = []\n\t\tclasses.each do |_class|\n\t\t\t_class.features.each do |feature|\n\t\t\t\tcollection << feature\n\t\t\tend\n\t\tend\n\t\trace.features.each do |feature|\n\t\t\tcollection << feature\n\t\tend\n\t\tfeats.each do |feat|\n\t\t\tcollection << feat\n\t\tend\n\t\tcollection\n\tend",
"def elements\n # execute query\n ordered_objects.compact.uniq\n end",
"def items\n items, iter = [], @obj.items\n while (i = iter.next) do\n items << i\n end\n items\n end",
"def get_all_fences\n @coll.find.to_a\n end",
"def all_objects(opts = {})\n objects(\"*\", opts)\n end",
"def all_objects\n Registry.all(:root, :module, :class)\n end",
"def sequence_to_array_objects\n @sequence = Array.new if @sequence.nil?\n\n array = []\n if !@sequence.empty?\n @sequence.each { |element|\n downcaseElement = element.downcase\n if instance_attribute_defined?(downcaseElement)\n object = get(downcaseElement)\n if object.kind_of?(Array)\n array.concat object\n else\n array << object\n end\n end\n }\n else\n if !@objects.nil?\n @objects.each { |o|\n array << o\n }\n end\n end\n return array;\n end",
"def get_drawable_objects()\n @ary = []\n @ary += @monsters\n @ary += @towers.values\n @ary += @bullets\n @ary << @placed_tower if @placed_tower\n @ary\n end",
"def array\n @@array\n end",
"def all(_obj)\n raise NotImplementedError\n end",
"def child_objects(valkyrie: false)\n af_objects = Wings::ActiveFedoraConverter.new(resource: self).convert.objects\n return af_objects unless valkyrie\n af_objects.map(&:valkyrie_resource)\n end",
"def all\n Maglev::PERSISTENT_ROOT[self].values\n end",
"def iteration_associations\n [].freeze\n end",
"def available_go_cabs\n arr = []\n @go_cabs.select { |cab| arr << cab if (cab.available == true) }\n return arr\n end",
"def all\n return @recipearray\n end",
"def all\n @rarray\n end",
"def get_glade_all(obj = self)\r\n get_glade_active_record(obj)\r\n get_glade_variables(obj)\r\n end",
"def related_objects\n related_objects = Array.new\n\n\t\tself.meta_data_group_assignments.uniq.each do |assignment|\n\t\t\tobject_type = assignment.meta_data_group_assignable_type\n\t\t\tobject_id = assignment.meta_data_group_assignable_id\n\n\t\t\trelated_object = eval(object_type+'.find('+object_id.to_s+')')\n\t\t\trelated_objects.push(related_object)\n\t\tend\n\n\t\tputs related_objects.inspect\n\n return related_objects\n end",
"def get_objects(target_class, table_name, inclusive = false)\r\n answer = Array.new\r\n\r\n \r\n # Get all the coord_systems with this type of features on them\r\n coord_system_ids_with_features = MetaCoord.find_all_by_table_name(table_name).collect{|mc| mc.coord_system_id}\r\n\r\n # Get the features of the original slice\r\n if coord_system_ids_with_features.include?(self.seq_region.coord_system_id)\r\n sql = ''\r\n if inclusive\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{self.seq_region.id.to_s}\r\nAND (( seq_region_start BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\r\nOR ( seq_region_end BETWEEN #{self.start.to_s} AND #{self.stop.to_s} )\r\nOR ( seq_region_start <= #{self.start.to_s} AND seq_region_end >= #{self.stop.to_s} )\r\n )\r\nSQL\r\n else\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{self.seq_region.id.to_s}\r\nAND seq_region_start >= #{self.start.to_s}\r\nAND seq_region_end <= #{self.stop.to_s} \r\nSQL\r\n end\r\n answer.push(target_class.find_by_sql(sql))\r\n coord_system_ids_with_features.delete(self.seq_region.coord_system_id)\r\n end\r\n\r\n # Transform the original slice to other coord systems and get those\r\n # features as well. At the moment, only 'direct' projections can be made.\r\n # Later, I'm hoping to add functionality for following a path from one\r\n # coord_system to another if they're not directly linked in the assembly\r\n # table.\r\n coord_system_ids_with_features.each do |target_coord_system_id|\r\n target_slices = self.project(CoordSystem.find(target_coord_system_id).name)\r\n target_slices.each do |slice|\r\n if slice.class == Slice\r\n if inclusive\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\r\nAND (( seq_region_start BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\r\nOR ( seq_region_end BETWEEN #{slice.start.to_s} AND #{slice.stop.to_s} )\r\nOR ( seq_region_start <= #{slice.start.to_s} AND seq_region_end >= #{slice.stop.to_s} )\r\n )\r\nSQL\r\n else\r\n sql = <<SQL\r\nSELECT * FROM #{table_name}\r\nWHERE seq_region_id = #{slice.seq_region.id.to_s}\r\nAND seq_region_start >= #{slice.start.to_s}\r\nAND seq_region_end <= #{slice.stop.to_s} \r\nSQL\r\n end \r\n answer.push(target_class.find_by_sql(sql))\r\n end\r\n end\r\n end\r\n\r\n answer.flatten!\r\n answer.uniq!\r\n\r\n return answer\r\n end",
"def as_array\n @fm.dup\n end",
"def get_objects(data)\n get_block_data(data, /obj/, /endobj/, 6).collect { |o| get_chunk(o) }.compact\n end",
"def features\n model.instance_variable_get(\"@features\")\n end",
"def all_objectives\n Objective.all\n end",
"def oids\n\t\treturn @storage.keys\n\tend",
"def object\n @elements.map { |element| element.object }\n end",
"def free\n retval = []\n all.each{|r| retval << r if r.task_id.nil?}\n retval\n end",
"def all\n []\n end",
"def to_a; Array(force) end",
"def get_instances\n all_instances = Array.new()\n @groups.values.each do |instances|\n instances.each do |instance|\n all_instances << instance\n end\n end\n all_instances\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def object_types\n feature_object_types.collect(&:category).select{|c| c}\n end",
"def collect_objects\n results = []\n begin\n object_ids.each do |model_name, ids|\n results << model_name.to_s.constantize.find(ids)\n end\n results.flatten\n # rescue ActiveRecord::RecordNotFound\n # generate_objects!\n # collect_objects\n end\n end",
"def busy_go_cabs\n arr = []\n @go_cabs.select { |cab| arr << cab if (cab.available == false) }\n return arr\n end",
"def getVersionedObjects\n readVersionedObjects\n\n return @VersionedObjects\n end",
"def objects\n [@player] + @map.objects\n end",
"def objects\n @lmdb.transaction do\n if ret = @dbs[:control]['objects']\n ret.unpack1 'Q>' # 64-bit unsigned network-endian integer\n end\n end\n end",
"def list_objects\n objects = @model_class.method(:list).arity == 0 ? @model_class.list : @model_class.list(true)\n objects.map { |obj| Array(obj).find { |o| o.is_a?(@model_class) } }\n end",
"def get_all\n @data\n end",
"def get_all_image_type_obj_for_job\r\n image_type_obj_array = []\r\n images_for_jobs.each do |images_for_job|\r\n image_type_obj_array << ImageType.where([\"images_for_job_id = ?\", images_for_job.id])\r\n end\r\n image_type_obj_array = image_type_obj_array.flatten\r\n image_type_obj_array\r\n end",
"def objects\n @object_permission_map.keys\n end",
"def manipulable_entities\r\n result = []\r\n result.concat( patches )\r\n result.concat( edges )\r\n result.concat( vertices )\r\n result.concat( handles )\r\n result.concat( manual_interior_points )\r\n result\r\n end",
"def get_items\n\t\t@arr\n\tend",
"def objects\n # array to hold objects being backed up\n objects = []\n result = veeamconfig('job', 'info', '--name', \"#{@resource[:name]}\").lines\n\n # loop through every line of output\n result.each do |line|\n # the Include Disk lines are what we need\n if line.include? 'Include Disk:'\n # tease out the disk/volume being backed up\n object = line.split(': ')[1].strip\n # append the disk/volume to the array\n objects << object\n end\n end\n\n # return the disks/volumes being backed up, sorted properly\n return objects.sort_by(&:downcase)\n end",
"def load_objects\n @objects = scope.all\n instance_variable_set \"@#{object_name.pluralize}\", @objects\n end",
"def get_objects\n return self.pageobjects\n end",
"def to_a\n [ self ]\n end"
] |
[
"0.72875047",
"0.7075519",
"0.7053895",
"0.70462984",
"0.6974509",
"0.69432837",
"0.68581146",
"0.68282115",
"0.6693439",
"0.66029346",
"0.65807647",
"0.65681255",
"0.652994",
"0.64497",
"0.63681597",
"0.6362593",
"0.6349647",
"0.6338608",
"0.6305448",
"0.62015057",
"0.61837673",
"0.61801445",
"0.61542225",
"0.61323625",
"0.61323625",
"0.61151165",
"0.6111106",
"0.6104426",
"0.60558",
"0.6041806",
"0.6040873",
"0.6040198",
"0.599471",
"0.5984835",
"0.5969225",
"0.59672874",
"0.59531796",
"0.59531796",
"0.59481114",
"0.59207904",
"0.5908445",
"0.5893468",
"0.5885692",
"0.588271",
"0.58660656",
"0.5857558",
"0.5853923",
"0.5845724",
"0.58424807",
"0.5840391",
"0.58270276",
"0.5826107",
"0.5823907",
"0.58200526",
"0.5790956",
"0.57808113",
"0.5778268",
"0.57721573",
"0.57670504",
"0.5753936",
"0.5745096",
"0.57269984",
"0.57265395",
"0.5719682",
"0.5718985",
"0.57152337",
"0.571109",
"0.5707145",
"0.5703391",
"0.5683827",
"0.5680875",
"0.56743854",
"0.56621605",
"0.5659216",
"0.56548196",
"0.56446755",
"0.5643927",
"0.5635779",
"0.56348765",
"0.56287247",
"0.5627911",
"0.56277126",
"0.562597",
"0.5619016",
"0.5603657",
"0.56027293",
"0.55880404",
"0.55850327",
"0.5577069",
"0.5575957",
"0.5565977",
"0.5564075",
"0.5559265",
"0.5557246",
"0.554913",
"0.55435765",
"0.5539983",
"0.5536012",
"0.55290854",
"0.5521801"
] |
0.60012096
|
32
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get Added Value of Parameter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
def param_plus(param_id, *args, &block)
val = super(param_id, *args, &block)
maesb_sets.compact.inject(val) {|r, item| r += item.params[param_id] }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parameterReturn(param)\n return param\nend",
"def param; end",
"def param; end",
"def param_plus(param_id)\r\n @param_plus[param_id]\r\n end",
"def param( value )\n @paramNum += 1\n @params[@paramNum.to_s] = value\n return \":\" + @paramNum.to_s\n end",
"def parameter_string\n\t\tend",
"def add_parameter one\n # <leader>rap[name of param] from here\n # FIXME: make this work with g:ruby_refactoring_sans_superfluous_syntax and\n # ditch RAddParameterNB (would cause <leader>rap to respond immediately)\nend",
"def add_parameter(parameter)\n @parameters ||= []\n @parameters << parameter\n end",
"def param\n params[0]\n end",
"def get_value\n @value \n end",
"def get_param\n @params[name]\n end",
"def addParameter(request, parameter)\n pp [:got_addParameter, parameter, request] if $DEBUG\n request = request.request if request.kind_of? Java::Burp::IHttpRequestResponse\n request = request.to_java_bytes if request.respond_to? :to_java_bytes\n parameter = Buby::Parameter::Base.new parameter if parameter.kind_of? Hash\n String.from_java_bytes(__addParameter(request, parameter))\n end",
"def get_parameters; end",
"def get_parameters; end",
"def parameter_type; end",
"def parameter_type; end",
"def getParam(value)\n param = \"\"\n value.getParameters().each do |p|\n #TODO: Actually Get all parameters, cookies, jason, url, maybe we should get only url,get/post parameters\n #http://portswigger.net/burp/extender/api/constant-values.html#burp.IParameter.PARAM_BODY\n param += \"%s\" % p.getType() + \":\" + p.getName() + \"=\" + p.getValue() + \",\"\n end\n return param\n\n end",
"def parameter(name)\n parameters.find { |p| p.name == name.to_s }\n end",
"def params=(value); end",
"def add (parameter1, parameter2)\n\t# adds two values\n\treturn parameter1 + parameter2\nend",
"def get_value\n value\n end",
"def get_value\n value\n end",
"def add_parameter(name, value = 0, description = \"\")\n\t\t\tif (@parameters.key? name) or (@species.key? name)\n\t\t\t\traise \"duplicate parameter #{name}\"\n\t\t\tend\n\n\t\t\t@parameters[name] = Parameter.new(name, value, description)\n\n\t\t\tself\n\t\tend",
"def get_param(param)\n #$LOG.debug \"Get Param: #{@params[param]}\"\n return @params[param]\n end",
"def param(name)\n @params[name]\n end",
"def add_parameter(tag)\n add_or_update_parameter Parameter.from_yard_tag(tag, self)\n end",
"def get_parameters\r\n @parameters\r\n end",
"def param_value(key)\n @obj[key]\n end",
"def param( name, *args, &block )\n\t\t\tself.log.debug \"New param %p\" % [ name ]\n\t\t\tself.log.debug \" adding parameter %p to %p\" % [ name, self.paramvalidator ]\n\t\t\tself.paramvalidator.add( name, *args, &block )\n\t\tend",
"def get_value\n @value\n end",
"def add_parameter(id,handle,deriv_method) \n @params[id] = AmpParam.new(handle,deriv_method)\n end",
"def active_parameter\n attributes.fetch(:activeParameter)\n end",
"def get_value name=nil\n @value\n end",
"def get_parameter_value(document, name)\n # Retrieve the XML node representing the desird info value\n parameter_element = REXML::XPath.first(document, \"/handler/parameters/parameter[@name='#{name}']\")\n # If the desired element is nil, return nil; otherwise return the text value of the element\n parameter_element.nil? ? nil : parameter_element.text\n end",
"def parameters\n @parameters\n end",
"def value(name)\n name = attr_alias(name)\n\n (obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil\n end",
"def get(name)\n parameter = get_parameter(name)\n puts parameter.to_s\n end",
"def get_parameter(index)\n @parameters[index]\n end",
"def param(type, title, param)\n param_value(catalogue, type, title, param)\nend",
"def param(type, title, param)\n param_value(catalogue, type, title, param)\nend",
"def get_param(name)\n\n if !self.has_param(name)\n return Param(name)\n end\n\n Loggging.log.debug \"action get_param: name = #{name}\"\n Loggging.log.debug \"action get_param: value= #{@params[name].get_data('value')}\"\n Loggging.log.debug \"action get_param: type = #{@params[name].get_data('type')}\"\n return Param.new(\n name,\n @params[name].get_data(\"value\"),\n @params[name].get_data(\"type\"),\n true\n )\n end",
"def param(value, param) #method\n @new_context[param] = get_value(value)\n end",
"def getParam()\n param = CodeElemVariable.new(@parentElem)\n param.name = @name\n param.vtype = @vtype\n param.utype = @utype\n param.templates = @templates\n param.arrayElemCount = @arrayElemCount\n\n return param\n end",
"def parameter\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n __IDENTIFIER6__ = nil\n t = nil\n\n begin\n # at line 504:6: t= type IDENTIFIER\n @state.following.push( TOKENS_FOLLOWING_type_IN_parameter_509 )\n t = type\n @state.following.pop\n __IDENTIFIER6__ = match( IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_parameter_516 )\n # --> action\n\n @current_method.set_to_parameter_variables(__IDENTIFIER6__.text,VariableSymbol.new(__IDENTIFIER6__.text, t))\n \n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end\n \n return \n end",
"def parameter(name)\n @parameters[name.to_sym]\n end",
"def value\r\n @value\r\n end",
"def get_param(param)\n #$LOG.debug \"Get Param: #{@h[param]}\"\n return @h[param]\n end",
"def profile_parameter=(_arg0); end",
"def getvalue\n @variable.get_value @name\n end",
"def copy_and_add_param(key,value=nil,type=nil)\n new = self.copy\n new.add_param(key,value,type)\n return new\n end",
"def addParameter(*parms)\n\t\t\t\tparms = parms.first if parms.class == Array and (parms.first.class == Hash || parms.first.kind_of?(SAPNW::RFC::Parameter))\n\t\t\t case parms\n\t\t\t\t when Array\n\t\t\t\t\t name, direction, type, len, ulen, decimals = parms\n\t\t\t\t when Hash\n name = parms.has_key?(:name) ? parms[:name] : nil\n direction = parms.has_key?(:direction) ? parms[:direction] : nil\n type = parms.has_key?(:type) ? parms[:type] : nil\n len = parms.has_key?(:len) ? parms[:len] : nil\n ulen = parms.has_key?(:ulen) ? parms[:ulen] : nil\n decimals = parms.has_key?(:decimals) ? parms[:decimals] : nil\n\t\t\t when SAPNW::RFC::Export, SAPNW::RFC::Import, SAPNW::RFC::Changing, SAPNW::RFC::Table\n\t\t\t\t\t # this way happens when a function def is manually defined\n\t\t\t\t\t self.add_parameter(parms)\n @parameters[parms.name] = parms\n\t\t\t\t\t\treturn parms\n\t\t\t\t else\n\t\t\t raise \"invalid SAPNW::RFC::FunctionDescriptor parameter supplied: #{parms.inspect}\\n\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\t #$stderr.print \"parm: #{name} direction: #{direction} type: #{type} len: #{len} decimals: #{decimals}\\n\"\n case direction\n\t\t\t\t when SAPNW::RFC::IMPORT\n\t\t\t\t\t if @parameters.has_key?(name) and @parameters[name].direction == SAPNW::RFC::EXPORT\n\t\t\t\t\t p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\telse\n\t\t\t\t\t p = SAPNW::RFC::Import.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\tend\n\t\t\t\t\twhen SAPNW::RFC::EXPORT\n\t\t\t\t\t if @parameters.has_key?(name) and @parameters[name].direction == SAPNW::RFC::IMPORT\n\t\t\t\t\t p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\telse\n\t\t\t\t\t p = SAPNW::RFC::Export.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\t\tend\n\t\t\t\t\twhen SAPNW::RFC::CHANGING\n\t\t\t\t\t p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\twhen SAPNW::RFC::TABLES\n\t\t\t\t\t p = SAPNW::RFC::Table.new(self, name, type, len, ulen, decimals)\n\t\t\t\t\telse\n\t\t\t\t\t raise \"unknown direction (#{name}): #{direction}\\n\"\n\t\t\t\tend\n @parameters[p.name] = p\n\t\t\t\treturn p\n\t\t\tend",
"def report_parameter_value(gcode)\n bot.status.set_parameter(gcode.value_of(:P), gcode.value_of(:V))\n end",
"def parameters\n @params.extra_parameters\n end",
"def profile_parameter; end",
"def introduce_parameter(name, age)\n puts \"My name is #{name}\"\n puts \"My age is \" + age.to_s #{name}\"\nend",
"def a_param\n if @params.size > 1\n return @params[1]\n end\n return @params[0]\n end",
"def [](name)\n parameters[name]\n end",
"def getParamDetail(paramName)\n printDebugMessage('getParamDetail', 'Begin', 1)\n printDebugMessage('getParamDetail', 'paramName: ' + paramName, 2)\n xmlDoc = restRequest(baseUrl + '/parameterdetails/' + paramName)\n doc = REXML::Document.new(xmlDoc)\n printDebugMessage('getParamDetail', 'End', 1)\n return doc.root.elements['//parameter']\n end",
"def add(val)\n \n end",
"def value\n @value ||= XmlRpc::API::Message.parse_value(@document.root.elements[\"params/param/value\"])\n end",
"def add_parameter(tag)\n @parameters << Parameter.from_yard_tag(tag, self)\n end",
"def value \n @value\n end",
"def parameter\n resp = @ssm.get_parameter(\n name: @name, with_decryption: @decrypt\n )\n @type = resp.parameter.type\n @value = resp.parameter.value\n @exists = true\n rescue Aws::SSM::Errors::ParameterNotFound\n @exists = false\n end",
"def param(val)\n Build.param(val)\n end",
"def get_param(name, value)\n Config::Param.new(name: name, value: value)\n end",
"def parameter(name)\n @variables[name.to_sym] = :param\n end",
"def state_param_plus(param_id)\r\r\n @states.each do |state|\r\r\n return $data_states[state].param_plus[param_id]\r\r\n end\r\r\n return 0\r\r\n end",
"def value() end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def add(value)\n end",
"def agi; param(6); end",
"def old_value; end",
"def add_parameter( key, value, prompt=nil )\n @parameters[ key ] = [value, prompt]\n end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end"
] |
[
"0.68150127",
"0.6556336",
"0.6556336",
"0.65206426",
"0.64703137",
"0.64075214",
"0.6360481",
"0.6358102",
"0.63555354",
"0.62309027",
"0.61933863",
"0.6134356",
"0.6124009",
"0.6124009",
"0.6114801",
"0.6114801",
"0.61133057",
"0.6104645",
"0.61037576",
"0.60607696",
"0.6060142",
"0.6060142",
"0.60455024",
"0.60333335",
"0.60326356",
"0.6025301",
"0.6020613",
"0.601697",
"0.6011134",
"0.6010925",
"0.60045993",
"0.6002571",
"0.60012543",
"0.5998007",
"0.59838027",
"0.5974338",
"0.59739286",
"0.5965837",
"0.59366673",
"0.59366673",
"0.59288156",
"0.59166825",
"0.5908262",
"0.59082156",
"0.59013003",
"0.58637124",
"0.58629805",
"0.5862619",
"0.5854846",
"0.58402747",
"0.58063394",
"0.580441",
"0.57918185",
"0.5788793",
"0.5787846",
"0.5787006",
"0.57832247",
"0.5772736",
"0.57694376",
"0.57686377",
"0.57540363",
"0.57510823",
"0.5743606",
"0.5741012",
"0.57350516",
"0.5718098",
"0.5717937",
"0.5713958",
"0.57105565",
"0.57105565",
"0.57105565",
"0.57105565",
"0.57105565",
"0.57105565",
"0.57105565",
"0.5705785",
"0.5701043",
"0.5694687",
"0.56911737",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103",
"0.56866103"
] |
0.0
|
-1
|
I used the method above because in the method below I want to find if the name of the item is in the new array. if it is, Im going to increment it one. If not, Im going to put it into the array.
|
def consolidate_cart(cart)
new_cart = []
counter = 0
while counter < cart.length do
new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)
#We want to figureout if item is in our new cart
#This method checks to see if the item we're looking for is in the new cart. Takes in items name and collection or cart. :item key points to name of the item.
# This will either return the item or it will retrun nil. RETURNS THE ITEM OR RETURNS NIL
#This above code produces nil or cart[counter], per the above method. If nil is prodcued then a new hash called new_cart_item is added to the new array with a new hash called :count.
#If it already exist, the counter is incremented by one.
#My question is, what is new_cart_item
if new_cart_item
#If this has a truthy value, do whats below. New_cart_item is the item!!! It will be truthy if it is in the array. If in the array, we will just incremement count by 1. And do this every time this item comes up.
new_cart_item[:count] += 1
else new_cart_item = {
#Else is all other options. Either truthy of falsey. If new_cart_item returns nil, then we will do below. Which is creating our item. Creating a new hash, which is the same hash with :count added. So you can say, if this is not already in our array, which will produce nil, we will add :count to the array and and put it into the new array. We will give it a count of 1. Once its been built the count will be incremented by one for each time the item is in the old cart.
:item => cart[counter][:item],
:price => cart[counter][:price],
:clearance => cart[counter][:clearance],
:count => cart[counter][:count] = 1
}
new_cart<< new_cart_item
end
counter += 1
end
new_cart
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found = false\n \t\tnew_array.each do |new_hash_item|\n \t\t\t#binding.pry\n \t\t\tif new_hash_item.has_value?(original_array_element[:name])\n \t\t\t\tnew_hash_item[:count] += 1\n name_found = true\n \t\t\tend\n end\n if name_found == false\n new_element = {name: original_array_element[:name], count: 1}\n new_array.push(new_element)\n end\n \tend\n end\n return new_array\nend",
"def increment_item_count(cart, item_name)\n index = 0\n while index < cart.length do\n current_item = cart[index]\n if ( current_item[:item] == item_name )\n current_item[:count] += 1\n end\n index += 1\n end\n cart\nend",
"def add_item(list_items, item_name, item_qty)\n if list_items.include?(item_name)\n list_items[item_name] += item_qty\n else\n list_items[item_name] = item_qty\n end\nend",
"def update_quantity(list_name,item_name_to_adjust,new_quantity)\n#find all array elements in given list with the given item name\n list_name.each do |array_item|\n if array_item[:item_name] == item_name_to_adjust\n #set the quantity to the new specified quantity\n array_item[:quantity] = new_quantity\n end \n end \nend",
"def add_item(list, item_name, quantity = 1)\n # steps:\n # check IF item is included in list\n # increment item by quantity\n # ELSE - set item as new key and assign it to quantity as value\n list.include?(item_name) ? list[item_name] += quantity : list[item_name] = quantity\n\n # output: return the updated hash\n list\nend",
"def add_item(list, item_name, quantity = 1)\n if list.include?(item_name)\n list[item_name] += quantity\n else\n list[item_name] = quantity\n end\n list\nend",
"def consolidate_cart(cart)\n \n #declare new array\n new_cart = []\n \n #start with a counter so it begins at the first item\n counter = 0 \n \n #then create while loop\n while counter < cart.length \n \n #take each item in the cart and see if it is already in the new cart\n #calling the find_item_by_name_in_collection to check if item is in the new cart. Second argument is the collection we want to search want to see if the item is in our new cart.\n #So this will return either the item found or if not found it will return nil\n \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)\n #if item is already in cart, we just want to increase the count\n if new_cart_item != nil \n \n #if new_cart_item does not equal nil then we want to access new_cart_item and inside we want to access the count and increase by 1\n new_cart_item[:count] += 1\n \n #otherwise, item is nil. We would need to create our item. Inside the hash we need to construct the new item in the new cart\n else\n new_cart_item = {\n :item => cart[counter][:item], \n :price => cart[counter][:price],\n :clearance => cart[counter][:clearance],\n #this is the first time count is being used, the old item did not have count\n :count => 1\n }\n #after the new_cart is built, we are going to shovel new_cart_item variable\n new_cart << new_cart_item\n end\n #to ensure there is not an infinite loop \n counter += 1\n end\n new_cart\nend",
"def incremented?(original_array,new_array)\n original_array.each_index do |index|\n if new_array[index] > original_array[index] and ! @interfaces[@interfaces.keys[index]][1]\n original_array[index] = new_array[index]\n @interfaces[@interfaces.keys[index]][0] += 1\n @interfaces[@interfaces.keys[index]][1] = true\n # For testing when you want to see how many times an iface is incrementing.\n # puts \"#{@interfaces.keys[index]} => #{@interfaces[@interfaces.keys[index]][0]}\"\n push_xymon_notice(@interfaces.keys[index]) if @interfaces[@interfaces.keys[index]][0] == 10\n end\n end\n end",
"def add_item_quantity (list, item, quantity=1)\nif list.include?(item)\nlist [item] += quantity\nelse list [item] = quantity\nend\nlist\nend",
"def consolidate_cart(cart)\n new_cart = []\ncart.each do |grocery_item|\n current_item = find_item_by_name_in_collection(grocery_item[:item],new_cart)\n if current_item\n new_cart.each do |new_cart_item|\n if new_cart_item[:item] == current_item[:item]\n new_cart_item[:count]+=1 \n end\n end\n else\n grocery_item[:count] = 1 \n new_cart << grocery_item\nend\nend\nnew_cart\nend",
"def findSet(originalname,checkitem) \n if @store[checkitem].is_a?(Integer) then\n #Updating refrence to speed up further query\n if originalname!=checkitem then\n @store[originalname]=checkitem\n end\n return Array.[](checkitem,@store[checkitem]) #Return the Absolute Parent name and the number of element it has\n else\n findSet(originalname,@store[checkitem]) \n end\n end",
"def update_qty!(list, item, qty)\r\n counter = 0\r\n if list.include?(item)\r\n list[item] = qty\r\n else\r\n puts \"Sorry, that item isn't in the list\"\r\n end\r\n list\r\nend",
"def replace(arr)\n puts \"Please enter the name to replace:\"\n old_name = gets.chomp\n index = arr.index(old_name)\n puts \"Please enter the name to include instead:\"\n new_name = gets.chomp\n arr[index] = new_name\nend",
"def add_item(grocery_hash, new_item)\n new_item.each do |i|\n grocery_hash[i] += 1\n end\n grocery_hash\nend",
"def take_a_number(array, name)\n array.push(name)\n\n place = array.index(name)\n place = place.to_i\n place += 1\n\n puts \"Welcome, #{name}. You are number #{place} in line.\"\nend",
"def consolidate_cart(cart)\nindex = 0\nnew_cart = []\n\nwhile index < cart.length do\n item = find_item_by_name_in_collection(cart[index][:item],new_cart)\n if item\n new_cart_index = 0\n while new_cart_index < new_cart.length do\n if new_cart[new_cart_index][:item]===item[:item]\n new_cart[new_cart_index][:count]+=1\n end\n new_cart_index+=1\n end\n else \n cart[index][:count] = 1\n new_cart << cart[index]\n end\n index+=1\nend\nnew_cart\nend",
"def create_list(items)\n\n# Make an empty hash for grocery_list:\np grocery_list = {} \n\n \n# Takes the string of items that user puts in the create_list method, and turns it into an array:\np items = items.split\n\n# Iterate through each item in the array. This step turns the array into a hash buy asking if it has an item from the array as a key. If the item appears more than once in the array, it will count it as one key and give it a value of +1.\n items.each do | item |\n if grocery_list.has_key?(item)\n grocery_list[item] += 1\n else\n grocery_list[item] = 1\n end \n\n end\n grocery_list \nend",
"def update_quantity(item, new_quantity)\n if $old_list.to_h.include?(item) == true\n $old_list[item] = new_quantity\n p $old_list\n else\n p \"that item isn't on the list\"\n end\n \nend",
"def take_a_number(array, name)\n place = array.length+1\n if array == []\n array.push(name)\n puts \"Welcome, \" + array.join(', ') + \". You are number #{place} in line.\"\n array\n\n # if there are already people in line, it should add a person to the end of the line\n # adding multiple people in a row should correctly build the line\n else array != []\n array.push(name)\n puts \"Welcome, #{name}. You are number #{place} in line.\"\n array\n end\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def new_list(items)\n grocery_list = Hash.new(0)\n items.split(\" \").each do |x|\n grocery_list[x] += 1\n end\n grocery_list \nend",
"def add_item(list,new_item,item_count)\n\tlist[new_item] = item_count\nend",
"def update_item(list, name, change_in_quantity)\n normalize_string(name)\n if (list[name] + change_in_quantity <= 0)\n remove_item(list, name)\n else\n list[name] += change_in_quantity\n return list\n end\nend",
"def add_item(item, qty)\n for ele in @order do\n order_item = ele.keys[0]\n if order_item.name == item.name\n ele[order_item] += qty\n return \n end\n end\n @order.push({item => qty})\n \n end",
"def add_item(list_name, item_name, quantity = 1)\r\n if list_name.has_key?(item_name)\r\n list_name[item_name] += quantity\r\n else\r\n list_name[item_name] = quantity\r\n end\r\nend",
"def add_item(item_name, item_qty)\n# $list_items[item_name] = item_qty\n # my_hash[key] = value\n # This will create a NEW key value pair\n # OR update (aka replace) the value for an existing key.\n \n # my_hash[key] += value\n # will INCREASE the value for an existing key.\n if $list_items.include?(item_name)\n # Increase that item\n $list_items[item_name] += item_qty\n else\n # Create the new item\n $list_items[item_name] = item_qty\n end\nend",
"def add_book_to_inventory_by_book_title(new_book_title)\n new_book_array =\n {\n title: new_book_title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n new_book_title != @title\n @inventory.push(new_book_array)\nend",
"def push_to_array_jeff(original_array, new_item)\n # I think this is my best\n\n # make new_array that's one item longer than original\n original_length = original_array.length\n new_array = [nil] * (original_length + 1)\n # add all original items to new_array\n original_array.each_with_index do |val, idx|\n new_array[idx] = val\n end \n # make new_item the last element of new_array\n new_array[original_length] = new_item\n return new_array\nend",
"def selling_array(stonks) \n \n index_to_remove = stonks.find_index(buy(stonks))\n \nreturn index_to_remove + 1 \n\nend",
"def find_index(name)\n\t\tindex = 0\n\t\tfound = false\n\n\t\ttodo_items.each do |item|\n\t\t\tif item.name == name\n\t\t\tfound = true\n\t\tend\n\t\tif found\n\t\t\tbreak\n\t\telse\n\t\t\tindex += 1\n\t\tend\n\tend\n\t\tif found\n\t\t\treturn index\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def consolidate_cart(cart)\n new_cart = {}\n cart.each do |hash| #hash is the whole array\n hash.each do |name, describe| #name: avocado, cheese. describe: price, clearance\n #if new_cart has name and count already, increase the count\n if new_cart[name]\n new_cart[name][:count] += 1\n #new_cart is empty so set name as key and describe as value\n else\n new_cart[name] = describe\n new_cart[name][:count] = 1 #set count = 1 cuz we set name and describe for 1 item\n end\n end\n end\n new_cart\nend",
"def add_new_name_to_tags(orig, tag_name)\n return_array = []\n \n # sort of deep clone\n orig.each {|x| return_array << x.clone}\n\n name_key_found = false\n\n return_array.each do |r|\n if r[:Key] == 'Name'\n r[:Value] = tag_name\n name_key_found = true\n end\n break if name_key_found\n end\n\n unless name_key_found\n return_array << { Key: 'Name', Value: tag_name}\n end\n\n return_array\nend",
"def add(item, quantity, grocery_list)\n if grocery_list.include?(item)\n p \"Item is already on the grocery list.\"\n else \n grocery_list[item] = quantity\n end\n #print_list(grocery_list)\nend",
"def add(item, quantity, grocery_list)\n if grocery_list.include?(item)\n p \"Item is already on the grocery list.\"\n else \n grocery_list[item] = quantity\n end\n #print_list(grocery_list)\nend",
"def add_ingredient_by_name(new_ingredient)\n #self.ingredients < Ingredient.find_ingredient_by_name(new_ingredient)\n end",
"def add_item(grocery_list, item, quantity)\n grocery_list = grocery_list.each {|item,quantity|}\n if grocery_list.has_key?(item)\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\nend",
"def update_event_list(array)\n array.push(\"cycling\")\nend",
"def consolidate_cart(cart)\n index = 0\n new_cart = []\n \n cart.each do |grocery_item|\n current_item = find_item_by_name_in_collection(grocery_item[:item], new_cart)\n if current_item\n new_cart_index = 0\n new_cart.each do |new_cart_item|\n if new_cart_item[:item] === current_item[:item]\n new_cart_item[:count] += 1\n end\n new_cart_index += 1\n end\n else\n grocery_item[:count] = 1\n new_cart << grocery_item\n end\n index += 1\n end\n new_cart\nend",
"def update_item (item, new_quantity)\r\n if $grocery_list.include? item\r\n $grocery_list[item] = new_quantity\r\n else \r\n puts \"that item is not in the list!\"\r\n end\r\nend",
"def update_qty(list_items, item_name, new_qty)\n raise ArguementError.new(\"This item does not exist\") unless list_items.include?(item_name)\n list_items[item_name] = item_qty\nend",
"def find_dup(arr)\n arr.each do |item|\n item_count = arr.count(item)\n return item if item_count > 1\n end\nend",
"def grocery_list *items\n for item in items\n if item in list\n item.count += 1\n else\n list << item\n end\n end\nend",
"def add_item(list, item_name, qty=1)\n if list.has_key?(item_name)\n list[item_name] += qty\n else\n list[item_name] = qty\n end\n list\nend",
"def update_quan(older_list, item, quantity)\r\n older_list[item] = quantity\r\n return older_list \r\nend",
"def inventory_array(older, newer)\n newer.each do |item|\n name, quantity = item\n older.reject! { |olditem| olditem[0] == name }\n older << item\n end\n\n older.sort { |item_a, item_b| item_a[0] <=> item_b[0] }\nend",
"def consolidate_cart(cart)\n new_cart = []\n counter = 0 \n while counter < cart.length do \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart) #returns item if it finds it, and if it doesn't find it will return nil\n if new_cart_item != nil #if this variable has a truthy value,\n new_cart_item[:count] += 1 \n else #if that new cart item is nil, create our item. in hash construct item for the new cart\n new_cart_item = {\n :item => cart[counter][:item],\n :price => cart[counter][:price], \n :clearance => cart[counter][:clearance],\n :count => 1 #here we are going over item's name price and clearance value and adding a count key value pair and setting that equal to one.\n }\n new_cart << new_cart_item\nend \ncounter += 1 \nend\nnew_cart \nend",
"def assign_rooms(array)\n new_array = []\n counter = 1\n array.each do |name|\n new_array.push(\"Hello, #{name}! You'll be assigned to room #{counter}!\")\n counter += 1\nend\n return new_array\nend",
"def consolidate_cart(cart)\n updated_cart = []\n i = 0\n while i < cart.length do\n updated_cart_item = find_item_by_name_in_collection(cart[i][:item], updated_cart)\n if updated_cart_item #if it does have a value\n updated_cart_item[:count] += 1\n else\n updated_cart_item = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n updated_cart << updated_cart_item\n end\n i += 1\n end\n updated_cart\nend",
"def find_item(word, array)\n iter = 0\n while iter < array.length\n # is \"this\" same as \"the\"?\n if word == array[iter]\n return iter + 1 #in this case, iter +1 will add 1 to the position number\n end\n\n iter += 1\n end\n puts \"#{word} doesn't exist\"\nend",
"def consolidate_cart(cart)\n# [{:item => \"AVOCADO\", :price => 3.00, :clearance => true },\n# {:item => \"AVOCADO\", :price => 3.00, :clearance => true },\n# {:item => \"KALE\", :price => 3.00, :clearance => false}]\n new_cart = []\n i = 0\n while i < cart.length do\n new_cart_item = find_item_by_name_in_collection(cart[i][:item], new_cart)\nif new_cart_item != nil\n new_cart_item[:count] += 1\nelse\n new_cart_item = {\n :item=> cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\nend\n i+=1\n end\n new_cart\nend",
"def add_to_list(item, grocery_list)#add item and grocery_list to method\n if grocery_list.include?(item)#check if item is on list\n puts \"#{item} is already on your list\"#if item on list\n else\n grocery_list.push(item)#push new items to grocery list\n end\nend",
"def movies_with_director_key(name, movies_collection)\n \nnew_array = []\n\n counter = 0 \n while counter < movies_collection.length do \n array_info = movie_with_director_name(name, movies_collection[counter])\n new_array << array_info\ncounter += 1\nend\nreturn new_array\nend",
"def take_a_number(array, name)\n if array == []\n array.push(name)\n puts \"Welcome, #{array[0]}. You are number #{array.length} in line.\"\n elsif array != []\n array.push(name)\n puts \"Welcome, #{array.last}. You are number #{array.length} in line.\"\n end\nend",
"def update_item(list, name, quantity)\r\n # steps: \r\n # check if item is present\r\n if list[name] != nil\r\n # update with new amount\r\n list[name] = quantity\r\n end\r\n return list\r\n # output: list\r\nend",
"def increment_new_list(new_list, old_list, if_origin)\n list = Hash.new\n new_list.map { |k, v| v.to_i == 1 ? list[k+'s'] = v.to_i : list[k] = v.to_i }\n old_list.each do |k,v|\n if v.to_i == 1\n list[k+'s'] ? list[k+'s'] += v.to_i : list[k] = v.to_i\n else\n list[k] = list[k] ? list[k] + v.to_i : v.to_i\n end\n end\n if_origin ? old_list = list : list\n end",
"def add_new_items(list, item_name, quantity=1)\n list[item_name] = quantity\n list\nend",
"def find_dup(array)\n array.inject(Hash.new(0)) { |hash, item| hash[item] += 1; hash }.key(2)\nend",
"def add_item_to_list(list_name,item_to_add,quantity_to_add = 1)\n#create a hash element with the item name and the quantity, if specified\n#if no quantity is specified, default value = 1\n new_item = { \n item_name: item_to_add,\n quantity: quantity_to_add\n }\n# insert the hash into array \n list_name.push(new_item)\n new_item\nend",
"def count_elements (array)\n result_array = []\n\n array.each do |data|\n flag =0\n result_array.each do |k|\n if k[:name] == data[:name]\n k[:count] +=1\n flag =1\n end\n end\n if(flag == 0)\n data[:count] = 1\n result_array << data\n end\n end\n result_array\nend",
"def add_item(new_list, item_name, quantity=1)\r\n \r\n new_list[item_name] = quantity\r\n \r\nend",
"def increment list, entry\n if list[entry].class != NilClass\n list[entry] += 1\n end\nend",
"def add_item(new_item, quantity = $default_quantity)\r\n if !$grocery_list.include? new_item\r\n $grocery_list[new_item] = quantity\r\n else\r\n puts \"that item is already in your list!\"\r\n end\r\nend",
"def add_member_to_group(arr) # linking back to index.rb\n puts \"Enter name: \"\n name = gets.chomp\n arr.push(name) #passing in our group 'arr'\n # pp arr #printing and seeing array\nend",
"def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end",
"def create_list(grocery_items)\n grocery_list = Hash.new(0)\n grocery_items.split.each { |item| grocery_list[item] += 1 }\n grocery_list\nend",
"def has_item(name)\n @items.each_with_index do |item, index|\n if (item.name.casecmp(name) == 0)\n return index\n end\n end\n return -1\n end",
"def add_an_item(grocery_list, new_item, qty = 1)\n grocery_list[new_item] = qty\n grocery_list\nend",
"def count_elements(array)\n new_array = []\n for person in array.uniq\n new_array.push{:name => person[:name], :count => array.count(name)}\n end\nend",
"def edit_ingredient(r,i)\n ingredient_select = prompt_list_of_ingredients(r,i)\n new_ingredient_pair = gets_new_ingredient_pair\n # iteration over ingredients array with index and deletes and inserts hashes at index when ingredient names match.\n i.each_with_index do |ingredient_pair,index|\n ingredient_pair.each do |ing,p|\n if ingredient_select == ing \n i.delete_at(index)\n i.insert(index, new_ingredient_pair)\n end\n end\n end\nend",
"def girl_or_boy array\n dup_array = []\n array.each do |ele|\n if not dup_array.include? ele\n dup_array.push(ele)\n elsif dup_array.include? ele\n return \"boy\"\n end\n end\n return \"girl\"\nend",
"def update_quantity(thingtochange)\n userinputarray=thingtochange.split(\",\")\n $list_hash.each do|current_item, qty| \n if current_item==userinputarray[0]\n $list_hash[current_item]=userinputarray[1]\n else\n end\n end\nend",
"def update_item(list_name, item_name, quantity)\r\n list_name[item_name] = quantity if list_name.has_key?(item_name)\r\nend",
"def my_array_modification_method!(source, thing_to_modify)\n first_integer = []\n first_integer.push(i_want_pets[2])\n i_want_pets.delete_at(2)\n i_want_pets.insert(2, (first_integer.join.to_i + thing_to_modify) )\n\n second_integer = []\n second_integer.push(i_want_pets[7])\n i_want_pets.delete_at(7)\n i_want_pets.push(second_integer.join.to_i + thing_to_modify)\n\nend",
"def make_list(list, string_of_items)\n string_of_items.split(\" \").each do |item|\n list[item].nil? ? list[item] = 1 : list[item] += 1\n end\n list\nend",
"def update_quantity(list, item_name, quantity)\n\tlist.each do |item, qty|\n\t\tif item === item_name\n\t\t\tlist[item] = quantity\n\t\tend\n\tend\nend",
"def movies_with_director_key(name, movies_collection)\n new_movies_arr = []\n i = 0 \n while i < movies_collection.length do \n new_movies_arr << movie_with_director_name(name, movies_collection[i])\n i += 1 \n end \n new_movies_arr\nend",
"def consolidate_cart(cart)\n new_cart = []\n count = 0\n while count < cart.length\n new_cart_item = find_item_by_name_in_collection(cart[count][:item], new_cart)\n if new_cart_item != nil\n new_cart_item[:count] += 1\n else\n new_cart_item = {\n :item => cart[count][:item], \n :price => cart[count][:price],\n :clearance => cart[count][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\n end\n count += 1\n end\n new_cart\nend",
"def add_item(groccery_items, item)\n groccery_items[item] = 1\n p groccery_items\nend",
"def update_element_from_index(array, index_number, element)\nreturn array[index_number] = element\n\nend",
"def find_item(array, target)\n array.select do |elem| elem== target\n return array.index(target)+1\n end\n\n\n\n\nend",
"def add_item(list, name, qty=1)\n list.has_key?(name) ? list[name] += qty : list[name] = qty\n p list\nend",
"def add_item(list, name, qty=1)\n list.has_key?(name) ? list[name] += qty : list[name] = qty\n p list\nend",
"def ele_replace!(array, hash)\n array.map! do |ele| #go through the array\n if hash.has_key?(ele) #hash contains a key thats also in the array arr = [4,2,0,2] vs hash = {2=>two, 0 => zero} \n hash[ele] #convert array values with corresponding hash values -> [ ... ,two,zero,two]\n else\n ele #if array value doesnt correspond with hash key, place array index back to original position -> [ 4,...,...,...]\n end\n end\nend",
"def update_quantity(grocery_list, item, new_quantity)\n\tif grocery_list.include?(item.to_sym)\n\t\tgrocery_list[item.to_sym] = new_quantity\n\telse\n\t\tputs \"item name invalid\"\n\tend\nend",
"def take_a_number(array, new_customer)\n \n array << new_customer\n customer_index = array.find_index(new_customer)\n \n customer_status = \"Welcome, #{new_customer}. You are number #{customer_index + 1} in line.\"\n \n puts customer_status\n \nend",
"def movies_with_director_key(name, movies_collection) #iterate over movies collection. \n new_array = []\n row_index = 0 \n while row_index < movies_collection.length do \n new_array << movie_with_director_name(name, movies_collection[row_index]) \n row_index += 1 \nend\nreturn new_array\nend",
"def supply_check(array)\n index = 0\n array.each do |item|\n if item == \"batteries\"\n true\n else\n false\n end\n index += 1\n end\nend",
"def assign_rooms(array_of_names)\n room_assignments = []\n\n array_of_names.each_with_index do |name, index|\n room_assignments << \"Hello, #{name}! You'll be assigned to room #{index + 1}!\"\n end\n\n room_assignments\nend",
"def add(array, element)\n array.push(element) unless array.include?(element)\nend",
"def indexOf(payload_name)\n return nil if first_item.nil?\n final_item = first_item\n result_items = final_item.payload\n link_list_count = 0\n if payload_name == final_item.payload and link_list_count == 0\n return link_list_count\n end\n while payload_name != nil and payload_name != final_item.payload\n unless final_item.next_list_item == nil\n final_item = final_item.next_list_item\n link_list_count += 1\n else\n return nil\n end\n end\n # puts \"\\n at the end\"\n link_list_count\n end",
"def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend",
"def add_item(list, list_item, item_quantity)\n if list.has_key?(list_item)\n puts \"Item is already in list\"\n else\n list[list_item] = item_quantity\n end\n p list\n list\nend",
"def refill(item_name:, quantity:)\n total_items_quantity[item_name] += quantity\n items_running_low[item_name] = false\n end",
"def current_list(grocery_list, item, qty)\n grocery_list[item] = qty\n grocery_list\nend",
"def count_elements(abc)\n\n z=0\n i=1\n xyz=Array.new()\n xyz[0]=abc[0]\n\n\n xyz[0][:count]=1\n while i<abc.size do\n\n if xyz[z][:name]==abc[i][:name]\n\n\n xyz[z][:count]+=1\n i+=1\n\n else\n z+=1\n\n xyz[z]=abc[i]\n\n xyz[z][:count]=1\n i+=1\n\n end\n end\n #puts xyz.size\n print xyz\nend",
"def take_a_number (array, name)\n\narray.push(name)\nposition = array.length\n\n puts \"Welcome, #{name}. You are number #{position} in line.\"\n\nend",
"def count_elements(array)\n newArray = []\n array.each do |obj|\n newArray.push(obj)\n obj[:count] = 0\n #if newArray.length > 0\n newArray.each do |obj|\n if obj.include?(:count)\n obj[:count] += 1\n else\n obj[:count] = 1\n end\n #binding.pry\n end\n #end\n end\n newArray.shift\n return newArray\nend",
"def update_quantity(list, item_name, quantity)\n # steps:\n # check IF item is included in list\n # update the item’s quantity\n # ELSE, print a message to the user\n list.include?(item_name) ? list[item_name] = quantity : puts(\"No #{item_name} on the list.\")\n\n # output: return the updated hash or the original hash\n list\nend",
"def list_creater(items)\n my_array = items.split(\" \")\n my_list = Hash.new(0)\n my_array.each {|item| my_list[item] += 1}\n return my_list\nend"
] |
[
"0.65487725",
"0.6353932",
"0.6237777",
"0.6213303",
"0.61805165",
"0.6168216",
"0.6113214",
"0.59783983",
"0.5969943",
"0.5910795",
"0.5903968",
"0.59027946",
"0.58798784",
"0.58712655",
"0.58654684",
"0.58600324",
"0.58470786",
"0.58024645",
"0.5781512",
"0.5776512",
"0.5776512",
"0.5754075",
"0.5746097",
"0.57267594",
"0.5723031",
"0.5702554",
"0.5693211",
"0.5693023",
"0.56683904",
"0.56674194",
"0.5667197",
"0.5662019",
"0.56594354",
"0.5626203",
"0.5626203",
"0.56257397",
"0.56205314",
"0.56162",
"0.5605949",
"0.55912846",
"0.5580478",
"0.557366",
"0.55732554",
"0.55613256",
"0.55462515",
"0.55427456",
"0.553215",
"0.5517158",
"0.55082345",
"0.55063426",
"0.5505847",
"0.5500258",
"0.5498363",
"0.5482491",
"0.54819417",
"0.54750603",
"0.5469294",
"0.54641086",
"0.54562557",
"0.544652",
"0.5434377",
"0.5434254",
"0.5433721",
"0.5430254",
"0.5422548",
"0.5418142",
"0.5413807",
"0.5408841",
"0.54075503",
"0.54023165",
"0.54013574",
"0.53969723",
"0.5391001",
"0.5388605",
"0.5383968",
"0.5375573",
"0.5371734",
"0.53714985",
"0.5367078",
"0.5361442",
"0.53568095",
"0.53539115",
"0.53539115",
"0.53525543",
"0.5351773",
"0.5350019",
"0.53474283",
"0.5344203",
"0.53440523",
"0.5343387",
"0.53424734",
"0.5340306",
"0.5338811",
"0.5336714",
"0.5334118",
"0.5329597",
"0.5319017",
"0.5319015",
"0.53150403",
"0.5314465"
] |
0.6157613
|
6
|
Returns true if a particular concern exists
|
def exists? concern
mapper.instance_variable_get('@concerns').include?(concern)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def register?(curation_concern)\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"curation_concern=#{curation_concern.id}\",\n \"doi_enabled_cc_type?(curation_concern)=#{doi_enabled_cc_type?(curation_concern)}\",\n \"doi_minting_enabled?=#{doi_minting_enabled?}\",\n # \"curation_concern.doi_has_status?=#{curation_concern.doi_has_status?}\",\n \"\" ], bold_puts: debug_verbose_puts if debug_verbose\n #rv = doi_enabled_cc_type?(curation_concern) && doi_minting_enabled? && curation_concern.doi_has_status?\n return false unless doi_enabled_cc_type?(curation_concern) && doi_minting_enabled?\n doi_findable = doi_findable?( curation_concern )\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"curation_concern=#{curation_concern.id}\",\n \"doi_findable=#{doi_findable}\",\n \"\" ], bold_puts: debug_verbose_puts if debug_verbose\n rv = !doi_findable\n # TODO: add more checks here to catch cases when updating is unnecessary\n # TODO: check that required metadata is present if set to registered or findable\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"rv=#{rv}\",\n \"\" ], bold_puts: debug_verbose_puts if debug_verbose\n return rv\n end",
"def objected?\n objections.any?\n end",
"def exists?\n is_binded\n end",
"def doi_enabled_cc_type?(curation_concern)\n curation_concern.class.ancestors.include?(::Deepblue::DoiBehavior)\n # && curation_concern.class.ancestors.include?(::Deepblue::DataCiteDoiBehavior)\n end",
"def is_consumable?\n true\n end",
"def suitable_for?(discipline)\n name = name_discipline(discipline)\n count = self.disciplines.count(:conditions => ['name = ?', name])\n return count > 0\n>>>>>>> 336471e6be257cf55c9afa2a65f928fde34e41fe:app/models/project.rb\n end",
"def championship_associate?\n return false unless associations?\n\n @championship_associate ||= @associations.key?(:championship)\n end",
"def include?(model)\n exists?(model.id)\n end",
"def coupons?\n coupons.any?\n end",
"def exists?\n self.class.exists?(features)\n end",
"def has_contract?\n !@contract.nil?\n end",
"def coming_under?(model)\n @determine.nil? or !!@determine.call(model)\n end",
"def exists?(object); end",
"def exists?(object); end",
"def exists?()\n #This is a stub, used for indexing\n end",
"def contested?\n if issue\n self.class.where(issue_id: issue.id).count > 1 \n elsif pact\n self.class.where(pact_id: pact.id).count > 1\n end\n end",
"def exist?\n raise NotImplementedError\n end",
"def exists?\n criteria.exists?\n end",
"def has?(name)\n @_componentable_container.include?(name)\n end",
"def booked?\n collaboration.present?\n end",
"def exist?\n true\n end",
"def association_condition?(name)\n !association_condition_details(name).nil?\n end",
"def suitable?\n @confines.all?(&:true?)\n end",
"def own?\n @cache[:is_own] ||= begin\n require_valid\n owner == obj_module || owner == obj_singleton_class\n end\n end",
"def conjunction?\n type != HQMF::PopulationCriteria::OBSERV\n end",
"def exists?\n @provider.get(:ensure) != :absent\n end",
"def can_destroyed?\n return !self.business_user\n # list of associations to check (automatic)\n #has_assocs = []\n #self.class.reflections.each do |r_name, r|\n # has_assocs << r_name if [:has_one, :has_many, :has_and_belongs_to_many].include? r.macro\n #end\n \n # check for emptyness\n #has_assocs.each do |r_name|\n # assoc = self.send(r_name)\n # nothing = assoc.respond_to?('empty?') ? assoc.empty? : assoc.nil?\n # return false unless nothing\n #end\n \n true\n end",
"def company?\n directive.company?\n end",
"def exist?\n NotImplemented\n end",
"def exist?\n NotImplemented\n end",
"def has_dependency?(dependency)\n !find(dependency).nil?\n end",
"def campaign_exists?\n badge_id.present? && campaign.present?\n end",
"def actuale? opt = \"\"\n relation = opt.to_s.tableize\n\n actuale = false\n model.dependent_relations.each do |dependent_relation|\n tmp = self.send dependent_relation\n if relation == dependent_relation\n actuale ||= tmp.all.size > 1\n else\n actuale ||= tmp.exists?\n end\n end\n actuale\n end",
"def includes_contingency?\n application_interview_decision_type.nil? ? false : application_interview_decision_type.contingency_option\n end",
"def decorable?(key, klass, attribute)\n decorable.key?(klass) && decorable[klass].include?(attribute.to_s)\n end",
"def has_one?\n true\n end",
"def exists?; end",
"def has_dependency?\n return true unless @dependency.nil?\n end",
"def only_one_responsible?\n responsibles.count == 1\n end",
"def has_related_clinics?\n if under_supervision_clinics.count > 0 || clinics.count > 0\n return true\n end\n return false\n end",
"def has_associations?\n (!self.pulves.empty? ||\n !self.labours.empty? || \n !self.factures.empty? || \n !self.ventes.empty?)\n end",
"def applicable?\n true\n end",
"def exists?\n self.ensure == :present\n end",
"def belongs_to?\n\n !!belongs_to_config\n\n end",
"def exist?\n @resource.exist?\n end",
"def contains?(klass)\n # Import a domain class on demand by referencing the class base name in the context\n # of this module. If the class name can be resolved, then also check that it\n # was introspected. Primitive classes like String can be resolved, but are not\n # introspected. Domain classes are introspected when the name is resolved.\n (!!const_get(klass.name.demodulize) rescue false) and @introspected.include?(klass)\n end",
"def exists?()\n end",
"def has_many?\n @macro == :belongs_to\n end",
"def suitable_for_any?\n \treturn self.disciplines.count > 0\n end",
"def ability?\n self.__ability.present?\n end",
"def coupled?\n true\n end",
"def conditions_met?(object, associations); end",
"def assoc_with? obj\n obj.is_loggable? && is_tempora_assoc?(obj).present?\n end",
"def association?(object, associations); end",
"def exists?\n Puppet.debug(self.class.to_s.split('::').last + ': Calling exists method : ')\n @property_hash[:ensure] == :present\n end",
"def has?(key)\n respond_to? key\n end",
"def can_destroyed?\n # list of associations to check (automatic)\n has_assocs = []\n self.class.reflections.each do |r_name, r|\n has_assocs << r_name if [:has_one, :has_many, :has_and_belongs_to_many].include? r.macro\n end\n\n # check for emptyness\n has_assocs.each do |r_name|\n assoc = self.send(r_name)\n nothing = assoc.respond_to?('empty?') ? assoc.empty? : assoc.nil?\n return false unless nothing\n end\n \n true\n end",
"def has_accessories_percept\n if (self.has_accessories && self.has_services)\n return false\n else\n return true\n end\n end",
"def concrete?\n owner_id.nil?\n end",
"def resource_exists?\n ciudades\n end",
"def include?(name)\n !!find_by_name(name)\n end",
"def eager_loadable?\n !eager_loaded && !criteria.inclusions.empty?\n end",
"def used?\n return true unless Counsel.where(survey: self).empty?\n return true unless Solicitation.where(survey: self).empty?\n return true unless Promulgation.for_survey(self).empty?\n return false\n end",
"def exists?\n\t\treturn false\n\tend",
"def patient_suitable_for_circumcision?\n # Memoize as this may be called a number of times within one request.\n # It is a pre-condition to a number of encounters.\n return @patient_suitable_for_circumcision unless @patient_suitable_for_circumcision.nil?\n\n @patient_suitable_for_circumcision = begin\n Observation.joins(:encounter)\\\n .where(concept: concept('Suitable for circumcision'),\n value_coded: concept('Yes').concept_id)\\\n .where('DATE(obs_datetime) = ?', date.to_date)\\\n .merge(Encounter.where(patient: patient, program: program))\\\n .exists?\n end\n end",
"def exists?\n fail NotImplementedError\n end",
"def exist?\n self.class.exists?(dn)\n end",
"def advised?\n advisor_company_affiliations.with_access.present?\n end",
"def cookbook?\n File.exist? \"#{@config.workspace}/metadata.rb\"\n end",
"def exist?\n not self.name.nil?\n end",
"def doi?\n return false unless @curation_concern.respond_to? :doi\n @curation_concern.doi.present?\n end",
"def course_activity?\n self.strategy.class.name == \"CourseStrategy\"\n end",
"def exists\n self.class.exists(@name)\n end",
"def associated?\n @associated\n end",
"def exists?()\n\t\t\treturn @metadata.exists?\n\t\tend",
"def exist?\n !!@exist\n end",
"def exist?\n !!@exist\n end",
"def specific?\n @requirement.specific?\n end",
"def specific?\n @requirement.specific?\n end",
"def has_associated\n self.portfolio && self.design && self.plan\n end",
"def write_concern_error?\n !!(first_document && first_document['writeConcernError'])\n end",
"def included?\n @_included\n end",
"def exists?\n model.exists?(@id)\n end",
"def preconditions\n %i[\n has_one\n has_many\n ].include?(association.macro) && association.through_reflection.nil? && association.klass\n rescue NameError\n false\n end",
"def registered?\n !!(bibliography && bibliography.entries[key].equal?(self))\n end",
"def exists?(conditions = :none)\n return super if conditions.unfriendly_id?\n return true if exists_by_friendly_id?(conditions)\n super\n end",
"def in_to?\n [Referenced::BelongsTo, Embedded::EmbeddedIn].any? { |a| self.is_a?(a) }\n end",
"def has_container_model?(name)\n container_models.has_key?(name.to_str)\n end",
"def include?(something); end",
"def has?(essential)\n essentials.keys.include?(essential.to_sym)\n end",
"def exists?\n\t\tprovider.exists?\n\tend",
"def exists?\n\t\tprovider.exists?\n\tend",
"def exists?\n true\n end",
"def model_has_section?\n raise(DescriptorError, \"No model attached.\") unless model\n model_has_section = accessor && model.respond_to?(accessor.to_s)\n model_has_section ||= model.kind_of?(Hash) && model.key?(accessor.to_s)\n end",
"def valid_contract?()\n\t\t((self.house.kind_of?(Party)) ? true : false) and self.class.valid_contract?\n\tend",
"def has_association?(attr_name)\n _associations.has_key?(attr_name.to_sym)\n end",
"def resource_present?(type, title)\n !!catalog.resource(type, title)\n end",
"def include? object\n !!find(object)\n end",
"def exists(_obj)\n raise NotImplementedError\n end",
"def registered_for?(auction)\n self.auctions.include? auction\n end"
] |
[
"0.70485693",
"0.6434445",
"0.6415208",
"0.6409155",
"0.63483673",
"0.6341407",
"0.6309783",
"0.6258535",
"0.62329644",
"0.6208513",
"0.61902153",
"0.61816335",
"0.61488104",
"0.61488104",
"0.6148396",
"0.61426073",
"0.609767",
"0.60826993",
"0.6078935",
"0.6068534",
"0.60672385",
"0.60604995",
"0.6047874",
"0.6017401",
"0.60172164",
"0.60159814",
"0.6015626",
"0.6008254",
"0.600632",
"0.600632",
"0.60034937",
"0.5994933",
"0.59946865",
"0.59929216",
"0.59895283",
"0.59855115",
"0.5980642",
"0.59731776",
"0.597202",
"0.5968392",
"0.5965093",
"0.5961137",
"0.59546417",
"0.59481055",
"0.59481007",
"0.59445924",
"0.5931659",
"0.5929714",
"0.5928483",
"0.5920861",
"0.5920184",
"0.59186596",
"0.5917672",
"0.59173936",
"0.59140563",
"0.5902172",
"0.5899774",
"0.5899392",
"0.5898268",
"0.58961564",
"0.58809364",
"0.5880403",
"0.5879033",
"0.58761317",
"0.5875287",
"0.58751076",
"0.5874625",
"0.5871198",
"0.58677644",
"0.5867554",
"0.5865348",
"0.58642775",
"0.5863979",
"0.5862556",
"0.5860552",
"0.58595693",
"0.58595693",
"0.58556515",
"0.58556515",
"0.5855366",
"0.58526474",
"0.58500624",
"0.5840615",
"0.5836796",
"0.5835429",
"0.58331895",
"0.58309543",
"0.58302104",
"0.5829187",
"0.58286923",
"0.5827264",
"0.5827264",
"0.58271587",
"0.5821872",
"0.58211714",
"0.5818535",
"0.58147985",
"0.58142054",
"0.5810168",
"0.58085525"
] |
0.84185463
|
0
|
The abstract concern should be able to handle resources having a preferred collection/resource target.
|
def call(mapper, concern_options = {})
@mapper = mapper
@concern_options = concern_options
build
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resource_class\n raise NotImplementedError\n end",
"def reference_resource\n return super if defined?(super)\n\n raise NotImplementedError\n end",
"def resource_collection\n @resource_collection ||= @run_context.resource_collection\n end",
"def resource_collection\n run_context && run_context.resource_collection\n end",
"def resource_class\n return Passworks::AssetResource if collection_name == 'assets'\n # CertificateResource has no overrides, but follow along the normal flow.\n return Passworks::CertificateResource if collection_name == 'certificates'\n return Passworks::TemplateResource if collection_name == 'templates'\n if collection_uuid\n Passworks::PassResource\n elsif ['boarding_passes', 'coupons', 'store_cards', 'event_tickets', 'generics'].include?(collection_name)\n Passworks::CampaignResource\n else\n raise 'Invalid Resource Class'\n end\n end",
"def setup_request\n @resource_name = params[:resource].singularize.camelize\n @resource_klass_name = \"Entity::#{@resource_name}\"\n \n begin \n # Check that resource is managed by this controller\n unless ACCEPTED_RESOURCES[@resource_name]\n raise NameError\n end\n \n # Get resource arity\n @resource_arity = ACCEPTED_RESOURCES[@resource_name][:arity] || 'collection'\n \n rescue NameError => e\n render json: { errors: process_errors([\"Unknown Resource\"], 400) }, status: :bad_request\n return false\n end\n \n true\n end",
"def is_resource_like\n return (self.is_resource || self.is_collection_object)\n end",
"def collection_resource?\n @resource_arity.to_s == 'collection'\n end",
"def resource_class\n if any?\n first.class\n else\n raise ArgumentError, 'Cannot determine resource class on empty collection'\n end\n end",
"def resource_type\n :collection if collection?\n end",
"def resource_type\n :collection if collection?\n end",
"def as_resource(options = {})\n links = self_link\n\n if is_collection?\n links[:web] = {\n :href => \"#{@@web_url}/#{pk}\"\n }\n end\n \n resource = {\n :id => pk,\n :accession => objectnumber,\n :sort_number => sortnumber,\n :sort_title => sort_title,\n :sort_name => sort_name,\n :constituents => constituents.map {\n |c| c.as_resource({'no_objects' => true, 'no_bio' => true})\n },\n :titles => titles.as_resource,\n :series => series == nil ? nil : series.as_resource,\n :dates => date_resource(datebegin, dateend, dated),\n :sites => sites.count > 0 ? sites.map {\n |s| s.as_resource({'no_objects' => true})} : nil,\n :movements => movements.count > 0 ? movements.map {\n |m| m.as_resource({'no_objects' => true})} : nil,\n :acquisition => acquisition != nil ? \n acquisition.as_resource({'no_objects' => true}) : nil,\n :exhibitions => exhibitions.count > 0 ? exhibitions.map {\n |e| {\n :location => location(e.pk) != nil ? location(e.pk).as_resource : nil,\n :exhibition => e.as_resource({'no_objects' => true})\n }\n } : nil,\n :edition => edition,\n :medium => medium,\n :dimensions => dimensions,\n :credit => creditline,\n :has_essay => has_essay?,\n :has_extended_label => has_essay?,\n :copyright => copyright,\n :current_location => current_location == nil ? \n nil : current_location.as_resource,\n :media => media.count > 0 ? media.map { |m|\n m.as_resource\n } : nil,\n :object_types => object_types.count > 0 ? object_types.map { |t|\n t.as_resource({'no_objects' => true})\n } : nil,\n :permanent_collection => permanent_collection?,\n :recent_acquisition => is_recent_acquisition?,\n :_links => links\n }\n\n if options['no_essay'] != 'true'\n resource[:essay] = essay\n resource[:extended_label] = extended_label\n end\n\n return resource\n end",
"def fix_resource_reference(resource_collection, always_raise = false)\n matching_resource = resource_collection.find(resource)\n if Array(matching_resource).size > 1\n msg = \"Notification #{self} from #{notifying_resource} was created with a reference to multiple resources, \"\\\n \"but can only notify one resource. Notifying resource was defined on #{notifying_resource.source_line}\"\n raise Chef::Exceptions::InvalidResourceReference, msg\n end\n self.resource = matching_resource\n\n rescue Chef::Exceptions::ResourceNotFound => e\n # in unified mode we allow lazy notifications to resources not yet declared\n if !unified_mode || always_raise\n err = Chef::Exceptions::ResourceNotFound.new(<<~FAIL)\n resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \\\n but #{resource} cannot be found in the resource collection. #{notifying_resource} is defined in \\\n #{notifying_resource.source_line}\n FAIL\n err.set_backtrace(e.backtrace)\n raise err\n end\n rescue Chef::Exceptions::InvalidResourceSpecification => e\n err = Chef::Exceptions::InvalidResourceSpecification.new(<<~F)\n Resource #{notifying_resource} is configured to notify resource #{resource} with action #{action}, \\\n but #{resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \\\n is defined near #{notifying_resource.source_line}\n F\n err.set_backtrace(e.backtrace)\n raise err\n end",
"def resource_type\n\t\t\t\t\t\traise \"Not implemented.\"\n\t\t\t\t\tend",
"def resource_class\n resource_specification.klass\n end",
"def resource_specification\n self.class.resource_specification\n end",
"def is_resource\n return self.resource_type == Resource::RESOURCE;\n end",
"def resources\n @pruned_resources || super\n end",
"def resource_class\n \t@resource_class ||= get_resource_class\n end",
"def present_collection(collection = resource); nil; end",
"def resource_class\n # TODO does this need to have draft?\n @resource_class ||= resource_name.classify.constantize\n end",
"def get_resource_to_use\n return @resources.first\n end",
"def generic_resource( unit )\n resources unit, concerns: [:search_suggestion, :uniqueness_validation, :retrieve_resource]\n end",
"def check_resource_semantics!; end",
"def find_associated_resources(resource_descr, resource_type, target_type,authorizer)\n debug \"central find_associated_resources: descr: '#{resource_descr.inspect}' resource_type: #{resource_type}\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end",
"def subclass_resource_equivalents\n @subclass_resource_names ||= [resource_name.to_sym]\n end",
"def parent_resource_class\n @parent_resource_class ||= parent_resource_name.classify.constantize\n end",
"def initialize_resources_class_accessors! #:nodoc:\n\n\n # First priority is the namespaced model, e.g. User::Group\n self.resource_class ||= begin\n namespaced_class = self.name.sub(/Controller/, '').singularize\n namespaced_class.constantize\n rescue NameError\n nil\n end\n\n\n\n # Second priority is the top namespace model, e.g. EngineName::Article for EngineName::Admin::ArticlesController\n self.resource_class ||= begin\n namespaced_classes = self.name.sub(/Controller/, '').split('::')\n namespaced_class = [namespaced_classes.first, namespaced_classes.last].join('::').singularize\n namespaced_class.constantize\n rescue NameError\n nil\n end\n\n\n\n # Third priority the camelcased c, i.e. UserGroup\n self.resource_class ||= begin\n camelcased_class = self.name.sub(/Controller/, '').gsub('::', '').singularize\n camelcased_class.constantize\n rescue NameError\n nil\n end\n\n\n\n # Otherwise use the Group class, or fail\n self.resource_class ||= begin\n class_name = self.controller_name.classify\n class_name.constantize\n rescue NameError => e\n raise unless e.message.include?(class_name)\n nil\n end\n\n\n\n self.resource_instance_name = self.controller_name.singularize.to_sym #test_name\n\n self.collection_name = self.controller_name.to_sym\n\n\n\t\tself.resource_name = resource_class.to_s\n\n end",
"def collection_class\n defined?(Effective::StyleGuide) ? Effective::StyleGuide : super\n end",
"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 resource_scope # Thing\n @_effective_resource_relation ||= (\n relation = case @_effective_resource_scope # If this was initialized by the resource_scope before_filter\n when ActiveRecord::Relation\n @_effective_resource_scope\n when Hash\n effective_resource.klass.where(@_effective_resource_scope)\n when Symbol\n effective_resource.klass.send(@_effective_resource_scope)\n when nil\n effective_resource.klass.respond_to?(:all) ? effective_resource.klass.all : effective_resource.klass\n else\n raise \"expected resource_scope method to return an ActiveRecord::Relation or Hash\"\n end\n\n unless relation.kind_of?(ActiveRecord::Relation) || effective_resource.active_model?\n raise(\"unable to build resource_scope for #{effective_resource.klass || 'unknown klass'}. Please name your controller to match an existing model, or manually define a resource_scope.\")\n end\n\n relation\n )\n end",
"def base_collection\n @base_collection ||= resource_model.all\n end",
"def is_collection\n return self.resource_type == Resource::LEARNING_COLLECTION;\n end",
"def as_resource\n {\n :primary => @primary.as_resource,\n :other => @other.count > 0 ? @other.map {|t| t.as_resource} : nil\n }\n end",
"def resource\n return Object unless resource_type\n return resource_type.constantize unless resource_id\n return _resource\n end",
"def method_for_association_chain #:nodoc:\n resource_collection_name\n end",
"def resource_class\n resource_finder.is_a?(Class) ? resource_finder : resource_finder.name.classify.constantize\n end",
"def resource\n @resource ||= resource_set.createResource(uri)\n end",
"def resource_specification\n read_inheritable_attribute(:resource_specification)\n 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 is_collection_object\n return self.resource_type == Resource::COLLECTION_OBJECT;\n end",
"def resource_class\n @resource_class ||= resource_class_name.constantize\n end",
"def resource; end",
"def resource_scope # Thing\n @_effective_resource_relation ||= (\n relation = case @_effective_resource_scope # If this was initialized by the resource_scope before_filter\n when ActiveRecord::Relation\n @_effective_resource_scope\n when Hash\n effective_resource.klass.where(@_effective_resource_scope)\n when Symbol\n effective_resource.klass.send(@_effective_resource_scope)\n when nil\n effective_resource.klass.all\n else\n raise \"expected resource_scope method to return an ActiveRecord::Relation or Hash\"\n end\n\n unless relation.kind_of?(ActiveRecord::Relation)\n raise(\"unable to build resource_scope for #{effective_resource.klass || 'unknown klass'}.\")\n end\n\n relation\n )\n end",
"def base_resource\n\t\t\t Subresource.new persisted? ? self.class.identify(self) : self.class.base_resource\n\t\t\tend",
"def controlled_resources\n @controlled_resources ||= if params[:media_name]\n super.where(type: singular_linked_media_type)\n else\n super\n end\n end",
"def current_resource_owner\n return @current_resource_owner if defined?(@current_resource_owner)\n\n super\n end",
"def resolve_resource_reference(resource_collection, always_raise = false)\n return resource if resource.is_a?(Chef::Resource) && notifying_resource.is_a?(Chef::Resource)\n\n unless resource.is_a?(Chef::Resource)\n fix_resource_reference(resource_collection, always_raise)\n end\n\n unless notifying_resource.is_a?(Chef::Resource)\n fix_notifier_reference(resource_collection)\n end\n end",
"def calligraphy_resource(*resources, &block)\n options = resources.extract_options!.dup\n\n if apply_common_behavior_for :calligraphy_resource, resources, options, &block\n return self\n end\n\n with_scope_level(:resource) do\n options = apply_action_options options\n\n resource_scope(SingletonResource.new(resources.pop, api_only?, @scope[:shallow], options)) do\n yield if block_given?\n\n concerns(options[:concerns]) if options[:concerns]\n\n set_mappings_for_web_dav_resources\n end\n end\n end",
"def resource_singular() self.class.read_inheritable_attribute(:resource_singular) end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def setup_request\n @resource_name = params[:resource]\n @resource_klass_name = \"Entity::#{@resource_name}\"\n \n begin \n # Check that resource is managed by this controller\n unless ACCEPTED_RESOURCES.include? @resource_name\n raise NameError\n end\n\n rescue NameError => e\n logger.info(\"ressource-name:\"+@resource_name)\n render json: { errors: process_errors([\"Unknown Resource\"], 400) }, status: :bad_request\n return false\n end\n \n true\n end",
"def resource_class\n @resource_class ||= self.controller_name.singularize.classify.constantize\n end",
"def descriptive_resources\n find_related_frbr_objects( :is_described_by, :which_resources?) \n end",
"def descriptive_resources\n find_related_frbr_objects( :is_described_by, :which_resources?) \n end",
"def load_collection\n current_ability.scope_for(authorization_action, resource_class) do\n resource_base.accessible_by(current_ability, authorization_action)\n end\n end",
"def resource_base\n if @mediator.through\n resource_base_through\n else\n resource_class\n end\n end",
"def resource\n get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_find, params[:id]))\n end",
"def set_resource\n self.resource = commentable.is_a?(Comment) ? commentable.resource : commentable if self.resource_id.nil?\n end",
"def resource\n self.class.resource\n end",
"def resource_belongs_to(subject, resource_helper: true, urls: true, **options)\n resource_helper(subject) if resource_helper\n collection = options[:collection] || resource_class.model_name.plural\n source_relation_proc = BelongsTo.source_relation(subject, collection, options)\n protected define_method(:source_relation, &source_relation_proc)\n protected define_method(:index_url, &BelongsTo.index_url(subject, urls)) if urls\n end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def initialize_resources_class_accessors! #:nodoc:\n # First priority is the namespaced model, e.g. User::Group\n self.resource_class ||= begin\n namespaced_class = self.name.sub(/Controller$/, '').singularize\n namespaced_class.constantize\n rescue NameError\n nil\n end\n\n # Second priority is the top namespace model, e.g. EngineName::Article for EngineName::Admin::ArticlesController\n self.resource_class ||= begin\n namespaced_classes = self.name.sub(/Controller$/, '').split('::')\n namespaced_class = [namespaced_classes.first, namespaced_classes.last].join('::').singularize\n namespaced_class.constantize\n rescue NameError\n nil\n end\n\n # Third priority the camelcased c, i.e. UserGroup\n self.resource_class ||= begin\n camelcased_class = self.name.sub(/Controller$/, '').gsub('::', '').singularize\n camelcased_class.constantize\n rescue NameError\n nil\n end\n\n # Otherwise use the Group class, or fail\n self.resource_class ||= begin\n class_name = self.controller_name.classify\n class_name.constantize\n rescue NameError => e\n raise unless e.message.include?(class_name)\n nil\n end\n\n self.parents_symbols = self.parents_symbols.try(:dup) || []\n\n # Initialize resources configuration hash\n self.resources_configuration = self.resources_configuration.try(:dup) || {}\n self.resources_configuration.each do |key, value|\n next unless value.is_a?(Hash) || value.is_a?(Array)\n self.resources_configuration[key] = value.dup\n end\n\n config = (self.resources_configuration[:self] ||= {})\n config[:collection_name] = self.controller_name.to_sym\n config[:instance_name] = self.controller_name.singularize.to_sym\n\n config[:route_collection_name] = config[:collection_name]\n config[:route_instance_name] = config[:instance_name]\n\n # Deal with namespaced controllers\n namespaces = self.controller_path.split('/')[0..-2]\n\n # Remove namespace if its a mountable engine\n namespaces.delete_if do |namespace|\n begin\n \"#{namespace}/engine\".camelize.constantize.isolated?\n rescue StandardError, LoadError\n false\n end\n end\n\n config[:route_prefix] = namespaces.join('_').to_sym unless namespaces.empty?\n\n # Deal with default request parameters in namespaced controllers, e.g.\n # Forum::Thread#create will properly pick up the request parameter\n # which will be forum_thread, and not thread\n # Additionally make this work orthogonally with instance_name\n config[:request_name] = self.resource_class.to_s.underscore.gsub('/', '_')\n\n # Initialize polymorphic, singleton, scopes and belongs_to parameters\n polymorphic = self.resources_configuration[:polymorphic] || { symbols: [], optional: false }\n polymorphic[:symbols] = polymorphic[:symbols].dup\n self.resources_configuration[:polymorphic] = polymorphic\n end",
"def enclosing_collection_resources\n @enclosing_collection_resources ||= []\n end",
"def resource_collection_name #:nodoc:\n self.resources_configuration[:self][:collection_name]\n end",
"def current_collection() instance_variable_get(\"@#{resource_plural}\") end",
"def smart_resource_url\n url = nil\n if respond_to? :show\n url = resource_url rescue nil\n end\n url ||= smart_collection_url\n end",
"def resource_base\n @resource_base ||= model_of_controller.respond_to?(:authorized) ?\n model_of_controller.authorized(current_permission) :\n model_of_controller.scoped\n end",
"def resource_class\n @modified_resource_class ||= self.class.resource_class.clone\n end",
"def get_resource\n params.each do |name, value|\n if name.end_with?('_id')\n c = name.chomp('_id').classify.constantize rescue NameError\n if c.method_defined?(:collaborations)\n @resource = c.friendly.find(value)\n end\n end\n end\n end",
"def check_mixed_resources\n end",
"def resource_class\n @options[:resource_class]\n end",
"def find_associated_resources(resource_descr, resource_type, target_type, authorizer)\n debug \"find_associated_resources: descr: '#{resource_descr.inspect}'\"\n source_resource = nil\n target_resources = nil\n if resource_descr.kind_of? OMF::SFA::Model::Resource\n source_resource = resource_descr\n elsif resource_descr.kind_of? Hash\n model = eval(\"OMF::SFA::Model::#{resource_type.camelize}\")\n if resource_descr[:or]\n source_resource = nil\n resource_descr[:or].keys.each do |key|\n if source_resource.nil?\n source_resource = model.where({key => resource_descr[:or][key]})\n else\n source_resource = source_resource.or({key => resource_descr[:or][key]})\n end\n end\n else\n source_resource = model.where(resource_descr)\n end\n source_resource = source_resource.first\n if source_resource.kind_of? OMF::SFA::Model::Account and target_type.to_s.pluralize == 'leases'\n target_resources = []\n source_resource.resources.each { |res|\n if res.resource_type == 'lease'\n target_resources << res\n end\n }\n elsif !source_resource.nil? and source_resource.class.method_defined?(target_type)\n target_resources = source_resource.send(target_type)\n else\n raise OMF::SFA::AM::Rest::BadRequestException.new \"Invalid URL.\"\n end\n else\n raise FormatException.new \"Unknown resource description type '#{resource_descr.class}' (#{resource_descr})\"\n end\n unless source_resource\n raise UnknownResourceException.new \"Resource '#{resource_descr.inspect}' is not available or doesn't exist\"\n end\n raise InsufficientPrivilegesException unless authorizer.can_view_resource?(source_resource)\n return source_resource, target_resources\n end",
"def collection_representer_klass\n resource_module::Representer::Collection\n end",
"def resource_class\n\t\t\t\t@resource_class ||= resource_name.classify.constantize\n\t\t\tend",
"def current_resource\n @current_resource ||= @item\n end",
"def access_to_resources?(record)\n @normalized_resources.include?(record.resource)\n end",
"def representer_klass\n resource_module::Representer::Resource\n end",
"def resource_data\n raise ArgumentError.new 'The resource_data method must be implemented by the resource controller'\n end",
"def resource_class\n @resource_class ||= self.class.to_s.split(\":\").last\n end",
"def load_resource_with_associated_resources\n item = load_resource\n load_storage_system(item)\n\n # item.set_storage_pool(OneviewSDK::StoragePool.new(item.client, name: storage_pool)) if storage_pool\n # Workaround for issue in oneview-sdk:\n if storage_pool\n sp = OneviewSDK::StoragePool.find_by(item.client, name: storage_pool, storageSystemUri: item['storageSystemUri']).first\n raise \"Storage Pool '#{sp['name']}' not found\" unless sp\n item['storagePoolUri'] = sp['uri']\n end\n\n if snapshot_pool\n snapshot_pool_resource = OneviewSDK::StoragePool.find_by(item.client, name: snapshot_pool, storageSystemUri: item['storageSystemUri']).first\n item.set_snapshot_pool(snapshot_pool_resource)\n end\n item.set_storage_volume_template(OneviewSDK::VolumeTemplate.new(item.client, name: volume_template)) if volume_template\n\n # Convert capacity integers to strings\n item['provisionedCapacity'] = item['provisionedCapacity'].to_s if item['provisionedCapacity']\n item['allocatedCapacity'] = item['allocatedCapacity'].to_s if item['allocatedCapacity']\n\n unless item.exists? # Also set provisioningParameters if the volume does not exist\n item['provisioningParameters'] ||= {}\n item['provisioningParameters']['shareable'] = item['shareable'] if item['provisioningParameters']['shareable'].nil?\n item['provisioningParameters']['provisionType'] ||= item['provisionType']\n item['provisioningParameters']['requestedCapacity'] ||= item['provisionedCapacity']\n item['provisioningParameters']['storagePoolUri'] ||= item['storagePoolUri']\n end\n item\n end",
"def assign_resource\n self.resource ||= find_wizard_resource\n end",
"def belongs_to(parent_resource)\n parent_resource = parent_resource.to_sym\n parent_resources << parent_resource unless parent_resource.in?(parent_resources)\n end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def resource_class\n @resource_class ||= resource_name.classify.constantize\n end",
"def resource_collection\n client.run_status.run_context.resource_collection\n end",
"def decorated_change_set_resource\n @decorated_change_set_resource ||= @change_set.resource.decorate\n end",
"def resource\n @resource\n end",
"def find_resource(obj)\n\n\n\n resources.detect do |r|\n\n\n\n r.resource_name.to_s == obj.to_s || r.resource_class.to_s == obj.to_s\n\n\n\n end ||\n\n\n\n if obj.respond_to? :base_class\n\n\n\n resources.detect{ |r| r.resource_class.to_s == obj.base_class.to_s }\n\n\n\n end\n\n\n\n end",
"def load_resource_with_associated_resources\n item = load_resource\n load_storage_system(item)\n\n # item.set_storage_pool(OneviewSDK::StoragePool.new(item.client, name: storage_pool)) if storage_pool\n # Workaround for issue in oneview-sdk:\n if storage_pool\n sp = OneviewSDK::StoragePool.find_by(item.client, name: storage_pool).first\n raise \"Storage Pool '#{sp['name']}' not found\" unless sp\n item['storagePoolUri'] = sp['uri']\n end\n\n item.set_snapshot_pool(OneviewSDK::StoragePool.new(item.client, name: snapshot_pool)) if snapshot_pool\n item.set_storage_volume_template(OneviewSDK::VolumeTemplate.new(item.client, name: volume_template)) if volume_template\n\n # Convert capacity integers to strings\n item['provisionedCapacity'] = item['provisionedCapacity'].to_s if item['provisionedCapacity']\n item['allocatedCapacity'] = item['allocatedCapacity'].to_s if item['allocatedCapacity']\n\n unless item.exists? # Also set provisioningParameters if the volume does not exist\n item['provisioningParameters'] ||= {}\n item['provisioningParameters']['shareable'] = item['shareable'] if item['provisioningParameters']['shareable'].nil?\n item['provisioningParameters']['provisionType'] ||= item['provisionType']\n item['provisioningParameters']['requestedCapacity'] ||= item['provisionedCapacity']\n item['provisioningParameters']['storagePoolUri'] ||= item['storagePoolUri']\n end\n item\n end",
"def resources; end",
"def resources; end",
"def target\n resource\n end",
"def identify(_collection)\n raise NotImplementedError\n end",
"def assign_collection\n source, collection = get_source_and_collection\n collection.updatable_by?(current_user) || raise(Hobo::PermissionDeniedError, \"#{self.class.name}#assign_collection\")\n collection.real_source << source unless(collection.real_source.include?(source))\n collection.save!\n end",
"def class_of_resource\n @class_of_resource ||= resource_name.classify.constantize\n end",
"def resource_list\n self.resources\n end",
"def autorequire(rel_catalog = nil)\n reqs = super\n\n [\n @parameters[:prior_to].value,\n @parameters[:resource].value,\n ].flatten.each do |rel|\n reqs << Puppet::Relationship.new(self, catalog.resource(rel.to_s))\n end\n\n reqs\n end"
] |
[
"0.65963537",
"0.6441069",
"0.63092786",
"0.62719566",
"0.6143603",
"0.6134698",
"0.6100378",
"0.6081047",
"0.6069944",
"0.59489024",
"0.59489024",
"0.59281707",
"0.5880016",
"0.587787",
"0.5839482",
"0.58336556",
"0.5832619",
"0.5824523",
"0.58217174",
"0.57979053",
"0.5787124",
"0.57822794",
"0.57719773",
"0.5768204",
"0.5741458",
"0.5733314",
"0.57147104",
"0.57089126",
"0.5706617",
"0.5702911",
"0.5702134",
"0.5698985",
"0.567473",
"0.5648337",
"0.564184",
"0.5635501",
"0.5628897",
"0.5624476",
"0.5621405",
"0.55927396",
"0.5587692",
"0.5585802",
"0.55854565",
"0.55837184",
"0.55745816",
"0.5569886",
"0.55474794",
"0.55305636",
"0.5522709",
"0.55224025",
"0.551072",
"0.551072",
"0.551072",
"0.55017245",
"0.5496497",
"0.54882926",
"0.54882926",
"0.54864424",
"0.5479485",
"0.54708475",
"0.5470348",
"0.54684067",
"0.5466433",
"0.54646236",
"0.54585886",
"0.54583925",
"0.5457488",
"0.5457233",
"0.5455216",
"0.5450671",
"0.54481196",
"0.5447222",
"0.54445153",
"0.5440468",
"0.5439014",
"0.54369545",
"0.54284567",
"0.5427544",
"0.54265386",
"0.5416977",
"0.5408632",
"0.5401373",
"0.5396471",
"0.53948814",
"0.5384461",
"0.5372416",
"0.5372416",
"0.5372416",
"0.53705496",
"0.5369148",
"0.5366625",
"0.536657",
"0.53637576",
"0.5357275",
"0.5357275",
"0.5355064",
"0.53474057",
"0.5344168",
"0.534151",
"0.5340696",
"0.5339138"
] |
0.0
|
-1
|
Create new limitable session
|
def log_limitable_request!
token = generate_limitable_token
opts = session_limitable_condition unique_session_id: token,
last_accessed_at: Time.current
authenticate_limitable? && session_limitable_adapter.create!(opts) && token
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_session\n raise NotImplementedError\n end",
"def new_session\n open_session do |sess|\n sess.extend(SessionMethods)\n yield sess if block_given?\n end\n end",
"def new_session(options)\n options[:source_profile] = options[:source_profile].to_sym\n options[:profile] = options[:profile].to_sym\n\n user_prof = user_profile(options[:source_profile], options[:config_file])\n options = user_prof.to_h.deep_merge(options).deep_symbolize_keys\n\n sb = SessionBuilder.new(\n mfa_device: mfa_device(options),\n session_duration_seconds: options[:duration],\n source_profile: user_prof\n )\n set_user_session_profile(options[:profile], sb.session_profile)\n end",
"def create_session\n @connection.create_session(@config || {})\n end",
"def create_new_session\n session = reviewer_access_sessions.build\n session.save!\n session\n end",
"def new\n @session = Session.new('')\n end",
"def create!(*args)\n session = new(*args)\n session.save!\n session\n end",
"def create!(*args)\n session = new(*args)\n session.save!\n end",
"def create!(*args)\n session = new(*args)\n session.save!\n end",
"def new\n @session = Session.new\n end",
"def new_session(options={})\n if supports_sessions?\n api.rest_method('ADD_AUTHORIZATION', {\n :scope => 'session',\n :note => \"RHC/#{RHC::VERSION::STRING} (from #{Socket.gethostname rescue 'unknown'} on #{RUBY_PLATFORM})\",\n :reuse => true\n }, options)\n end\n end",
"def create\n\t \t\tmodule_grand_access = permission_control(\"session\",\"create\")\n\t \t\tif module_grand_access\n\t \t\t\tsession = Session.new(session_params)\n\t \t\t\tsession.created_by = current_user.id\n\t \t\t\tif session.save!\n\t \t\t\t\trender json: session, status: :created\n\t \t\t\telse\n\t \t\t\t\trender json: session.errors,status: :bad_request\n\t \t\t\tend\n\t \t\telse\n \t \t\t\trender json: { error: \"You dont have permission to perform this action,Please contact Site admin\" }, status: :unauthorized\t \t\t\t\n\t\t\tend\n\t \tend",
"def create_session\n @user = User.new(nickname: User.temp_user_name)\n @user.save\n session[:user_id] = @user.id\n @user\n end",
"def new\n @session = Session.new\n end",
"def create_session(session_id, data)\n session_id = escape(session_id)\n new_session = new(session_id, data)\n new_session\n end",
"def create\n return if Settings.readonly \n\n @session = Session.new(session_params)\n\n respond_to do |format|\n if @session.save\n format.html { redirect_to sessions_url, notice: 'Session was successfully created.' }\n format.json { render :show, status: :created, location: @session }\n else\n format.html { render :new }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def open_session; end",
"def init_session\n if session\n if session.updated_at < Time.now - ::Gricer.config.max_session_duration\n self.session = Session.create previous_session: session, ip_address: @ip_address, agent: agent, requested_locale: @request_locale\n else\n self.session.touch\n end\n else\n self.is_first_in_session = true\n self.session = Session.create ip_address: @ip_address, agent: agent, requested_locale: @request_locale\n self.session.touch\n end\n \n session\n end",
"def create_session(timeout=nil)\n if timeout.class == Fixnum && !block_given?\n return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createSession, [Java::long.java_class]).call(timeout),::VertxWeb::Session)\n end\n raise ArgumentError, \"Invalid arguments when calling create_session(timeout)\"\n end",
"def new_session\n IntegrationSession.new\n end",
"def new\n @session = User::Session.new\n end",
"def start_session\n generate_token(:token)\n setup_session\n update_last_session\n end",
"def create_monthly_session(user)\n today = DateTime.now\n year = today.year\n month = today.month\n current_monthly_session = MonthlySession.new(:month => month, :year => year)\n current_monthly_session.user = user\n current_monthly_session.available_sessions = ENV['COMMUNITY_MONTHLY_SESSION_LIMIT']\n current_monthly_session.save!\n return current_monthly_session\n end",
"def createSession(groupID, authorID, validUntil)\n call :createSession, :groupID => groupID, :authorID => authorID, :validUntil => validUntil\n end",
"def create_write_and_return_new_session!\n require 'timeout'\n\n session = DropboxSession.new(api_key, api_secret)\n\n # grab the request token for session\n session.get_request_token\n\n template = Backup::Template.new(\n {:session => session, :cached_file => cached_file}\n )\n template.render(\"storage/dropbox/authorization_url.erb\")\n\n # wait for user to hit 'return' to continue\n Timeout::timeout(180) { STDIN.gets }\n\n # this will raise an error if the user did not\n # visit the authorization_url and grant access\n #\n # get the access token from the server\n # this will be stored with the session in the cache file\n session.get_access_token\n\n template.render(\"storage/dropbox/authorized.erb\")\n write_cache!(session)\n template.render(\"storage/dropbox/cache_file_written.erb\")\n\n session\n\n rescue => err\n raise Errors::Storage::Dropbox::AuthenticationError.wrap(\n err, 'Could not create or authenticate a new session'\n )\n end",
"def session_uplimit(limit = nil)\n args = generate_speed_args(\"speed-limit-up-enabled\", \"speed-limit-up\", limit)\n remote_request(\"session-set\", args)\n end",
"def create_session\n raw_token, enc_token = account.create_session(ip, meta_info)\n set_account_cache(account, raw_token)\n set_auth_token_cache(enc_token, raw_token)\n return raw_token\n end",
"def set_session\n \n end",
"def create_sessions(max)\n iTerm = app('iTerm')\n 1.upto(max) do |num|\n iTerm.current_terminal.launch_(session: \"Default Session\")\n iTerm.current_terminal.current_session.name.set(\"tab_#{num}\")\n # puts iTerm.current_terminal.current_session.name.get\n end\nend",
"def create_smite_api_session\n session_timestamp = Time.now.getutc.strftime(\"%Y%m%d%H%M%S\")\n session_string = \"#{ENV['SMITE_API_DEV_ID']}\" + 'createsession' + \"#{ENV['SMITE_API_AUTHKEY']}\" + session_timestamp\n session_signature = Digest::MD5.hexdigest(session_string)\n\n smite_session = RestClient.get(\"#{SMITE_PC_URL}/createsessionJson/#{ENV['SMITE_API_DEV_ID']}/#{session_signature}/#{session_timestamp}\")\n JSON.parse(smite_session)['session_id']\nend",
"def create(description, permitted_ips: nil)\n fail ArgumentError, 'description is required' unless description\n fail 'Cannot create session, please add the api_key to your configuration' unless @client.configuration.api_key\n\n params = {description: description, secret: @client.configuration.api_key}\n params[:permitted_ips] = permitted_ips if permitted_ips\n\n @resource.post(params)['Response']\n end",
"def create\n session = Session.new\n session.name = params[:name]\n session.description = params[:description]\n session.start_time = params[:date]\n # TODO: need date\n # TODO: need topic\n session.active = true;\n # add ot_session.id\n ot_session = @@opentok.create_session({media_mode: :routed})\n session.session_id = ot_session.session_id\n # try and save the session\n saved = session.save\n # add moderators\n params[:moderators].each do |moderator|\n SessionUser.create(session_id: session.id, user_id: moderator[:id], role: 'moderator', center_stage: true)\n end\n # add subscribers\n params[:subscribers].each do |subscriber|\n puts subscriber\n SessionUser.create(session_id: session.id, user_id: subscriber[:id], role: 'publisher', center_stage: false)\n end\n if saved\n render json: {message: \"Event: #{session.name} successfully added\"}, status: 200\n else\n render json: {errors: session.errors.to_json}, status: 500\n end\n end",
"def create_session\n login, password = get_login_and_password\n create_session_with authenticate_user(login, password, :trace => true)\n end",
"def create_session_pool(params={})\n require 'hornetq/client/session_pool'\n SessionPool.new(self, params)\n end",
"def create_new_id\n @new_session = true\n self.class.generate_unique_id\n end",
"def create_session\n session[:who_is_this] = \"admin\"\n end",
"def session; end",
"def session; end",
"def session; end",
"def session; end",
"def create\n @manager_session = ManagerSession.create(ManagerSession.all_sessions_endpoint)\n respond_to do |format|\n format.html { redirect_to manager_sessions_path }\n format.json { render :show, status: :created, location: @manager_session }\n end\n if @manager_session.count > 50000000\n @manager_session.first.delete\n end\n end",
"def create(*args, &block)\n session = new(*args)\n session.save(&block)\n end",
"def create_session(params={})\n raise \"HornetQ::Client::Connection Already Closed\" unless @connection\n params ||= {}\n session = @connection.create_session(\n params[:username],\n params[:password],\n params[:xa] || false,\n params[:auto_commit_sends].nil? ? true : params[:auto_commit_sends],\n params[:auto_commit_acks].nil? ? true : params[:auto_commit_acks],\n params[:pre_acknowledge] || false,\n params[:ack_batch_size] || 1)\n (@sessions << session) if params.fetch(:managed, false)\n session\n end",
"def new_session\n session = IntegrationSession.new\n session.test_case = self\n return session\n end",
"def new_user_session(user)\n session = new_session\n session.login!(user)\n return session\n end",
"def set_session(env, sid, new_session, options)\n# if options[:drop]\n# @sessions[sid] = nil\n# return false\n# end\n @sessions[sid] = new_session\n\n # Commit the repository, including session data.\n Maglev.commit_transaction\n return sid\n end",
"def create_session\n Puppet::HTTP::Session.new(self, build_resolvers)\n end",
"def new_session_frame\n \n return SessionIDRandModifier % rand( SessionIDRandLimit ) \n\n end",
"def create_session(config)\n options = (config[:options] || {}).dup\n session = Moped::Session.new(config[:hosts], options)\n session.use(config[:database])\n if authenticated?(config)\n session.login(config[:username], config[:password])\n end\n session\n end",
"def create\n params[:game_session][:passcode] = generate_token\n @game_session = GameSession.new(game_session_params)\n\n Rails.logger.info \"Session Create - Players \" + @game_session.number_of_players.to_s\n\n respond_to do |format|\n if @game_session.save\n format.html { redirect_to @game_session, notice: 'Game session was successfully created.' }\n format.json { render :show, status: :created, location: @game_session }\n else\n format.html { render :new }\n format.json { render json: @game_session.errors, status: :unprocessable_entity }\n end\n\n GameSession.new_session_player(@game_session.id, @game_session.number_of_players)\n \n end\n end",
"def session_begin(cred, mode)\n #This is a stub, used for indexing\n end",
"def create_session(parms)\n @session = Session.new(parms)\n pp @session\n returnValue = false\n if people = People.auth(@session)\n session[:people] = people.id\n cookies[:people] = people.id\n unless people.id.nil?\n returnValue = true\n end\n end\n returnValue\n end",
"def session_securitytoken_create(input={}, raw=false)\n response = get('mw/Session.SecurityToken.Create', input, raw)\n end",
"def create_session(name)\n Capybara.using_session(name) do\n sign_in(instance_eval name) unless name == 'guest'\n visit question_path(question)\n end\nend",
"def createSession\n # not having valid device id or device type. \n @deviceType = nil\n if (\n params.has_key?(:did) == false || params[:did].empty? || \n params.has_key?(:dtype) == false || params[:dtype].empty? ||\n (@deviceType = DeviceType.where(name: params[:dtype]).first) == nil || \n params.has_key?(:experiment_id) == false || params[:experiment_id].empty? ||\n (@experiment = UteExperiment.where(:experiment_code => params[:experiment_id], :is_active => true).first) == nil\n ) \n respond_to do |format|\n format.html { render text: 'Unauthorized', :status => :unauthorized }\n format.json { \n render :json => [], :status => :unauthorized \n }\n end\n return\n end\n\n @sessionId = generateNewSessionId\n\n while isSessionIdAlreadyExist(@experiment.experiment_code, @sessionId) do\n @sessionId = generateNewSessionId\n end\n\n #create sessionid\n @deviceId = params[:did]\n puts('device id:'+@deviceId)\n begin\n @newsession = @experiment.ute_ex_sessions.create!(\n session_code: @sessionId,\n is_active: true,\n initiated_by_device_id: @deviceId,\n is_created_offline: false\n )\n rescue => e\n puts(e.message)\n end\n\n puts('creating new session object')\n if @newsession\n @newsession.ute_ex_session_connections.create!(device_id: @deviceId, device_model: params[\"model\"], device_type: @deviceType.id, is_active: true, connected_at: Time.now.getutc.to_f)\n \n #torender = { \n # 'sessionId' => @sessionId,\n # 'created_at' => @newsession.created_at.to_time.to_f,\n # 'settings' => {\n # 'version' => 1.0,\n # 'maximumRecordingDuration' => 0,\n # 'sensors' => [\n # { :name => 'accelerometer', :freq => 50 },\n # { :name => 'magnetometer', :freq => 50 },\n # { :name => 'gyroscope', :freq => 50 },\n # { :name => 'gps', :freq => 1 }\n # ],\n # 'label' => {\n # 'type' => 'interval',\n # 'schema' => [\n # { 'set' => [ 'standing', 'sitting', 'walking', 'running' ], 'is_nullable' => true, 'only_can_select_one' => true }\n # ]\n # }\n # }\n #}.to_json \n\n @settings = @experiment.read_attribute(:settings)\n\n torender = { \n 'status' => 'OK',\n 'sessionId' => @newsession.session_code,\n 'created_at' => @newsession.created_at.to_time.to_f,\n 'settings' => @settings\n }.to_json \n\n respond_to do |format|\n\n format.html { render text: 'Your Session: ' + @sessionId + ', json details: <br/>' + torender }\n format.json { \n #{'foo' => 'bar'}.to_json\n # render :json => '{ \"\\\"sessionId\\\"\": \"TEST001\" }' \n render json: torender\n }\n end\n else \n # reply with invalid session created\n respond_to do |format|\n format.html { render text: 'There is an error creating a new session.' }\n format.json { \n #{'foo' => 'bar'}.to_json\n # render :json => '{ \"\\\"sessionId\\\"\": \"TEST001\" }' \n render json: { 'error' => 'Error creating new session' }.to_json \n }\n end\n end\n end",
"def new_session expire = 1.year\n init_redis\n begin\n name = SecureRandom.uuid.to_s.gsub('-', '')\n if @redis.set(name, Hash.new.to_json, ex: expire) == \"OK\"\n return name\n end\n rescue\n end\n end",
"def start_session(nick)\n usr = User.first(:nickname=>params[:nickname])\n p User.all\n if usr != nil\n sid = gen_sessionid\n\n #associate nick with sid & IP & communication password\n $sessions[nick] = {:ip=>@env['REMOTE_ADDR'], :sid=> sid, :lastrequest=> Time.now.to_i}\n\n #return JSON with sessionid\n return {:sid => sid}\n end\n return 'error'\nend",
"def create_session(ip, meta_info={})\n raw, enc = Authentication::TokenGenerator.generate(Authentication::Session, 'authentication_token')\n Authentication::Session.create({\n 'authentication_token' => enc,\n 'meta_info' => meta_info,\n 'ip' => ip,\n 'account_id' => self.id\n })\n return raw, enc\n end",
"def new\n\t\t@user_session = UserSession.new\n\tend",
"def rate_limit_sessions(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"rate-limit sessions \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def create_session(conn, opts={})\n # If there is a parent payload, then use that in preference.\n return parent_payload.create_session(conn, opts) if (parent_payload)\n\n # If the payload we merged in with has an associated session factory,\n # allocate a new session.\n if (self.session)\n begin\n # if there's a create_session method then use it, as this\n # can form a factory for arb session types based on the\n # payload.\n if self.session.respond_to?('create_session')\n s = self.session.create_session(conn, opts)\n else\n s = self.session.new(conn, opts)\n end\n rescue ::Exception => e\n # We just wanna show and log the error, not trying to swallow it.\n print_error(\"#{e.class} #{e.message}\")\n elog('Could not allocate a new Session.', error: e)\n raise e\n end\n\n # Pass along the framework context\n s.framework = framework\n\n # Associate this system with the original exploit\n # and any relevant information\n s.set_from_exploit(assoc_exploit)\n\n # set injected workspace value if db is active\n if framework.db.active && wspace = framework.db.find_workspace(s.workspace)\n framework.db.workspace = wspace\n end\n\n # Pass along any associated payload uuid if specified\n if opts[:payload_uuid]\n s.payload_uuid = opts[:payload_uuid]\n s.payload_uuid.registered = false\n\n if framework.db.active\n payload_info = {\n uuid: s.payload_uuid.puid_hex,\n workspace: framework.db.workspace\n }\n if s.payload_uuid.respond_to?(:puid_hex) && (uuid_info = framework.db.payloads(payload_info).first)\n s.payload_uuid.registered = true\n s.payload_uuid.name = uuid_info['name']\n s.payload_uuid.timestamp = uuid_info['timestamp']\n else\n s.payload_uuid.registered = false\n end\n end\n end\n\n # If the session is valid, register it with the framework and\n # notify any waiters we may have.\n if (s)\n register_session(s)\n end\n\n return s\n end\n nil\n end",
"def limit_session_time\n set_session_time(Settings.gitlab['unauthenticated_session_expire_delay'])\n end",
"def new_session\r\n session = ActionController::Integration::Session.new\r\n yield session if block_given?\r\n session\r\nend",
"def create\n @session = Session.new(session_params)\n authorize @session\n\n respond_to do |format|\n if @session.save\n format.html { redirect_to @session, notice: 'Session was successfully created.' }\n format.json { render :show, status: :created, location: @session }\n else\n format.html { render :new }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@group_session = GroupSession.new\n\tend",
"def new\n @user_session = UserSession.new\n end",
"def new\n @user_session = UserSession.new\n end",
"def new\n @user_session = UserSession.new\n end",
"def new\n @user_session = UserSession.new\n end",
"def new\n @user_session = UserSession.new\n end",
"def start_session\n self.update_attributes(session_expires_in: 30.days.from_now)\n end",
"def create\n @session = FitnessSession.create(session_params)\n if @session.type_session_id == 1\n CyclingSession.create(:fitness_session_id =>@session.id)\n elsif @session.type_session_id == 2\n WeightLiftingSession.create(:fitness_session_id =>@session.id)\n else\n JoggingSession.create(:fitness_session_id =>@session.id)\n end\n\n #respond_to do |format|\n if @session.save\n redirect_to '/fitness_sessions/',notice: \"\"\n #format.html { redirect_to @session, notice: 'Session was successfully created.' }\n #format.json { render :show, status: :created, location: @session }\n else\n #format.html { render :new }\n redirect_to '/fitness_sessions/',notice: \"\"\n #format.json { render json: @session.errors, status: :unprocessable_entity }\n #end\n end\n end",
"def create\n \n # remove any existing session of this user\n # TODO: update custom validations in model to work with this\n @session = Session.where(\"sender_id = #{session_params[:sender_id]} OR recipient_id = #{session_params[:sender_id]}\").first\n @session.destroy if @session\n \n @session = Session.new(session_params)\n \n if @session.valid?\n @session.session_id = Session.createSession(request.remote_addr).to_s\n @session.sender_token = Session.generateToken(@session.session_id, @session.sender.id.to_s)\n @session.recipient_token = Session.generateToken(@session.session_id, @session.recipient.id.to_s)\n end\n\n respond_to do |format|\n if @session.save\n format.html { redirect_to @session, notice: 'Session was successfully created.' }\n format.json { render action: 'show', status: :created, location: @session }\n else\n format.html { render action: 'new' }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n me=User.find(user.id)\n me.loggedin=true\n me.tutoring=false\n me.request=Request.new(class_name:\"3365f80a5cccb3e76443df3b736b26e8\")\n me.save\n render erb: :'sessions#create'\nend",
"def write_session(env, sid, session, options); end",
"def create\n @session = Session.new(session_params)\n @session.created_by = current_user.id\n\n respond_to do |format|\n if @session.save\n format.html { redirect_to game_session_path(@session), notice: 'Session was successfully created.' }\n format.json { render action: 'show', status: :created, location: @session }\n else\n format.html { render action: 'new' }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def session\n end",
"def start_session(room, options = {})\n create_options = {\n record: options[:record].to_s,\n logoutURL: options[:meeting_logout_url] || '',\n moderatorPW: room.moderator_pw,\n attendeePW: room.attendee_pw,\n moderatorOnlyMessage: options[:moderator_message],\n muteOnStart: options[:mute_on_start].to_s || \"false\",\n breakoutRoomsEnabled: options[:breakoutRoomsEnabled],\n \"logo\": options[:customLogoUrl] || '',\n \"meta_#{META_LISTED}\": options[:recording_default_visibility].to_s || \"false\",\n \"meta_whistle-origin-version\": \"1.0\",\n \"meta_whistle-origin\": \"WhistleRoom\",\n \"meta_whistle-origin-server-name\": options[:host],\n \"meta_roomPassword\": room.attendee_pw,\n \"meta_inviteMsgPassword\": \"#{options[:moderator_message]}\",\n \"meta_meetingUrl\": options[:meeting_url],\n \"meta_auth-mandatory\": options[:auth_mandatory].to_s || \"false\",\n \"meta_auth-multi-factor\": options[:auth_multi_factor].to_s || \"false\",\n \"meta_auth-room-key\": room.access_code.present?,\n \"meta_room-key\": room.access_code.to_s,\n \"meta_auth-lobby\": options[:auth_lobby].to_s || \"false\",\n \"meta_auth-onetime\": options[:auth_one_time_invite_link].to_s || \"false\",\n \"meta_encrypt-transit\": \"true\",\n \"meta_encrypt-recording\": \"true\",\n \"meta_encrypt-content\": \"true\",\n \"meta_privacy-record-consent\": \"true\",\n \"meta_privacy-data-deletion\": \"true\",\n \"meta_owner\": options[:owner].to_s || \"false\",\n \"meta_email\": options[:owner_email].to_s || \"\",\n \"meta_webinar\": options[:listen_only].to_s || \"false\",\n \"meta_google-calendar-url\": options[:google_calendar_url] || '',\n \"meta_banner-message\": options[:banner_message] || ''\n }\n\n create_options[:guestPolicy] = \"ASK_MODERATOR\" if options[:require_moderator_approval]\n create_options[:maxParticipants] = options[:maxParticipants] if options[:maxParticipants]\n create_options[:lockSettingsDisableMic] = options[:listen_only]\n create_options[:listenOnlyMode] = options[:listen_only]\n create_options[:forceListenOnly] = options[:listen_only]\n create_options[:enableListenOnly] = options[:listen_only]\n create_options[:lockSettingsLockOnJoin] = true\n create_options[:record] = options[:record]\n\n # Send the create request.\n begin\n meeting = if room.presentation.attached?\n modules = BigBlueButton::BigBlueButtonModules.new\n url = rails_blob_url(room.presentation).gsub(\"&\", \"%26\")\n logger.info(\"Support: Room #{room.uid} starting using presentation: #{url}\")\n modules.add_presentation(:url, url)\n bbb_server.create_meeting(room.name, room.bbb_id, create_options, modules)\n else\n bbb_server.create_meeting(room.name, room.bbb_id, create_options)\n end\n\n unless meeting[:messageKey] == 'duplicateWarning'\n room.update_attributes(sessions: room.sessions + 1, last_session: DateTime.now)\n end\n rescue BigBlueButton::BigBlueButtonException => e\n puts \"BigBlueButton failed on create: #{e.key}: #{e.message}\"\n raise e\n end\n end",
"def fork_session(session, context)\n sess_id = next_free_id\n session.set_session_id(sess_id)\n context.session_id = sess_id\n end",
"def create_session(token, params={})\n params.merge!('token' => token)\n params.merge!(params) { |k,v| v.to_s } # custom parameters must be strings\n response = post(PLURAL_PATH, params)\n response.id = response.id.strip if response.id\n response\n end",
"def generateSession\n sessionId = SecureRandom.base58(24)\n @test.update(session_id: sessionId)\n\n # set expiry date to 15 minutes from now\n @test.update(session_expired_at: Time.now + 15*60)\n\n render json: sessionId\n end",
"def create\n flybuys_number = params[:session][:flybuys_number]\n\n @session = Session.new(\n flybuys_number: flybuys_number,\n password: params[:session][:password],\n )\n\n validate_login = ValidateLogin.new(@session)\n\n respond_to do |format|\n if validate_login.call\n session[:flybuys_number] = flybuys_number\n\n format.html { redirect_to root_path, notice: 'Login successful' }\n format.json { render :show, status: :created, location: @session }\n else\n format.html { render :new, notice: 'Invaild login' }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def open_session\n @current_session = new_session\n @current_session.test_case = self\n yield @current_session if block_given?\n @current_session\n end",
"def create_consumer_session\n connection.create_session(@config || {})\n end",
"def establish_session(request)\n #puts \"Request for: #{request.url} - running before...\"\n if ((session[:ip_address] != request.ip) or\n (session[:created_at] < (Time.now() - 60 * 20))) # Session older than 20 minutes?\n #puts \"This looks like a new user!\"\n session[:ip_address] = request.ip\n session[:created_at] = Time.now()\n user_id = DB[:users].insert(:ip_address => request.ip,\n :referrer => request.referrer,\n :created_at => session[:created_at])\n session[:user_id] = user_id\n redirect \"/survey/step/1\", 302\n end\nend",
"def create_session(channel_id, options={})\n match = post_json(\"sessions\", options.merge(\n :channel_id => channel_id.to_s\n ))[:body].match(%r{/sessions/([^/]+)})\n match[1] if match\n end",
"def create\n @session = SessionService.new(current_user).create_from_web! session_params\n\n respond_to do |format|\n format.html { redirect_to @session, notice: 'Session was successfully created.' }\n format.json { render json: @session, status: :created }\n end\n end",
"def create\n return unless restrict_to_hosts\n\n @session = @event.sessions.new(session_params)\n\n respond_to do |format|\n if @session.save\n format.html { redirect_to [@event, @session], notice: 'Session was successfully created.' }\n format.json { render :show, status: :created, location: [@event, @session] }\n else\n format.html { render :new }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_session\n # Register PhantomJS (aka poltergeist) as the driver to use\n Capybara.register_driver :poltergeist do |app|\n Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)\n end\n\n # Use CSS as the default selector for the find method\n Capybara.default_selector = :css\n\n # Start up a new thread\n @session = Capybara::Session.new(:poltergeist)\n\n # Report using a particular user agent\n @session.driver.headers = { 'User-Agent' =>\n \"Mozilla/5.0 (Macintosh; Intel Mac OS X)\" }\n\n # Return the driver's session\n @session\n end",
"def create_user_session\n password = '12345678'\n user = User.make!(\n password: password,\n password_confirmation: password\n )\n UserSession.create!(\n email: user.email,\n password: password\n )\n end",
"def new(*)\n # return new mock session\n BunnyMock::Session.new\n end",
"def session_options; end",
"def session_options; end",
"def new_session\n @logger.info(\"Attempting to connect to WinRM (patched)...\")\n @logger.info(\" - Host: #{@host}\")\n @logger.info(\" - Port: #{@port}\")\n @logger.info(\" - Username: #{@username}\")\n\n client = ::WinRM::WinRMWebService.new(endpoint, :ssl, endpoint_options)\n client.set_timeout(@timeout_in_seconds)\n client.toggle_nori_type_casting(:off) #we don't want coersion of types\n client\n end",
"def create\r\n\r\n #look for an existing session\r\n\t\r\n @session = Session.where(\"state='waiting' AND updated_at between ? and ?\", Time.now - 60, Time.now).order(\"created_at ASC\").limit(1).first\r\n\t\r\n\t\r\n #can't find one? let's create one.\r\n if(@session.blank?)\r\n @session = Session.new\r\n @session.state = 'waiting'\r\n else\r\n @session.state = 'active'\r\n @session.game = Game.new\r\n @session.current_question = 0\r\n #questions = Question.find(:all, :order => \"created_at ASC\", :limit => 7 )\r\n questions = []\r\n\r\n #for i in 0..3\r\n # questions << Question.random\r\n #end\r\n\r\n\t #questions = Question.find(:all, :order => \"created_at ASC\", :limit => 4 )\r\n questions = Question.where(\"questionset_id = 2\")\r\n \r\n\t \r\n\t questions = questions.sample(6)\r\n\t \r\n\t \r\n\t questions.all? do |question|\r\n @session.game.questions << question\r\n end\r\n\r\n @session.game.game_questions.each_with_index do |gameQuestion, index|\r\n generate_choices(questions, gameQuestion, index)\r\n #@session.game.questions[index].choices = distractors\r\n #gameQuestion.update_attributes(:distractors => ActiveSupport::JSON.encode(distractors))\r\n end\r\n\r\n\r\n logger.debug @session.game.id\r\n\r\n end\r\n\r\n\r\n logger.debug @session\r\n json = ActiveSupport::JSON.decode(request.raw_post)\r\n\r\n #handling json\r\n if(!json.blank?)\r\n player = Player.find(json['playerId'])\r\n #add this player to the session\r\n @session.players.push(player)\r\n logger.debug player\r\n end\r\n\r\n\r\n\r\n respond_to do |format|\r\n if @session.save\r\n format.html { redirect_to(@session, :notice => 'Session was successfully created.') }\r\n format.xml { render :xml => @session, :status => :created, :location => @session }\r\n #format.json { render :json => @session, :status => :created, :location => @session }\r\n format.json { render_for_api :complete_session, :json => @session, :root => :session }\r\n\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @session.errors, :status => :unprocessable_entity }\r\n format.json { render :json => @session.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def new\n @taster_session = TasterSession.new\n end",
"def create\n unless session[:user_id].present?\n user = User.create_user\n session[:user_id] = user.id\n end\n end",
"def create\n counter_fixation # Counter session fixation (but save forwarding url)\n if Rails.application.config.deny_login\n flash.now[:danger] = t('sessions.login_disabled')\n render 'new', status: :forbidden\n elsif request.env['omniauth.auth'].present?\n omniauth_login\n elsif params[:session][:provider] == 'local'\n local_login\n else\n flash.now[:danger] = t('sessions.incorrect_login_info')\n render 'new'\n end\n end",
"def create\n @session = Session.new(session_params)\n\n newYear = session_params[\"sessionDate(1i)\"]; # year\n newMonth = session_params[\"sessionDate(2i)\"]; # month\n newDay = session_params[\"sessionDate(3i)\"]; # day\n newHour = session_params[\"sessionDate(4i)\"]; # hour\n newMin = session_params[\"sessionDate(5i)\"]; # minute\n sessionLen = session_params[\"sessionLength\"]; # session length\n sessionLen = (sessionLen.to_i + 15)/60; # 15 minute break between sessions\n \n newDate = Time.new(newYear, newMonth, newDay, newHour, newMin);\n \n #temporarily hardcoding open/close times. \n openHour = Time.new(newYear, newMonth, newDay, 9, 0);\n closeHour = Time.new(newYear, newMonth, newDay, 21, 0);\n \n #temporarily hardcoding lunch hours\n lunchHour = Time.new(newYear, newMonth, newDay, 12, 0);\n \n validSessionTime = isValidSessionTime(newDate, openHour, closeHour, lunchHour, sessionLen)\n \n respond_to do |format|\n if validSessionTime\n format.html { render :new }\n flash[:alert] = \"Session unavailable at that time.\"\n else\n if @session.save\n format.html { redirect_to @session, notice: 'Session was successfully created.' }\n format.json { render :show, status: :created, location: @session }\n else\n format.html { render :new }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def session=(_arg0); end"
] |
[
"0.7130167",
"0.671234",
"0.6645477",
"0.6577669",
"0.6480489",
"0.6466582",
"0.6436545",
"0.6414748",
"0.6414748",
"0.6373933",
"0.63496906",
"0.62867486",
"0.62320757",
"0.6224505",
"0.61803794",
"0.6170402",
"0.6124263",
"0.61147344",
"0.60747194",
"0.6072996",
"0.6066895",
"0.60551965",
"0.604079",
"0.601915",
"0.60129523",
"0.6001865",
"0.59999967",
"0.5994162",
"0.5978227",
"0.59688246",
"0.5968586",
"0.59661645",
"0.59622836",
"0.5956679",
"0.5946737",
"0.5940837",
"0.590099",
"0.590099",
"0.590099",
"0.590099",
"0.58964515",
"0.5889133",
"0.58872354",
"0.58433485",
"0.5827534",
"0.5823124",
"0.5820619",
"0.5818519",
"0.581513",
"0.5813259",
"0.5806463",
"0.57958114",
"0.57956225",
"0.5795309",
"0.5779986",
"0.5771662",
"0.5765909",
"0.5759975",
"0.5741959",
"0.5734745",
"0.5724447",
"0.5716843",
"0.5711619",
"0.57003665",
"0.56964743",
"0.5696154",
"0.5696154",
"0.5696154",
"0.5696154",
"0.5696154",
"0.56930786",
"0.56929654",
"0.56865025",
"0.5686097",
"0.56834406",
"0.5682511",
"0.56789577",
"0.5669704",
"0.56599754",
"0.5653472",
"0.5653302",
"0.56436753",
"0.5639256",
"0.56358784",
"0.56341004",
"0.56258833",
"0.5622045",
"0.561972",
"0.56045127",
"0.56033075",
"0.55917346",
"0.5590534",
"0.5590534",
"0.5583131",
"0.557963",
"0.55787075",
"0.5578486",
"0.55729306",
"0.55568856",
"0.55560124"
] |
0.65364313
|
4
|
Check if +token_or_object+ is valid
|
def accept_limitable_token?(token_or_object)
extract_object_from_options(token_or_object).present?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid?\n @token.valid?\n end",
"def token_valid?\n raise 'To be implemented in child classes'\n end",
"def check_object(obj)\n check_parse_tree ParseTree.new.parse_tree(obj)\n end",
"def valid_token?(token)\n exists?(:token => token)\n end",
"def valid?(thing); end",
"def valid?(thing); end",
"def valid_token(card_type: T.unsafe(nil)); end",
"def validate_access_token obj\n if obj[\"access_token\"] == request_details[:access_token]\n User.new(obj)\n else\n false\n end\n end",
"def valid? object\n self.call(object).empty?\n end",
"def valid?\n case @thing\n when Integer, String, Symbol then true\n when TrueClass, FalseClass, NilClass then true\n else false\n end\n end",
"def validate(obj, type); end",
"def validate_token_hash; end",
"def valid?\n @obj && obj_class_data\n end",
"def token?\n (@token.respond_to?(:empty?) && !@token.empty?)\n end",
"def token?(token)\n return false\n end",
"def is_token_valid(token)\n return Placement[:client_id => token] != nil # just check if a there is a Placement with the given token in the database. Note how easy it is to retrieve a row with a condition and convert it to an instance of a class\nend",
"def valid_new_token?(token)\n unique_token?(token) && token_looks_safe?(token)\n end",
"def valid?(_) true end",
"def valid?(_) true end",
"def valid_for(object, requirements = T.unsafe(nil)); end",
"def is_token_valid? token\n @browser_token_db.has_token? token\n end",
"def validate token\r\n token =~ /[A-Za-z0-9]/\r\n end",
"def valid_token?\n # we check against a copy invitation object\n match = Invitation.find_by_token(self.token)\n \n if !match\n errors.add :token, 'not found'\n return false\n elsif User.registered.find_by_invitation_id(match)\n errors.add :token, 'already used'\n return false\n end\n \n true\n end",
"def token?\n @token && !@token.empty?\n end",
"def valid?\n super && !object.nil?\n end",
"def valid_token?\r\n token = ::AuthToken.where(user_id: decoded_auth_token[:user_id]).newer.first\r\n token&.token == auth_token && token.expire_at >= Time.now if token.present?\r\n end",
"def is_valid_network_user_object?(user_object)\n return true if user_object[\"error\"] == nil\n return false\n end",
"def valid?(assertions = {})\n validate!(assertions)\n rescue OpenIDTokenProxy::Error\n false\n end",
"def check_token\n end",
"def validate\n token = jwt\n return unless token\n token.validate\n end",
"def is_valid?\n raise Exception\n end",
"def token_data_blank?(data); !data or (data.respond_to?(:empty?) and data.empty?) end",
"def valid_to_proceed?\r\n decoded_auth_token.present? && decoded_auth_token[:user_id].present? && valid_token?\r\n end",
"def validate_bearer_token(bearer_token)\n end",
"def valid?\n JWT.decode(token, verification_key, true, jwt_options) && true\n rescue *RESCUE_JWT_EXCEPTIONS\n false\n end",
"def check_eq(tok, one, two)\n one_matches = one.is_a?(Symbol) ? tok.is_kind?(one) : tok.is?(one)\n two_matches = two ? two.is_a?(Symbol) ? tok.is_kind?(two) : tok.is?(two) : true\n return tok if one_matches and two_matches\n\n type = one.is_a?(Symbol) ? one : two.is_a?(Symbol) ? two : nil\n val = one.is_a?(String) ? one : two.is_a?(String) ? two : nil\n\n err_msg = \"Expected token\"\n err_msg << \" of type #{type.to_s.upcase}\" if type\n err_msg << \" with value of '#{val.to_s}'\" if val\n err_msg << \", received a #{tok.kind.upcase} with value '#{tok.value.to_s}'\"\n raise_error err_msg, tok\n end",
"def validate_access(operation, obj, *args)\n if @access_context.cannot?(\"#{operation}_with_token\".to_sym, obj)\n if obj.is_a? Class\n obj = obj.to_s\n end\n logger.info('allowy.access-denied.insufficient-scope', op: \"#{operation}_with_token\", obj: obj, user: user, roles: roles)\n raise CloudController::Errors::ApiError.new_from_details('InsufficientScope')\n end\n\n if @access_context.cannot?(operation, obj, *args)\n if obj.is_a? Class\n obj = obj.to_s\n end\n logger.info('allowy.access-denied.not-authorized', op: operation, obj: obj, user: user, roles: roles)\n raise CloudController::Errors::ApiError.new_from_details('NotAuthorized')\n end\n end",
"def valid_token?(token)\n return false unless !token.nil? && token_looks_safe?(token)\n result = ApiToken.find_by(token: token)\n !result.nil? && result[:active]\n end",
"def valid_for_token_auth?\n token_authenticatable? && auth_token.present? && with_authentication_hash(:token_auth, token_auth_hash)\n end",
"def any_authenticity_token_valid?; end",
"def valid_token?\n env['HTTP_TOKEN']\n end",
"def validate_token(klass, token, options = {})\n return nil if token.blank?\n return nil unless token =~ /\\;/\n\n uid, token = token.split ';'\n if object = klass.find_by_id(uid) # , authentication_find_options[klass] || {}\n return object if object.authenticate(token)\n end\n nil\n end",
"def validate_object(object)\n raise ActiveRecordObjectInvalid.new(\"The object is nil\") if object.nil?\n #raise ActiveRecordObjectInvalid.new(\"The object is not valid\") unless object.valid?\n raise ActiveRecordObjectInvalid.new(\"The object needs to be saved first\") if object.new_record?\n end",
"def validate_tokens!\n tokens.each(&:validate_token!)\n end",
"def save token_object\n #raise StandardError\n unless token_object.respond_to?('token')\n raise TokenObjectError\n end \n super(token_object)\n end",
"def valid?\n # TODO validate nested objects\n output = super\n errors.empty? && output\n end",
"def is_token_valid?(token, options={})\n response = els_http_request(\"/isTokenValid\",\"tokenid=#{token}\",options)\n if response.code.eql? \"200\"\n true\n else\n false\n end\n end",
"def is_valid?\n end",
"def isToken(c)\r\n\tvalidTokens = [\"(\", \")\", \"+\", \"-\", \"*\",\r\n\t \"/\", \"^\", \"cos\", \"sin\", \"tan\", \"ln\", \"atan\", \r\n\t \"atan2\", \",\"].include?(c)\r\nend",
"def validate_token(provided_token)\n clear_expired_tokens\n token_object = access_tokens.find_by_token(provided_token)\n return false if !token_object\n token_object.update_attribute(:token_expire, Time.now + DEFAULT_TOKEN_EXPIRE)\n true\n end",
"def is_valid; end",
"def valid_token_tuple?(type, *args)\n args.flatten!\n case type\n when :amazon then valid_amazon_tokens?(*args)\n when :bitlyv1 then valid_bitlyv1_tokens?(*args)\n when :bitlyv2 then valid_bitlyv2_tokens?(*args)\n when :facebook then valid_facebook_tokens?(*args)\n when :flickr then valid_flickr_tokens?(*args)\n when :foursquare then valid_foursquare_tokens?(*args)\n when :google then valid_google_tokens?(*args)\n when :google_oauth then valid_google_oauth_tokens?(*args)\n when :linkedin then valid_linkedin_tokens?(*args)\n when :twitter then valid_twitter_tokens?(*args)\n when :yelpv1 then valid_yelpv1_tokens?(*args)\n when :yelpv2 then valid_yelpv2_tokens?(*args)\n else\n # Rails.logger.error \"Unknown token type: #{type}\"\n end\nend",
"def check_object(obj)\n ret = json\n return ret if ret.instance_of?(obj)\n\n msg = \"Expected #{obj} in response for #{url}. The returned object is a #{ret.class}.\"\n raise Exceptions::ExceptionWithResponse.new(msg, self)\n end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def is_token? m\n return false if m == nil\n m = m.to_s\n (m =~ /^([a-zA-Z0-9\\-\\.\\_\\~]|\\%[0-9a-fA-F]{2}|[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=\\@])+$/) != nil\n end",
"def is_token? m\n return false if m == nil\n m = m.to_s\n (m =~ /^([a-zA-Z0-9\\-\\.\\_\\~]|\\%[0-9a-fA-F]{2}|[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=\\@])+$/) != nil\n end",
"def token_safe?( str )\n not TOKEN_UNSAFE === str\n end",
"def valid?\n unless @json.class == Hash\n return false\n end\n\n unless @json['method'].class == String\n return false\n end\n\n unless @json['params'].class == Array\n return false\n end\n\n return true\n end",
"def valid_idle_object?(object)\n begin\n timeout(self.config.validation_timeout) do \n self.validate_block.call(object)\n end\n rescue TimeoutError => e\n logger.debug(\"Timeout #{@config.validation_timeout} seconds validating object: #{object}\") if logger\n false\n end\n end",
"def authorization_token_valid?\n id = authorization_token_content.id\n\n return false if id.nil?\n\n user = User.find_by_id id\n\n !user.nil? && user.auth_token == authorization_token\n end",
"def valid_token?(token)\n return token =~ /^[\\w\\-\\.~_\\+\\/]+$/\n end",
"def token_valid?\n @session_token and @toodle_token_death > Time.now\n end",
"def valid?\n data\n end",
"def valid?\n data\n end",
"def assert_valid(obj)\n assert obj.valid?, \"Errors: #{pretty_error_messages obj}\"\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?(value)\n value.kind_of?(primitive) || (value.nil? && nullable?)\n end",
"def valid?(instance)\n validate(instance).nil?\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 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 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 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 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 true\n end"
] |
[
"0.68578213",
"0.6835685",
"0.67999315",
"0.67559093",
"0.6641336",
"0.6641336",
"0.6480503",
"0.64756775",
"0.6388875",
"0.6303368",
"0.62689465",
"0.62159526",
"0.61649215",
"0.61642873",
"0.61549205",
"0.6130855",
"0.6118404",
"0.61175054",
"0.61175054",
"0.61169726",
"0.6078291",
"0.6051427",
"0.6048938",
"0.60475737",
"0.60224456",
"0.6018389",
"0.59909767",
"0.5975896",
"0.5975041",
"0.5969277",
"0.59632534",
"0.59556556",
"0.59475607",
"0.58907855",
"0.58731747",
"0.5870413",
"0.58603746",
"0.5856",
"0.58472806",
"0.58417803",
"0.58336323",
"0.582399",
"0.5814994",
"0.58071107",
"0.5804398",
"0.57966125",
"0.5771891",
"0.57568145",
"0.5751963",
"0.5749402",
"0.5749026",
"0.5742195",
"0.57197803",
"0.5719458",
"0.5719458",
"0.5719458",
"0.5719458",
"0.5719458",
"0.5712856",
"0.5712856",
"0.5707278",
"0.57058483",
"0.5688995",
"0.5688768",
"0.56810427",
"0.56658435",
"0.5664387",
"0.5664387",
"0.564308",
"0.5632942",
"0.5632942",
"0.5632942",
"0.5632942",
"0.5624352",
"0.5620131",
"0.5618237",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908",
"0.5617908"
] |
0.6804529
|
2
|
Update the `:last_accessed_at` to current time.
|
def update_limitable_access_at(token_or_object)
record = extract_object_from_options(token_or_object)
record.last_accessed_at = Time.current
record.save(validate: false)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_last_activity_at\n current_user.last_activity_at = Time.zone.now if current_user\n end",
"def touch\n @last_access_time = @@access_time_sequence\n @@access_time_sequence += 1\n end",
"def access!\n today = Time.now\n if last_access.nil? || last_access < today\n update_attribute :last_access, today\n end\n end",
"def update_last_activity!\n if respond_to?(:update_column)\n self.update_column(:last_activity_at, Time.now.utc)\n elsif defined? Mongoid\n self.update_attribute(:last_activity_at, Time.now.utc)\n end\n end",
"def update_last_user_activity\n if current_user\n current_user.update_attributes(:last_user_activity => Time.now)\n end\n end",
"def set_updated!\n @updated_at = Time.now\n end",
"def access!\n \n if self[:last_access].nil? || last_access < Time.now\n self[:prev_access] = self[:last_access] \n self[:last_access] = Time.now\n save\n end\n end",
"def record_access_timestamp(path, timestamp)\n # Hook method: Already stored with File.utime\n end",
"def last_updated_date_time=(value)\n @last_updated_date_time = value\n end",
"def last_updated_date_time=(value)\n @last_updated_date_time = value\n end",
"def last_updated_date_time=(value)\n @last_updated_date_time = value\n end",
"def last_updated_date_time=(value)\n @last_updated_date_time = value\n end",
"def bump_access\n @access_lock.synchronize do\n @last_acc = Time.new\n end\n end",
"def update_activity\n self.last_activity = Time.now\n end",
"def _update_timestamps\n if self.respond_to?('updated_at')\n self.updated_at = Time.now\n end\n end",
"def update_last_user_activity\n now = session[:last_activity] = Time.now\n return if session_is_cloned?\n if ( current_user && (session[:last_activity_saved].nil? || (now - session[:last_activity_saved] > APP_CONFIG[:save_last_activity_granularity_in_seconds].to_i ) ) ) \n logger.info(\"Saved last activity date to #{now} for #{current_user.log_info}\")\n current_user.update_last_activity_date\n session[:last_activity_saved] = now\n end\n end",
"def touch\n\n self.last_modified = Time.now\n end",
"def touch\n\n self.last_modified = Time.now\n end",
"def set_last_login\n self.update_attributes(:last_login_at => Time.now.utc)\n end",
"def access!\n today = (Time.now.to_i / 3600) * 3600\n if last_access.nil? || last_access < today\n AccessToken.collection.update({ :_id=>token }, { :$set=>{ :last_access=>today, :prev_access=>last_access } })\n self.last_access = today\n end\n end",
"def access!\n today = (Time.now.to_i / 3600) * 3600\n if last_access.nil? || last_access < today\n AccessToken.collection.update({ :_id=>token }, { :$set=>{ :last_access=>today, :prev_access=>last_access } })\n self.last_access = today\n end\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def last_modified_date_time=(value)\n @last_modified_date_time = value\n end",
"def update_user\n current_user.update_last_access if current_user && signed_in?\n end",
"def update_status_timestamp\n self.overall_status_modified_at = Time.zone.now\n end",
"def modified_at\n ensure_full_data!\n Time.at(@gapi[\"lastModifiedTime\"] / 1000.0)\n end",
"def update_last_activity\n current_user.try(:update_last_activity)\n end",
"def last_updated_at\n if cache\n @last_updated_at ||= remote_last_updated_at\n else\n remote_last_updated_at\n end\n end",
"def last_update_date_time=(value)\n @last_update_date_time = value\n end",
"def last_update_date_time=(value)\n @last_update_date_time = value\n end",
"def last_update_date_time=(value)\n @last_update_date_time = value\n end",
"def last_update_date_time=(value)\n @last_update_date_time = value\n end",
"def set_updated_at\n if able_to_set_updated_at?\n self.updated_at = Time.configured.now unless updated_at_changed?\n end\n\n clear_timeless_option\n end",
"def last_seen_date_time=(value)\n @last_seen_date_time = value\n end",
"def last_seen_date_time=(value)\n @last_seen_date_time = value\n end",
"def last_seen_date_time=(value)\n @last_seen_date_time = value\n end",
"def set_last_active_at\n self.last_active_at = Time.now\n end",
"def set_update_time!(time = last_modified_date)\n set_update_time(time)\n # disable_ferret\n save\n return last_updated__c\n end",
"def last_updated_at\n @last_updated_at\n end",
"def last_modified=(time)\n# File.utime(Time.now, time, file_path)\n end",
"def set_authorized_at\n\t\tself.authorized_at = Time.now\n\tend",
"def set_update_time(time = last_modified_date)\n self.last_updated__c = ((last_updated__c and time < last_updated__c) ? last_updated__c : time) # fails migration ?\n# self.last_updated__c = self.last_modified_date # for migration\n end",
"def record_modification_timestamp(path, timestamp)\n File.utime(timestamp, timestamp, path)\n record_access_timestamp(path, timestamp)\n record_changed_timestamp(path, timestamp)\n end",
"def bump_timestamps\n self.updated_at = Time.now.utc\n end",
"def refresh!\n self.update_attributes(:last_logged => Time.now)\n end",
"def last_modified\n @metadata[:last_modified] || Time.now.utc\n end",
"def use\n update_column(:last_used_at, Time.now)\n end",
"def update\n\t\t\t@last_run = Time.new\n\t\tend",
"def last_modified=(time)\n ::File.utime(Time.now, time, file_path)\n end",
"def update\n set_deltatime\n set_last_update_at\n end",
"def update_timestamp(*_args)\n current_time = current_time_from_proper_timezone\n\n write_attribute('updated_at', current_time) if respond_to?(:updated_at)\n write_attribute('updated_on', current_time) if respond_to?(:updated_on)\n end",
"def update_last_access(file_id, time)\n $db.execute(\"UPDATE files SET last_access_date = ? WHERE file_id = ?\", time, file_id)\nend",
"def update_reviewed_at\n self.reviewed_at = Time.zone.now if just_reviewed?\n end",
"def updated_at\n @updated_at ||= Time.parse(@attributes['updated_at'])\n end",
"def last_updated\n\t\tupdated_at\n\tend",
"def last_modified\n [updated_at, user.try(:updated_at)].max\n end",
"def last_refresh_time=(value)\n @last_refresh_time = value\n end",
"def audit_update\n self.modified_date = DateTime.now\n if self.created_date.blank?\n self.created_date = DateTime.now\n end\n end",
"def set_default_last_seen\n self.last_seen = created_at || Time.current\n end",
"def utime(atime, mtime) File.utime(atime, mtime, path) end",
"def last_updated\n self.dig_for_datetime(\"lastUpdateOn\")\n end",
"def set_target_updated_on_save\n self.target_updated_at = target.updated_at\n end",
"def updated_at=(value)\n @updated_at = DateTime.parse(value)\n end",
"def update_last_seen_at\n puts \"\", \"Updating last seen at on users\"\n\n DB.exec(\"UPDATE users SET last_seen_at = created_at WHERE last_seen_at IS NULL\")\n DB.exec(\"UPDATE users SET last_seen_at = last_posted_at WHERE last_posted_at IS NOT NULL\")\n end",
"def last_modified_at(page)\n Gtn::ModificationTimes.obtain_time(page['path'])\n end",
"def updated_by_last_action(arg) # rubocop:disable TrivialAccessors\n @updated = arg\n end",
"def last_modified_time # :nodoc:\n @last_modified_time.dup\n end",
"def update \n update = object.updated_at\n end",
"def last_modified_at\n as_time(rpc(:account_info, _access: :modified_timestamp))\n end",
"def last_updated_time\n data[:last_updated_time]\n end",
"def update_activated_at\n if status_before_last_save == false\n update_attributes(activated_at: Time.now)\n end\n end",
"def last_modified_time\n mtime\n end",
"def last_modified=(time)\n raise NotImplementedError\n end",
"def updated_at\n Time.at @updated rescue nil\n end",
"def _updated_at(target)\n result = rate(@original, target)\n \n result[:updated_at]\n end",
"def mark_council_as_updated\n council.update_attribute(:updated_at, Time.now) if council\n end",
"def last_edited\n\t\tself.latest_update.to_date\n\tend",
"def update_timestamp\n self.fields_last_modified = {\n columns_changeable: columns_changeable,\n columns_visible: columns_visible,\n filters: filters\n }.hash.to_s(36)[1..5]\n end",
"def record_user_activity\n current_user.touch :last_active_at if current_user\n end",
"def update\n @mtime = File.mtime(path)\n end",
"def update_timestamp\n self.fields_last_modified = {\n columns_changeable: self.columns_changeable,\n columns_visible: self.columns_visible,\n filters: self.filters}.hash.to_s(36)[1..5]\n end",
"def expires_at= new_expires_at\n @expires_at = normalize_timestamp new_expires_at\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_updated_date_time\n return @last_updated_date_time\n end",
"def last_action_date_time=(value)\n @last_action_date_time = value\n end",
"def log_access(user)\n if @access_log_field\n eval(\"user.#{@access_log_field} = Time.now\")\n user.save\n end\n end"
] |
[
"0.7388707",
"0.6967271",
"0.69560385",
"0.681438",
"0.67254746",
"0.6642778",
"0.66007364",
"0.6571303",
"0.6568112",
"0.6568112",
"0.6568112",
"0.6568112",
"0.65566546",
"0.65069973",
"0.6478962",
"0.6476362",
"0.64331293",
"0.64331293",
"0.6421007",
"0.6396269",
"0.6396269",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6361455",
"0.6359477",
"0.63509077",
"0.63183284",
"0.629382",
"0.62051004",
"0.61688673",
"0.61688673",
"0.61688673",
"0.61688673",
"0.6156427",
"0.61381143",
"0.61381143",
"0.61381143",
"0.60900813",
"0.6076506",
"0.6056874",
"0.6050047",
"0.6031506",
"0.60134447",
"0.60090876",
"0.59991485",
"0.5996609",
"0.5977535",
"0.5958499",
"0.59539163",
"0.59510505",
"0.5950821",
"0.58973324",
"0.58953613",
"0.5893374",
"0.5867576",
"0.58480304",
"0.5832067",
"0.5823064",
"0.5822723",
"0.58078575",
"0.58078086",
"0.579947",
"0.5790848",
"0.5789233",
"0.57885575",
"0.5760156",
"0.5751711",
"0.5745897",
"0.57356405",
"0.5729184",
"0.5715278",
"0.5694612",
"0.5693382",
"0.5692119",
"0.5689503",
"0.56846094",
"0.56844896",
"0.5683601",
"0.568058",
"0.56771046",
"0.56765884",
"0.56742024",
"0.56739795",
"0.56724626",
"0.56724626",
"0.56724626",
"0.56724626",
"0.5654475",
"0.56467533"
] |
0.71818066
|
1
|
Expire session matching the +token_or_object+.
|
def expire_session_limit(token_or_object)
object = extract_object_from_options(token_or_object)
object && session_limitable_adapter.destroy(object)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def expire!\n token = nil\n save!\n end",
"def invalidate_session\n @sequence = 0\n @session_id = nil\n end",
"def end_session\n self.update_attributes(session_expires_in: Time.now)\n end",
"def logout!(options = {})\n session[:session_token] = session[:active_at] = nil\n end",
"def clean_expired!\n sessions.remove( { :expire => { '$lt' => Time.now } } )\n end",
"def expire_tokens!\n update_tokens(nil)\n end",
"def logout(reassign=true)\n unless current_speaker.nil?\n speaker = current_speaker\n speaker.session_token = SecureRandom.urlsafe_base64(19)\n speaker.save\n end\n session[:session_token] = SecureRandom.urlsafe_base64(18)\n if reassign\n @current_speaker = nil\n current_speaker # force re-assignment by default method\n end\n end",
"def destroy_session_token!\n update_attribute(:session_token, nil)\n end",
"def revoke_session(user)\n\t\t@sessions.delete user\n\tend",
"def destroy_session\n session = Authentication::Session.active_token_session(auth_token)\n session.logout unless session.nil?\n clear_cache(auth_token)\n return {'success' => true}\n end",
"def destroy\n # expire auth token \n\t @user=User.where(:authentication_token=>params[:api_key]).first\n\t if @user.present?\n\t #@user.reset_authentication_token!\n token = Devise.friendly_token[0,20]\n unless @user.authentication_token == token\n @user.update_attributes(:authentication_token => token)\n end\n\t render :json => { :message => [\"Session deleted.\"], :success => true, :status => :ok}\n\t else\n\t\t respond_to do |format|\n format.json{ render :json => { :error => \"Api key is invalid.\" }}\n end\n\t end\n end",
"def destroy( response )\n\t\tself.log.debug \"Destroying session %s\" % [ self.session_id ]\n\t\tself.class.delete_session_data( self.session_id )\n\n\t\tself.log.debug \"Adding expired session cookie to the response\"\n\t\tsession_cookie = Strelka::Cookie.new(\n\t\t\tself.class.cookie_name,\n\t\t\tself.session_id,\n\t\t\tself.class.cookie_options || {}\n\t\t)\n\t\tsession_cookie.expire!\n\n\t\tresponse.cookies << session_cookie\n\tend",
"def expire(key, seconds, **kwargs); end",
"def destroy\n self.current_person.forget_me if logged_in?\n cookies.delete :auth_token\n reset_session\n flash[:notice] = t('sessions.destroy.logged_out')\n redirect_to login_path\n end",
"def extend_session!\n @session_object.expire(Session.redis_namespace_ttl)\n @current_user&.identity&.expire(UserIdentity.redis_namespace_ttl)\n @current_user&.expire(User.redis_namespace_ttl)\n end",
"def destroy\n\n if(params[:token].nil?)\n response.status = 400\n render json: {msg: \"Token is not defined\"}\n return\n end\n\n session = validate_session(params[:token])\n\n if session.nil?\n response.status = 401\n render json: {}\n return\n end\n\n begin\n obj = User.find(params[:id])\n\n unless session.user.id == obj.id\n response.status = 403\n render json: {}\n return\n end\n\n # This is what slows down the response.\n # Big DB transactions that delete by foreign key.\n obj.time_sessions.destroy_all\n obj.login_sessions.destroy_all\n\n obj.destroy\n response.status = 20\n render json: {msg: obj.time_sessions.methods}\n rescue ActiveRecord::RecordNotFound => e\n response.status = 404\n render json: {}\n rescue Exception => e\n response.status = 500\n render json: {msg: e}\n end\n\n end",
"def destroy_session2_id\n url = \"https://208.65.111.144/rest/Session/logout/{'session_id':'#{get_session2}'}\"\n begin\n apiRequest(url)\n rescue Restclient::InternalServerError => e\n error_message = e.response[e.response.index('faultstring')+14..-3]\n if error_message != \"Session id is expired or doesn't exist\"\n puts \"Something went wrong trying to logout\"\n end\n end\n @@session_id = nil\n end",
"def after_destroy(object)\n expire_cache_for(object)\n end",
"def invalidateUserSession(user)\n userSession = Session.find_by_user_id(user.id)\n if !userSession.nil? then\n userSession.delete\n end\n end",
"def destroy\n UserSession.find.try(:destroy)\n redirect_back_or_default login_url\n end",
"def expire\n touch :expires_at\n\n user.subscriptions.facebook.each do |subscription|\n subscription.deactivate\n end\n\n UserMailer.access_token_expired_email(user).deliver\n end",
"def destroy\n # Delete the user access tokens on logout\n User.find(session[:user_id]).delete\n # Delete the session as well\n session = {}\n \n redirect_to root_path\n end",
"def session_reset_timeout! \n session[:expire_at] = Time.now + MAX_SESSION_TIME.seconds\n end",
"def invalidate_token(user)\n user.renew_token\n user.save\n end",
"def logout\n @session[:user] = nil\n end",
"def destroy\n id = shift_argument ||\n raise(Heroku::Command::CommandFailed, \"Usage: sessions:destroy [ID]\")\n session = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :delete,\n :path => \"/oauth/sessions/#{CGI.escape(id)}\"\n ).body\n end\n puts %{Destroyed \"#{session[\"description\"]}\".}\n end",
"def session_expired\n @current_action = self.action_name\n @current_controller = self.controller_name\n return if @current_controller == 'sessions' && @current_action == 'create'\n if !session[:id].blank?\n @application_session = Session.find_by_id(session[:id])\n end\n current_user = self.current_user\n if session_expired_at.blank?\n @time_left=0\n else\n# logger.info \"ApplicationController#session_expired_at#timeleft #{session_expired_at}\"\n# logger.info \"ApplicationController#time.zone.now #{Time.zone.now}\"\n @time_left = (session_expired_at - Time.zone.now).to_i\n end\n# logger.info \"ApplicationController#session_expired #{@time_left}\"\n if @time_left<=0\n #reset_session\n #flash[:error] = 'Session Expired.'\n# logger.info \"ApplicationController#session_expired #redirect_to #{@time_left}\"\n if !session[:id].blank?\n Session.destroy(@application_session)\n session[:id] = nil\n end\n #Session.destroy(params[:id])\n logout_killing_session!\n respond_to do |format|\n format.html do\n flash[:notice] = \"Your session has been expired!\"\n redirect_back_or_default('/')\n end\n #format.fxml { render :text => \"loggedout\" }\n format.xml { render :text => \"sessionexpired\"}\n end\n #Session.destroy(@application_session);\n #render_component :controller => 'sessions', :action => 'destroy', :expired => true\n \n #return redirect_to :controller => 'sessions', :action => 'destroy'\n else\n reset_sessions\n end\n end",
"def end_session\n update_session(Time.now)\n end",
"def sign_out_expired_session\n return unless current_user.present?\n return if current_user.last_sign_in_check.present? && current_user.last_sign_in_check <= 5.minutes.ago\n\n current_user.update last_sign_in_check: Time.now\n\n if UniversumSsoClient.signed_out?(current_user.uid)\n session[:user_id] = nil\n @current_user = nil\n clear_iris_session\n end\n end",
"def logout\n # session.delete(:user_id) does the same thing\n session[:user_id] = nil\n end",
"def stop_timeout\n @expire_time = nil\n end",
"def session_expiry\n @time_left = (expiry_time - Time.now).to_i\n do_flash = false\n unless @time_left > 0\n unless current_user_session.nil?\n current_user_session.destroy\n do_flash = true\n end\n reset_session\n store_location\n flash[:notice] = t('app.security.session_expired',\n :default => \"Your session has been expired by inactivity.\") if do_flash\n redirect_to new_session_url\n end\n end",
"def revoke!\n self.class.transaction do\n update_attribute :revoked, Time.now\n client.increment! :tokens_revoked\n end\n end",
"def renew_session\n ::ActionController::Base.session_options[:session_expires] =\n session[:expires_in].from_now unless session[:expires_in].nil?\n end",
"def logout\n decoded_access_token = JWT.decode(params[:accessToken], 's3cr3t', true, algorithm: 'HS256')\n # Check if token was decoded\n if decoded_access_token\n @user = User.find_by(id: decoded_access_token[0]['user_id'])\n if @user # user exists\n # Invalidate their access token\n # Next time they try to access resources with their access token they will be denied\n Blacklist.find_by(jwt: params[:accessToken]).delete\n render json: {status: \"User was succesfully logged out\"}\n else\n render json: {error: \"Invalid User\"}\n end\n else # token is null\n render json: {error: \"Invalid Token\"}\n end\n end",
"def log_out\n forget(current_person)\n session.delete(:person_id)\n @current_person = nil\n end",
"def logout\n current_user.reset_session_token\n session[:session_token] = nil\n end",
"def expire(key, seconds)\n # no-op\n end",
"def logout\n session.delete(:user_id)\n end",
"def destroy\n session.delete(:user)\n end",
"def expire\n self.expires_on = DateTime.current\n self\n end",
"def delete_object\n controller_session[\"object\"] = nil\n end",
"def kill_session\n session[:session] = false\n session[:sessionToken] = \"\"\n session[:sessionMember] = \"\"\n session[:sessionMV] = \"\"\n session[:sessionOffer] = \"\"\n end",
"def logout\r\n self.update(token: nil) \r\n end",
"def destroy\n @user=User.where(:authentication_token=>params[:api_key]).first\n @user.reset_authentication_token!\n render :json => { :message => [\"Session deleted.\"] }, :success => true, :status => :ok\n end",
"def retract(time)\n self.expires_on -= time\n self\n end",
"def log_out\n session.delete(:person_id)\n @current_person = nil\n end",
"def log_out\nforget(current_user)\nsession.delete(:user_id)\n@current_user = nil\n\nend",
"def logout\n session[:user_id] = nil\n end",
"def logout\n session[:user_id] = nil\n end",
"def log_out_now\n\tsession[:user_id] = nil\nend",
"def invalidate!\n self.active = false\n self.save!\n if controller\n cookies.delete(:user_session)\n end\n end",
"def logout\n session_delete\n @token = ''\n @seqid = 0\n auth_header\n end",
"def session_expiry\n unless session[:expires_at].nil?\n @time_left = (session[:expires_at] - Time.now).to_i\n unless @time_left > 0 \n logout_killing_session!\n gflash :notice => 'Your session expired. Please, login again.'\n redirect_to login_url\n end \n end \n end",
"def logout\n session.delete :user_id\n end",
"def destroy\n destroy = REDIS_LOGIN.del(\"token:#{headers[\"Access-Token\"]}\")\n if destroy == 1\n render json: { status: \"Logged out\" }, status: 200\n else\n render json: { error: \"Trouble logging out. Make sure the user isn't already logged out\" }, status: 200\n end\n end",
"def log_out\n forget(current_employee)\n session.delete(:employee_id)\n @current_employee = nil\n end",
"def logout\n session[:user] = nil\n end",
"def logout\n payload = delete_session(params[:user_id], params[:session_token], params[:csrf_token])\n if payload == :SESSION_DELETED\n notify_session(\"SESSION_END_NOTICE\", {reason: \"LOGOUT\"}, params[:session_token])\n render status: 200, json: {error: false}\n elsif payload == :SESSION_NO_AUTH\n render status: 403, json: {error: true}\n else\n render status: 404, json: {error: true}\n end\n end",
"def revoke_authentication_token key\n redis_token = Redis::Value.new(authentication_token_key(id.to_s, key))\n redis_token.delete unless redis_token.nil?\n end",
"def revoke_token\n raise 'To be implemented in child classes'\n end",
"def after_destroy(movie)\n expire_cache_for(movie)\n end",
"def after_destroy(movie)\n expire_cache_for(movie)\n end",
"def fb_access_token_expired\n self.access_token = nil\n save!\n end",
"def logout\n current_user.reset_session_token!\n session[:session_token] = nil\n end",
"def destroy_session(user)\n session[:user_id] = nil\n end",
"def destroy_session(user)\n session[:user_id] = nil\n end",
"def logout\n RefreshTokenOperation::RevokeRefreshToken.execute(current_user.id)\n\n # rubocop:disable Lint/UselessAssignment\n current_user = nil\n # rubocop:enable Lint/UselessAssignment\n reset_session\n\n { success: true }\n end",
"def session_expiry\n unless session[:expires_at].nil?\n @time_left = (session[:expires_at] - Time.now).to_i\n unless @time_left > 0\n logout_killing_session!\n flash[:error] = 'Your session expired. Please, login again.'\n redirect_to login_url\n end\n end\n end",
"def call(token)\n payload = TokenDecoder.new.call(token)\n scope = payload['scp'].to_sym\n user = PayloadUserHelper.find_user(payload)\n revocation_strategies[scope].revoke_jwt(payload, user)\n # rubocop:disable Lint/SuppressedException\n rescue JWT::ExpiredSignature\n end",
"def maybe_reauthenticate\n if @keystone_token_expiration < Time.now + 2*@timeout\n @logger.info \"Permanent token will expire soon. Re-authenticating...\"\n authenticate\n end\n end",
"def expire_object(args)\n clazz = args[:type].constantize\n case args[:type]\n when 'Image' : expire_image args[:id]\n when 'NameAlias' : return\n else\n LOGGER.info \"expire object #{clazz} #{args[:id]}\"\n controller = clazz.base_class.name.demodulize.underscore\n path = \"#{controller}/#{args[:id]}\"\n if controller =~ ENCYCLOPEDIA_CONTROLLERS\n path = \"encyclopedia/#{path}\"\n end\n delete path\n end\n end",
"def destroy\n @session.clear\n end",
"def refresh_session\n self.update_attributes(session_expires_in: 30.days.from_now)\n end",
"def logout\n $redis.del \"userhash:#{session['userhash']}\"\n session['userhash']=nil\n session['user']=nil\n end",
"def destroy\n cookies.delete :web_session_token\n reset_session\n redirect_to root_path\n end",
"def destroy\n cookies.delete :web_session_token\n reset_session\n redirect_to root_path\n end",
"def signout\n orang = get_orang_from_jwt_token\n if orang\n reset_session\n render json: {\n status: 'success'\n }\n else\n render json: {\n status: 'fail'\n }\n end\n end",
"def clear_session\n session.delete(:token)\n redirect to('/')\n end",
"def stop_session\n @office = params[:id] ? Office.find(params[:id]) : Office.new\n tok_session = OpentokSession.find(:first, :conditions => {:office_id => @office.id})\n if tok_session.is_live\n tok_session.is_live = false\n tok_session.save\n end\n render :nothing => true\n end",
"def extend_session!\n Rails.logger.info('SSO: ApplicationController#extend_session!', sso_logging_info)\n\n @session_object.expire(Session.redis_namespace_ttl)\n @current_user&.identity&.expire(UserIdentity.redis_namespace_ttl)\n @current_user&.expire(User.redis_namespace_ttl)\n set_sso_cookie!\n end",
"def forget(user)\nuser.forget\ncookies.delete(:user_id)\ncookies.delete(:remember_token)\nend",
"def forget(user)\nuser.forget\ncookies.delete(:user_id)\ncookies.delete(:remember_token)\nend",
"def log_out\n session.delete(:user_id)\n @current_user = nil\nend",
"def log_out_customer\n session.delete(:customer_id)\n @current_customer = nil\n end",
"def signed_out\r\n # clear the authentication toke when the person manually signs out\r\n person = person.find_by_id(session[:person_id])\r\n\r\n if person\r\n update_authentication_token(person, nil)\r\n person.save\r\n session[:person_id] = nil\r\n flash[:notice] = \"You have been signed out.\"\r\n else\r\n redirect_to :sign_in\r\n end\r\n end",
"def revoke(user, session)\n\t\trevoke_session user if authorize(user, session)\n\tend",
"def token_expired\n @token.nil? || Time.now >= @token_expires_on + expiration_threshold\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def logout\n auth_token = request.headers['Authorization']\n if auth_token == nil\n \n auth_token = params[\"Authorization\"]\n end\n\t#if there is no token then you cant logout\n if auth_token == nil\n return json_response({message: \"Invalid token\", status_code: '422'})\n end\n is_token_valid = JsonWebToken.decode(auth_token)\n \n result = JsonWebToken.invalidate(auth_token)\n \n if result != nil\n respose = json_response({message: \"You have succesfully logged out...\", status_code: result})\n else\n response = json_response({message: \"Something went wrong...\", status_code: '422'})\n end\n \n return response\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n # sessions.delete(:team_id)\n @current_user = nil\n # @current_team = nil\n\n end",
"def expire!\n headers['Age'] = max_age.to_s if fresh?\n end",
"def logout\n current_user.update(valid_jwt: false)\n end",
"def destroy\n @user = User.user_by_token(request.cookies[\"token\"])\n return if @user != @reservation.user\n\n @reservation.destroy\n head :no_content\n end",
"def forget(user)\n user.forget\n cookies.delete(:investor_id)\n cookies.delete(:remember_token)\n end",
"def refresh_session_token\n session_signature = Digest::MD5.hexdigest(@toodle_uid + Babar::Base.toodle_app_token) \n session_token_url = \"http://api.toodledo.com/2/account/token.php?\" + self.parse_params({:userid => @toodle_uid, :appid => Babar::Base.toodle_app_id , :sig => session_signature,})\n puts session_signature, session_token_url\n @session_token = JSON.parse(Typhoeus::Request.get(session_token_url).body)[\"token\"]\n @toodle_token_death = Time.now + Babar::Base.toodle_app_token_lifetime\n [@session_token, @toodle_token_death]\n end",
"def logout\n session.delete(:subscription_id)\n session.delete(:customer_id)\n redirect_to \"/ssp/index\"\n end",
"def log_out\n session.delete(:doctor_id)\n @current_doctor = nil\nend",
"def forget(player)\n return if player.nil?\n player.forget\n cookies.delete(:player_id)\n cookies.delete(:remember_token)\n end",
"def log_out\n forget(current_user) #called from user.rb. it sets remember_token attribute to nil.\n session.delete(:user_id) #deletes session.\n @current_user = nil # new value of this instance variable.\n end"
] |
[
"0.6366113",
"0.634913",
"0.6299228",
"0.6176928",
"0.61189204",
"0.59891504",
"0.5950706",
"0.59456265",
"0.59401256",
"0.5930891",
"0.5928277",
"0.59167",
"0.58880484",
"0.58853513",
"0.5880049",
"0.58356476",
"0.58177674",
"0.57804483",
"0.5754164",
"0.5742323",
"0.5733262",
"0.5710553",
"0.57093024",
"0.57040185",
"0.57027334",
"0.57005775",
"0.56873345",
"0.5687109",
"0.568601",
"0.5681049",
"0.5677148",
"0.56761855",
"0.56753254",
"0.5675142",
"0.5655714",
"0.56513965",
"0.5647962",
"0.5647321",
"0.56466556",
"0.5641887",
"0.5625263",
"0.5624389",
"0.5609159",
"0.5606358",
"0.55918425",
"0.5585958",
"0.557379",
"0.5570811",
"0.5570079",
"0.5570079",
"0.55654186",
"0.55638194",
"0.55628604",
"0.5553899",
"0.55535",
"0.5553333",
"0.55472296",
"0.5535518",
"0.55277455",
"0.55231386",
"0.5520549",
"0.55158585",
"0.55158585",
"0.5513839",
"0.5512698",
"0.5497074",
"0.5497074",
"0.5486675",
"0.54859716",
"0.54737884",
"0.5472458",
"0.5469332",
"0.5468076",
"0.5461829",
"0.5461321",
"0.54607624",
"0.54607624",
"0.5446563",
"0.5439824",
"0.5438831",
"0.5437135",
"0.5434026",
"0.5434026",
"0.5432787",
"0.54231656",
"0.5421859",
"0.54212636",
"0.54207665",
"0.54187053",
"0.54174477",
"0.5416405",
"0.5413598",
"0.5409199",
"0.5404585",
"0.54038",
"0.54037696",
"0.5403095",
"0.54023653",
"0.54001766",
"0.5399671"
] |
0.78240633
|
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.